2 ## Bioperl Test Harness Script for Modules
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
10 # to handle systems with no installed Test module
11 # we include the t dir (where a copy of Test.pm is located)
13 eval { require Test; };
21 use Bio::Tools::CodonTable;
25 # create a table object by giving an ID
27 my $myCodonTable = Bio::Tools::CodonTable -> new ( -id => 16);
28 ok defined $myCodonTable;
29 ok $myCodonTable->isa('Bio::Tools::CodonTable');
31 # defaults to ID 1 "Standard"
32 $myCodonTable = Bio::Tools::CodonTable->new();
33 ok $myCodonTable->id(), 1;
37 $myCodonTable->id(10);
38 ok $myCodonTable->id, 10;
40 ok $myCodonTable->name(), 'Euplotid Nuclear';
46 $myCodonTable->translate();
50 ok $myCodonTable->translate(''), '';
52 my @ii = qw(ACT acu ATN gt ytr sar);
53 my @res = qw(T T X V L Z );
56 if ($res[$i] ne $myCodonTable->translate($ii[$i]) ) {
58 print $ii[$i], ": |", $res[$i], "| ne |", $myCodonTable->translate($ii[$i]), "|\n" if( $DEBUG);
63 ok $myCodonTable->translate('ag'), '';
64 ok $myCodonTable->translate('jj'), '';
65 ok $myCodonTable->translate('jjg'), 'X';
66 ok $myCodonTable->translate('gt'), 'V';
67 ok $myCodonTable->translate('g'), '';
69 # a more comprehensive test on ambiguous codes
71 atgaaraayacmacracwackacyacsacvachacdacbacxagragyatmatwatyathcarcayc
72 cmccrccwcckccyccsccvcchccdccbccxcgmcgrcgwcgkcgycgscgvcghcgdcgbcgxctmctrct
73 wctkctyctsctvcthctdctbctxgargaygcmgcrgcwgckgcygcsgcvgchgcdgcbgcxggmggrggw
74 ggkggyggsggvgghggdggbggxgtmgtrgtwgtkgtygtsgtvgthgtdgtbgtxtartaytcmtcrtcwt
75 cktcytcstcvtchtcdtcbtcxtgyttrttytramgamggmgrracratrayytaytgytrsaasagsartaa;
78 @ii = grep { length == 3 } split /(.{3})/, $seq;
79 print join (' ', @ii), "\n" if( $DEBUG);
81 MKNTTTTTTTTTTTRSIIIIQHPPPPPPPPPPPRRRRRRRRRRRLLLLLLLLLLLEDAAAAAAAAAAAGGG
82 GGGGGGGGVVVVVVVVVVV*YSSSSSSSSSSSCLF*RRRBBBLLLZZZ*
86 @res = split //, $prot;
87 print join (' ', @res), "\n" if( $DEBUG );
90 if ($res[$i] ne $myCodonTable->translate($ii[$i]) ) {
92 print $ii[$i], ": |", $res[$i], "| ne |",
93 $myCodonTable->translate($ii[$i]), "| @ $i\n" if( $DEBUG);
99 # reverse translate amino acids
101 ok $myCodonTable->revtranslate('J'), 0;
104 @ii = qw(A l ACN Thr sER ter Glx);
106 [qw(gct gcc gca gcg)],
107 [qw(ggc gga ggg act acc aca acg)],
108 [qw(tct tcc tca tcg agt agc)],
109 [qw(act acc aca acg)],
110 [qw(tct tcc tca tcg agt agc)],
112 [qw(gaa gag caa cag)]
117 for my $i (0..$#ii) {
118 my @codonres = $myCodonTable->revtranslate($ii[$i]);
119 for my $j (0..$#codonres) {
120 if ($codonres[$j] ne $res[$i][$j]) {
122 print $ii[$i], ': ', $codonres[$j], " ne ",
123 $res[$i][$j], "\n" if( $DEBUG);
132 $myCodonTable->id(1);
134 ok $myCodonTable->is_start_codon('ATG');
135 ok( $myCodonTable->is_start_codon('GGH'), 0);
136 ok $myCodonTable->is_start_codon('HTG');
137 ok $myCodonTable->is_start_codon('CCC'), 0;
139 ok $myCodonTable->is_ter_codon('UAG');
140 ok $myCodonTable->is_ter_codon('TaG');
141 ok $myCodonTable->is_ter_codon('TaR');
142 ok $myCodonTable->is_ter_codon('tRa');
143 ok $myCodonTable->is_ter_codon('ttA'), 0;
145 ok $myCodonTable->is_unknown_codon('jAG');
146 ok $myCodonTable->is_unknown_codon('jg');
147 ok $myCodonTable->is_unknown_codon('UAG'), 0;
150 ok $myCodonTable->translate_strict('ATG'), 'M';