kegg_parse_img_ids.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:SHOGUN 作者: knights-lab 项目源码 文件源码
def main():
    parser = make_arg_parser()
    args = parser.parse_args()

    sam_files = [os.path.join(args.input, filename) for filename in os.listdir(args.input) if filename.endswith('.sam')]

    img_map = IMGMap()

    ncbi_tree = NCBITree()

    with open(args.output, 'w') if args.output else sys.stdout as outf:
        csv_outf = csv.writer(outf, quoting=csv.QUOTE_ALL, lineterminator='\n')
        csv_outf.writerow(['sample_id', 'sequence_id', 'ncbi_tid', 'img_id'])
        for file in sam_files:
            with open(file) as inf:
                lca_map = build_lca_map(yield_alignments_from_sam_inf(inf), ncbi_tree, img_map)
                for key in lca_map:
                    img_ids, ncbi_tid = lca_map[key]
                    csv_outf.writerow([os.path.basename(file)[:-4],  key, ncbi_tid, ','.join(img_ids)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号