#!/usr/bin/env python
import re
import os
import sys
import argparse
## basic argument
parser = argparse.ArgumentParser(description="you should add those parameter")
parser.add_argument('-i', '--input', help = 'the software repeatHMM analysis result', required = True)
parser.add_argument('-o', '--output', help = 'the outdir', default = os.path.abspath("./"))
parser.add_argument('-p', '--pafile', help = 'the pa file pathway', required = True)
argv = vars(parser.parse_args())
inf = os.path.abspath(argv['input'].strip())
oud = os.path.abspath(argv['output'].strip())
paf = os.path.abspath(argv['pafile'].strip())
def checkDir(Dir):
if not os.path.exists(Dir):
os.makedirs(Dir)
checkDir(oud)
def trimpa(paf):
padoc={}
with open(paf,'r') as pal:
for palic in pal:
if palic.startswith("#"):
continue
Palicon=palic.strip().split(',')
padoc[str(Palicon[0])]=[str(str(Palicon[1]).replace("chr", "")),str(Palicon[2]),str(Palicon[3]),str(abs(float(Palicon[5]))),str(Palicon[4])]
return padoc
def trimre(pad,inf):
ous="Gene\tChr\tStart\tEnd\tRepeat motif\tRepeat counts\tDistribution\n"
with open(inf,'r') as inl:
for inlic in inl:
if "p2sp" in inlic and "INFO:" in inlic and "allocr" in inlic and "[0, 0]" not in inlic:
inlicon=inlic.strip().split("p2sp [")
inlicontmp1=inlicon[1].strip().split("\'")
genamet=inlicontmp1[1]
repeatnum=str(inlicontmp1[3].strip().split("allocr:")[1]).replace(",", " ")
if str(genamet) in pad.keys():
ous+=str(genamet)+"\t"+str(pad[genamet][0])+"\t"+str(pad[genamet][1])+"\t"+str(pad[genamet][2])+"\t"+str(pad[genamet][3])+"\t"+str(pad[genamet][4])+"\t"+repeatnum+"\n"
return ous
if __name__ == "__main__":
pado = trimpa(paf)
outr = trimre(pado,inf)
outfile=oud+"/repeatHMM.result.xls"
outc=open(outfile,'w')
outc.write(str(outr))
python33
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 我试了几个网站,都没有设置字体反爬,比如说之前还设置了该技术的58同城,汽车之家等,不知道因为什么现在都没有这个东...
- 元组是一个不可变的序列。 元组的操作的方式基本上和列表是一致的,所以你在操作元组时,就把元组当成是一个不可变的列表...