Hi,
I am new to Biopython and programming in general. I am having difficulty generating viable scripts to convert the id in my pasta files to consecutive numbers. I have a text file containing:
1 2 3 4 etc...
and my code currently reads:
from Bio import SeqIO
lines_file = open("Numbers1_50.txt")
fout = open("output.fasta", "w")
handle = open("input.fasta", "r")
for seq_record in SeqIO.parse(handle, "fasta"):
seq_record.id = lines_file[0]
seq_record.description = ""
print seq_record.id)
SeqIO.write(fout, lines_file[0]+".fasta","fasta")
lines_file.close()
fout.close()
However, I keep getting an error at the line containing: seq_record.id = lines_file[0]
TypeError: '_io.TextIOWrapper' object is not subscriptable
If anyone has a moment to explain my error, I would greatly appreciate it! Thanks.
Thank you for your help! I tried enumerate the id's as you suggested however I received the following error:
return text.replace("\n", " ").replace("\r", " ").replace(" ", " ") AttributeError: 'int' object has no attribute 'replace'
I am not sure what happened here.
Edited. I should have coerced the integer to a string.