protdist works for me on phylip 3.61
[bioperl-run.git] / t / Hmmer.t
blob5b36f9d06aca58ff8d426265d34ee630e711ac19
1 #!/usr/local/bin/perl
2 #-*-Perl-*-
3 # ## Bioperl Test Harness Script for Modules
4 # #
5 use strict;
6 BEGIN {
7 eval { require Test; };
8 if( $@ ) {
9 use lib 't';
11 use Test;
12 use vars qw($NTESTS);
13 $NTESTS = 20;
14 plan tests => $NTESTS;
17 use Bio::Tools::Run::Hmmer;
18 use Bio::Root::IO;
19 use Bio::SeqIO;
20 use Bio::AlignIO;
21 use Bio::Seq;
23 END {
24 foreach ( $Test::ntest..$NTESTS ) {
25 skip('Unable to run Hmmer tests, exe may not be installed',1);
27 unlink Bio::Root::IO->catfile(qw(t data hmmer.hmm));
29 ok(1);
31 my $verbose = 1 if $ENV{'BIOPERLDEBUG'};
33 my $db = Bio::Root::IO->catfile("t","data","pfam_sample_R11");
34 my @params = ('DB'=>$db,'E'=>5,'program'=>'hmmpfam','A'=>2,'-verbose' => $verbose);
36 #test HMMPFAM
37 my $factory = Bio::Tools::Run::Hmmer->new(@params);
38 ok $factory->isa('Bio::Tools::Run::Hmmer');
39 ok $factory->E, 5;
40 my $prot_file= Bio::Root::IO->catfile("t","data","hmmpfam_protein_input");
42 my $seq1 = Bio::Seq->new();
43 my $seqstream = Bio::SeqIO->new(-file => $prot_file,
44 -format => 'fasta');
45 $seq1 = $seqstream->next_seq();
47 my $hmmpfam_present = $factory->executable();
49 unless ($hmmpfam_present) {
50 warn("hmmpfam program not found. Skipping tests $Test::ntest to $NTESTS.\n");
51 exit 0;
54 my $searchio = $factory->run($seq1);
56 my @feat;
57 while (my $result = $searchio->next_result){
58 while(my $hit = $result->next_hit){
59 while (my $hsp = $hit->next_hsp){
60 push @feat, $hsp;
65 ok $feat[0]->isa('Bio::SeqFeatureI');
66 ok ($feat[0]->feature1->start,25);
67 ok ($feat[0]->feature1->end,92);
68 ok ($feat[0]->feature2->start,1);
69 ok ($feat[0]->feature2->end,124);
71 #test HMMSEARCH
72 @params = ('HMM'=>$db,'E'=>5,'program'=>'hmmsearch','-verbose' => $verbose);
73 $factory = Bio::Tools::Run::Hmmer->new(@params);
74 ok $factory->isa('Bio::Tools::Run::Hmmer');
75 ok $factory->E, 5;
76 $prot_file= Bio::Root::IO->catfile("t","data","hmmpfam_protein_input");
78 $seq1 = Bio::Seq->new();
79 $seqstream = Bio::SeqIO->new(-file => $prot_file,
80 -format => 'fasta');
81 $seq1 = $seqstream->next_seq();
83 my $hmmsearch = $factory->executable();
85 unless ($hmmsearch) {
86 warn("hmmsearch program not found. Skipping tests $Test::ntest to $NTESTS.\n");
87 exit 0;
89 $searchio = $factory->run($seq1);
90 @feat= ();
91 while (my $result = $searchio->next_result){
92 while(my $hit = $result->next_hit){
93 while (my $hsp = $hit->next_hsp){
94 push @feat, $hsp;
99 ok $feat[0]->isa('Bio::SeqFeatureI');
100 ok ($feat[0]->feature1->start,1);
101 ok ($feat[0]->feature1->end,124);
102 ok ($feat[0]->feature2->start,25);
103 ok ($feat[0]->feature2->end,92);
105 #test HMMBUILD
106 my $hmmout= Bio::Root::IO->catfile("t","data","hmmer.hmm");
107 @params = ('HMM'=>$hmmout,'program'=>'hmmbuild');
108 $factory = Bio::Tools::Run::Hmmer->new(@params);
109 ok $factory->isa('Bio::Tools::Run::Hmmer');
110 my $aln_file= Bio::Root::IO->catfile("t","data","cysprot.msf");
111 my $aio = Bio::AlignIO->new(-file=>$aln_file,-format=>'msf');
112 my $aln = $aio->next_aln;
113 $factory->run($aln);
114 ok -e $hmmout;
118 #test HMMALIGN
119 $hmmout= Bio::Root::IO->catfile("t","data","hmmer.hmm");
120 @params = ('HMM'=>$hmmout,'program'=>'hmmalign');
121 $factory = Bio::Tools::Run::Hmmer->new(@params);
122 ok $factory->isa('Bio::Tools::Run::Hmmer');
123 my $seqfile= Bio::Root::IO->catfile("t","data","cysprot1a.fa");
124 my $seqio = Bio::SeqIO->new(-file => $seqfile,
125 -format=> 'fasta');
126 my @seqs;
127 while( my $seq = $seqio->next_seq ) {
128 push @seqs, $seq;
130 $aio = $factory->run(@seqs);
131 $aln = $aio->next_aln;
132 ok($aln);
133 #$aio = Bio::AlignIO->new(-format => 'clustalw');
134 #$aio->write_aln($aln);
135 ok($aln->each_seq, 3);