Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Splicedseq.t: Reorganized new tests to use "-requires_networking"

for online tests, and made a format cleaning
  • Loading branch information...
commit 37766bd3a641b64b2ae109ce12695c695c8712a8 1 parent 2c19034
@fjossandon fjossandon authored
Showing with 49 additions and 46 deletions.
  1. +49 −46 t/SeqIO/Splicedseq.t
View
95 t/SeqIO/Splicedseq.t
@@ -3,38 +3,35 @@
use strict;
-BEGIN {
+BEGIN {
use lib '.';
use Bio::Root::Test;
-
- test_begin(-tests => 18);
-
- use_ok('Bio::SeqIO');
-}
-ok my $str = Bio::SeqIO->new(
- '-file'=> test_input_file('U58726.gb'),
- '-format' => 'GenBank');
+ test_begin(-tests => 19);
-my $seq;
+ use_ok('Bio::SeqIO');
+}
+ok my $str = Bio::SeqIO->new(-file => test_input_file('U58726.gb'),
+ -format => 'GenBank');
+my $seq;
ok ( $seq = $str->next_seq() );
# Here is a cute way to verify the sequence by seeing if the
# the translation matches what is annotated in the file -js
-foreach my $ft ( grep { $_->primary_tag eq 'CDS'}
- $seq->top_SeqFeatures ) {
+foreach my $ft ( grep { $_->primary_tag eq 'CDS'}
+ $seq->top_SeqFeatures ) {
if( $ft->has_tag('translation') ) {
- my ($translation) = $ft->get_tag_values('translation');
- my $t = $ft->spliced_seq(-nosort => 1);
- my $pepseq = $t->translate()->seq();
- chop($pepseq);# chop is to remove stop codon
- is($translation,$pepseq);
- }
+ my ($translation) = $ft->get_tag_values('translation');
+ my $t = $ft->spliced_seq(-nosort => 1);
+ my $pepseq = $t->translate()->seq();
+ chop($pepseq); # chop is to remove stop codon
+ is($translation, $pepseq);
+ }
}
-my $stream = Bio::SeqIO->new(-file => test_input_file('M12730.gb'),
- -format => 'genbank');
+my $stream = Bio::SeqIO->new(-file => test_input_file('M12730.gb'),
+ -format => 'genbank');
# Jump down to M12730 which lists CDS join(1959..2355,1..92)
while ($seq->accession ne "M12730") {
$seq = $stream->next_seq;
@@ -51,36 +48,42 @@ foreach my $feat2 ( @features ) {
}
my ($protein_seq) = $feat->get_tag_values("translation");
like($protein_seq, qr(^MKERYGTVYKGSQRLIDE.*ANEKQENALYLIIILSRTSIT$),
- "protein sequence");
+ "protein sequence");
my ($nucleotide_seq) = $feat->spliced_seq(-nosort => 1)->seq;
like($nucleotide_seq, qr(^ATGAAAGAAAGATATGGA.*TCAAGGACTAGTATAACATAA$),
- "nucleotide sequence - correct CDS range");
+ "nucleotide sequence - correct CDS range");
is(length($nucleotide_seq), 489, "nucleotide length");
-my $str2 = Bio::SeqIO->new('-file'=> test_input_file('AF032047.gbk'),
- '-format' => 'GenBank');
+# Test for Fix spliced seq #72
+my $str2 = Bio::SeqIO->new(-file => test_input_file('AF032047.gbk'),
+ -format => 'GenBank');
my @feats = $str2-> next_seq -> get_SeqFeatures;
- # feat[1] has 2 exons from remote sequence AF032048.1
-
-my $db_in;
-eval{
- use Bio::DB::GenBank;
- $db_in = Bio::DB::GenBank -> new;
- my $seq_obj = $db_in->get_Seq_by_id('AF032048.1');
-};
-if($@){
- warn("Warning: Problem with accessing GenBank entry AF032048.1 to test spliced_seq on remote DBs. Skipping 2 tests\n");
-} else {
+# feat[1] has 2 exons from remote sequence AF032048.1
+my $len_nodb;
+warnings_like { $len_nodb = length($feats[1]->spliced_seq()->seq); }
+ [ {carped => qr/cannot get remote location for/},
+ {carped => qr/cannot get remote location for/}
+ ],
+ "appropriate warning if db not provided for remote sequence";
+ok($len_nodb == 374, "correct number of Ns added if remote sequence not provided");
+
+SKIP: {
+ test_skip(-tests => 3, -requires_networking => 1);
+ my $db_in;
+ eval {
+ use Bio::DB::GenBank;
+ ok $db_in = Bio::DB::GenBank->new();
+ my $seq_obj = $db_in->get_Seq_by_id('AF032048.1');
+ };
+ if ($@) {
+ print "$@\n";
+ skip "Warning: Problem accessing GenBank entry AF032048.1 "
+ . "to test spliced_seq on remote DBs", 2;
+ }
+
my $len_w_db;
- warning_is{
- $len_w_db = length($feats[1]->spliced_seq(-db => $db_in)->seq)
- } [] , "no warnings if genbank db provided for remote source seq";
- ok($len_w_db == 374, "correct length if source sequence is provided remotely")
+ warning_is { $len_w_db = length($feats[1]->spliced_seq(-db => $db_in)->seq) }
+ [],
+ "no warnings if GenBank db provided for remote sequence";
+ ok($len_w_db == 374, "correct length if remote sequence is provided")
}
-my $len_nodb;
-warnings_like{
- $len_nodb = length($feats[1]->spliced_seq()->seq);
-} [{carped => qr/cannot get remote location for/} ,
- {carped => qr/cannot get remote location for/}], "appropriate warning if db not provided for remote source seq";
-
-ok($len_nodb == 374, "correct number of Ns added if source sequence not provided");
Please sign in to comment.
Something went wrong with that request. Please try again.