[Bioperl-l] Hit length using length_aln()

Brian Desany bdesany@bcm.tmc.edu
Fri, 12 Jul 2002 18:15:44 -0500


Ken,

I just saw Jason's post, but here's my input anyway:

To find the length of the query, the subject (a.k.a. hit) and the hsp:

$result->query_length
This is a Bio::Search::Result::GenericResult (gets all it's methods from
Bio::Search::Result::ResultI I think).

$hit->length
This is a Bio::Search::Hit::GenericHit, which doesn't have a length_aln
method.

$hsp->length
This is a Bio::Search::HSP::GenericHSP

When I run into issues like this I like to go into the perl debugger and
type 'm $object' to see what methods the object has, and as a bonus it tells
you from where in it's inheritance it get it. To see what kind of object you
have in the first place, type 'x ref($hsp)'. This has been really useful to
me in figuring out a lot of bioperl (incl. the Blast parsing parts) because
it can be kinda complicated.

HTH

-Brian.



>-----Original Message-----
>From: bioperl-l-admin@bioperl.org
>[mailto:bioperl-l-admin@bioperl.org]On
>Behalf Of Ken
>Sent: Friday, July 12, 2002 5:55 PM
>To: bioperl-l@bioperl.org
>Subject: [Bioperl-l] Hit length using length_aln()
>
>
>I'm still learning BioPerl so bear with me.
>I want the total length for a hit across all the HSPs so I
>figured I should
>use length_aln.
>All I get is an error message:
>  Can't locate object method "length_aln" via package
>"Bio::Search::Hit::GenericHit"
>
>I can't locate length_aln() in that package either, so Perl
>and I agree
>there...
>I found it in Bio::Search::Hit::BLASTHit.
>
>I'm able to return all of the HSPs from the hit object - so I
>know that I've
>got a good reference to the hit.
>
>The code is pretty straightforward:
>---------------------------------------------------------------
>--------------------------
>my $searchio = new Bio::SearchIO ('-format' => 'blast', '-file'
>=>$blastfile );
>my $result = $searchio->next_result;
># get info about the first hit
>while( my $hit = $result->next_hit()) {
>	my @hsps_lens;
>	my $hit_name = $hit->name ;
>	#for each hit look at each HSP
>	my @hsp_s = $hit->hsps();
>	my $lenObj = $hit->length_aln();
>---------------------------------------------------------------
>--------------------------
>If I remove the reference to length_aln() everything works.
>I've thought about creating something that adds the length of
>each HSP, but I
>figured that's what length_aln() does.
>Any ideas why this doesn't work?
>Thanks in advance for any help,
>Ken Graham
>Biological Chemistry
>U.C. Davis School of Medicine
>_______________________________________________
>Bioperl-l mailing list
>Bioperl-l@bioperl.org
>http://bioperl.org/mailman/listinfo/bioperl-l
>