Entering edit mode
4.4 years ago
Balatheskulter
•
0
I needed to pick up a sequence from a fast file, that fast file contains nearly 200 contigs. I needed to pick up a certain sequence from particular contigs. I have used this command but this command is not proper, I got the following error. Please help me out.
from Bio import SeqIO
with open("outfile2.txt","w") as f:
for seq in SeqIO.parse("RI_solani.fa","fasta"):
chrs={}
chrs[seq.id] = seq.seq
f.writestrseq.id) + "\n")
f.write(str(chrs['KB317696.1'][0:70]))
f.write(str(chrs['KB317696.1'][70:140]) + "\n")
KeyError Traceback (most recent call last)
<ipython-input-23-e727c4ed6266> in <module>
5 chrs[seq.id] = seq.seq
6 f.writestrseq.id) + "\n")
--> 7 f.write(str(chrs['KB317696.1'][0:70]))
8 f.write(str(chrs['KB317696.1'][70:140]) + "\n")
KeyError: 'KB317696.1'
Thank you @geek_y. This helped me a lot.