BioPerl
view release on metacpan or search on metacpan
Bio/SearchIO/SearchResultEventBuilder.pm view on Meta::CPAN
Title : start_result
Usage : $handler->start_result($resulttype)
Function: Begins a result event cycle
Returns : none
Args : Type of Report
=cut
sub start_result {
my ($self,$type) = @_;
$self->{'_resulttype'} = $type;
$self->{'_hits'} = [];
$self->{'_hsps'} = [];
$self->{'_hitcount'} = 0;
return;
}
=head2 end_result
Title : end_result
Usage : my @results = $parser->end_result
Function: Finishes a result handler cycle
Returns : A Bio::Search::Result::ResultI
Args : none
=cut
# this is overridden by IteratedSearchResultEventBuilder
# so keep that in mind when debugging
sub end_result {
my ($self,$type,$data) = @_;
if( defined $data->{'runid'} &&
$data->{'runid'} !~ /^\s+$/ ) {
if( $data->{'runid'} !~ /^lcl\|/) {
$data->{"RESULT-query_name"} = $data->{'runid'};
} else {
($data->{"RESULT-query_name"},
$data->{"RESULT-query_description"}) =
split(/\s+/,$data->{"RESULT-query_description"},2);
}
if( my @a = split(/\|/,$data->{'RESULT-query_name'}) ) {
my $acc = pop @a ; # this is for accession |1234|gb|AAABB1.1|AAABB1
# this is for |123|gb|ABC1.1|
$acc = pop @a if( ! defined $acc || $acc =~ /^\s+$/);
$data->{"RESULT-query_accession"}= $acc;
}
delete $data->{'runid'};
}
my %args = map { my $v = $data->{$_}; s/RESULT//; ($_ => $v); }
grep { /^RESULT/ } keys %{$data};
$args{'-algorithm'} = uc( $args{'-algorithm_name'}
|| $data->{'RESULT-algorithm_name'}
|| $type);
($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
( $args{'-iterations'} = $self->{'_iterations'} )
: ( $args{'-hits'} = $self->{'_hits'} );
my $result = $self->factory('result')->create_object(%args);
$result->hit_factory($self->factory('hit'));
($self->isa('Bio::SearchIO::IteratedSearchResultEventBuilder')) ?
( $self->{'_iterations'} = [] )
: ( $self->{'_hits'} = [] );
return $result;
}
=head2 start_hsp
Title : start_hsp
Usage : $handler->start_hsp($name,$data)
Function: Begins processing a HSP event
Returns : none
Args : type of element
associated data (hashref)
=cut
sub start_hsp {
my ($self,@args) = @_;
return;
}
=head2 end_hsp
Title : end_hsp
Usage : $handler->end_hsp()
Function: Finish processing a HSP event
Returns : none
Args : type of event and associated hashref
=cut
sub end_hsp {
my ($self,$type,$data) = @_;
if( defined $data->{'runid'} &&
$data->{'runid'} !~ /^\s+$/ ) {
if( $data->{'runid'} !~ /^lcl\|/) {
$data->{"RESULT-query_name"}= $data->{'runid'};
} else {
($data->{"RESULT-query_name"},
$data->{"RESULT-query_description"}) =
split(/\s+/,$data->{"RESULT-query_description"},2);
}
if( my @a = split(/\|/,$data->{'RESULT-query_name'}) ) {
my $acc = pop @a ; # this is for accession |1234|gb|AAABB1.1|AAABB1
# this is for |123|gb|ABC1.1|
$acc = pop @a if( ! defined $acc || $acc =~ /^\s+$/);
$data->{"RESULT-query_accession"}= $acc;
}
delete $data->{'runid'};
}
# this code is to deal with the fact that Blast XML data
# always has start < end and one has to infer strandedness
# from the frame which is a problem for the Search::HSP object
# which expect to be able to infer strand from the order of
# of the begin/end of the query and hit coordinates
( run in 0.929 second using v1.01-cache-2.11-cpan-71847e10f99 )