1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 37,
11 -requires_modules => [qw(IO::String LWP::UserAgent)]);
13 use_ok('Bio::DB::CUTG');
14 use_ok('Bio::CodonUsage::Table');
15 use_ok('Bio::CodonUsage::IO');
17 use_ok('Bio::Tools::SeqStats');
20 my $outfile = test_output_file();
21 my $verbose = test_debug();
23 # try reading from file
24 ok my $io = Bio::CodonUsage::IO->new
25 (-file=> test_input_file('MmCT'));
26 ok my $cut2 = $io->next_data();
27 is int($cut2->aa_frequency('LEU')), 10;
30 ok $io = Bio::CodonUsage::IO->new(-file => ">$outfile");
31 $io->write_data($cut2);
34 # can we read what we've written?
35 ok $io = Bio::CodonUsage::IO->new(-file => "$outfile");
36 ok $cut2 = $io->next_data();
37 is int($cut2->aa_frequency('LEU')), 10;
39 # now try making a user defined CUT from a sequence
40 ok my $seqobj = Bio::SeqIO->new (-file =>test_input_file('HUMBETGLOA.fa'),
41 -format => 'fasta')->next_seq;
42 is $seqobj->subseq(10,20), 'TTGACACCACT';
43 ok my $codcont_Ref = Bio::Tools::SeqStats->count_codons($seqobj);
44 is $codcont_Ref->{'TGA'}, 16;
45 ok my $cut = Bio::CodonUsage::Table->new(-data=>$codcont_Ref);
46 is $cut->codon_rel_frequency('CTG'), 0.18;
47 is $cut->codon_abs_frequency('CTG'), 2.6;
48 is $cut->codon_count('CTG'), 26;
49 is $cut->get_coding_gc(1), "39.70";
50 ok my $ref = $cut->probable_codons(20);
53 # http://www.kazusa.or.jp/codon/cgi-bin/spsearch.cgi?species=Pan+troglodytes&c=s
54 # http://www.kazusa.or.jp/codon/cgi-bin/showcodon.cgi?species=37011&aa=1&style=GCG
55 # requiring Internet access, set env BIOPERLDEBUG to 1 to run
57 test_skip(-tests => 14, -requires_networking => 1);
58 ok my $tool = Bio::WebAgent->new(-verbose => $verbose);
60 is $tool->delay(1), 1;
64 ok my $db = Bio::DB::CUTG->new();
65 $db->verbose($verbose ? $verbose : -1);
67 eval {$cdtable = $db->get_request(-sp =>'Pan troglodytes');};
68 skip "Server/network problems? Skipping those tests\n$@", 9 if $@;
70 # tests for Table.pm, the answers seem to change with time, so not specific
71 cmp_ok($cdtable->cds_count(), '>', 10);
72 cmp_ok(int($cdtable->aa_frequency('LEU')), '>', 1);
73 ok $cdtable->get_coding_gc('all');
74 cmp_ok($cdtable->codon_rel_frequency('ttc'), '<', 1);
76 ## now lets enter a non-existent species ans check handling..
77 ## should default to human...
78 my $db2 = Bio::DB::CUTG->new();
79 $db2->verbose($verbose ? $verbose : -1);
80 eval {$cut2 = $db2->get_request(-sp =>'Wookie magnus');};
81 skip "Server/network problems? Skipping those tests\n$@", 5 if $@;
82 is $cut2->species(), 'Homo sapiens';
84 $db = Bio::DB::CUTG->new();
85 $db->verbose($verbose ? $verbose : -1);
86 eval {$cdtable = $db->get_request(-sp =>'Homo sapiens');};
87 skip "Server/network problems? Skipping those tests\n$@", 4 if $@;
89 # tests for Table.pm, the answers seem to change with time, so not specific
90 cmp_ok($cdtable->cds_count(), '>', 10);
91 cmp_ok(int($cdtable->aa_frequency('LEU')), '>', 1);
92 ok $cdtable->get_coding_gc('all');
93 cmp_ok($cdtable->codon_rel_frequency('ttc'), '<', 1);
95 my $db3 = Bio::DB::CUTG->new(-sp =>'Bacillus subtilis', -gc => 1);
96 $db3->verbose($verbose ? $verbose : -1);
98 eval {$cut3 = $db3->get_request();};
99 skip "Server/network problems? Skipping those tests\n$@", 5 if $@;
100 print $cut3->codon_rel_frequency('ATG');