1-情景:现在有一个txt文件,里面许多fasta格式的蛋白序列,需要去除其中重复的序列,得到非冗余的序列。
2-用到的python数据结构为字典
Python-Set数据结构的使用
python 字典数据结构的操作
python 字典-根据value来获取key
3-代码如下
#打开fasta文件 newfile, 写入outfile1,冗余的部分写入outfile2, 在outfile1中找到outfile2中相同的部分,写入outfile
import os
path="C:/Users/luo/Desktop/P/1 SeqDeal-replace/Nr blast/"
file=open(path+"sum.txt",'r')
newfile=path+"0.txt"
outfile=open(newfile, "w")
seq1=dict()
seq2=<