1 # You may distribute this module under the same terms as perl itself
2 # POD documentation - main docs before the code
6 Bio::Tools::Run::Hmmer - Wrapper for local execution of hmmsearch
7 ,hmmbuild, hmmcalibrate, hmmalign, hmmpfam
11 #run hmmpfam|hmmalign|hmmsearch
12 my $factory = Bio::Tools::Run::Hmmer->new('program'=>'hmmsearch','hmm'=>'model.hmm');
14 # Pass the factory a Bio::Seq object or a file name
16 # returns a Bio::SearchIO object
17 my $search = $factory->run($seq);
21 while (my $result = $searchio->next_result){
22 while(my $hit = $result->next_hit){
23 while (my $hsp = $hit->next_hsp){
24 print join("\t", ( $r->query_name,
38 #build a hmm using hmmbuild
39 my $aio = Bio::AlignIO->new(-file=>"protein.msf",-format=>'msf');
40 my $aln = $aio->next_aln;
41 my $factory = Bio::Tools::Run::Hmmer->new('program'=>'hmmbuild','hmm'=>'model.hmm');
45 my $factory = Bio::Tools::Run::Hmmer->new('program'=>'hmmcalibrate','hmm'=>'model.hmm');
50 Wrapper module for Sean Eddy's HMMER suite of program to allow running of hmmsearch,hmmpfam,hmmalign, hmmbuild,hmmconvert. Binaries are available at http://hmmer.wustl.edu/
56 User feedback is an integral part of the evolution of this and other
57 Bioperl modules. Send your comments and suggestions preferably to one
58 of the Bioperl mailing lists. Your participation is much appreciated.
60 bioperl-l@bioperl.org - General discussion
61 http://bio.perl.org/MailList.html - About the mailing lists
65 Report bugs to the Bioperl bug tracking system to help us keep track
66 the bugs and their resolution. Bug reports can be submitted via email
69 bioperl-bugs@bioperl.org
70 http://bugzilla.bioperl.org/
78 Shawn Hoon shawnh@gmx.net
82 The rest of the documentation details each of the object
83 methods. Internal methods are usually preceded with a _
87 package Bio
::Tools
::Run
::Hmmer
;
89 use vars
qw($AUTOLOAD @ISA @HMMER_PARAMS @HMMER_SWITCHES %OK_FIELD);
95 use Bio::Tools::Run::WrapperBase;
97 @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);
100 @HMMER_PARAMS=qw(HMM PROGRAM DB N A E T Z );
101 @HMMER_SWITCHES=qw(N);
102 foreach my $attr ( @HMMER_PARAMS,@HMMER_SWITCHES)
103 { $OK_FIELD{$attr}++; }
109 Usage : $factory>program_name()
110 Function: holds the program name
118 return $self->program(@_);
124 Usage : $factory->program_dir(@params)
125 Function: returns the program directory, obtiained from ENV variable.
132 return Bio
::Root
::IO
->catfile($ENV{HMMERDIR
}) if $ENV{HMMERDIR
};
137 my $attr = $AUTOLOAD;
140 $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr};
141 $self->{$attr} = shift if @_;
142 return $self->{$attr};
148 Usage : $HMMER->new(@params)
149 Function: creates a new HMMER factory
150 Returns: Bio::Tools::Run::HMMER
156 my ($class,@args) = @_;
157 my $self = $class->SUPER::new
(@args);
158 $self->io->_initialize_io();
162 $value = shift @args;
163 next if( $attr =~ /^-/ ); # don't want named parameters
164 $self->$attr($value);
172 Usage : $obj->run($seqFile)
173 Function: Runs HMMER and returns Bio::SearchIO
174 Returns : A Bio::SearchIO
175 Args : A Bio::PrimarySeqI or file name
180 my ($self,@seq) = @_;
182 if (ref $seq[0] && $seq[0]->isa("Bio::PrimarySeqI") ){# it is an object
184 my $infile1 = $self->_writeSeqFile(@seq);
185 return $self->_run($infile1);
187 elsif(ref $seq[0] && $seq[0]->isa("Bio::Align::AlignI")){
188 my $infile1 = $self->_writeAlignFile(@seq);
189 return $self->_run($infile1);
192 return $self->_run(@seq);
201 Function: Internal(not to be used directly)
202 Returns : An array of Bio::SeqFeature::Generic objects
208 my ($self,$file)= @_;
210 my $str = $self->executable;
211 my $param_str = $self->_setparams;
212 $str.=" $param_str ".$file;
214 $self->debug("HMMER command = $str");
216 if($self->program_name=~/hmmpfam|hmmsearch|hmmalign/){
217 open(HMM
,"$str |") || $self->throw("HMMER call ($str) crashed: $?\n");
218 my $searchio= Bio
::SearchIO
->new(-fh
=>\
*HMM
,-format
=>"hmmer");
221 else { # for hmmbuild or hmmcalibrate
222 my $status = system($str);
223 $self->throw("HMMER call($str) crashed: $?\n") unless $status==0;
232 Usage : Internal function, not to be called directly
233 Function: creates a string of params to be used in the command string
235 Returns : string of params
243 foreach my $attr(@HMMER_PARAMS){
244 next if $attr=~/HMM|PROGRAM|DB/i;
245 my $value = $self->$attr();
246 next unless (defined $value);
247 my $attr_key = ' -'.(uc $attr);
248 $param_string .= $attr_key.' '.$value;
250 foreach my $attr(@HMMER_SWITCHES){
251 my $value = $self->$attr();
252 next unless (defined $value);
253 my $attr_key = ' -'.($attr);
254 $param_string .=$attr_key;
256 my ($hmm) = $self->HMM || $self->DB || $self->throw("Need to specify either HMM file or Database");
257 $param_string.=' '.$hmm;
259 return $param_string;
265 Title : _writeSeqFile
266 Usage : obj->_writeSeqFile($seq)
267 Function: Internal(not to be used directly)
274 my ($self,@seq) = @_;
275 my ($tfh,$inputfile) = $self->io->tempfile(-dir
=>$self->tempdir);
276 my $in = Bio
::SeqIO
->new(-fh
=> $tfh , '-format' => 'Fasta');
288 =head2 _writeAlignFile
290 Title : _writeAlignFile
291 Usage : obj->_writeAlignFile($seq)
292 Function: Internal(not to be used directly)
299 my ($self,@align) = @_;
300 my ($tfh,$inputfile) = $self->io->tempfile(-dir
=>$self->tempdir);
301 my $in = Bio
::AlignIO
->new(-fh
=> $tfh , '-format' => 'msf');
302 foreach my $s(@align){