def main():
usage="%prog [options]" + '\n' + __doc__ + "\n"
parser = OptionParser(usage,version="%prog " + __version__)
parser.add_option("-i","--input",action="store",type="string",dest="input_file",help="Input BAM file")
parser.add_option("-r","--refgene",action="store",type="string",dest="refgene_bed",help="Reference gene model in BED format. Must be strandard 12-column BED file. [required]")
parser.add_option("-q","--mapq",action="store",type="int",dest="map_qual",default=30,help="Minimum mapping quality (phred scaled) for an alignment to be called \"uniquely mapped\". default=%default")
parser.add_option("-n","--frag-num",action="store",type="int",dest="fragment_num",default=3,help="Minimum number of fragment. default=%default")
(options,args)=parser.parse_args()
if not (options.input_file and options.refgene_bed):
parser.print_help()
sys.exit(0)
if not os.path.exists(options.input_file + '.bai'):
print >>sys.stderr, "cannot find index file of input BAM file"
print >>sys.stderr, options.input_file + '.bai' + " does not exists"
sys.exit(0)
for file in (options.input_file, options.refgene_bed):
if not os.path.exists(file):
print >>sys.stderr, file + " does NOT exists" + '\n'
sys.exit(0)
print '\t'.join([str(i) for i in ("chrom","tx_start", "tx_end","symbol","frag_count","frag_mean","frag_median","frag_std")])
for tmp in fragment_size(options.refgene_bed, pysam.Samfile(options.input_file), options.map_qual, options.fragment_num):
print tmp
RNA_fragment_size.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录