美文网首页
python: pick fna sequence

python: pick fna sequence

作者: 胡童远 | 来源:发表于2022-06-13 09:48 被阅读0次
    import re, sys, os
    # 构建序列名-序列字典
    with open("protein_rm_enter.faa") as f:
        Dict = {}
        keys = []
        for line in f:
            if line[0] == ">":
                key = line.strip()
                keys.append(key)
                Dict[key] = []
            else:
                Dict[key].append(line.strip())
    # 遍历目标序列名,提取目标序列            
    with open("protein2.target", 'w') as o:
        with open("apd.target") as target:
            for tar in target:
                tar = tar.strip()
                tar = ">{}_1".format(tar)
                if tar in keys:
                    o.write("{}\t{}\n".format(tar, ''.join(Dict[tar])))
    

    相关文章

      网友评论

          本文标题:python: pick fna sequence

          本文链接:https://www.haomeiwen.com/subject/rtcomrtx.html