chapmanb/bcbb — Issue #51: GFF.write fails when using a single SeqRecord.
Author: mercutio22
Created: 2012-03-10 02:16:36+00:00
State: open

In [6]: seqTP53

Out[6]: SeqRecord(seq=Seq('TGGTTCAAGTAATTCTCCTGCCTCAGACTCCAGAGTAGCTGGGATTACAGGCGC...CCC', IUPACAmbiguousDNA()), id='NG_017013.1', name='NG_017013', description='Homo sapiens tumor protein p53 (TP53), RefSeqGene on chromosome 17.', dbxrefs=[])

with open('tp53.gff', 'w') as file:
GFF.write(seqTP53, file)

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (8, 0))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/merc/gitcode/mirna-django/src/scripts/ in ()
1 with open('tp53.gff', 'w') as file:
----> 2 GFF.write(seqTP53, file)
3

/usr/local/lib/python2.7/dist-packages/bcbio-0.1-py2.7.egg/BCBio/GFF/GFFOutput.pyc in write(recs, out_handle, include_fasta)
183 """
184 writer = GFF3Writer()
--> 185 return writer.write(recs, out_handle, include_fasta)

/usr/local/lib/python2.7/dist-packages/bcbio-0.1-py2.7.egg/BCBio/GFF/GFFOutput.pyc in write(self, recs, out_handle, include_fasta)
74 fasta_recs = []
75 for rec in recs:
---> 76 self._write_rec(rec, out_handle)
77 self._write_annotations(rec.annotations, rec.id, out_handle)
78 for sf in rec.features:

/usr/local/lib/python2.7/dist-packages/bcbio-0.1-py2.7.egg/BCBio/GFF/GFFOutput.pyc in _write_rec(self, rec, out_handle)
99 def _write_rec(self, rec, out_handle):
100 # if we have a SeqRecord, write out optional directive

--> 101 if len(rec.seq) > 0:
102 out_handle.write("##sequence-region %s 1 %s\n" % (rec.id, len(rec.seq)))
103

AttributeError: 'str' object has no attribute 'seq'