Hi, I would like to overwrite a feature in a genbank file using BioPython, using ambiguous locations.
For example, I can set an ambiguous location:
from Bio import SeqFeature
start_pos = SeqFeature.AfterPosition(5)
end_pos = SeqFeature.BeforePosition(10)
my_location = SeqFeature.FeatureLocation(start_pos, end_pos)
Which is correct.
What I can't work out how to do is to use this ambiguous location to add a new feature to a sequence.
I can read in a genbank file, assign the records to a SeqRecord, and assign the genbank features to SeqFeatures :
for record in SeqIO.parse(myinfile, "genbank"):
new_gb = SeqRecord(record.seq)
Then I can overwrite a feature:
which, when I print the SeqRecord out in genbank format (to stdout), correctly overwrites the first feature:
out_handle = StringIO()
SeqIO.write(new_gb, out_handle, "genbank")
new_gb_output = out_handle.getvalue()
What I am stuck on is :
1) How to I add a completely new feature to a SeqRecord?
2) How can I use ambiguous locations in the location of a feature in a SeqRecord?
I'm sure this is simple but I can't seem to work it out.
Thanks and I'm sorry if this is stupid, I'm learning.