Skip to content

Commit

Permalink
Bio::SeqIO::embl::_write_id_line: accession_number() returns 'unknown…
Browse files Browse the repository at this point in the history
…' for unassigned accession#

Signed-off-by: Kai Blin <kai.blin@biotech.uni-tuebingen.de>
  • Loading branch information
Kai Blin committed Nov 10, 2011
1 parent d447967 commit c7fc2c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Bio/SeqIO/embl.pm
Expand Up @@ -505,7 +505,7 @@ sub _write_ID_line {

# The sequence name is supposed to be the primary accession number,
my $name = $seq->accession_number();
if (!$name) {
if (!defined($name) || $name eq 'unknown') {
# but if it is not present, use the sequence ID.
$name = $seq->id();
}
Expand Down
15 changes: 14 additions & 1 deletion t/SeqIO/embl.t
Expand Up @@ -8,7 +8,7 @@ BEGIN {
use lib '../..';
use Bio::Root::Test;

test_begin(-tests => 95);
test_begin(-tests => 96);

use_ok('Bio::SeqIO::embl');
}
Expand Down Expand Up @@ -315,3 +315,16 @@ foreach my $feature ($seq->top_SeqFeatures) {
is($embl_species->ncbi_taxid, 9606, "The taxid of the source feature overrides that of the OX line");
is($embl_species->binomial(), 'Anopheles gambiae', "Name has roundtripped");
}

# Handle Seq objects that only define an ID, not an accession number
{
my $seq = Bio::Seq->new(-seq=>'actg', -id=>'test_id');

my $string;
open(my $str_fh, '>', \$string) || skip("Can't open string, skipping", 1);

my $out = Bio::SeqIO->new(-format=>'embl', -fh=>$str_fh);
$out->write_seq($seq);

ok($string =~ m/ID test_id;/, "The ID field was written correctly");
}

0 comments on commit c7fc2c7

Please sign in to comment.