001、
[root@pc1 test1]# ls a.fa rm.list test.py [root@pc1 test1]# cat a.fa ## 测试fasta >chr1 tttcccggg >chr2 tttgggjjj cccjjjjjj >chr3 ccc >chr4 aaaaatt [root@pc1 test1]# cat rm.list ## 删除列表 chr2 chr4 [root@pc1 test1]# cat test.py ## 删除程序 #!/usr/bin/env python3 # -*- coding: utf-8 -*- rm_list = [] with open("rm.list", "r") as in_put1: for i in in_put1.readlines(): rm_list.append(i.strip("\n")) in_put1.close() with open("a.fa", "r") as in_put2: for i in in_put2: if i[0] == ">": for j in rm_list: if j in i: out = False break else: out = True if out: print(i.strip()) in_put2.close()
[root@pc1 test1]# cat rm.list chr2 chr4 [root@pc1 test1]# python3 test.py ## 处理结果 >chr1 tttcccggg >chr3 ccc
。
标签:test1,python,pc1,list,##,序列,rm,fasta,root From: https://www.cnblogs.com/liujiaxin2018/p/17763749.html