Question: Problem with Parse SeqIO SOLVED - link to cross-reference
gravatar for felipelira3
3.2 years ago by
felipelira30 wrote:

Anybody have this problem before? Any suggestion about the reason?

The script creates the files containing the genome sequences but it appears at the end of the process.

Line in my script

File "/home/flira/scripts/", line 97, in <module>
    SeqIO.write(SeqIO.parse(genbank_file, "genbank"), genome_file, "fasta")

Warnings that appear:

  File "/usr/lib/python2.7/dist-packages/Bio/SeqIO/", line 481, in write
    count = writer_class(fp).write_file(sequences)
  File "/usr/lib/python2.7/dist-packages/Bio/SeqIO/", line 209, in write_file
    count = self.write_records(records)
  File "/usr/lib/python2.7/dist-packages/Bio/SeqIO/", line 193, in write_records
    for record in records:
  File "/usr/lib/python2.7/dist-packages/Bio/SeqIO/", line 600, in parse
    for r in i:
  File "/usr/lib/python2.7/dist-packages/Bio/GenBank/", line 478, in parse_records
    record = self.parse(handle, do_features)
  File "/usr/lib/python2.7/dist-packages/Bio/GenBank/", line 462, in parse
    if self.feed(handle, consumer, do_features):
  File "/usr/lib/python2.7/dist-packages/Bio/GenBank/", line 434, in feed
    self._feed_feature_table(consumer, self.parse_features(skip=False))
  File "/usr/lib/python2.7/dist-packages/Bio/GenBank/", line 159, in parse_features
    raise ValueError("Premature end of line during features table")

Link for the same issue in

python • 1.7k views
ADD COMMENTlink modified 3.2 years ago • written 3.2 years ago by felipelira30

Cross-pointed on the stackoverflow

We discourage simultaneously crossposting identical question on multiple sites.

This duplicates the effort of the answerers (they can't see that a question was answered).

And it also spreads out the answers, which makes it harder to other users to track the thread.

ADD REPLYlink written 3.2 years ago by Sej Modha4.8k

Sorry for that but the frequency of responses here has a delay comparing with Stackoverflow and I published there too. For instance, I put the link to both topics and edited the title to solved in both.

ADD REPLYlink written 3.2 years ago by felipelira30
gravatar for a.zielezinski
3.2 years ago by
a.zielezinski9.6k wrote:

Philipp Bayer is right - remember to close all the files you open in the script.

This will do the trick:

from Bio import SeqIO

l = ['GCF_000302915.1_Pav631_1.0_genomic.gbff']
for genbank_file in l:
    fh = open(genbank_file)
    oh = open(genbank_file + '.fasta', 'w')
    for seq_record in SeqIO.parse(fh, 'genbank'):
ADD COMMENTlink modified 3.2 years ago • written 3.2 years ago by a.zielezinski9.6k
gravatar for Philipp Bayer
3.2 years ago by
Philipp Bayer6.9k
Philipp Bayer6.9k wrote:

Normally this should work (and it does on my system). Are you writing to the genbank_file in the script before that? Perhaps you haven't closed the file handle yet so that writing to the file hasn't synced?

ADD COMMENTlink written 3.2 years ago by Philipp Bayer6.9k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2197 users visited in the last hour