Skip to content

Instantly share code, notes, and snippets.

View heliy's full-sized avatar

Liuyuan He heliy

  • Peking University
  • Beijing, China
View GitHub Profile
@heliy
heliy / opencvlogo.py
Created May 6, 2015 02:12
Exercises --------- -# Try to create the logo of OpenCV using drawing functions available in OpenCV.
import numpy as np
import cv2 #3.0.0-dev
import math
r1 = 70
r2 = 30
ang = 60
d = 170
@heliy
heliy / ctypes-hw.py
Created June 3, 2014 11:54
ctypes的使用测试
"""
7万个SNP的hw平横检验MAF的过滤
纯 python ver:
pypy 约 20s
python 约 25s
用 ctypes 调用 c ver:
pypy 约 18s
python 约 12s <- 比pypy还要好
@heliy
heliy / sysevatree.py
Created May 8, 2014 11:56
最大简约法进化系统发育树 固定模型
# coding:utf-8
"""
构建最大简约法进化系统发育树
使用 sh:
python sysevatree data > eva-tree.txt
"""
import sys
@heliy
heliy / go_is-a_tree.py
Created April 18, 2014 09:46
GO的is-a关系树 输入为原始obo文件 结果约56万行
import sys
import re
id="id"
ns="namespace"
ia="is-a"
nps="node-ptrs"
def get_terms_namespaces(go_file):
terms={}
@heliy
heliy / gb_plot.py
Created April 3, 2014 07:48
GeneBank文件绘图 超*初级
import matplotlib.pyplot as plt
import numpy as np
import sys
def get_features(gb):
context=open(gb,"r").read().split("FEATURES")[1].split("ORIGIN")[0].splitlines()
dc={}
for line in context:
if line[5]==' ':
continue
@heliy
heliy / adjacent.py
Last active August 29, 2015 13:57
网络上n层相邻节点 广度优先
import sys
def putin(name,other,peers):
if name in peers.keys():
peers[name].append(other)
else:
peers[name]=[other]
def take_peers(filename,split_sign="\t"):
inters=open(filename,'r').read().splitlines()
@heliy
heliy / genesppi.py
Created December 19, 2013 10:35
#PPI中癌基因子图
#coding:UTF-8
#!/usr/bin/python
import networkx as nx
import matplotlib.pyplot as plt
def cancergenes(filename="cancer_gene_census.tsv"):
doms,recs=[],[]
for line in open(filename,'r').read().split('\r'):
cons=line.split("\t")
@heliy
heliy / aat.py
Created December 13, 2013 13:57
snp关联分析及提取相关基因
#coding:utf-8
import sys
#处理permutaion的阈值 返回SNPlist
def promusnp(mperm,p=0.001):
f=open(mperm,"r")
res=[]
total=[]
line=f.readline()
@heliy
heliy / seqcutloc.py
Last active December 31, 2015 00:38
查找长序列里剪切识别位点
#coding:UTF-8
#!/usr/bin/python
#使用方法:
#python seqcutloc.py fasta文件 序列 输出文件
#./seqcutloc.py fasta文件 序列 输出文件
#算法是通过将长序列按碱基切开 在拼接回原序列
#eg seq:ATAATCGGCGATTAATCGAAT cut:AAT
#切完后得到子序列 AT CGGCGATT CG 长度为2 8 2