2 ## Bioperl Test Harness Script for Modules
6 use vars qw($NUMTESTS);
8 eval { require Test; };
15 plan tests => $NUMTESTS;
18 END { unlink qw(cysprot.dnd cysprot1a.dnd) }
20 use Bio::Tools::Run::Alignment::TCoffee;
27 for ( $Test::ntest..$NUMTESTS ) {
28 skip("TCoffee program not found. Skipping.\n",1);
30 unlink("t_coffee.log");
36 my $factory = Bio::Tools::Run::Alignment::TCoffee->new(@params);
38 ok ($factory =~ /Bio::Tools::Run::Alignment::TCoffee/);
41 $factory->ktuple($ktuple);
43 my $new_ktuple = $factory->ktuple();
44 ok $new_ktuple, 3, " couldn't set factory parameter";
46 my $what_matrix = $factory->matrix();
47 ok $what_matrix, qr/BLOSUM/i, "couldn't get factory parameter";
50 $factory->quiet($bequiet); # Suppress tcoffee messages to terminal
52 my $inputfilename = Bio::Root::IO->catfile("t","data","cysprot.fa");
56 my $coffee_present = $factory->executable();
57 unless ($coffee_present) {
58 warn "tcoffee program not found. Skipping tests $Test::ntest to $NUMTESTS.\n";
61 my $version = $factory->version;
62 ok ($version >= 1.22, 1, "Code tested only on t_coffee versions > 1.22" );
63 $aln = $factory->align($inputfilename);
65 ok( $aln->no_sequences, 7);
67 my $str = Bio::SeqIO->new('-file' =>
68 Bio::Root::IO->catfile("t","data","cysprot.fa"),
69 '-format' => 'Fasta');
72 while ( my $seq = $str->next_seq() ) {
73 push (@seq_array, $seq) ;
76 my $seq_array_ref = \@seq_array;
78 $aln = $factory->align($seq_array_ref);
79 ok $aln->no_sequences, 7;
80 my $s1_perid = $aln->average_percentage_identity;
83 my $profile1 = Bio::Root::IO->catfile("t","data","cysprot1a.msf");
84 my $profile2 = Bio::Root::IO->catfile("t","data","cysprot1b.msf");
85 $aln = $factory->profile_align($profile1,$profile2);
86 ok $aln->no_sequences, 7;
88 my $str1 = Bio::AlignIO->new(-file=> Bio::Root::IO->catfile("t","data","cysprot1a.msf"));
89 my $aln1 = $str1->next_aln();
90 ok $aln1->no_sequences, 3;
92 my $str2 = Bio::AlignIO->new(-file=> Bio::Root::IO->catfile("t","data","cysprot1b.msf"));
93 my $aln2 = $str2->next_aln();
94 ok $aln2->no_sequences, 4;
96 $aln = $factory->profile_align($aln1,$aln2);
97 ok $aln->no_sequences, 7;
100 $str1 = Bio::AlignIO->new(-file=> Bio::Root::IO->catfile("t","data","cysprot1a.msf"));
101 $aln1 = $str1->next_aln();
102 $str2 = Bio::SeqIO->new(-file=> Bio::Root::IO->catfile("t","data","cysprot1b.fa"));
103 my $seq = $str2->next_seq();
105 ok $aln1->no_sequences, 3;
106 ok( int($aln1->average_percentage_identity), 39);
107 $aln = $factory->profile_align($aln1,$seq);
108 ok( $aln->no_sequences, 4);
109 if( $version <= 1.22 ) {
110 ok( $aln->overall_percentage_identity > 18);
111 ok( int($aln->average_percentage_identity), 44);
113 my $overall = int($aln->overall_percentage_identity);
114 ok( $overall >=21 && $overall <= 23, 1, 'expect 21 >= val >= 23');
115 my $avg = int($aln->average_percentage_identity);
116 ok( $avg == 47 || $avg ==48, 1, 'expect 47 or 48');
119 # test new 'run' generic running of factory
121 $aln = $factory->run('-type' => 'profile',
123 '-seq' => Bio::Root::IO->catfile("t","data","cysprot1b.fa"));
125 ok( $aln->no_sequences, 7);
126 if( $version <= 1.22 ) {
127 ok( $aln->overall_percentage_identity > 18);
128 ok( int($aln->average_percentage_identity), 44);
130 my $overall = int $aln->overall_percentage_identity;
131 ok($overall == 14 || $overall == 13,1,'expect 13 or 14');
132 my $avg = int($aln->average_percentage_identity);
133 ok($avg == 41 || $avg == 42, 1, 'expect 41 or 42');
136 $aln = $factory->run('-type' => 'align',
137 '-seq' => Bio::Root::IO->catfile("t","data","cysprot.fa"));
138 ok ($aln->no_sequences, 7);
139 ok ($aln->percentage_identity,$s1_perid); #calculated before