[Biopython-dev] [Biopython] Using SeqLocation to extract subsequence

Peter biopython at maubp.freeserve.co.uk
Tue Nov 3 17:41:31 UTC 2009


On Tue, Nov 3, 2009 at 5:23 PM, Kyle Ellrott <kellrott at gmail.com> wrote:
>>
>> def FeatureDescGuess( feature ):
>>   desc = ""
>>   try:
>>       desc=feature.qualifiers['product'][0]
>>   except KeyError:
>>       pass
>>   return desc
>>
>> Could be just:
>>
>> def FeatureDescGuess( feature ):
>>   return feature.qualifiers.get('product', [""])[0]
>>
>> and therefore doesn't really need an entire function.
>
> That could attempt to get the first element of a None type, if the 'product'
> qualifier doesn't exist.

No, because we supply a default value (a list containing the empty string).

> Actually, I wrote it that way so it could be extended.  First it would try
> 'product' and if that didn't exist replace it with something like a
> 'db_xref' or a 'note' entry.  I was hoping to get some input on what people
> think would be 'order of importance' of things to try.

I might try and follow the NCBI's conventions used in FAA files for each
GenBank file - see the bacteria folder on their FTP site.

Peter




More information about the Biopython-dev mailing list