1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 33,
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);
52 # requiring Internet access, set env BIOPERLDEBUG to 1 to run
54 test_skip(-tests => 10, -requires_networking => 1);
55 ok my $tool = Bio::WebAgent->new(-verbose => $verbose);
57 is $tool->delay(1), 1;
61 ok my $db = Bio::DB::CUTG->new();
62 $db->verbose($verbose ? $verbose : -1);
64 eval {$cdtable = $db->get_request(-sp =>'Pan troglodytes');};
65 skip "Could not connect to server, server/network problems? Skipping those tests", 5 if $@;
67 # tests for Table.pm, the answers seem to change with time, so not specific
68 cmp_ok($cdtable->cds_count(), '>', 600);
69 cmp_ok(int($cdtable->aa_frequency('LEU')), '>', 1);
70 ok $cdtable->get_coding_gc('all');
71 cmp_ok($cdtable->codon_rel_frequency('ttc'), '<', 1);
73 ## now lets enter a non-existent species ans check handling..
74 ## should default to human...
75 my $db2 = Bio::DB::CUTG->new();
76 $db2->verbose($verbose ? $verbose : -1);
77 eval {$cut2 = $db2->get_request(-sp =>'Wookie magnus');};
78 skip "Could not connect to server, server/network problems? Skipping those tests", 1 if $@;
79 is $cut2->species(), 'Homo sapiens';