| 1 | # | ||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Search::Result::HmmpfamResult | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Cared for by Sendu Bala <bix@sendu.me.uk> | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # Copyright Sendu Bala | ||||||||||||||||||||||||||||
| 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::Search::Result::HmmpfamResult - A parser and result object for hmmpfam | ||||||||||||||||||||||||||||
| 17 | results | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # generally we use Bio::SearchIO to build these objects | ||||||||||||||||||||||||||||
| 22 | use Bio::SearchIO; | ||||||||||||||||||||||||||||
| 23 | my $in = Bio::SearchIO->new(-format => 'hmmer_pull', | ||||||||||||||||||||||||||||
| 24 | -file => 'result.hmmer'); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | while (my $result = $in->next_result) { | ||||||||||||||||||||||||||||
| 27 | print $result->query_name, " ", $result->algorithm, " ", $result->num_hits(), " hits\n"; | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | This object implements a parser for hmmpfam result output, a program in the HMMER | ||||||||||||||||||||||||||||
| 33 | package. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 40 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 41 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 44 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head2 Support | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 53 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 54 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 55 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 60 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 61 | web: | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 AUTHOR - Sendu Bala | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Email bix@sendu.me.uk | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 72 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # Let the code begin... | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | package Bio::Search::Result::HmmpfamResult; | ||||||||||||||||||||||||||||
| 79 | 3 | $Bio::Search::Result::HmmpfamResult::VERSION = '1.7.3'; | |||||||||||||||||||||||||||
| 80 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 3 | ▶ | use Bio::Search::Hit::HmmpfamHit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 3 | ▶ | use base qw(Bio::Root::Root Bio::Search::Result::PullResultI); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 new | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Title : new | ||||||||||||||||||||||||||||
| 89 | Usage : my $obj = Bio::SearchIO::Result::hmmpfam->new(); | ||||||||||||||||||||||||||||
| 90 | Function: Builds a new Bio::SearchIO::Result::hmmpfam object | ||||||||||||||||||||||||||||
| 91 | Returns : Bio::SearchIO::Result::hmmpfam | ||||||||||||||||||||||||||||
| 92 | Args : -chunk => [Bio::Root::IO, $start, $end] (required if no -parent) | ||||||||||||||||||||||||||||
| 93 | -parent => Bio::PullParserI object (required if no -chunk) | ||||||||||||||||||||||||||||
| 94 | -parameters => hash ref of search parameters (key => value), optional | ||||||||||||||||||||||||||||
| 95 | -statistics => hash ref of search statistics (key => value), optional | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | where the array ref provided to -chunk contains an IO object | ||||||||||||||||||||||||||||
| 98 | for a filehandle to something representing the raw data of the | ||||||||||||||||||||||||||||
| 99 | result, and $start and $end define the tell() position within the | ||||||||||||||||||||||||||||
| 100 | filehandle that the result data starts and ends (optional; defaults | ||||||||||||||||||||||||||||
| 101 | to start and end of the entire thing described by the filehandle) | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 3 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 107 | 3 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 3 | $self->_setup(@args); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 3 | foreach my $field (qw( header hit_table hsp_table alignments next_model models query_length )) { | |||||||||||||||||||||||||||
| 112 | 21 | $self->_fields->{$field} = undef; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 3 | $self->_dependencies( { ( query_name => 'header', | |||||||||||||||||||||||||||
| 116 | query_accession => 'header', | ||||||||||||||||||||||||||||
| 117 | query_description => 'header', | ||||||||||||||||||||||||||||
| 118 | hit_table => 'header', | ||||||||||||||||||||||||||||
| 119 | num_hits => 'hit_table', | ||||||||||||||||||||||||||||
| 120 | no_hits_found => 'hit_table', | ||||||||||||||||||||||||||||
| 121 | hsp_table => 'hit_table', | ||||||||||||||||||||||||||||
| 122 | next_alignment => 'hsp_table' ) } ); | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 3 | return $self; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||
| 128 | # PullParserI discovery methods so we can answer all ResultI questions | ||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 3 | ▶ | sub _discover_header { | ||||||||||||||||||||||||||
|
Subroutine
_discover_header: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 132 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 133 | 3 | $self->_chunk_seek(0); | |||||||||||||||||||||||||||
| 134 | 3 | my $header = $self->_get_chunk_by_end("all domains):\n"); | |||||||||||||||||||||||||||
| 135 | 3 | $self->{_after_header} = $self->_chunk_tell; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 3 | ▶ | $header || $self->throw("Could not find hmmer header, is file really hmmer format?"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 3 | ($self->_fields->{query_name}) = $header =~ /^Query(?:\s+sequence)?:\s+(\S+)/m; | |||||||||||||||||||||||||||
| 140 | 3 | ($self->_fields->{query_accession}) = $header =~ /^Accession:\s+(\S+)/m; | |||||||||||||||||||||||||||
| 141 | 3 | ($self->_fields->{query_description}) = $header =~ /^Description:\s+(\S.+)/m; | |||||||||||||||||||||||||||
| 142 | 3 | ▶ | $self->_fields->{query_accession} ||= ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->_fields->{"query_accession"} ||= ""
MC/DC100%1/1
$self->_fields->{"query_accession"} ||= ""
$self->_fields->{"query_accession"}
Truth table100%2/2
A
A= $self->_fields->{"query_accession"}
| |||||||||||||||||||||||||||||
| 143 | 3 | ▶ | $self->_fields->{query_description} ||= ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->_fields->{"query_description"} ||= ""
MC/DC100%1/1
$self->_fields->{"query_description"} ||= ""
$self->_fields->{"query_description"}
Truth table100%2/2
A
A= $self->_fields->{"query_description"}
| |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 3 | $self->_fields->{header} = 1; # stop this method being called again | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 3 | ▶ | sub _discover_hit_table { | ||||||||||||||||||||||||||
|
Subroutine
_discover_hit_table: called CC=12 SCAR=27.0
| |||||||||||||||||||||||||||||
| 149 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 3 | $self->_chunk_seek($self->{_after_header}); | |||||||||||||||||||||||||||
| 152 | 3 | my $table = $self->_get_chunk_by_end("for domains:\n"); | |||||||||||||||||||||||||||
| 153 | 3 | $self->{_after_hit_table} = $self->_chunk_tell; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 3 | my $evalue_cutoff = $self->get_field('evalue_cutoff'); | |||||||||||||||||||||||||||
| 156 | 3 | ▶ | undef $evalue_cutoff if $evalue_cutoff eq '[unset]'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 3 | my $score_cutoff = $self->get_field('score_cutoff'); | |||||||||||||||||||||||||||
| 158 | 3 | ▶ | undef $score_cutoff if $score_cutoff eq '[unset]'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 3 | my $hsps_cutoff = $self->get_field('hsps_cutoff'); | |||||||||||||||||||||||||||
| 160 | 3 | ▶ | undef $hsps_cutoff if $hsps_cutoff eq '[unset]'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 3 | my @table; | |||||||||||||||||||||||||||
| 163 | 3 | my $no_hit = 1; | |||||||||||||||||||||||||||
| 164 | 3 | ▶ | while ($table =~ /^(\S+)\s+(\S.+?)?\s+(\S+)\s+(\S+)\s+(\d+)\n/gm) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 57 | $no_hit = 0; | |||||||||||||||||||||||||||
| 166 | 57 | my $evalue = abs($4); # consistency for tests under Windows | |||||||||||||||||||||||||||
| 167 | 57 | ▶ | next if ($evalue_cutoff && $evalue > $evalue_cutoff); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$evalue_cutoff and $evalue > $evalue_cutoff
MC/DC0%0/2
$evalue_cutoff and $evalue > $evalue_cutoff
$evalue_cutoff
$evalue > $evalue_cutoff
Truth table33%1/3
A and B
A= $evalue_cutoffB= $evalue > $evalue_cutoff
| |||||||||||||||||||||||||||||
| 168 | 57 | ▶ | next if ($score_cutoff && $3 < $score_cutoff); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$score_cutoff and $3 < $score_cutoff
MC/DC0%0/2
$score_cutoff and $3 < $score_cutoff
$score_cutoff
$3 < $score_cutoff
Truth table33%1/3
A and B
A= $score_cutoffB= $3 < $score_cutoff
| |||||||||||||||||||||||||||||
| 169 | 57 | ▶ | next if ($hsps_cutoff && $5 < $hsps_cutoff); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hsps_cutoff and $5 < $hsps_cutoff
MC/DC0%0/2
$hsps_cutoff and $5 < $hsps_cutoff
$hsps_cutoff
$5 < $hsps_cutoff
Truth table33%1/3
A and B
A= $hsps_cutoffB= $5 < $hsps_cutoff
| |||||||||||||||||||||||||||||
| 170 | 57 | push(@table, [$1, $2, $3, $evalue, $5]); | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 3 | $self->_fields->{hit_table} = \@table; | |||||||||||||||||||||||||||
| 173 | 3 | ▶ | $self->{_next_hit_index} = @table > 0 ? 0 : -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 3 | $self->_fields->{no_hits_found} = $no_hit; | |||||||||||||||||||||||||||
| 176 | 3 | $self->_fields->{num_hits} = @table; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 3 | ▶ | sub _discover_hsp_table { | ||||||||||||||||||||||||||
|
Subroutine
_discover_hsp_table: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 180 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 3 | $self->_chunk_seek($self->{_after_hit_table}); | |||||||||||||||||||||||||||
| 183 | 3 | my $table = $self->_get_chunk_by_end("top-scoring domains:\n"); | |||||||||||||||||||||||||||
| 184 | 3 | ▶ | $table ||= $self->_get_chunk_by_end("//\n"); # A0 reports | ||||||||||||||||||||||||||
|
Condition33%1/3
$table ||= $self->_get_chunk_by_end("//\n")
MC/DC0%0/2
$table ||= $self->_get_chunk_by_end("//\n")
$table
$self->_get_chunk_by_end("//\n")
Truth table33%1/3
A ||= B
A= $tableB= $self->_get_chunk_by_end("//\n")
| |||||||||||||||||||||||||||||
| 185 | 3 | $self->{_after_hsp_table} = $self->_chunk_tell; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 3 | my %table; | |||||||||||||||||||||||||||
| 188 | # can't save this regex work for the hsp object because the hit object needs | ||||||||||||||||||||||||||||
| 189 | # its length, so may as well just do all the work here | ||||||||||||||||||||||||||||
| 190 | 3 | ▶ | while ($table =~ /^(\S+)\s+(\d+)\/\d+\s+(\d+)\s+(\d+)\s+\S\S\s+(\d+)\s+(\d+)\s+\S(\S)\s+(\S+)\s+(\S+)/gm) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | # rank query_start query_end hit_start hit_end score evalue | ||||||||||||||||||||||||||||
| 192 | 59 | my $evalue = abs($9); # consistency for tests under Windows | |||||||||||||||||||||||||||
| 193 | 59 | push(@{$table{$1}->{hsp_data}}, [$2, $3, $4, $5, $6, $8, $evalue]); | |||||||||||||||||||||||||||
| 194 | 59 | ▶ | if ($7 eq ']') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 34 | $table{$1}->{hit_length} = $6; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 3 | $self->_fields->{hsp_table} = \%table; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 3 | ▶ | sub _discover_alignments { | ||||||||||||||||||||||||||
|
Subroutine
_discover_alignments: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 202 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 203 | 3 | $self->_fields->{alignments} = { }; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 26 | ▶ | sub _next_alignment { | ||||||||||||||||||||||||||
|
Subroutine
_next_alignment: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 207 | 26 | my $self = shift;; | |||||||||||||||||||||||||||
| 208 | 26 | ▶ | return if $self->{_no_more_alignments}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 25 | my $aligns = $self->_fields->{alignments}; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 25 | ▶ | unless (defined $self->{_after_previous_alignment}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 3 | $self->_chunk_seek($self->{_after_hsp_table}); | |||||||||||||||||||||||||||
| 214 | 3 | my $chunk = $self->_get_chunk_by_end(": domain"); | |||||||||||||||||||||||||||
| 215 | 3 | ▶ | unless ($chunk) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 1 | $self->{_no_more_alignments} = 1; | |||||||||||||||||||||||||||
| 217 | 1 | return; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 2 | $self->{_after_previous_alignment} = $self->_chunk_tell; | |||||||||||||||||||||||||||
| 221 | 2 | $self->{_next_alignment_start_text} = $chunk; | |||||||||||||||||||||||||||
| 222 | 2 | return $self->_next_alignment; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 22 | $self->_chunk_seek($self->{_after_previous_alignment}); | |||||||||||||||||||||||||||
| 226 | 22 | my $chunk = $self->_get_chunk_by_end(": domain"); | |||||||||||||||||||||||||||
| 227 | 22 | ▶ | unless ($chunk) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 1 | $self->_chunk_seek($self->{_after_previous_alignment}); | |||||||||||||||||||||||||||
| 229 | 1 | $chunk = $self->_get_chunk_by_end("//"); | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 1 | ▶ | unless ($chunk) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | $self->{_no_more_alignments} = 1; | |||||||||||||||||||||||||||
| 233 | 0 | return; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 22 | $self->{_after_previous_alignment} = $self->_chunk_tell; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 22 | ▶ | if (defined $self->{_next_alignment_start_text}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 22 | $chunk = $self->{_next_alignment_start_text}.$chunk; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 22 | $chunk =~ s/(\S+: domain)$//; | |||||||||||||||||||||||||||
| 244 | 22 | $self->{_next_alignment_start_text} = $1; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 22 | my ($name, $domain) = $chunk =~ /^(\S+): domain (\d+)/; | |||||||||||||||||||||||||||
| 247 | 22 | $aligns->{$name.'~~~~'.$domain} = $chunk; | |||||||||||||||||||||||||||
| 248 | 22 | return 1; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 21 | ▶ | sub _discover_next_hit { | ||||||||||||||||||||||||||
|
Subroutine
_discover_next_hit: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 252 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | 21 | my @hit_table = @{$self->get_field('hit_table')}; | |||||||||||||||||||||||||||
| 254 | 21 | ▶ | return if $self->{_next_hit_index} == -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | #[name description score significance num_hsps rank] | ||||||||||||||||||||||||||||
| 257 | 16 | my @hit_data = (@{$hit_table[$self->{_next_hit_index}++]}, $self->{_next_hit_index}); | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 16 | $self->_fields->{next_hit} = Bio::Search::Hit::HmmpfamHit->new(-parent => $self, | |||||||||||||||||||||||||||
| 260 | -hit_data => \@hit_data); | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 16 | ▶ | if ($self->{_next_hit_index} > $#hit_table) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 5 | $self->{_next_hit_index} = -1; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =head2 next_hit | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | Title : next_hit | ||||||||||||||||||||||||||||
| 270 | Usage : while( $hit = $result->next_hit()) { ... } | ||||||||||||||||||||||||||||
| 271 | Function: Returns the next available Hit object, representing potential | ||||||||||||||||||||||||||||
| 272 | matches between the query and various entities from the database. | ||||||||||||||||||||||||||||
| 273 | Returns : a Bio::Search::Hit::HitI object or undef if there are no more. | ||||||||||||||||||||||||||||
| 274 | Args : none | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 21 | ▶ | sub next_hit { | ||||||||||||||||||||||||||
|
Subroutine
next_hit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 279 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 280 | 21 | my $hit = $self->get_field('next_hit'); | |||||||||||||||||||||||||||
| 281 | 21 | undef $self->_fields->{next_hit}; | |||||||||||||||||||||||||||
| 282 | 21 | return $hit; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =head2 next_model | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | Title : next_model | ||||||||||||||||||||||||||||
| 288 | Usage : my $domain = $result->next_model | ||||||||||||||||||||||||||||
| 289 | Function: Returns the next domain - this is an alias for next_hit() | ||||||||||||||||||||||||||||
| 290 | Returns : L<Bio::Search::Hit::HitI> object | ||||||||||||||||||||||||||||
| 291 | Args : none | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =cut | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 3 | *next_model = \&next_hit; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =head2 hits | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | Title : hits | ||||||||||||||||||||||||||||
| 300 | Usage : my @hits = $result->hits | ||||||||||||||||||||||||||||
| 301 | Function: Returns the HitI objects contained within this Result | ||||||||||||||||||||||||||||
| 302 | Returns : Array of Bio::Search::Hit::HitI objects | ||||||||||||||||||||||||||||
| 303 | Args : none | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | See Also: L<Bio::Search::Hit::HitI> | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =cut | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 3 | ▶ | sub hits { | ||||||||||||||||||||||||||
|
Subroutine
hits: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 310 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 311 | 3 | ▶ | my $old = $self->{_next_hit_index} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_next_hit_index'} || 0
MC/DC0%0/1
$self->{'_next_hit_index'} || 0
$self->{'_next_hit_index'}
Truth table50%1/2
A
A= $self->{'_next_hit_index'}
| |||||||||||||||||||||||||||||
| 312 | 3 | $self->rewind; | |||||||||||||||||||||||||||
| 313 | 3 | my @hits; | |||||||||||||||||||||||||||
| 314 | 3 | ▶ | while (defined(my $hit = $self->next_hit)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 5 | push(@hits, $hit); | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | 3 | ▶ | $self->{_next_hit_index} = @hits > 0 ? $old : -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 3 | return @hits; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =head2 models | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | Title : models | ||||||||||||||||||||||||||||
| 324 | Usage : my @domains = $result->models; | ||||||||||||||||||||||||||||
| 325 | Function: Returns the list of HMM models seen - this is an alias for hits() | ||||||||||||||||||||||||||||
| 326 | Returns : Array of L<Bio::Search::Hit::HitI> objects | ||||||||||||||||||||||||||||
| 327 | Args : none | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | =cut | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 3 | *models = \&hits; | |||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | =head2 sort_hits | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | Title : sort_hits | ||||||||||||||||||||||||||||
| 336 | Usage : $result->sort_hits('<score') | ||||||||||||||||||||||||||||
| 337 | Function : Sorts the hits so that they come out in the desired order when | ||||||||||||||||||||||||||||
| 338 | hits() or next_hit() is called. | ||||||||||||||||||||||||||||
| 339 | Returns : n/a | ||||||||||||||||||||||||||||
| 340 | Args : A coderef for the sort function. See the documentation on the Perl | ||||||||||||||||||||||||||||
| 341 | sort() function for guidelines on writing sort functions. | ||||||||||||||||||||||||||||
| 342 | You will be sorting array references, not HitI objects. The | ||||||||||||||||||||||||||||
| 343 | references contain name as element 0, description as element 1, | ||||||||||||||||||||||||||||
| 344 | score as element 2, significance as element 3 and number of hsps | ||||||||||||||||||||||||||||
| 345 | as element 4. | ||||||||||||||||||||||||||||
| 346 | By default the sort order is ascending significance value (ie. | ||||||||||||||||||||||||||||
| 347 | most significant hits first). | ||||||||||||||||||||||||||||
| 348 | Note : To access the special variables $a and $b used by the Perl sort() | ||||||||||||||||||||||||||||
| 349 | function the user function must access | ||||||||||||||||||||||||||||
| 350 | Bio::Search::Result::HmmpfamResult namespace. | ||||||||||||||||||||||||||||
| 351 | For example, use : | ||||||||||||||||||||||||||||
| 352 | $result->sort_hits( | ||||||||||||||||||||||||||||
| 353 | sub{$Bio::Search::Result::HmmpfamResult::a->[2] | ||||||||||||||||||||||||||||
| 354 | <=> | ||||||||||||||||||||||||||||
| 355 | $Bio::Search::Result::HmmpfamResult::b->[2]}); | ||||||||||||||||||||||||||||
| 356 | NOT $result->sort_hits($a->[2] <=> $b->[2]); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =cut | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 2 | ▶ | sub sort_hits { | ||||||||||||||||||||||||||
|
Subroutine
sort_hits: called CC=4 SCAR=14.7
Pod
documented
| |||||||||||||||||||||||||||||
| 361 | 2 | my ($self, $code_ref) = @_; | |||||||||||||||||||||||||||
| 362 | 0 | ▶ | $code_ref ||= sub { $a->[3] <=> $b->[3] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$code_ref ||= sub {
$Bio::Search::Result::HmmpfamResult::a->[3] <=> $Bio::Search::Result::HmmpfamResult::b->[3];
}
MC/DC0%0/2
$code_ref ||= sub {
$Bio::Search::Result::HmmpfamResult::a->[3] <=> $Bio::Search::Result::HmmpfamResult::b->[3];
}
$code_ref
sub {
$Bio::Search::Result::HmmpfamResult::a->[3] <=> $Bio::Search::Result::HmmpfamResult::b->[3];
}
Truth table33%1/3
A ||= B
A= $code_refB= sub {
$Bio::Search::Result::HmmpfamResult::a->[3] <=> $Bio::Search::Result::HmmpfamResult::b->[3];
}
| |||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | # avoid creating hit objects just to sort, hence force user to sort on | ||||||||||||||||||||||||||||
| 365 | # the array references in hit table | ||||||||||||||||||||||||||||
| 366 | 2 | my $table_ref = $self->get_field('hit_table'); | |||||||||||||||||||||||||||
| 367 | 2 | ▶ | @{$table_ref} > 1 || return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 2 | my @sorted = sort $code_ref @{$table_ref}; | |||||||||||||||||||||||||||
| 370 | 2 | ▶ | @sorted == @{$table_ref} || $self->throw("Your sort routine failed to give back all hits!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | 2 | $self->_fields->{hit_table} = \@sorted; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =head2 rewind | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | Title : rewind | ||||||||||||||||||||||||||||
| 377 | Usage : $result->rewind; | ||||||||||||||||||||||||||||
| 378 | Function: Allow one to reset the Hit iterator to the beginning, so that | ||||||||||||||||||||||||||||
| 379 | next_hit() will subsequently return the first hit and so on. | ||||||||||||||||||||||||||||
| 380 | Returns : n/a | ||||||||||||||||||||||||||||
| 381 | Args : none | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =cut | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 3 | ▶ | sub rewind { | ||||||||||||||||||||||||||
|
Subroutine
rewind: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 386 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 387 | 3 | ▶ | unless ($self->_fields->{hit_table}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | $self->get_field('hit_table'); | |||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | 3 | ▶ | $self->{_next_hit_index} = @{$self->_fields->{hit_table}} > 0 ? 0 : -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | 3 | 1; | |||||||||||||||||||||||||||