sub create_hit
{ my ($self, @args) = @_;
my ($blast, $raw_data, $shallow_parse) =
$self->_rearrange( [qw(RESULT
RAW_DATA
SHALLOW_PARSE)], @args);
my %args = @args;
$args{'-PROGRAM'} = $blast->analysis_method;
$args{'-QUERY_LEN'} = $blast->query_length;
$args{'-ITERATION'} = $blast->iterations;
my $hit = Bio::Search::Hit::BlastHit->new( %args );
unless( $shallow_parse ) {
$self->_add_hsps( $hit,
$args{'-PROGRAM'},
$args{'-QUERY_LEN'},
$blast->query_name,
@{$raw_data} );
}
return $hit;} |
sub _add_hsps
{ my( $self, $hit, $prog, $qlen, $qname, @data ) = @_;
my $start = 0;
my $hspCount = 0;
require Bio::Search::HSP::BlastHSP;
my( @hspData, @hspList, @errs, @bad_names );
my($line, $set_desc, @desc);
$set_desc = 0;
my $hname = $hit->name;
my $hlen;
hit_loop:
foreach $line( @data ) {
if( $line =~ /^\s*Length = ([\d,]+)/ ) {
$hit->_set_description(@desc);
$set_desc = 1;
$hit->_set_length($1);
$hlen = $hit->length;
next hit_loop;
} elsif( !$set_desc) {
$line =~ s/^\s+|\s+$//g;
push @desc, $line;
next hit_loop;
} elsif( $line =~ /^\s*Score/ ) {
if( not scalar @hspData ) {
$start = 1;
push @hspData, $line;
next hit_loop;
} elsif( scalar @hspData) {
$hspCount++;
$self->verbose and do{ print STDERR +( $hspCount % 10 ? "+" : "+\n" ); };
my $hspObj = Bio::Search::HSP::BlastHSP->new
(-RAW_DATA =>\@ hspData,
-RANK => $hspCount,
-PROGRAM => $prog,
-QNAME => $qname,
-HNAME => $hname,
-QLENGTH => $qlen,
-HLENGTH => $hlen,
);
push @hspList, $hspObj;
@hspData = ();
push @hspData, $line;
next;
} else {
push @hspData, $line;
}
} elsif( $start ) {
if( $line =~ /^(end|>|Parameters|CPU|Database:)/ ) {
$hspCount++;
$self->verbose and do{ print STDERR +( $hspCount % 10 ? "+" : "+\n" ); };
my $hspObj = Bio::Search::HSP::BlastHSP->new
(-RAW_DATA =>\@ hspData,
-RANK => $hspCount,
-PROGRAM => $prog,
-QNAME => $qname,
-HNAME => $hname,
-QLENGTH => $qlen,
-HLENGTH => $hlen,
);
push @hspList, $hspObj;
} else {
push @hspData, $line;
}
}
}
$hit->{'_length'} or $self->throw( "Can't determine hit sequence length.");
if($prog =~ /TBLAST[NX]/) {
$hit->{'_logical_length'} = $hit->{'_length'} / 3; }
$hit->{'_hsps'} = [ @hspList ];
} |
User feedback is an integral part of the evolution of this
and other Bioperl modules. Send your comments and suggestions preferably
to one of the Bioperl mailing lists.
Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bio.perl.org/MailList.html - About the mailing lists
Copyright (c) 2001 Steve Chervitz. All Rights Reserved.
This software is provided "as is" without warranty of any kind.
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _