How to retrieve all features inside a given range from genbank record, using biopython?
f1 = FeatureLocation(10, 40, strand=+1)
recs = [rec for rec in SeqIO.parse('my_genbank.gb', "genbank")]
feats = [feat for feat in rec.features if feat.type == "CDS"]
for feat in feats:
if feat.location in f1:
print feat.location
print '\n'
i've tried this, but i get this error
ValueError: Currently we only support checking for integer positions being within a FeatureLocation.
Thank you for your reply! Although, i still don't get it I need to check if the feature is inside a given range, not the other way around I try something like:
but i get this
I don't think your approach will really work in that case.
Try the following instead:
call the script as:
I adapted this slightly from here, so there are answers out there already if you need more info.
If you want to filter by strand still, you can do that in addition by testing
f
further.