[Biopython] when is a SeqRecord not a SeqRecord
Hernán Morales Durand
hernan.morales at gmail.com
Tue Sep 11 13:38:12 UTC 2012
2012/7/18 Brad Chapman <chapmanb at 50mail.com>
>
> Dilara;
>
> > I'm trying to understand what is why when I print filtered_rec I get a
> > SeqRecord but if I try to access any particular attribute of a SeqRecord
> > such as letter_annotations I sometimes get an attribute error --
> > AttributeError: 'NoneType' object has no attribute
> > 'letter_annotations.'
>
> > def check_meanQ(record, q_threshold):
> > seqlen=len(record)
> > quality_scores=array(record.letter_annotations["phred_quality"])
> > if round(quality_scores.mean()) <= q_threshold:
> > print "Discarded ", record.id, "because mean Q was",
> > round(quality_scores.mean())
> > elif round(quality_scores.mean()) > q_threshold:
> > return record
>
> This function returns different results based on the comparison of
> mean quality scores to your threshold:
>
> - When it is below the threshold, it returns None (since you do not
> define an explicit return value)
> - When it is above the threshold, it returns a SeqRecord.
>
>
And of course, you may implement a Null Object Pattern here, like a
NullSeqRecord.
Cheers,
Hernán
More information about the Biopython
mailing list