changes all issue tracking in preparation for switch to github issues
[bioperl-live.git] / Bio / SearchIO / hmmer.pm
blob6897947321570d7344e9312f46fdaeaccdfa4e8d
2 # BioPerl module for Bio::SearchIO::hmmer
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Kai Blin <kai.blin@biotech.uni-tuebingen.de>
8 # Copyright Kai Blin
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::SearchIO::hmmer - A parser for HMMER2 and HMMER3 output (hmmscan, hmmsearch, hmmpfam)
18 =head1 SYNOPSIS
20 # do not use this class directly it is available through Bio::SearchIO
21 use Bio::SearchIO;
22 my $in = Bio::SearchIO->new(-format => 'hmmer',
23 -file => 't/data/L77119.hmmer');
24 while( my $result = $in->next_result ) {
25 # this is a Bio::Search::Result::HMMERResult object
26 print $result->query_name(), " for HMM ", $result->hmm_name(), "\n";
27 while( my $hit = $result->next_hit ) {
28 print $hit->name(), "\n";
29 while( my $hsp = $hit->next_hsp ) {
30 print "length is ", $hsp->length(), "\n";
35 =head1 DESCRIPTION
37 This object implements a parser for HMMER output. It works with both HMMER2 and HMMER3
39 =head1 FEEDBACK
41 =head2 Mailing Lists
43 User feedback is an integral part of the evolution of this and other
44 Bioperl modules. Send your comments and suggestions preferably to
45 the Bioperl mailing list. Your participation is much appreciated.
47 bioperl-l@bioperl.org - General discussion
48 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
50 =head2 Support
52 Please direct usage questions or support issues to the mailing list:
54 I<bioperl-l@bioperl.org>
56 rather than to the module maintainer directly. Many experienced and
57 reponsive experts will be able look at the problem and quickly
58 address it. Please include a thorough description of the problem
59 with code and data examples if at all possible.
61 =head2 Reporting Bugs
63 Report bugs to the Bioperl bug tracking system to help us keep track
64 of the bugs and their resolution. Bug reports can be submitted via the
65 web:
67 https://github.com/bioperl/bioperl-live/issues
69 =head1 AUTHOR - Kai Blin
71 Email kai.blin-at-biotech.uni-tuebingen.de
73 =head1 APPENDIX
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
78 =cut
80 # Let the code begin...
82 package Bio::SearchIO::hmmer;
84 use strict;
86 use Bio::Factory::ObjectFactory;
88 use base qw(Bio::SearchIO);
90 sub new {
91 my ( $caller, @args ) = @_;
92 my $class = ref($caller) || $caller;
94 my $self = $class->SUPER::new(@args);
95 $self->_initialize(@args);
97 # Try to guess the hmmer format version if it's not specified.
98 my $version;
99 my %param = @args;
101 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
103 # If the caller specified a version, go for that
104 if (defined($param{"-version"})) {
105 $version = $param{"-version"};
106 } else {
108 # read second line of the file
109 my $first_line = $self->_readline;
110 $_ = $self->_readline;
112 if ( m/HMMER\s3/ ) {
113 $version = "3";
114 } else {
115 $version = "2";
118 $self->_pushback($_);
119 $self->_pushback($first_line);
122 my $format = "hmmer$version";
123 return unless( $class->_load_format_module($format) );
125 bless($self, "Bio::SearchIO::$format");
127 return $self;
130 sub _initialize {
131 my ( $self, @args ) = @_;
132 $self->SUPER::_initialize(@args);
133 my $handler = $self->_eventHandler;
134 $handler->register_factory(
135 'result',
136 Bio::Factory::ObjectFactory->new(
137 -type => 'Bio::Search::Result::HMMERResult',
138 -interface => 'Bio::Search::Result::ResultI'
142 $handler->register_factory(
143 'hit',
144 Bio::Factory::ObjectFactory->new(
145 -type => 'Bio::Search::Hit::HMMERHit',
146 -interface => 'Bio::Search::Hit::HitI'
150 $handler->register_factory(
151 'hsp',
152 Bio::Factory::ObjectFactory->new(
153 -type => 'Bio::Search::HSP::HMMERHSP',
154 -interface => 'Bio::Search::HSP::HSPI'