Bio::Factory
BlastHitFactory
Toolbar
Summary
Bio::Factory::BlastHitFactory - Factory for Bio::Search::Hit::BlastHit objects
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
use Bio::Factory::BlastHitFactory;
my $hit_fact = Bio::Factory::BlastHitFactory->new();
my $hit = $hit_fact->create_hit( %parameters );
See documentation for create_hit() for information about %parameters.
Description
This module encapsulates code for creating Bio::Search::Hit::BlastHit
and Bio::Search::HSP::BlastHSP objects from traditional BLAST report
data (i.e., non-XML formatted).
Methods
Methods description
Title : create_hit Usage : $hit = $factory->create_hit( %params ); Function: Creates a new Bio::Search::Hit::BlastHit object given raw BLAST report data, formatted in traditional BLAST report format. Returns : A single Bio::Search::Hit::BlastHit object Args : Named parameters to be passed to the BlastHit object. Parameter keys are case-insensitive. See Bio::Search::Hit::BlastHit::new() documentation for details about these parameters. The only additional parameter required is: -RESULT => a Bio::Search::Result::BlastResult object. From this result object, the program, query length, and iteration are obtained and passed on to the BlastHit. |
Methods code
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,
-QUERY_NAME => $qname,
-HIT_NAME => $hname,
);
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,
-QUERY_NAME => $qname,
-HIT_NAME => $hname,
);
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 ];
}
1; } |
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 new
{ my ($class, @args) = @_;
my $self = $class->SUPER::new(@args);
return $self; } |
General documentation
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://bioperl.org/MailList.html - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
Steve Chervitz <sac@bioperl.org>
See
the FEEDBACK section for where to send bug reports and comments.
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 _