Entering edit mode
9.2 years ago
mhoss
▴
20
I'm trying to add a qualifier to a new feature and then save as a genbank file. I'm quite new to python and appreciate the help.
DF posted a great guild a few years ago for making genbank files that I have been following - Add A New Feature In Biopython
But I am stuck adding a qualifier to a new feature. Here is his guide. I would like to add a qualifier after step 4. Thanks.
################ B: Make a SeqFeature ################
# 1. Create a start location and end location for the feature
# Obviously this can be AfterPosition, BeforePosition etc.,
# to handle ambiguous or unknown positions
from Bio import SeqFeature
my_start_pos = SeqFeature.ExactPosition(2)
my_end_pos = SeqFeature.ExactPosition(6)
# 2. Use the locations do define a FeatureLocation
from Bio.SeqFeature import FeatureLocation
my_feature_location = FeatureLocation(my_start_pos,my_end_pos)
# 3. Define a feature type as a text string
# (you can also just add the type when creating the SeqFeature)
my_feature_type = "CDS"
# 4. Create a SeqFeature
from Bio.SeqFeature import SeqFeature
my_feature = SeqFeature(my_feature_location,type=my_feature_type)
#how would you add a qualifier here with key = note and value = test?
# **my_feature = SeqFeature(my_feature_location,type=my_feature_type,qualifier=....)
# 5. Append your newly created SeqFeature to your SeqRecord
my_sequence_record.features.append(my_feature)
#optional: print the SeqRecord to STDOUT in genbank format, with your new feature added.
#print "\nThis bit is the SeqRecord, printed out in genbank format, with a feature added.\n"
#print(my_sequence_record.format("gb"))