[Biopython] AssertionError

Pierre-Yves pingou at pingoured.fr
Wed Jul 21 05:22:12 EDT 2010


On Wed, 2010-07-21 at 10:17 +0100, Peter wrote:

> If seq is a SeqRecord (a variable name I avoid),
Changed.

>  then seq.seq is
> a Seq object, and slicing a Seq object gives another Seq object.
> This means you shouldn't do this:
> 
>  Seq(seq.seq[start:stop], generic_dna)
> 
> Just do this:
> 
> seq.seq[start:stop]

Indeed:
 seq_out = SeqRecord( seq_record.seq[start:stop],
                      id = row[col_name]
                    )
just works.

> >
> > But the creation of the sequence object fails with the following error:
> > Traceback (most recent call last):
> >  File "FastaExtractor.py", line 91, in <module>
> >    s = Seq(seq.seq[start:stop], generic_dna)
> >  File "/usr/lib64/python2.6/site-packages/Bio/Seq.py", line 87, in
> > __init__
> >    type(data) == type(u""))  # but can be a unicode string
> > AssertionError
> 
> That should be a clearer error message, the Seq object is not
> expecting you to give it a Seq object - but a string or unicode.

A clearer error message would indeed be nice.


Pierre



More information about the Biopython mailing list