Bio::SearchIO::XML PsiBlastHandler
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::SearchIO::XML::PsiBlastHandler - XML Handler for NCBI Blast PSIBLAST XML parsing.
Package variables
Privates (from "my" definitions)
%MODEMAP = ( 'BlastOutput' => 'result', 'Iteration' => 'iteration', 'Hit' => 'hit', 'Hsp' => 'hsp')
%MAPPING = ( 'BlastOutput_program' => 'RESULT-algorithm_name', 'BlastOutput_version' => 'RESULT-algorithm_version', 'BlastOutput_db' => 'RESULT-database_name', 'BlastOutput_reference' => 'RESULT-program_reference', 'BlastOutput_query-def' => 'RESULT-query_description', 'BlastOutput_query-len' => 'RESULT-query_length', 'BlastOutput_query-ID' => 'runid', 'Parameters_matrix' => { 'RESULT-parameters' => 'matrix'}, 'Parameters_expect' => { 'RESULT-parameters' => 'expect'}, 'Parameters_include' => { 'RESULT-parameters' => 'include'}, 'Parameters_sc-match' => { 'RESULT-parameters' => 'match'}, 'Parameters_sc-mismatch' => { 'RESULT-parameters' => 'mismatch'}, 'Parameters_gap-open' => { 'RESULT-parameters' => 'gapopen'}, 'Parameters_gap-extend' => { 'RESULT-parameters' => 'gapext'}, 'Parameters_filter' => {'RESULT-parameters' => 'filter'}, 'Statistics_db-num' => 'RESULT-database_entries', 'Statistics_db-len' => 'RESULT-database_letters', 'Statistics_hsp-len' => { 'RESULT-statistics' => 'hsplength'}, 'Statistics_eff-space' => { 'RESULT-statistics' => 'effectivespace'}, 'Statistics_kappa' => { 'RESULT-statistics' => 'kappa' }, 'Statistics_lambda' => { 'RESULT-statistics' => 'lambda' }, 'Statistics_entropy' => { 'RESULT-statistics' => 'entropy'}, 'Iteration_iter-num' => 'ITERATION-number', 'Iteration_converged' => 'ITERATION-converged', 'Hsp_bit-score' => 'HSP-bits', 'Hsp_score' => 'HSP-score', 'Hsp_evalue' => 'HSP-evalue', 'Hsp_query-from' => 'HSP-query_start', 'Hsp_query-to' => 'HSP-query_end', 'Hsp_hit-from' => 'HSP-hit_start', 'Hsp_hit-to' => 'HSP-hit_end', 'Hsp_positive' => 'HSP-conserved', 'Hsp_identity' => 'HSP-identical', 'Hsp_gaps' => 'HSP-gaps', 'Hsp_hitgaps' => 'HSP-hit_gaps', 'Hsp_querygaps' => 'HSP-query_gaps', 'Hsp_qseq' => 'HSP-query_seq', 'Hsp_hseq' => 'HSP-hit_seq', 'Hsp_midline' => 'HSP-homology_seq', 'Hsp_align-len' => 'HSP-hsp_length', 'Hsp_query-frame'=> 'HSP-query_frame', 'Hsp_hit-frame' => 'HSP-hit_frame', 'Hit_id' => 'HIT-name', 'Hit_len' => 'HIT-length', 'Hit_accession' => 'HIT-accession', 'Hit_def' => 'HIT-description', 'Hit_num' => 'HIT-order', 'Iteration_iter-num' => 'HIT-iteration', 'Iteration_stat' => 'HIT-iteration_statistic', )
%IGNOREDTAGS = ( 'Hsp_num' => 1, 'Hsp_pattern-from' => 1, 'Hsp_pattern-to' => 1, 'Hsp_density' => 1, 'Iteration_message' => 1, 'Hit_hsps' => 1, 'BlastOutput_param' => 1, 'Iteration_hits' => 1, 'Statistics' => 1, 'Parameters' => 1, 'BlastOutput' => 1, 'BlastOutput_iterations' => 1, )
Inherit
Bio::Root::Root XML::SAX::Base
Synopsis
  # This is not to be used directly.
Description
This is the XML handler for BLAST PSIBLAST XML parsing. Currently it passes
elements off to the event handler, which is ultimately responsible for
Bio::Search object generation.
This was recently split off from the original code for Bio::SearchIO::blastxml
primarily for maintenance purposes.
Methods
start_documentDescriptionCode
end_documentDescriptionCode
start_elementDescriptionCode
end_elementDescriptionCode
charactersDescriptionCode
eventHandler
No description
Code
Methods description
start_documentcode    nextTop
 Title   : start_document
Usage : $parser->start_document;
Function: SAX method to indicate starting to parse a new document
Returns : none
Args : none
end_documentcodeprevnextTop
 Title   : end_document
Usage : $parser->end_document;
Function: SAX method to indicate finishing parsing a new document
Returns : Bio::Search::Result::ResultI object
Args : none
start_elementcodeprevnextTop
 Title   : start_element
Usage : $parser->start_element($data)
Function: SAX method to indicate starting a new element
Returns : none
Args : hash ref for data
end_elementcodeprevnextTop
 Title   : end_element
Usage : $parser->end_element($data)
Function: Signals finishing an element
Returns : Bio::Search object dpending on what type of element
Args : hash ref for data
characterscodeprevnextTop
 Title   : characters
Usage : $parser->characters($data)
Function: Signals new characters to be processed
Returns : characters read
Args : hash ref with the key 'Data'
Methods code
start_documentdescriptionprevnextTop
sub start_document {
    my ($self) = @_;
    $self->{'_lasttype'} = '';
    $self->{'_values'} = {};
    $self->{'_result'}= [];
}
end_documentdescriptionprevnextTop
sub end_document {
   my ($self,@args) = @_;
   
   # reset data carried throughout parse
$self->{'_resultdata'} = undef; # pass back ref to results queue; caller must reset handler results queue
return $self->{'_result'};
}
start_elementdescriptionprevnextTop
sub start_element {
    my ($self,$data) = @_;
    # we currently don't care about attributes
my $nm = $data->{'Name'}; if( my $type = $MODEMAP{$nm} ) { if( $self->eventHandler->will_handle($type) ) { my $func = sprintf("start_%s",lc $type); $self->eventHandler->$func($data->{'Attributes'}); } }
}
end_elementdescriptionprevnextTop
sub end_element {
    my ($self,$data) = @_;

    my $nm = $data->{'Name'};
    my $rc;
    if($nm eq 'BlastOutput_program' &&
       $self->{'_last_data'} =~ /(t?blast[npx])/i ) {
        $self->{'_type'} = uc $1; 
    }
    if ($nm eq 'Iteration') {
        map {
            $self->{'_values'}->{$_} = $self->{'_resultdata'}->{$_};
            } keys %{ $self->{'_resultdata'} };
    }
    if( my $type = $MODEMAP{$nm} ) {
        if( $self->eventHandler->will_handle($type) ) {
            my $func = sprintf("end_%s",lc $type);
            $rc = $self->eventHandler->$func($self->{'_type'},
                                              $self->{'_values'});
        }
    }
    elsif( exists $MAPPING{$nm} ) {
        if ( ref($MAPPING{$nm}) =~ /hash/i ) {
            my $key = (keys %{$MAPPING{$nm}})[0];
            $self->{'_values'}->{$key}->{$MAPPING{$nm}->{$key}} = $self->{'_last_data'};
        } else {
            $self->{'_values'}->{$MAPPING{$nm}} = $self->{'_last_data'};
        }
    }
    elsif( exists $IGNOREDTAGS{$nm} ){
        # ignores these elements for now
} else { $self->debug("ignoring unrecognized element type $nm\n"); } $self->{'_last_data'} = ''; # remove read data if we are at
# end of an element
# add to ResultI array
$self->{'_result'} = $rc if( $nm eq 'BlastOutput' ); # reset values for each Result round
if ($nm eq 'BlastOutput') { $self->{'_values'} = {}; }
}
charactersdescriptionprevnextTop
sub characters {
   my ($self,$data) = @_;
   return unless ( defined $data->{'Data'} && $data->{'Data'} !~ /^\s+$/ );
   $self->{'_last_data'} .= $data->{'Data'};
}
eventHandlerdescriptionprevnextTop
sub eventHandler {
    my $self = shift;
    return $self->{'_handler'} = shift if @_;
    return $self->{'_handler'};
}

1;
}
General documentation
DEPENDENCIESTop
In addition to parts of the Bio:: hierarchy, this module uses:
 XML::SAX::Base
which comes with the XML::SAX distribution.
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support Top
Please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via the
web:
  https://redmine.open-bio.org/projects/bioperl/
AUTHOR - Jason Stajich, Chris FieldsTop
Email jason-at-bioperl.org
Email cjfields-at-uiuc dot edu
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
SAX methodsTop