From 637aab3582142f59bcc64a8f86f26848c4208e30 Mon Sep 17 00:00:00 2001 From: "Francisco J. Ossandon" Date: Tue, 29 Apr 2014 17:24:14 -0400 Subject: [PATCH] BioFetch.t & SwissProt.t: Fixed some number of skipped tests and cleaned format and indentation --- t/RemoteDB/BioFetch.t | 270 +++++++++++++++++++++++++------------------------ t/RemoteDB/SwissProt.t | 52 +++++----- 2 files changed, 162 insertions(+), 160 deletions(-) rewrite t/RemoteDB/BioFetch.t (87%) diff --git a/t/RemoteDB/BioFetch.t b/t/RemoteDB/BioFetch.t dissimilarity index 87% index d68047c7e..19169108d 100644 --- a/t/RemoteDB/BioFetch.t +++ b/t/RemoteDB/BioFetch.t @@ -1,134 +1,136 @@ -# -*-Perl-*- Test Harness script for Bioperl -# $Id$ - -use strict; - -BEGIN { - use lib '.'; - use Bio::Root::Test; - - test_begin(-tests => 36, - -requires_modules => [qw(IO::String LWP::UserAgent)], - -requires_networking => 1); - - use_ok('Bio::DB::BioFetch'); -} - -my $verbose = test_debug(); - -my $dbwarn = "Warning: Couldn't connect to EMBL with Bio::DB::BioFetch!\n"; - -my ($db,$db2,$seq,$seqio); - -SKIP :{ - # get a single seq - ok defined($db = Bio::DB::BioFetch->new(-verbose => $verbose)); - # get a RefSeq entry - ok $db->db('refseq'); - eval { - $seq = $db->get_Seq_by_acc('NM_006732'); # RefSeq VERSION - }; - skip($dbwarn, 4) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->accession_number,'NM_006732'); - is($seq->accession_number,'NM_006732'); - is( $seq->length, 3776); -} - -SKIP: { - # EMBL - $db->db('embl'); - eval { - $seq = $db->get_Seq_by_acc('J02231'); - }; - skip($dbwarn, 3) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->id, 'J02231'); - is($seq->length, 200); -} - -SKIP: { - eval { - $seqio = $db->get_Stream_by_id(['AEE33958']); - }; - skip($dbwarn, 3) if $@; - undef $db; # testing to see if we can remove gb - $seq = $seqio->next_seq(); - isa_ok($seqio, 'Bio::SeqIO'); - isa_ok($seq, 'Bio::SeqI'); - cmp_ok( $seq->length, '>=', 1); -} - -SKIP: { - #swissprot - ok $db2 = Bio::DB::BioFetch->new(-db => 'swissprot'); - eval { - $seq = $db2->get_Seq_by_id('YNB3_YEAST'); - }; - skip($dbwarn, 5) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->length, 125); - is($seq->division, 'YEAST'); - $db2->request_format('fasta'); - eval { - $seq = $db2->get_Seq_by_acc('P43780'); - }; - skip($dbwarn, 2) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->length,103); -} - -$seq = $seqio = undef; - -SKIP: { - ok $db = Bio::DB::BioFetch->new(-retrievaltype => 'tempfile', - -format => 'fasta', - -verbose => $verbose - ); - $db->db('embl'); - eval { - $seqio = $db->get_Stream_by_id('J00522 AF303112 J02231'); - }; - skip($dbwarn, 7) if $@; - my %seqs; - # don't assume anything about the order of the sequences - while ( my $s = $seqio->next_seq ) { - isa_ok($s, 'Bio::SeqI'); - my ($type,$x,$name) = split(/\|/,$s->display_id); - $seqs{$x} = $s->length; - } - isa_ok($seqio, 'Bio::SeqIO'); - is($seqs{'J00522'},408); - is($seqs{'AF303112'},1611); - is($seqs{'J02231'},200); -} - -SKIP: { - ok $db = Bio::DB::BioFetch->new(-db => 'embl', -verbose => $verbose ? $verbose : -1); - - # check contig warning (WebDBSeqI) - eval { - $seq = $db->get_Seq_by_acc('NT_006732'); - }; - like($@, qr{contigs are whole chromosome files}, 'contig warning'); - eval { - $seq = $db->get_Seq_by_acc('NM_006732'); - }; - skip($dbwarn, 3) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->length,3776); -} - -# unisave -SKIP: { - ok $db = Bio::DB::BioFetch->new(-db => 'unisave', - -verbose => $verbose); - eval { - $seq = $db->get_Seq_by_acc('LAM1_MOUSE'); - }; - skip($dbwarn, 3) if $@; - isa_ok($seq, 'Bio::SeqI'); - is($seq->display_id, 'LAM1_MOUSE'); - is($seq->accession, 'P14733'); - is($seq->length, 587); -} +# -*-Perl-*- Test Harness script for Bioperl +# $Id$ + +use strict; + +BEGIN { + use lib '.'; + use Bio::Root::Test; + + test_begin(-tests => 36, + -requires_modules => [qw(IO::String + LWP::UserAgent)], + -requires_networking => 1); + + use_ok('Bio::DB::BioFetch'); +} + +my $verbose = test_debug(); + +my $dbwarn = "Warning: Couldn't connect to EMBL with Bio::DB::BioFetch!\n"; + +my ($db,$db2,$seq,$seqio); + +SKIP :{ + # get a single seq + ok defined($db = Bio::DB::BioFetch->new(-verbose => $verbose)); + # get a RefSeq entry + ok $db->db('refseq'); + eval { + $seq = $db->get_Seq_by_acc('NM_006732'); # RefSeq VERSION + }; + skip($dbwarn, 4) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->accession_number,'NM_006732'); + is($seq->accession_number,'NM_006732'); + is( $seq->length, 3776); +} + +SKIP: { + # EMBL + $db->db('embl'); + eval { + $seq = $db->get_Seq_by_acc('J02231'); + }; + skip($dbwarn, 3) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->id, 'J02231'); + is($seq->length, 200); +} + +SKIP: { + eval { + $seqio = $db->get_Stream_by_id(['AEE33958']); + }; + skip($dbwarn, 3) if $@; + undef $db; # testing to see if we can remove gb + $seq = $seqio->next_seq(); + isa_ok($seqio, 'Bio::SeqIO'); + isa_ok($seq, 'Bio::SeqI'); + cmp_ok( $seq->length, '>=', 1); +} + +SKIP: { + #swissprot + ok $db2 = Bio::DB::BioFetch->new(-db => 'swissprot'); + eval { + $seq = $db2->get_Seq_by_id('YNB3_YEAST'); + }; + skip($dbwarn, 5) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->length, 125); + is($seq->division, 'YEAST'); + $db2->request_format('fasta'); + eval { + $seq = $db2->get_Seq_by_acc('P43780'); + }; + skip($dbwarn, 2) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->length,103); +} + +$seq = $seqio = undef; + +SKIP: { + ok $db = Bio::DB::BioFetch->new(-retrievaltype => 'tempfile', + -format => 'fasta', + -verbose => $verbose + ); + $db->db('embl'); + eval { + $seqio = $db->get_Stream_by_id('J00522 AF303112 J02231'); + }; + skip($dbwarn, 7) if $@; + my %seqs; + # don't assume anything about the order of the sequences + while ( my $s = $seqio->next_seq ) { + isa_ok($s, 'Bio::SeqI'); + my ($type,$x,$name) = split(/\|/,$s->display_id); + $seqs{$x} = $s->length; + } + isa_ok($seqio, 'Bio::SeqIO'); + is($seqs{'J00522'},408); + is($seqs{'AF303112'},1611); + is($seqs{'J02231'},200); +} + +SKIP: { + ok $db = Bio::DB::BioFetch->new(-db => 'embl', + -verbose => $verbose ? $verbose : -1); + + # check contig warning (WebDBSeqI) + eval { + $seq = $db->get_Seq_by_acc('NT_006732'); + }; + like($@, qr{contigs are whole chromosome files}, 'contig warning'); + eval { + $seq = $db->get_Seq_by_acc('NM_006732'); + }; + skip($dbwarn, 2) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->length,3776); +} + +# unisave +SKIP: { + ok $db = Bio::DB::BioFetch->new(-db => 'unisave', + -verbose => $verbose); + eval { + $seq = $db->get_Seq_by_acc('LAM1_MOUSE'); + }; + skip($dbwarn, 4) if $@; + isa_ok($seq, 'Bio::SeqI'); + is($seq->display_id, 'LAM1_MOUSE'); + is($seq->accession, 'P14733'); + is($seq->length, 587); +} diff --git a/t/RemoteDB/SwissProt.t b/t/RemoteDB/SwissProt.t index 4cd37e5c0..b5f94e33f 100755 --- a/t/RemoteDB/SwissProt.t +++ b/t/RemoteDB/SwissProt.t @@ -4,28 +4,28 @@ use strict; BEGIN { - use lib '.'; - use Bio::Root::Test; + use lib '.'; + use Bio::Root::Test; - test_begin(-tests => 23, - -requires_modules => [qw(IO::String - LWP::UserAgent - HTTP::Request::Common)], - -requires_networking => 1); + test_begin(-tests => 23, + -requires_modules => [qw(IO::String + LWP::UserAgent + HTTP::Request::Common)], + -requires_networking => 1); - use_ok('Bio::DB::SwissProt'); + use_ok('Bio::DB::SwissProt'); } -ok my $gb = Bio::DB::SwissProt->new(-retrievaltype =>'pipeline', - -delay => 0); +ok my $gb = Bio::DB::SwissProt->new(-retrievaltype => 'pipeline', + -delay => 0); my %expected_lengths = ( - 'NDP_MOUSE' => 131, - 'NDP_HUMAN' => 133, - 'BOLA_HAEIN'=> 103, - 'YNB3_YEAST'=> 125, - 'O39869' => 56, - 'DEGP_CHLTR'=> 497, + 'NDP_MOUSE' => 131, + 'NDP_HUMAN' => 133, + 'BOLA_HAEIN' => 103, + 'YNB3_YEAST' => 125, + 'O39869' => 56, + 'DEGP_CHLTR' => 497, 'DEGPL_CHLTR' => 497 ); @@ -64,18 +64,18 @@ SKIP: { } # test idtracker() method -ok $gb = Bio::DB::SwissProt->new(-retrievaltype =>'pipeline', - -delay => 0, - -verbose => 2); +ok $gb = Bio::DB::SwissProt->new(-retrievaltype => 'pipeline', + -delay => 0, + -verbose => 2); SKIP: { my $map; # check old ID eval {$map = $gb->id_mapper(-from => 'ACC+ID', - -to => 'ACC', - -ids => [qw(MYOD1_PIG PYRC_YEAST)]) - }; - skip("Problem with idtracker(), skipping these tests: $@", 3) if $@; + -to => 'ACC', + -ids => [qw(MYOD1_PIG PYRC_YEAST)] + )}; + skip("Problem with idtracker(), skipping these tests: $@", 6) if $@; cmp_ok(@{$map->{MYOD1_PIG}}, '>=', 1); is($map->{MYOD1_PIG}[0], 'P49811'); @@ -84,9 +84,9 @@ SKIP: { eval {$map = $gb->id_mapper(-from => 'ACC+ID', -to => 'EMBL', - -ids => [qw(PYRC_YEAST)]) - }; - skip("Problem with idtracker(), skipping these tests: $@", 1) if $@; + -ids => [qw(PYRC_YEAST)] + )}; + skip("Problem with idtracker(), skipping these tests: $@", 2) if $@; cmp_ok(@{$map->{PYRC_YEAST}}, '>=', 2); like($map->{PYRC_YEAST}[0], qr/^[A-Z0-9]/); -- 2.11.4.GIT