Skip to content

Instantly share code, notes, and snippets.

View hanfeisun's full-sized avatar
🏕️

Hanfei Sun hanfeisun

🏕️
View GitHub Profile
def update_one_sample(gsmid, parse_fields=['other_ids', 'paper', 'name', 'species', 'description', 'antibody', 'factor',
'cell type', 'cell line', 'tissue', 'strain']):
"""Given a gsmid, tries to create a new sample--auto-filling in the
meta fields
If overwrite is True and there is the sample that has the same gsmid, this function will overwrite that sample
NOTE: will try to save the sample!!
CLASS1 = ["BMAL1-ZT10_rep1", "BMAL1-ZT10_rep2"]
CLASS1_PATHS = ["/mnt/Storage/data/exam_data/BMAL1/BMAL1-ZT10_rep1.bam", "/mnt/Storage/data/exam_data/BMAL1/BMAL1-ZT10_rep2.bam"]
CLASS2 = ["BMAL1-ZT22_rep1"]
CLASS2_PATHS = ["/mnt/Storage/data/exam_data/BMAL1/BMAL1-ZT22_rep1.bam"]
GTF = "/mnt/Storage/data/RefGene/mm9.gtf"
SAMPLES = CLASS1 + CLASS2
def _bowtie(workflow, conf):
for target in conf.sample_targets:
bowtie = attach_back(workflow,
ShellCommand(
"{tool} -p {param[threads]} -S -m {param[max_align]} \
{param[genome_index]} {input[fastq]} {output[sam]} 2> {output[bowtie_summary]}",
input={"genome_dir": os.path.dirname(conf.get_path("lib", "genome_index")),
"fastq": target + ".fastq"},
output={"sam": target + ".sam",
"bowtie_summary": target + "_bowtie_summary.txt", },
def _macs2(workflow, conf):
# merge all treatments into one
merge_bams_treat = ShellCommand(
"{tool} merge {output[merged]} {param[bams]}",
tool="samtools",
input=[target + ".bam" for target in conf.treatment_targets],
output={"merged": conf.prefix + "_treatment.bam"})
merge_bams_treat.param = {"bams": " ".join(merge_bams_treat.input)}
if len(conf.treatment_targets) > 1:
def _macs2(workflow, conf):
# merge all treatments into one
merge_bams_treat = ShellCommand(
"{tool} merge {output[merged]} {param[bams]}",
tool="samtools",
input=[target + ".bam" for target in conf.treatment_targets],
output={"merged": conf.prefix + "_treatment.bam"})
merge_bams_treat.param = {"bams": " ".join(merge_bams_treat.input)}
if len(conf.treatment_targets) > 1:
@hanfeisun
hanfeisun / sicp_coin.py
Last active December 30, 2015 16:48
SICP iteration solution
first_denom = {1:1,2:5,3:10,4:25,5:50}
def cc_rec(amount, kinds_of_coins = 5):
if amount == 0:
return 1
elif amount < 0 or kinds_of_coins == 0:
return 0
else:
return cc_rec(amount, kinds_of_coins - 1) + \
cc_rec(amount - first_denom[kinds_of_coins], kinds_of_coins)
/*
* A white-list based PAC without regexp, by @janlay
* It's just simple and fast.
* Last update: Dec 9, 2013
* Special thanks to @Paveo
*/
function FindProxyForURL(url, host) {
var PROXY = "PROXY 127.0.0.1:8800;SOCKS 127.0.0.1:8801";
var DEFAULT = "DIRECT";
"""Library to interface with the GEO (GDS- GEO DataSets) repository"""
import os
import re
import sys
import urllib
import traceback
from datetime import datetime
import time
import enchant
SELECT st_geomfromtext('POINT(-1 38)', 4329);
select st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
select st_geomfromtext('LINESTRING(-13 21,0 0,3 2') as mycheckmark;
SELECT st_geomfromtext('POINT(-1 38)', 4329);
select st_asewkt('0101000020E9100000000000000000F0BF0000000000004340');
select st_geomfromtext('LINESTRING(-13 21,0 0,3 2') as mycheckmark;