Question: Need Help Adding Qualifier to Features In Biopython
1
gravatar for mhoss
4.3 years ago by
mhoss20
United States
mhoss20 wrote:

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 highlighted in yellow where I would like to add a qualifier. 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"))
genbank biopython • 2.1k views
ADD COMMENTlink modified 4.3 years ago • written 4.3 years ago by mhoss20
2
gravatar for mhoss
4.3 years ago by
mhoss20
United States
mhoss20 wrote:

Got it after I thought about it. If anyone needs this in the future -

notes={"notes":"test"}
my_feature = SeqFeature(my_feature_location,type=feature_type[feature_count],qualifiers=notes)
ADD COMMENTlink written 4.3 years ago by mhoss20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1381 users visited in the last hour