12
12
use vars qw($NUMTESTS);
15
# to handle systems with no installed Test module
16
# we include the t dir (where a copy of Test.pm is located)
18
eval { require Test; };
24
plan tests => $NUMTESTS;
28
require LWP::UserAgent;
29
require HTTP::Request::Common;
30
require Bio::DB::GenBank;
33
print STDERR "skipping DB tests...\n";
16
# to handle systems with no installed Test module
17
# we include the t dir (where a copy of Test.pm is located)
19
eval { require Test; };
25
plan tests => $NUMTESTS;
29
require LWP::UserAgent;
30
require HTTP::Request::Common;
31
require Bio::DB::GenBank;
34
print STDERR "IO::String, LWP::UserAgent or HTTP::Request not installed - skipping DB tests...\n";
43
print STDERR "URI::Escape not installed, so Bio::SeqFeature::Annotated not usable - skipping all tests...\n";
42
foreach ( $Test::ntest..$NUMTESTS) {
43
skip('Skipping tests which need the Bio::DB::GenBank module',1);
49
foreach ( $Test::ntest..$NUMTESTS) {
50
skip('Skipping tests which need the Bio::DB::GenBank module',1);
48
58
use Bio::SeqFeature::Generic;
49
59
use Bio::SeqFeature::FeaturePair;
50
60
use Bio::SeqFeature::SimilarityPair;
51
use Bio::Tools::Blast;
52
61
use Bio::SeqFeature::Computation;
62
require Bio::SeqFeature::Annotated;
55
63
use Bio::SeqFeature::Gene::Transcript;
56
64
use Bio::SeqFeature::Gene::UTR;
57
65
use Bio::SeqFeature::Gene::Exon;
331
339
# now let's test spliced_seq
333
ok $seqio = new Bio::SeqIO(-file => Bio::Root::IO->catfile(qw(t data AY095303S1.gbk)),
341
ok $seqio = new Bio::SeqIO(-file => Bio::Root::IO->catfile
342
(qw(t data AY095303S1.gbk)),
334
343
-format => 'genbank');
336
345
ok $geneseq = $seqio->next_seq();
337
346
my ($CDS) = grep { $_->primary_tag eq 'CDS' } $geneseq->get_SeqFeatures;
338
my $db = new Bio::DB::GenBank();
340
my $cdsseq = $CDS->spliced_seq($db);
342
ok($cdsseq->subseq(1,60, 'ATGCAGCCATACGCTTCCGTGAGCGGGCGATGTCTATC'.
343
'TAGACCAGATGCATTGCATGTGATACCGTTTGGGCGAC'));
344
ok($cdsseq->translate->subseq(1,100), 'MQPYASVSGRCLSRPDALHVIPFGRP'.
345
'LQAIAGRRFVRCFAKGGQPGDKKKLNVTDKLRLGNTPPTLDVLKAPRPTDAPSAIDDAPSTSGLGLGGGVASPR');
347
ok $seqio = new Bio::SeqIO(-file => Bio::Root::IO->catfile(qw(t data AF032047.gbk)),
349
unless( $skipdbtests ) {
350
$db = new Bio::DB::GenBank(-verbose=> $ENV{BIOPERLDEBUG});
352
my $cdsseq = $CDS->spliced_seq(-db => $db,-nosort => 1);
354
ok($cdsseq->subseq(1,60, 'ATGCAGCCATACGCTTCCGTGAGCGGGCGATGTCTATC'.
355
'TAGACCAGATGCATTGCATGTGATACCGTTTGGGCGAC'));
356
ok($cdsseq->translate->subseq(1,100), 'MQPYASVSGRCLSRPDALHVIPFGRP'.
357
'LQAIAGRRFVRCFAKGGQPGDKKKLNVTDKLRLGNTPPTLDVLKAPRPTDAPSAIDDAPSTSGLGLGGGVASPR');
359
skip('Cannot test for remote loc with spliced_seq w/o LWP installed',1);
360
skip('Cannot test for remote loc with spliced_seq w/o LWP installed',1);
363
ok $seqio = new Bio::SeqIO(-file => Bio::Root::IO->catfile
364
(qw(t data AF032047.gbk)),
348
365
-format => 'genbank');
349
366
ok $geneseq = $seqio->next_seq();
350
367
($CDS) = grep { $_->primary_tag eq 'CDS' } $geneseq->get_SeqFeatures;
352
$cdsseq = $CDS->spliced_seq($db);
353
ok($cdsseq->subseq(1,60, 'ATGGCTCGCTTCGTGGTGGTAGCCCTGCTCGCGCTACTCTCTCTG'.
354
'TCTGGCCTGGAGGCTATCCAGCATG'));
355
ok($cdsseq->translate->seq, 'MARFVVVALLALLSLSGLEAIQHAPKIQVYSRHPAENGKPNFL'.
356
'NCYVSGFHPSDIEVDLLKNGKKIEKVEHSDLSFSKDWSFYLLYYTEFTPNEKDEYACRVSHVTFPTPKTVKWDRTM*');
368
unless ($skipdbtests ) {
369
my $cdsseq = $CDS->spliced_seq( -db => $db, -nosort => 1);
370
ok($cdsseq->subseq(1,60, 'ATGGCTCGCTTCGTGGTGGTAGCCCTGCTCGCGCTACTCTCTCTG'.
371
'TCTGGCCTGGAGGCTATCCAGCATG'));
372
ok($cdsseq->translate->seq, 'MARFVVVALLALLSLSGLEAIQHAPKIQVYSRHPAENGKPNFL'.
373
'NCYVSGFHPSDIEVDLLKNGKKIEKVEHSDLSFSKDWSFYLLYYTEFTPNEKDEYACRVSHVTFPTPKTVKWDRTM*');
375
skip('Cannot test for remote loc with spliced_seq w/o LWP installed',1);
376
skip('Cannot test for remote loc with spliced_seq w/o LWP installed',1);
382
ok( $seqio = Bio::SeqIO->new(-format => 'genbank',
384
Bio::Root::IO->catfile(qw(t data NC_001284.gbk))));
385
my $genome = $seqio->next_seq;
387
foreach my $cds (grep { $_->primary_tag eq 'CDS' } $genome->get_SeqFeatures) {
388
my $spliced = $cds->spliced_seq(-nosort => 1)->translate->seq;
389
chop($spliced); # remove stop codon
390
ok($spliced,($cds->get_tag_values('translation'))[0],'spliced seq translation matches expected');
393
my $sfa = Bio::SeqFeature::Annotated->new(-start => 1,
399
-display_name => 'test.annot',
400
-seq_id => 'test.displayname' );
403
my $loc = $sfa->location;
404
ok $loc->isa("Bio::Location::Simple");
406
ok $sfa->display_name eq 'test.annot';
409
#test bsfa::from_feature
411
my $sfg = Bio::SeqFeature::Generic->new ( -start => 400,
414
-primary => 'nucleotide_motif',
415
-source => 'program_a',
423
$sfa2 = Bio::SeqFeature::Annotated->new(-feature => $sfg);
426
foreach ( $Test::ntest..$NUMTESTS ) { skip('Could not get sofa definitions from external server',1); }
429
ok $sfa2->type->name,'nucleotide_motif';
430
ok $sfa2->primary_tag, 'nucleotide_motif';
431
ok $sfa2->source,'program_a';
435
ok $sfa2->get_Annotations('silly')->value,20;
436
ok $sfa2->get_Annotations('new')->value,1;
438
my $sfa3 = Bio::SeqFeature::Annotated->new( -start => 1,
444
-display_name => 'test.annot',
445
-seq_id => 'test.displayname' );
447
$sfa3->from_feature($sfg);
450
foreach ( $Test::ntest..$NUMTESTS ) { skip('Could not get sofa definitions from external server',1); }
453
ok $sfa3->type->name,'nucleotide_motif';
454
ok $sfa3->primary_tag, 'nucleotide_motif';
455
ok $sfa3->source,'program_a';
459
ok $sfa3->get_Annotations('silly')->value,20;
460
ok $sfa3->get_Annotations('new')->value,1;