Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Parse FASTA records with no identifer, fixes Issue 3308

  • Loading branch information...
commit 0bdb1f2210df11482b785cf6e01f3c3129ed0d8e 1 parent 33a1120
@peterjc peterjc authored
Showing with 20 additions and 2 deletions.
  1. +6 −1 Bio/SeqIO/FastaIO.py
  2. +14 −1 Tests/test_SeqIO_FastaIO.py
View
7 Bio/SeqIO/FastaIO.py
@@ -46,7 +46,12 @@ def FastaIterator(handle, alphabet = single_letter_alphabet, title2ids = None):
id, name, descr = title2ids(line[1:].rstrip())
else:
descr = line[1:].rstrip()
- id = descr.split()[0]
+ try:
+ id = descr.split()[0]
+ except IndexError:
+ assert not descr, repr(line)
+ #Should we use SeqRecord default for no ID?
+ id = ""
name = id
lines = []
View
15 Tests/test_SeqIO_FastaIO.py
@@ -1,10 +1,12 @@
-# Copyright 2009 by Peter Cock. All rights reserved.
+# Copyright 2009-2011 by Peter Cock. All rights reserved.
# Parts copyright 1999 by Jeffrey Chang. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
import unittest
+from StringIO import StringIO
+
from Bio import SeqIO
from Bio.SeqIO.FastaIO import FastaIterator
from Bio.Alphabet import generic_protein, generic_nucleotide, generic_dna
@@ -98,6 +100,17 @@ def multi_check(self, filename, alphabet):
#Uncomment this for testing the methods are calling the right files:
#print "{%s done}" % filename,
+ def test_no_name(self):
+ """Test FASTA record with no identifier."""
+ handle = StringIO(">\nACGT")
+ record = SeqIO.read(handle, "fasta")
+ handle.close()
+ self.assertEqual(str(record.seq), "ACGT")
+ self.assertEqual("", record.id)
+ self.assertEqual("", record.name)
+ self.assertEqual("", record.description)
+
+
single_nucleic_files = ['Fasta/lupine.nu', 'Fasta/elderberry.nu',
'Fasta/phlox.nu', 'Fasta/centaurea.nu',
'Fasta/wisteria.nu', 'Fasta/sweetpea.nu',

0 comments on commit 0bdb1f2

Please sign in to comment.
Something went wrong with that request. Please try again.