~ubuntu-branches/ubuntu/oneiric/bioperl/oneiric

« back to all changes in this revision

Viewing changes to t/SeqStats.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090310071911-ever3si2bbzx1iks
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*-Perl-*-
2
 
## Bioperl Test Harness Script for Modules
3
 
##
4
 
 
5
 
use strict;
6
 
BEGIN {
7
 
    # to handle systems with no installed Test module
8
 
    # we include the t dir (where a copy of Test.pm is located)
9
 
    # as a fallback
10
 
    eval { require Test; };
11
 
    if( $@ ) { use lib 't'; }
12
 
    use Test;
13
 
    plan tests => 36;
14
 
}
15
 
 
16
 
use Bio::PrimarySeq;
17
 
use Bio::Tools::SeqStats;
18
 
use vars ('$DEBUG');
19
 
 
20
 
my ($seqobj, $count, $seqobj_stats, $wt);
21
 
 
22
 
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTG',
23
 
                               -alphabet=>'dna', -id=>'test');
24
 
$seqobj_stats  =  Bio::Tools::SeqStats->new(-seq=>$seqobj);
25
 
 
26
 
ok defined($seqobj_stats) && ref($seqobj_stats) &&
27
 
    $seqobj_stats->isa('Bio::Tools::SeqStats');
28
 
 
29
 
$count = $seqobj_stats->count_monomers();  # for DNA sequence
30
 
ok $count->{'A'}, 3;
31
 
ok $count->{'C'}, 4;
32
 
ok $count->{'G'}, 5;
33
 
ok $count->{'T'}, 4;
34
 
 
35
 
$count = $seqobj_stats->count_codons();
36
 
ok $count->{'ACT'}, 2;
37
 
ok $count->{'GTG'}, 1;
38
 
ok $count->{'GCG'}, 1;
39
 
ok $count->{'TCA'}, 1;
40
 
 
41
 
 
42
 
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTACTTCA', -alphabet=>'dna',
43
 
                               -id=>'test');
44
 
$seqobj_stats  =  Bio::Tools::SeqStats->new('-seq' => $seqobj);
45
 
$wt = $seqobj_stats->get_mol_wt();  # for DNA sequence
46
 
ok &round($$wt[0]), 2738 ;
47
 
 
48
 
$seqobj = Bio::PrimarySeq->new(-seq=>'ACXACNNCA',
49
 
                               -alphabet=>'dna', -id=>'test');
50
 
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
51
 
ok &round($$wt[0]), 2693;
52
 
ok &round($$wt[1]), 2813;
53
 
 
54
 
 
55
 
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTG',
56
 
                               -alphabet=>'dna', -id=>'test');
57
 
$count = Bio::Tools::SeqStats->count_monomers($seqobj);  # for DNA sequence
58
 
ok $count->{'A'}, 3;
59
 
ok $count->{'C'}, 4;
60
 
ok $count->{'G'}, 5;
61
 
ok $count->{'T'}, 4;
62
 
 
63
 
$seqobj = Bio::PrimarySeq->new(-seq=>'MQSERGITIDISLWKFETSKYYVT',
64
 
                               -alphabet=>'protein', -id=>'test');
65
 
$seqobj_stats  =  Bio::Tools::SeqStats->new('-seq' => $seqobj);
66
 
$count = $seqobj_stats->count_monomers();  # for amino sequence
67
 
ok $$count{'M'}, 1;
68
 
ok $$count{'I'}, 3;
69
 
ok $$count{'Y'}, 2;
70
 
ok $$count{'T'}, 3;
71
 
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
72
 
ok int $$wt[0], 2896;
73
 
ok int $$wt[1], 2896;
74
 
 
75
 
$seqobj = Bio::PrimarySeq->new(-seq=>'UYXUYNNYU', -alphabet=>'rna');
76
 
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
77
 
ok &round($$wt[0]), 2768;
78
 
ok &round($$wt[1]), 2891;
79
 
 
80
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'TGCCGTGTGTGCTGCTGCT', -alphabet=>'rna');
81
 
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
82
 
ok &round($$wt[0]), 6104 ;
83
 
 
84
 
# selenocysteine
85
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'MQSERGITIDISLWKFETSKYYVT',
86
 
                                  -alphabet=>'protein');
87
 
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
88
 
ok &round($$wt[0]), 2896 ;
89
 
 
90
 
#
91
 
# hydropathicity aka "gravy" score
92
 
#
93
 
 
94
 
# normal seq (should succeed)
95
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'MSFVLVAPDMLATAAADVVQIGSAVSAGS',
96
 
                                  -alphabet=>'protein');
97
 
my $gravy = Bio::Tools::SeqStats->hydropathicity($seqobj);
98
 
ok int($gravy*1000) == 1224;  # check to nearest 0.1%
99
 
 
100
 
# ambiguous sequence (should fail)
101
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'XXXB**BS', -alphabet=>'protein');
102
 
eval { Bio::Tools::SeqStats->hydropathicity($seqobj) };
103
 
ok $@ =~ /ambiguous amino acids/i;
104
 
 
105
 
# empty sequence (should fail)
106
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'', -alphabet=>'protein');
107
 
eval { Bio::Tools::SeqStats->hydropathicity($seqobj) };
108
 
ok $@ =~ /hydropathicity not defined/i;
109
 
 
110
 
# DNA sequence (should fail)
111
 
ok $seqobj = Bio::PrimarySeq->new(-seq=>'GATTACA', -alphabet=>'dna');
112
 
eval { Bio::Tools::SeqStats->hydropathicity($seqobj) };
113
 
ok $@ =~ /only meaningful for protein/;
114
 
 
115
 
 
116
 
#
117
 
# Extra functions
118
 
#
119
 
 
120
 
# perl does not have an explicit rounding function
121
 
sub round { return int ((shift @_) + 0.5 ) }