2 # BioPerl module for Bio::SearchIO::hmmer2
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::SearchIO::hmmer2 - A parser for HMMER output (hmmpfam, hmmsearch)
20 # do not use this class directly it is available through Bio::SearchIO
22 my $in = Bio::SearchIO->new(-format => 'hmmer2',
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";
37 This object implements a parser for HMMER output.
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
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.
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
67 https://redmine.open-bio.org/projects/bioperl/
69 =head1 AUTHOR - Jason Stajich
71 Email jason-at-bioperl.org
75 The rest of the documentation details each of the object methods.
76 Internal methods are usually preceded with a _
80 # Let the code begin...
82 package Bio
::SearchIO
::hmmer2
;
86 use Bio
::Factory
::ObjectFactory
;
88 use vars
qw(%MAPPING %MODEMAP
91 use base qw(Bio::SearchIO::hmmer);
95 # mapping of HMMER items to Bioperl hash keys
97 'HMMER_Output' => 'result',
103 'Hsp_bit-score' => 'HSP-bits',
104 'Hsp_score' => 'HSP-score',
105 'Hsp_evalue' => 'HSP-evalue',
106 'Hsp_query-from' => 'HSP-query_start',
107 'Hsp_query-to' => 'HSP-query_end',
108 'Hsp_hit-from' => 'HSP-hit_start',
109 'Hsp_hit-to' => 'HSP-hit_end',
110 'Hsp_positive' => 'HSP-conserved',
111 'Hsp_identity' => 'HSP-identical',
112 'Hsp_gaps' => 'HSP-hsp_gaps',
113 'Hsp_hitgaps' => 'HSP-hit_gaps',
114 'Hsp_querygaps' => 'HSP-query_gaps',
115 'Hsp_qseq' => 'HSP-query_seq',
116 'Hsp_hseq' => 'HSP-hit_seq',
117 'Hsp_midline' => 'HSP-homology_seq',
118 'Hsp_align-len' => 'HSP-hsp_length',
119 'Hsp_query-frame' => 'HSP-query_frame',
120 'Hsp_hit-frame' => 'HSP-hit_frame',
122 'Hit_id' => 'HIT-name',
123 'Hit_len' => 'HIT-length',
124 'Hit_accession' => 'HIT-accession',
125 'Hit_desc' => 'HIT-description',
126 'Hit_signif' => 'HIT-significance',
127 'Hit_score' => 'HIT-score',
129 'HMMER_program' => 'RESULT-algorithm_name',
130 'HMMER_version' => 'RESULT-algorithm_version',
131 'HMMER_query-def' => 'RESULT-query_name',
132 'HMMER_query-len' => 'RESULT-query_length',
133 'HMMER_query-acc' => 'RESULT-query_accession',
134 'HMMER_querydesc' => 'RESULT-query_description',
135 'HMMER_hmm' => 'RESULT-hmm_name',
136 'HMMER_seqfile' => 'RESULT-sequence_file',
137 'HMMER_db' => 'RESULT-database_name',
144 Usage : my $obj = Bio::SearchIO::hmmer2->new();
145 Function: Builds a new Bio::SearchIO::hmmer2 object
146 Returns : Bio::SearchIO::hmmer2
147 Args : -fh/-file => HMMER filename
153 my ( $self, @args ) = @_;
154 $self->SUPER::_initialize
(@args);
155 $self->{'_hmmidline'} = 'HMMER 2.2g (August 2001)';
161 Usage : my $hit = $searchio->next_result;
162 Function: Returns the next Result from a search
163 Returns : Bio::Search::Result::ResultI object
172 my ( $last, @hitinfo, @hspinfo, %hspinfo, %hitinfo );
176 my $verbose = $self->verbose; # cache for speed?
177 $self->start_document();
179 while ( defined( $_ = $self->_readline ) ) {
182 if (/^HMMER\s+(\S+)\s+\((.+)\)/o) {
183 my ( $prog, $version ) = split;
185 $self->_pushback($_);
186 $self->end_element( { 'Name' => 'HMMER_Output' } );
187 return $self->end_document();
189 $self->{'_hmmidline'} = $_;
190 $self->start_element( { 'Name' => 'HMMER_Output' } );
191 $self->{'_result_count'}++;
193 if ( defined $last ) {
194 ($reporttype) = split( /\s+/, $last );
197 'Name' => 'HMMER_program',
198 'Data' => uc($reporttype)
204 'Name' => 'HMMER_version',
209 elsif (s/^HMM file:\s+//o) {
210 $self->{'_hmmfileline'} = $lineorig;
213 'Name' => 'HMMER_hmm',
218 elsif (s/^Sequence\s+(file|database):\s+//o) {
219 $self->{'_hmmseqline'} = $lineorig;
220 if ( $1 eq 'database' ) {
223 'Name' => 'HMMER_db',
230 'Name' => 'HMMER_seqfile',
235 elsif (s/^Query(\s+(sequence|HMM))?(?:\s+\d+)?:\s+//o) {
238 # we're in a multi-query report
239 $self->_pushback( $self->{'_hmmidline'} );
240 $self->_pushback( $self->{'_hmmfileline'} );
241 $self->_pushback( $self->{'_hmmseqline'} );
242 $self->_pushback($lineorig);
248 'Name' => 'HMMER_query-def',
253 elsif (s/^Accession:\s+//o) {
257 'Name' => 'HMMER_query-acc',
262 elsif (s/^Description:\s+//o) {
266 'Name' => 'HMMER_querydesc',
271 elsif ( defined $self->{'_reporttype'}
272 && $self->{'_reporttype'} eq 'HMMSEARCH' )
275 # PROCESS HMMSEARCH RESULTS HERE
276 if (/^Scores for complete sequences/o) {
277 while ( defined( $_ = $self->_readline ) ) {
279 next if ( /^Sequence\s+Description/o || /^\-\-\-/o );
281 my ( $name, $n, $evalue, $score ) =
282 ( shift @line, pop @line, pop @line, pop @line );
283 my $desc = join( ' ', @line );
284 push @hitinfo, [ $name, $desc, $evalue, $score ];
285 $hitinfo{$name} = $#hitinfo;
288 elsif (/^Parsed for domains:/o) {
291 while ( defined( $_ = $self->_readline ) ) {
294 $self->_pushback($_);
297 next if ( /^(Model|Sequence)\s+Domain/ || /^\-\-\-/ );
301 my ( $n, $domainnum, $domainct, @vals ) = (
302 m
!^(\S
+)\s
+ # host name
303 (\d
+)/(\d+)\s+ # num/num
(ie
1 of
2)
304 (\d
+)\s
+(\d
+).+?
# sequence start and end
305 (\d
+)\s
+(\d
+)\s
+ # hmm start and end
314 # array lookup so that we can get rid of things
315 # when they've been processed
316 my $info = $hitinfo[ $hitinfo{$n} ];
317 if ( !defined $info ) {
319 "Incomplete Sequence information, can't find $n hitinfo says $hitinfo{$n}"
323 push @hspinfo, [ $n, @vals ];
327 elsif (/^Alignments of top/o) {
328 my ( $prelength, $lastdomain, $count, $width );
332 while ( defined( $_ = $self->_readline ) ) {
334 || /^\s+RF\s+[x\s]+$/o );
335 if ( /^Histogram/o || m!^//!o ) {
336 if ( $self->in_element('hsp') ) {
337 $self->end_element( { 'Name' => 'Hsp' } );
339 if ( $self->within_element('hit') ) {
340 $self->end_element( { 'Name' => 'Hit' } );
347 m
/^\s
*(.+):\s
+domain\s
+(\d
+)\s
+of\s
+(\d
+)\
,\s
+
348 from\s
+(\d
+)\s
+to\s
+(\d
+)/x
351 my ( $name, $domainct, $domaintotal, $from, $to ) =
352 ( $1, $2, $3, $4, $5 );
353 $domaincounter{$name}++;
354 if ( $self->within_element('hit') ) {
355 if ( $self->within_element('hsp') ) {
356 $self->end_element( { 'Name' => 'Hsp' } );
358 $self->end_element( { 'Name' => 'Hit' } );
361 $self->start_element( { 'Name' => 'Hit' } );
364 $hitinfo[ $hitinfo{$name} ] || $self->throw(
365 "Could not find hit info for $name: Insure that your database contains only unique sequence names"
369 if ( $info->[0] ne $name ) {
371 "Somehow the Model table order does not match the order in the domains (got "
373 . ", expected $name)" );
378 'Data' => shift @
{$info}
383 'Name' => 'Hit_desc',
384 'Data' => shift @
{$info}
389 'Name' => 'Hit_signif',
390 'Data' => shift @
{$info}
395 'Name' => 'Hit_score',
396 'Data' => shift @
{$info}
400 $self->start_element( { 'Name' => 'Hsp' } );
403 'Name' => 'Hsp_identity',
409 'Name' => 'Hsp_positive',
413 my $HSPinfo = shift @hspinfo;
414 my $id = shift @
$HSPinfo;
416 if ( $id ne $name ) {
418 "Somehow the domain list details do not match the table (got $id, expected $name)"
421 if ( $domaincounter{$name} == $domaintotal ) {
422 $hitinfo[ $hitinfo{$name} ] = undef;
426 'Name' => 'Hsp_hit-from',
427 'Data' => shift @
$HSPinfo
432 'Name' => 'Hsp_hit-to',
433 'Data' => shift @
$HSPinfo
438 'Name' => 'Hsp_query-from',
439 'Data' => shift @
$HSPinfo
444 'Name' => 'Hsp_query-to',
445 'Data' => shift @
$HSPinfo
450 'Name' => 'Hsp_score',
451 'Data' => shift @
$HSPinfo
456 'Name' => 'Hsp_evalue',
457 'Data' => shift @
$HSPinfo
464 # Might want to change this so that it
465 # accumulates all the of the alignment lines into
466 # three array slots and then tests for the
468 if (/^(\s+\*\-\>)(\S+)/o) { # start of domain
469 $prelength = CORE
::length($1);
472 # deal with fact that start en stop is on same line
474 if ($data =~ s/\<\-?\*?\s*$//)
476 $width = CORE
::length($data);
481 'Name' => 'Hsp_qseq',
488 elsif (/^(\s+)(\S+)\<\-\*\s*$/o) { #end of domain
491 'Name' => 'Hsp_qseq',
495 $width = CORE
::length($2);
498 elsif (( $count != 1 && /^\s+$/o )
499 || CORE
::length($_) == 0
504 elsif ( $count == 0 ) {
505 $prelength -= 3 unless ( $second_tier++ );
506 unless ( defined $prelength ) {
508 # $self->warn("prelength not set");
513 'Name' => 'Hsp_qseq',
514 'Data' => substr( $_, $prelength )
518 elsif ( $count == 1 ) {
519 if ( !defined $prelength ) {
520 $self->warn("prelength not set");
525 'Name' => 'Hsp_midline',
527 substr( $_, $prelength, $width )
534 'Name' => 'Hsp_midline',
535 'Data' => substr( $_, $prelength )
540 elsif ( $count == 2 ) {
541 if (/^\s+(\S+)\s+(\d+|\-)\s+(\S*)\s+(\d+|\-)/o) {
544 'Name' => 'Hsp_hseq',
550 $self->warn("unrecognized line: $_\n");
553 $count = 0 if $count++ >= 2;
557 elsif ( /^Histogram/o || m!^//!o ) {
558 while ( my $HSPinfo = shift @hspinfo ) {
559 my $id = shift @
$HSPinfo;
560 my $info = [ @
{ $hitinfo[ $hitinfo{$id} ] } ];
561 next unless defined $info;
562 $self->start_element( { 'Name' => 'Hit' } );
566 'Data' => shift @
{$info}
571 'Name' => 'Hit_desc',
572 'Data' => shift @
{$info}
577 'Name' => 'Hit_signif',
578 'Data' => shift @
{$info}
583 'Name' => 'Hit_score',
584 'Data' => shift @
{$info}
587 $self->start_element( { 'Name' => 'Hsp' } );
590 'Name' => 'Hsp_query-from',
591 'Data' => shift @
$HSPinfo
596 'Name' => 'Hsp_query-to',
597 'Data' => shift @
$HSPinfo
602 'Name' => 'Hsp_hit-from',
603 'Data' => shift @
$HSPinfo
608 'Name' => 'Hsp_hit-to',
609 'Data' => shift @
$HSPinfo
614 'Name' => 'Hsp_score',
615 'Data' => shift @
$HSPinfo
620 'Name' => 'Hsp_evalue',
621 'Data' => shift @
$HSPinfo
626 'Name' => 'Hsp_identity',
632 'Name' => 'Hsp_positive',
638 'Name' => 'Hsp_positive',
642 $self->end_element( { 'Name' => 'Hsp' } );
643 $self->end_element( { 'Name' => 'Hit' } );
650 elsif ( defined $self->{'_reporttype'}
651 && $self->{'_reporttype'} eq 'HMMPFAM' )
653 # process HMMPFAM results here
654 if (/^Scores for sequence family/o) {
655 while ( defined( $_ = $self->_readline ) ) {
657 next if ( /^Model\s+Description/o || /^\-\-\-/o );
660 my ( $model, $n, $evalue, $score ) =
661 ( shift @line, pop @line, pop @line, pop @line );
662 my $desc = join( ' ', @line );
663 push @hitinfo, [ $model, $desc, $score, $evalue, $n ];
664 $hitinfo{$model} = $#hitinfo;
667 elsif (/^Parsed for domains:/o) {
669 while ( defined( $_ = $self->_readline ) ) {
672 $self->_pushback($_);
675 next if ( /^Model\s+Domain/o || /^\-\-\-/o );
678 my ( $n, $domainnum, $domainct, @vals ) = (
679 m
!^(\S
+)\s
+ # domain name
680 (\d
+)/(\d
+)\s
+ # domain num out of num
681 (\d
+)\s
+(\d
+).+?
# seq start, end
682 (\d
+)\s
+(\d
+)\s
+ # hmm start, end
690 my $hindex = $hitinfo{$n};
691 if ( !defined $hindex ) {
693 [ $n, '', $vals[5], $vals[6], $domainct ];
694 $hitinfo{$n} = $#hitinfo;
697 my $info = $hitinfo[$hindex];
698 if ( !defined $info ) {
700 "incomplete Domain information, can't find $n hitinfo says $hitinfo{$n}"
704 push @hspinfo, [ $n, @vals ];
708 elsif (/^Alignments of top/o) {
709 my ( $prelength, $lastdomain, $count, $width );
712 while ( defined( $_ = $self->_readline ) ) {
717 && /^\s+RF\s+[x\s]+$/o )
720 next if ($_ =~ m/^\s+CS\s+/o && $count == 0);
721 if ( /^Histogram/o || m!^//!o || /^Query sequence/o ) {
722 if ( $self->in_element('hsp') ) {
723 $self->end_element( { 'Name' => 'Hsp' } );
725 if ( $self->in_element('hit') ) {
726 $self->end_element( { 'Name' => 'Hit' } );
728 $self->_pushback($_);
732 if (m/(\S+):.*from\s+(\d+)\s+to\s+(\d+)/o) {
733 my ( $name, $from, $to ) = ( $1, $2, $3 );
735 if ( $self->within_element('hit') ) {
736 if ( $self->in_element('hsp') ) {
737 $self->end_element( { 'Name' => 'Hsp' } );
739 $self->end_element( { 'Name' => 'Hit' } );
741 my $info = [ @
{ $hitinfo[ $hitinfo{$name} ] } ];
743 || $info->[0] ne $name )
746 "Somehow the Model table order does not match the order in the domains (got "
748 . ", expected $name). We're back loading this from the alignment information instead"
752 /score\s+([^,\s]+),\s+E\s+=\s+(\S+)/ox
754 push @hitinfo, $info;
755 $hitinfo{$name} = $#hitinfo;
757 $self->start_element( { 'Name' => 'Hit' } );
762 'Data' => shift @
{$info}
767 'Name' => 'Hit_desc',
768 'Data' => shift @
{$info}
773 'Name' => 'Hit_score',
774 'Data' => shift @
{$info}
779 'Name' => 'Hit_signif',
780 'Data' => shift @
{$info}
784 $self->start_element( { 'Name' => 'Hsp' } );
787 'Name' => 'Hsp_identity',
793 'Name' => 'Hsp_positive',
797 my $HSPinfo = shift @hspinfo;
798 my $id = shift @
$HSPinfo;
800 if ( $id ne $name ) {
802 "Somehow the domain list details do not match the table (got $id, expected $name)"
807 'Name' => 'Hsp_query-from',
808 'Data' => shift @
$HSPinfo
813 'Name' => 'Hsp_query-to',
814 'Data' => shift @
$HSPinfo
819 'Name' => 'Hsp_hit-from',
820 'Data' => shift @
$HSPinfo
825 'Name' => 'Hsp_hit-to',
826 'Data' => shift @
$HSPinfo
831 'Name' => 'Hsp_score',
832 'Data' => shift @
$HSPinfo
837 'Name' => 'Hsp_evalue',
838 'Data' => shift @
$HSPinfo
844 if (/^(\s+\*\-\>)(\S+)/o) {
847 $prelength = CORE
::length($1);
850 # deal with fact that start en stop is on same line
852 if ($data =~ s/\<\-?\*?\s*$//)
854 $width = CORE
::length($data);
859 'Name' => 'Hsp_hseq',
867 elsif (/^(\s+)(\S+)\<\-?\*?\s*$/o) {
870 $prelength -= 3 unless ( $second_tier++ );
873 'Name' => 'Hsp_hseq',
877 $width = CORE
::length($2);
880 elsif (CORE
::length($_) == 0
881 || ( $count != 1 && /^\s+$/o )
886 elsif ( $count == 0 ) {
887 $prelength -= 3 unless ( $second_tier++ );
888 unless ( defined $prelength ) {
890 # $self->warn("prelength not set");
895 'Name' => 'Hsp_hseq',
896 'Data' => substr( $_, $prelength )
900 elsif ( $count == 1 ) {
901 if ( !defined $prelength ) {
902 $self->warn("prelength not set");
907 'Name' => 'Hsp_midline',
909 substr( $_, $prelength, $width )
916 'Name' => 'Hsp_midline',
917 'Data' => substr( $_, $prelength )
922 elsif ( $count == 2 ) {
923 if ( /^\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)/o
924 || /^\s+(\S+)\s+(\-)\s+(\S*)\s+(\-)/o )
928 'Name' => 'Hsp_qseq',
935 "unrecognized line ($count): $_\n");
938 $count = 0 if $count++ >= 2;
942 elsif ( /^Histogram/o || m!^//!o ) {
944 while ( my $HSPinfo = shift @hspinfo ) {
945 my $id = shift @
$HSPinfo;
946 my $info = [ @
{ $hitinfo[ $hitinfo{$id} ] } ];
947 next unless defined $info;
948 $self->start_element( { 'Name' => 'Hit' } );
952 'Data' => shift @
{$info}
957 'Name' => 'Hit_desc',
958 'Data' => shift @
{$info}
963 'Name' => 'Hit_signif',
964 'Data' => shift @
{$info}
969 'Name' => 'Hit_score',
970 'Data' => shift @
{$info}
973 $self->start_element( { 'Name' => 'Hsp' } );
976 'Name' => 'Hsp_query-from',
977 'Data' => shift @
$HSPinfo
982 'Name' => 'Hsp_query-to',
983 'Data' => shift @
$HSPinfo
988 'Name' => 'Hsp_hit-from',
989 'Data' => shift @
$HSPinfo
994 'Name' => 'Hsp_hit-to',
995 'Data' => shift @
$HSPinfo
1000 'Name' => 'Hsp_score',
1001 'Data' => shift @
$HSPinfo
1006 'Name' => 'Hsp_evalue',
1007 'Data' => shift @
$HSPinfo
1012 'Name' => 'Hsp_identity',
1018 'Name' => 'Hsp_positive',
1024 'Name' => 'Hsp_positive',
1028 $self->end_element( { 'Name' => 'Hsp' } );
1029 $self->end_element( { 'Name' => 'Hit' } );
1035 # uncomment to see missed lines with verbose on
1042 $self->end_element( { 'Name' => 'HMMER_Output' } ) unless !$seentop;
1043 return $self->end_document();
1046 =head2 start_element
1048 Title : start_element
1049 Usage : $eventgenerator->start_element
1050 Function: Handles a start element event
1052 Args : hashref with at least 2 keys 'Data' and 'Name'
1058 my ( $self, $data ) = @_;
1060 # we currently don't care about attributes
1061 my $nm = $data->{'Name'};
1062 my $type = $MODEMAP{$nm};
1064 if ( $self->_eventHandler->will_handle($type) ) {
1065 my $func = sprintf( "start_%s", lc $type );
1066 $self->_eventHandler->$func( $data->{'Attributes'} );
1068 unshift @
{ $self->{'_elements'} }, $type;
1071 && $type eq 'result' )
1073 $self->{'_values'} = {};
1074 $self->{'_result'} = undef;
1080 Title : start_element
1081 Usage : $eventgenerator->end_element
1082 Function: Handles an end element event
1084 Args : hashref with at least 2 keys 'Data' and 'Name'
1090 my ( $self, $data ) = @_;
1091 my $nm = $data->{'Name'};
1092 my $type = $MODEMAP{$nm};
1095 if ( $nm eq 'HMMER_program' ) {
1096 if ( $self->{'_last_data'} =~ /(HMM\S+)/i ) {
1097 $self->{'_reporttype'} = uc $1;
1101 # Hsp are sort of weird, in that they end when another
1102 # object begins so have to detect this in end_element for now
1103 if ( $nm eq 'Hsp' ) {
1104 foreach (qw(Hsp_qseq Hsp_midline Hsp_hseq)) {
1105 my $data = $self->{'_last_hspdata'}->{$_};
1106 if ($data && $_ eq 'Hsp_hseq') {
1107 # replace hmm '.' gap symbol by '-'
1117 $self->{'_last_hspdata'} = {};
1120 if ( $self->_eventHandler->will_handle($type) ) {
1121 my $func = sprintf( "end_%s", lc $type );
1122 $rc = $self->_eventHandler->$func( $self->{'_reporttype'},
1123 $self->{'_values'} );
1125 my $lastelem = shift @
{ $self->{'_elements'} };
1127 elsif ( $MAPPING{$nm} ) {
1128 if ( ref( $MAPPING{$nm} ) =~ /hash/i ) {
1129 my $key = ( keys %{ $MAPPING{$nm} } )[0];
1130 $self->{'_values'}->{$key}->{ $MAPPING{$nm}->{$key} } =
1131 $self->{'_last_data'};
1134 $self->{'_values'}->{ $MAPPING{$nm} } = $self->{'_last_data'};
1138 $self->debug("unknown nm $nm, ignoring\n");
1140 $self->{'_last_data'} = ''; # remove read data if we are at
1142 $self->{'_result'} = $rc if ( defined $type && $type eq 'result' );
1149 Usage : $eventhandler->element({'Name' => $name, 'Data' => $str});
1150 Function: Convience method that calls start_element, characters, end_element
1152 Args : Hash ref with the keys 'Name' and 'Data'
1158 my ( $self, $data ) = @_;
1159 $self->start_element($data);
1160 $self->characters($data);
1161 $self->end_element($data);
1167 Usage : $eventgenerator->characters($str)
1168 Function: Send a character events
1176 my ( $self, $data ) = @_;
1178 if ( $self->in_element('hsp')
1179 && $data->{'Name'} =~ /Hsp\_(qseq|hseq|midline)/o
1180 && defined $data->{'Data'} )
1182 $self->{'_last_hspdata'}->{ $data->{'Name'} } .= $data->{'Data'};
1184 return unless ( defined $data->{'Data'} && $data->{'Data'} !~ /^\s+$/o );
1186 $self->{'_last_data'} = $data->{'Data'};
1189 =head2 within_element
1191 Title : within_element
1192 Usage : if( $eventgenerator->within_element($element) ) {}
1193 Function: Test if we are within a particular element
1194 This is different than 'in' because within can be tested
1197 Args : string element name
1202 sub within_element
{
1203 my ( $self, $name ) = @_;
1206 || !defined $self->{'_elements'}
1207 || scalar @
{ $self->{'_elements'} } == 0 );
1208 foreach ( @
{ $self->{'_elements'} } ) {
1209 return 1 if ( $_ eq $name );
1217 Usage : if( $eventgenerator->in_element($element) ) {}
1218 Function: Test if we are in a particular element
1219 This is different than 'within' because 'in' only
1220 tests its immediete parent.
1222 Args : string element name
1228 my ( $self, $name ) = @_;
1229 return 0 if !defined $self->{'_elements'}->[0];
1230 return ( $self->{'_elements'}->[0] eq $name );
1233 =head2 start_document
1235 Title : start_document
1236 Usage : $eventgenerator->start_document
1237 Function: Handle a start document event
1244 sub start_document
{
1246 $self->{'_lasttype'} = '';
1247 $self->{'_values'} = {};
1248 $self->{'_result'} = undef;
1249 $self->{'_elements'} = [];
1254 Title : end_document
1255 Usage : $eventgenerator->end_document
1256 Function: Handles an end document event
1257 Returns : Bio::Search::Result::ResultI object
1265 return $self->{'_result'};
1270 Title : result_count
1271 Usage : my $count = $searchio->result_count
1272 Function: Returns the number of results we have processed
1281 return $self->{'_result_count'};