Bio-SearchIO-blastxml
view release on metacpan or search on metacpan
lib/Bio/SearchIO/XML/BlastHandler.pm view on Meta::CPAN
'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'},
# HSP specific fields
'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 specific fields
'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',
# if these tags are present, they will overwrite the
# above with more current data (i.e. multiquery hits)
'Iteration_query-def' => 'RESULT-query_description',
'Iteration_query-len' => 'RESULT-query_length',
'Iteration_query-ID' => 'runid',
);
# these XML tags are ignored for now
my %IGNOREDTAGS = (
'Hsp_num' => 1,#'HSP-order',
'Hsp_pattern-from' => 1,#'patternend',
'Hsp_pattern-to' => 1,#'patternstart',
'Hsp_density' => 1,#'hspdensity',
'Iteration_message' => 1,
'Hit_hsps' => 1,
'BlastOutput_param' => 1,
'Iteration_hits' => 1,
'Statistics' => 1,
'Parameters' => 1,
'BlastOutput' => 1,
'BlastOutput_iterations' => 1,
);
sub start_document{
my ($self) = @_;
$self->{'_lasttype'} = '';
$self->{'_values'} = {};
$self->{'_result'}= [];
}
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'};
}
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'});
}
}
}
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 ) {
( run in 0.866 second using v1.01-cache-2.11-cpan-71847e10f99 )