2 ## Bioperl Test Harness Script for Modules
8 test_begin(-tests => 27);
9 use_ok('Bio::Tools::Run::Alignment::TCoffee');
10 use_ok('Bio::SimpleAlign');
11 use_ok('Bio::AlignIO');
15 END { unlink qw(cysprot.dnd cysprot1a.dnd) }
18 unlink("t_coffee.log");
22 my $factory = Bio::Tools::Run::Alignment::TCoffee->new(@params);
24 isa_ok ($factory, 'Bio::Tools::Run::Alignment::TCoffee');
27 $factory->ktuple($ktuple);
29 my $new_ktuple = $factory->ktuple();
30 is $new_ktuple, 3, "set factory parameter";
32 my $what_matrix = $factory->matrix();
33 like $what_matrix, qr/BLOSUM/i, "get factory parameter";
36 $factory->quiet($bequiet); # Suppress tcoffee messages to terminal
38 my $inputfilename = test_input_file('cysprot.fa');
42 test_skip(-requires_executable => $factory,
44 my $version = $factory->version;
45 cmp_ok ($version, '>=', 1.22, "Code tested only on t_coffee versions > 1.22" );
46 $aln = $factory->align($inputfilename);
48 is( $aln->num_sequences, 7);
50 my $str = Bio::SeqIO->new('-file' =>
51 test_input_file("cysprot.fa"),
52 '-format' => 'fasta');
55 while ( my $seq = $str->next_seq() ) {
56 push (@seq_array, $seq) ;
59 my $seq_array_ref = \@seq_array;
61 $aln = $factory->align($seq_array_ref);
62 is $aln->num_sequences, 7;
63 my $s1_perid = $aln->average_percentage_identity;
65 my $profile1 = test_input_file("cysprot1a.msf");
66 my $profile2 = test_input_file("cysprot1b.msf");
68 # convert any warnings about program to an actual exception
70 lives_ok {$aln = $factory->profile_align($profile1,$profile2)};
71 skip("T-COFFEE error, skipping tests", 15) if $@;
72 is $aln->num_sequences, 7;
74 my $str1 = Bio::AlignIO->new(-file=> test_input_file("cysprot1a.msf"));
75 my $aln1 = $str1->next_aln();
76 is $aln1->num_sequences, 3;
78 my $str2 = Bio::AlignIO->new(-file=> test_input_file("cysprot1b.msf"));
79 my $aln2 = $str2->next_aln();
80 is $aln2->num_sequences, 4;
82 $aln = $factory->profile_align($aln1,$aln2);
83 is $aln->num_sequences, 7;
85 $str1 = Bio::AlignIO->new(-file=> test_input_file("cysprot1a.msf"));
86 $aln1 = $str1->next_aln();
87 $str2 = Bio::SeqIO->new(-file=> test_input_file("cysprot1b.fa"));
88 my $seq = $str2->next_seq();
90 is $aln1->num_sequences, 3;
91 is( int($aln1->average_percentage_identity), 39);
92 $aln = $factory->profile_align($aln1,$seq);
93 is( $aln->num_sequences, 4);
94 if( $version <= 1.22 ) {
95 cmp_ok( $aln->overall_percentage_identity, '>', 18);
96 is( int($aln->average_percentage_identity), 44);
98 my $overall = int($aln->overall_percentage_identity);
99 ok( $overall >=21 && $overall <= 23, 'expect 21 >= val >= 23');
100 my $avg = int($aln->average_percentage_identity);
101 ok( $avg == 47 || $avg ==48, 'expect 47 or 48');
104 # test new 'run' generic running of factory
106 $aln = $factory->run('-type' => 'align',
107 '-seq' => test_input_file("cysprot.fa"));
108 is ($aln->num_sequences, 7, 'simple generic run');
109 is ($aln->percentage_identity,$s1_perid); #calculated before
111 lives_ok{ $aln = $factory->run('-type' => 'profile',
113 '-seq' => test_input_file("cysprot1b.fa"))} ;
115 skip("T-COFFEE error, skipping tests",3) if $@;
117 is( $aln->num_sequences, 7);
118 if( $version <= 1.22 ) {
119 cmp_ok( $aln->overall_percentage_identity, '>', 18);
120 is( int($aln->average_percentage_identity), 44);
122 my $overall = int $aln->overall_percentage_identity;
123 ok($overall == 14 || $overall == 13, 'expect 13 or 14');
124 my $avg = int($aln->average_percentage_identity);
125 ok($avg == 41 || $avg == 42, 'expect 41 or 42');
130 # warnings are already given above, no need to keep report
131 if (-e 'error_report.T-COFFEE') {
132 unlink('error_report.T-COFFEE');
134 if (my @dnds = glob('*.dnd')) {
135 for my $file (@dnds) {