2
## Bioperl Test Harness Script for Modules
7
# to handle systems with no installed Test module
8
# we include the t dir (where a copy of Test.pm is located)
10
eval { require Test; };
11
if( $@ ) { use lib 't'; }
17
use Bio::Tools::SeqStats;
20
my ($seqobj, $count, $seqobj_stats, $wt);
22
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTG',
23
-alphabet=>'dna', -id=>'test');
24
$seqobj_stats = Bio::Tools::SeqStats->new(-seq=>$seqobj);
26
ok defined($seqobj_stats) && ref($seqobj_stats) &&
27
$seqobj_stats->isa('Bio::Tools::SeqStats');
29
$count = $seqobj_stats->count_monomers(); # for DNA sequence
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;
42
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTACTTCA', -alphabet=>'dna',
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 ;
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;
55
$seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTG',
56
-alphabet=>'dna', -id=>'test');
57
$count = Bio::Tools::SeqStats->count_monomers($seqobj); # for DNA sequence
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
71
$wt = Bio::Tools::SeqStats->get_mol_wt($seqobj);
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;
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 ;
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 ;
91
# hydropathicity aka "gravy" score
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%
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;
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;
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/;
120
# perl does not have an explicit rounding function
121
sub round { return int ((shift @_) + 0.5 ) }