Today, when I executed the following code, I suddenly got an error and could not execute the code Error 'FastaIterator' object has no attribute 'records'
in Biopython. I have never had any errors before, so I'm so confused.
seq = SeqIO.parse(concensus_path, "fasta")
for record in seq.records:
SeqIO.write(record, folder + '/' + record.name.split('(')[0].replace('_0_', '_') + '.fasta', "fasta")
The first part of the long script is to split a fasta file containing multiple dna sequences into fasta file containing a single dna sequence.
Is there any way to deal with these problems? Input fasta file has no problems at all. I tried with a file that was working fine before, but it also gave an error...
According to the docs here, you can access the records by just iterating over the returned iterator:
from Bio import SeqIO
for record in SeqIO.parse("example.fasta", "fasta"):
print(record.id)