| 1 | # | ||||||||||||||||||||
| 2 | # BioPerl module for Bio::SearchIO::hmmer | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||
| 5 | # | ||||||||||||||||||||
| 6 | # Cared for by Kai Blin <kai.blin@biotech.uni-tuebingen.de> | ||||||||||||||||||||
| 7 | # | ||||||||||||||||||||
| 8 | # Copyright Kai Blin | ||||||||||||||||||||
| 9 | # | ||||||||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||
| 11 | # | ||||||||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | Bio::SearchIO::hmmer - A parser for HMMER2 and HMMER3 output (hmmscan, hmmsearch, hmmpfam) | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 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"; | ||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | =head1 DESCRIPTION | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | This object implements a parser for HMMER output. It works with both HMMER2 and HMMER3 | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =head1 FEEDBACK | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head2 Mailing Lists | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 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. | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||
| 48 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head2 Support | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 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. | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head2 Reporting Bugs | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 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: | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 AUTHOR - Kai Blin | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | Email kai.blin-at-biotech.uni-tuebingen.de | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =head1 APPENDIX | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||
| 76 | Internal methods are usually preceded with a _ | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | # Let the code begin... | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | package Bio::SearchIO::hmmer; | ||||||||||||||||||||
| 83 | 5 | $Bio::SearchIO::hmmer::VERSION = '1.7.3'; | |||||||||||||||||||
| 84 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 5 | ▶ | use Bio::Factory::ObjectFactory; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 5 | ▶ | use base qw(Bio::SearchIO); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 30 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||
| 91 | 30 | my ( $caller, @args ) = @_; | |||||||||||||||||||
| 92 | 30 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 30 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||
| 95 | 30 | $self->_initialize(@args); | |||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | # Try to guess the hmmer format version if it's not specified. | ||||||||||||||||||||
| 98 | 30 | my $version; | |||||||||||||||||||
| 99 | 30 | my %param = @args; | |||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 30 | @param{ map { lc $_ } keys %param } = values %param; # lowercase keys | |||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | # If the caller specified a version, go for that | ||||||||||||||||||||
| 104 | 30 | ▶ | if (defined($param{"-version"})) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 5 | $version = $param{"-version"}; | |||||||||||||||||||
| 106 | } else { | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | # read second line of the file | ||||||||||||||||||||
| 109 | 25 | my $first_line = $self->_readline; | |||||||||||||||||||
| 110 | 25 | $_ = $self->_readline; | |||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 25 | ▶ | if ( m/HMMER\s3/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | 11 | $version = "3"; | |||||||||||||||||||
| 114 | } else { | ||||||||||||||||||||
| 115 | 14 | $version = "2"; | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 25 | $self->_pushback($_); | |||||||||||||||||||
| 119 | 25 | $self->_pushback($first_line); | |||||||||||||||||||
| 120 | } | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 30 | my $format = "hmmer$version"; | |||||||||||||||||||
| 123 | 30 | ▶ | return unless( $class->_load_format_module($format) ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 30 | bless($self, "Bio::SearchIO::$format"); | |||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 30 | return $self; | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 60 | ▶ | sub _initialize { | ||||||||||||||||||
|
Subroutine
_initialize: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 131 | 60 | my ( $self, @args ) = @_; | |||||||||||||||||||
| 132 | 60 | $self->SUPER::_initialize(@args); | |||||||||||||||||||
| 133 | 60 | my $handler = $self->_eventHandler; | |||||||||||||||||||
| 134 | 60 | $handler->register_factory( | |||||||||||||||||||
| 135 | 'result', | ||||||||||||||||||||
| 136 | Bio::Factory::ObjectFactory->new( | ||||||||||||||||||||
| 137 | -type => 'Bio::Search::Result::HMMERResult', | ||||||||||||||||||||
| 138 | -interface => 'Bio::Search::Result::ResultI' | ||||||||||||||||||||
| 139 | ) | ||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | 60 | $handler->register_factory( | |||||||||||||||||||
| 143 | 'hit', | ||||||||||||||||||||
| 144 | Bio::Factory::ObjectFactory->new( | ||||||||||||||||||||
| 145 | -type => 'Bio::Search::Hit::HMMERHit', | ||||||||||||||||||||
| 146 | -interface => 'Bio::Search::Hit::HitI' | ||||||||||||||||||||
| 147 | ) | ||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | 60 | $handler->register_factory( | |||||||||||||||||||
| 151 | 'hsp', | ||||||||||||||||||||
| 152 | Bio::Factory::ObjectFactory->new( | ||||||||||||||||||||
| 153 | -type => 'Bio::Search::HSP::HMMERHSP', | ||||||||||||||||||||
| 154 | -interface => 'Bio::Search::HSP::HSPI' | ||||||||||||||||||||
| 155 | ) | ||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||
| 157 | } | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | 5 | 1; | |||||||||||||||||||