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 7, 2011
1 parent d447967 commit 5e552c0
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') {

This comment has been minimized.

Copy link
@kblin

kblin Nov 10, 2011

Member

@cjfields: Ok, this one still passes the test case and should address your concerns for RichSeq subclasses that return undef. If you're fine with this, I'll push it to master.

This comment has been minimized.

Copy link
@cjfields

cjfields Nov 10, 2011

Member

Yes, go ahead.

This comment has been minimized.

Copy link
@kblin

kblin Nov 10, 2011

Member

Wow, you're quick. Pushed to master, thanks.

# 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 5e552c0

Please sign in to comment.