~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to t/SeqFeature.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
## Bioperl Test Harness Script for Modules
3
3
##
4
4
# CVS Version
5
 
# $Id: SeqFeature.t,v 1.33 2003/10/25 14:52:22 heikki Exp $
 
5
# $Id: SeqFeature.t,v 1.41.4.4 2006/11/30 09:24:00 sendu Exp $
6
6
 
7
7
 
8
8
# Before `make install' is performed this script should be runnable with
10
10
 
11
11
use strict;
12
12
use vars qw($NUMTESTS);
13
 
my $skipdbtests ;
 
13
my $skipdbtests;
 
14
my $skip_all;
14
15
BEGIN { 
15
 
    # to handle systems with no installed Test module
16
 
    # we include the t dir (where a copy of Test.pm is located)
17
 
    # as a fallback
18
 
    eval { require Test; };
19
 
    if( $@ ) {
20
 
        use lib 't';
21
 
    }
22
 
    use Test;
23
 
    $NUMTESTS = 74;
24
 
    plan tests => $NUMTESTS;
25
 
 
26
 
    eval { 
27
 
        require IO::String; 
28
 
        require LWP::UserAgent;
29
 
        require HTTP::Request::Common;
30
 
        require Bio::DB::GenBank;
31
 
       };
32
 
    if( $@ ) {
33
 
        print STDERR "skipping DB tests...\n";
34
 
        $skipdbtests = 1;
35
 
    } else {
36
 
        $skipdbtests = 0;
37
 
    }
38
 
 
 
16
        # to handle systems with no installed Test module
 
17
        # we include the t dir (where a copy of Test.pm is located)
 
18
        # as a fallback
 
19
        eval { require Test; };
 
20
        if( $@ ) {
 
21
                use lib 't';
 
22
        }
 
23
        use Test;
 
24
        $NUMTESTS = 211;
 
25
        plan tests => $NUMTESTS;
 
26
 
 
27
        eval { 
 
28
                require IO::String; 
 
29
                require LWP::UserAgent;
 
30
                require HTTP::Request::Common;
 
31
                require Bio::DB::GenBank;
 
32
        };
 
33
        if( $@ ) {
 
34
                print STDERR "IO::String, LWP::UserAgent or HTTP::Request not installed - skipping DB tests...\n";
 
35
                $skipdbtests = 1;
 
36
        } else {
 
37
                $skipdbtests = 0;
 
38
        }
 
39
        eval {
 
40
                require URI::Escape;
 
41
        };
 
42
        if( $@ ) {
 
43
                print STDERR "URI::Escape not installed, so Bio::SeqFeature::Annotated not usable - skipping all tests...\n";
 
44
                $skip_all = 1;
 
45
        }
39
46
}
40
47
 
41
48
END {
42
 
    foreach ( $Test::ntest..$NUMTESTS) {
43
 
        skip('Skipping tests which need the Bio::DB::GenBank module',1);
44
 
    }
 
49
        foreach ( $Test::ntest..$NUMTESTS) {
 
50
                skip('Skipping tests which need the Bio::DB::GenBank module',1);
 
51
        }
45
52
}
46
53
 
 
54
exit(0) if $skip_all;
 
55
 
47
56
use Bio::Seq;
 
57
use Bio::SeqIO;
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;
53
 
 
54
 
use Bio::SeqIO;
 
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;
59
67
use Bio::SeqFeature::Gene::GeneStructure;
60
68
 
61
69
use Bio::Location::Fuzzy;
62
 
 
 
70
use Env qw(BIOPERLDEUG); # for importing bioperldebug var
63
71
ok(1);
64
72
 
65
73
# predeclare variables for strict
330
338
 
331
339
# now let's test spliced_seq
332
340
 
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');
335
344
 
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();
339
 
$CDS->verbose(-1);
340
 
my $cdsseq = $CDS->spliced_seq($db);
341
 
exit;
342
 
ok($cdsseq->subseq(1,60, 'ATGCAGCCATACGCTTCCGTGAGCGGGCGATGTCTATC'.
343
 
                   'TAGACCAGATGCATTGCATGTGATACCGTTTGGGCGAC'));
344
 
ok($cdsseq->translate->subseq(1,100), 'MQPYASVSGRCLSRPDALHVIPFGRP'.
345
 
   'LQAIAGRRFVRCFAKGGQPGDKKKLNVTDKLRLGNTPPTLDVLKAPRPTDAPSAIDDAPSTSGLGLGGGVASPR');
346
 
 
347
 
ok  $seqio = new Bio::SeqIO(-file => Bio::Root::IO->catfile(qw(t data AF032047.gbk)),
 
347
my $db;
 
348
 
 
349
unless( $skipdbtests ) {
 
350
 $db = new Bio::DB::GenBank(-verbose=> $ENV{BIOPERLDEBUG});
 
351
 $CDS->verbose(-1);
 
352
 my $cdsseq = $CDS->spliced_seq(-db => $db,-nosort => 1);
 
353
 
 
354
 ok($cdsseq->subseq(1,60, 'ATGCAGCCATACGCTTCCGTGAGCGGGCGATGTCTATC'.
 
355
                    'TAGACCAGATGCATTGCATGTGATACCGTTTGGGCGAC'));
 
356
 ok($cdsseq->translate->subseq(1,100), 'MQPYASVSGRCLSRPDALHVIPFGRP'.
 
357
    'LQAIAGRRFVRCFAKGGQPGDKKKLNVTDKLRLGNTPPTLDVLKAPRPTDAPSAIDDAPSTSGLGLGGGVASPR');
 
358
} else {
 
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);
 
361
 
 
362
}
 
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;
351
 
 
352
 
$cdsseq = $CDS->spliced_seq($db);
353
 
ok($cdsseq->subseq(1,60, 'ATGGCTCGCTTCGTGGTGGTAGCCCTGCTCGCGCTACTCTCTCTG'.
354
 
                   'TCTGGCCTGGAGGCTATCCAGCATG'));
355
 
ok($cdsseq->translate->seq, 'MARFVVVALLALLSLSGLEAIQHAPKIQVYSRHPAENGKPNFL'.
356
 
   'NCYVSGFHPSDIEVDLLKNGKKIEKVEHSDLSFSKDWSFYLLYYTEFTPNEKDEYACRVSHVTFPTPKTVKWDRTM*');
357
 
 
 
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*');
 
374
} else {
 
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);
 
377
}
 
378
 
 
379
 
 
380
# trans-spliced 
 
381
 
 
382
ok( $seqio = Bio::SeqIO->new(-format => 'genbank',
 
383
                                                                          -file   => 
 
384
                            Bio::Root::IO->catfile(qw(t data NC_001284.gbk))));
 
385
my $genome = $seqio->next_seq;
 
386
 
 
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');
 
391
}
 
392
 
 
393
my $sfa = Bio::SeqFeature::Annotated->new(-start => 1,
 
394
                                          -end => 5,
 
395
                                          -strand => "+",
 
396
                                          -frame => 2,
 
397
                                          -phase => 2,
 
398
                                          -score => 12,
 
399
                                          -display_name => 'test.annot',
 
400
                                          -seq_id => 'test.displayname' );
 
401
 
 
402
ok (defined $sfa);
 
403
my $loc = $sfa->location;
 
404
ok $loc->isa("Bio::Location::Simple");
 
405
 
 
406
ok $sfa->display_name eq 'test.annot';
 
407
 
 
408
 
 
409
#test bsfa::from_feature
 
410
{
 
411
  my $sfg = Bio::SeqFeature::Generic->new ( -start => 400,
 
412
                                            -end => 440,
 
413
                                            -strand => 1,
 
414
                                            -primary => 'nucleotide_motif',
 
415
                                            -source  => 'program_a',
 
416
                                            -tag => {
 
417
                                                     silly => 20,
 
418
                                                     new => 1
 
419
                                                    }
 
420
                                          );
 
421
        my $sfa2;
 
422
        eval {
 
423
                $sfa2 = Bio::SeqFeature::Annotated->new(-feature => $sfg);
 
424
        };
 
425
        if ($@) {
 
426
                foreach ( $Test::ntest..$NUMTESTS ) { skip('Could not get sofa definitions from external server',1); }
 
427
                exit(0);
 
428
        }
 
429
  ok $sfa2->type->name,'nucleotide_motif';
 
430
  ok $sfa2->primary_tag, 'nucleotide_motif';
 
431
  ok $sfa2->source,'program_a';
 
432
  ok $sfa2->strand,1;
 
433
  ok $sfa2->start,400;
 
434
  ok $sfa2->end,440;
 
435
  ok $sfa2->get_Annotations('silly')->value,20;
 
436
  ok $sfa2->get_Annotations('new')->value,1;
 
437
 
 
438
  my $sfa3 = Bio::SeqFeature::Annotated->new( -start => 1,
 
439
                                              -end => 5,
 
440
                                              -strand => "+",
 
441
                                              -frame => 2,
 
442
                                              -phase => 2,
 
443
                                              -score => 12,
 
444
                                              -display_name => 'test.annot',
 
445
                                              -seq_id => 'test.displayname' );
 
446
  eval {
 
447
        $sfa3->from_feature($sfg);
 
448
  };
 
449
  if ($@) {
 
450
        foreach ( $Test::ntest..$NUMTESTS ) { skip('Could not get sofa definitions from external server',1); }
 
451
        exit(0);
 
452
  }
 
453
  ok $sfa3->type->name,'nucleotide_motif';
 
454
  ok $sfa3->primary_tag, 'nucleotide_motif';
 
455
  ok $sfa3->source,'program_a';
 
456
  ok $sfa3->strand,1;
 
457
  ok $sfa3->start,400;
 
458
  ok $sfa3->end,440;
 
459
  ok $sfa3->get_Annotations('silly')->value,20;
 
460
  ok $sfa3->get_Annotations('new')->value,1;
 
461
}