[Bioperl-l] how to get blast result from the hit object?

Wiepert, Mathieu Wiepert.Mathieu@mayo.edu
Tue, 26 Nov 2002 07:02:56 -0600


> I looked at the perldoc of hit result for blast, only
> find result->get_by_acc(xxx) to get the gene accession
> code, but we will lost the alignment information as
> well as which CDS we should look at.
>  how to get the exact aligned sequence with our query
> without going to genbank again? sometime it is even
> impossible to get because some entry has multiple
> CDS..
> 

Hi,

I am not 100% sure what information you want, but the alignment information is in the HSP.  Normally, I iterate through my results (I have many blast files concatenated together), then iterate through hits, and then hsp's within hits?  The hsp's seem to actually contain what I think you are asking for, here is what I ripped from the synopsis of the GenericHSP module that gets used to give you back this information.

$qseq = $hsp->query_string;
$hseq = $hsp->hit_string;
$homo_string = $hsp->homology_string;

And if you wanted some lengths, 
$querylen = $hsp->length('query');
$hitlen = $hsp->length('hit');
$totallen = $hsp->length('total');

When the doc.bioperl.org server is back up, you can take a look at the modules online, in the meantime, you should be able to look at all the various POD's for the modules involved.

This is a small example of how you might get the query, hit, and homology strings, if that was what you wanted?

while ( my $result = $rc->next_result()) {
  print "\nQuery Name: ", $result->query_name(), "\n";
  while ( my $hit = $result->next_hit ) {
    print "\thit name is ", $hit->name, "\n";
    while( my $hsp = $hit->next_hsp ) {
      $qseq = $hsp->query_string;
      $hseq = $hsp->hit_string;
      $homo_string = $hsp->homology_string;
      $querylen = $hsp->length('query');
      $hitlen = $hsp->length('hit');
      $totallen = $hsp->length('total');
  }
}


I wasn't sure about the CDS part, sorry...

This code works with bioperl-live, I can't guarantee that it works with older code bases either.

-Mat