Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use Bio::SearchIO not Tools::Blast

svn path=/bioperl-live/trunk/; revision=3621
  • Loading branch information...
commit 5e3bdc11eb0ceffcd8e8966299a6367e792f2fd1 1 parent 333fdc2
@hyphaltip hyphaltip authored
Showing with 1 addition and 137 deletions.
  1. +1 −137 Bio/SeqFeature/SimilarityPair.pm
View
138 Bio/SeqFeature/SimilarityPair.pm
@@ -80,7 +80,7 @@ use strict;
use Bio::SeqFeature::FeaturePair;
use Bio::SeqFeature::Similarity;
-use Bio::Tools::Blast::Sbjct;
+use Bio::SearchIO;
@ISA = qw(Bio::SeqFeature::FeaturePair);
@@ -140,142 +140,6 @@ sub new {
return $self;
}
-=head2 from_searchResult
-
- Title : from_searchResult
- Usage : $sim_pair = Bio::SeqFeature::SimilarityPair->from_searchResult($blast_obj);
- $sim_pair->from_searchResult($blast_obj);
- Function: This method creates or fills SimilarityPair objects from objects
- representing similarity search results.
-
- Since there is no public interface search result objects are
- required to implement, this method basically checks for the type
- of the object and dispatches the actual SimilarityPair creation
- to a method capable of this.
-
- At present, the following classes are recognized:
- Bio::Tools::Blast::Sbjct
- Bio::Tools::Blast::HSP
- An exception will be thrown if an object of an unrecognized class
- is passed.
-
- Note that this is probably the point where you will want to add
- your class if you have a method for creating SimilarityPair
- objects from it.
-
- Note that passing an object that has already previously been
- filled is potentially error-prone, because undefined fields
- will not be (re-)set to an undef value.
-
- Returns : The object created or filled.
- Args :
-
-=cut
-
-sub from_searchResult {
- my ($obj, $blastobj) = @_;
-
- if(! ref($obj)) {
- $obj = $obj->new();
- }
- if($blastobj->isa('Bio::Tools::Blast::Sbjct')) {
- return $obj->_from_BlastObj($blastobj);
- } elsif($blastobj->isa('Bio::Tools::Blast::HSP')) {
- return $obj->_from_BlastObj($blastobj);
- } else {
- $obj->throw("don't know how to handle object of " . ref($blastobj));
- }
-}
-
-=head2 _from_blastObject
-
- Title : from_blastObject
- Usage : $sim_pair = Bio::SeqFeature::SimilarityPair->_from_blastObj($blast_obj);
- $sim_pair->_from_blastObj($blast_obj);
- Function: See documentation for from_searchResult(). This one handles
- Bio::Tools::Blast::Sbjct and Bio::Tools::Blast::HSP objects.
- Returns : A SimilarityPair object.
- Args :
-
-=cut
-
-sub _from_BlastObj {
- my ($obj, $blastObj) = @_;
-
- if(! ref($obj)) {
- $obj = $obj->new();
- }
- my $simqu = $obj->query();
- my $simsb = $obj->hit();
- my $report = $blastObj->parent();
- my $blastSbjct = $blastObj;
- if($blastObj->isa('Bio::Tools::Blast::HSP')) {
- $report = $report->parent();
- $blastSbjct = $blastSbjct->parent();
- }
- #
- # set the overall properties: score, bits, E value
- #
- $obj->score($blastObj->score());
- $obj->bits($blastObj->bits());
- $obj->significance($blastObj->signif());
- $obj->source_tag($report->program());
- #
- # set the query and hit specific properties
- #
- # seq names
- $simqu->seqname($report->query());
- $simsb->seqname($blastSbjct->name());
- # seq descriptions
- $simqu->seqdesc($report->query_desc());
- $simsb->seqdesc($blastSbjct->desc());
- # start and end points
- $simqu->start($blastObj->start('query'));
- $simsb->start($blastObj->start('sbjct'));
- $simqu->end($blastObj->end('query'));
- $simsb->end($blastObj->end('sbjct'));
- # frame and strand
- if($blastObj->isa('Bio::Tools::Blast::HSP')) {
- $simqu->strand($blastObj->strand('query'));
- $simsb->strand($blastObj->strand('sbjct'));
- my $frm = $blastObj->frame();
- if($frm) {
- # convert to 0,1,2 format
- $frm = ($frm * $simqu->strand($blastObj->strand('query'))) -1;
- $simqu->frame($frm);
- }
- } else {
- # scan through all HSPs, and if they agree set the respective field
- my @hsps = $blastObj->hsps();
- my $strandq = $hsps[0]->strand('query');
- my $strands = $hsps[0]->strand('sbjct');
- my $frm = $hsps[0]->frame();
- foreach my $hsp (@hsps) {
- if(!$hsp->strand('query') || $hsp->strand('query') != $strandq) {
- $strandq = undef;
- last; # frames can hardly agree in this case
- }
- if(defined($strands) && ($hsp->strand('sbjct') != $strands)) {
- $strands = undef;
- }
- # we can assume that either all hsps have a frame or none
- if($frm && ($frm != $hsp->frame())) {
- $frm = undef;
- }
- }
- $simqu->strand($strandq) if defined($strandq);
- $simsb->strand($strands) if defined($strands);
- $simqu->strand($frm) if $frm;
- }
- # 'percent' identity
- $simqu->frac_identical($blastObj->frac_identical('query'));
- $simsb->frac_identical($blastObj->frac_identical('sbjct'));
- #
- # return the created or fille object
- #
- return $obj;
-}
-
#
# Everything else is just inherited from SeqFeature::FeaturePair.
#
Please sign in to comment.
Something went wrong with that request. Please try again.