Skip to content

Instantly share code, notes, and snippets.

@Nanguage
Nanguage / process_bigwig.py
Last active Aug 30, 2019
code for processing(coarsen, normalize_use_control) bigwig file
View process_bigwig.py
import os
import re
from typing import Iterable, Tuple, Optional, Union, Callable, TypeVar
from functools import partial
from contextlib import ContextDecorator
from tqdm.auto import tqdm
Bin = Tuple[str, int, int]
Bigwig = "pyBigWig.bigWigFile"
BinValue = Tuple[Bin, float]
@Nanguage
Nanguage / fetch_douban_album.py
Last active Jul 5, 2019
Fetch pictures in Douban Album
View fetch_douban_album.py
"""
Fetch pictures in Douban Album
via Douban API V2(https://douban-api-docs.zce.me/photo.html)
"""
import os
import sys
import json
from typing import Dict, List, Iterator, Tuple
import shutil
from concurrent.futures import ThreadPoolExecutor
View parse_gff3.py
import attr
import typing
from collections import defaultdict
@attr.s(auto_attribs=True)
class GFF3Record:
seq_id : str = ""
source : str = ""
type_ : str = ""
start : int = 0
@Nanguage
Nanguage / fetch_kegg_pathway_seqs.py
Created May 30, 2019
Fetch KEGG pathway's all gene's sequences via KEGG Restful API
View fetch_kegg_pathway_seqs.py
import requests
import re
import os
from concurrent.futures import ThreadPoolExecutor
import pandas as pd
from tqdm import tqdm
def fetch_page(base_url):
@Nanguage
Nanguage / chatroom.py
Created May 15, 2019
A simple chat room.
View chatroom.py
#!/usr/bin/env python
"""
A simple chat room.
https://codeburst.io/building-your-first-chat-application-using-flask-in-7-minutes-f98de4adfa5d
$ pip install flask flask-socketio
$ python chatroom.py
Servies run on http://127.0.0.1:5000
@Nanguage
Nanguage / cuda_9.0_cudnn_7.0.sh
Created Aug 20, 2018 — forked from ashokpant/cuda_9.0_cudnn_7.0.sh
Install CUDA Toolkit v9.0 and cuDNN v7.0 on Ubuntu 16.04
View cuda_9.0_cudnn_7.0.sh
#!/bin/bash
# install CUDA Toolkit v9.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb)
CUDA_REPO_PKG="cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb"
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda-9-0
@Nanguage
Nanguage / add_subtitles.py
Last active Aug 20, 2018
Add subtitles to videos use ffmpeg
View add_subtitles.py
"""
Add subtitles to video.
Subtitles files should be in same directory with videos,
and with same file name.
usage:
$ python add_subtitles.py INPUT_DIR OUTPUT_DIR
"""
@Nanguage
Nanguage / extract_urls.py
Created Aug 19, 2018
Use you-get download youtube playlist
View extract_urls.py
"""
Extract the urls from YouTube playlist page html file.
usage:
$ python extract_urls.py PLAYLIST.html OUTPUT.txt
"""
import re
import sys
View SimpleHTTPServerWithUpload.py
#!/usr/bin/python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@Nanguage
Nanguage / tabs2spaces.py
Last active Jul 17, 2018 — forked from antivanov/tabs2spaces.py
Python script to replace tabs with spaces recursively for all files matching a specified file mask regex, the number of spaces if configurable
View tabs2spaces.py
USAGE = '''
Usage example:
python tabs2spaces.py . 4 ".*\.py$"
'''
import io
import argparse
import os