from Bio import SeqIO
from Bio import SeqRecord
from Bio import SeqFeature
for rec in SeqIO.parse("C:/Users/Siva/Downloads/sequence.gp","genbank"):
if rec.features:
for feature in rec.features:
if feature.type =="Region":
seq1 = feature.location.extract(rec).seq
print(seq1)
SeqIO.write(seq1,"region_AA_output1.fasta","fasta")
I am trying to write the output to a FASTA file but i am getting error. Can anybody help me? This the error which i got
Traceback (most recent call last):
File "C:\Users\Siva\Desktop\region_AA.py", line 10, in <module>
SeqIO.write(seq1,"region_AA_output1.fasta","fasta")
File "C:\Python34\lib\site-packages\Bio\SeqIO\__init__.py", line 472, in write
count = writer_class(fp).write_file(sequences)
File "C:\Python34\lib\site-packages\Bio\SeqIO\Interfaces.py", line 211, in write_file
count = self.write_records(records)
File "C:\Python34\lib\site-packages\Bio\SeqIO\Interfaces.py", line 196, in write_records
self.write_record(record)
File "C:\Python34\lib\site-packages\Bio\SeqIO\FastaIO.py", line 190, in write_record
id = self.clean(record.id)
AttributeError: 'str' object has no attribute 'id'