[Bioperl-l] Hit length using length_aln()

Jason Stajich jason@cgt.mc.duke.edu
Fri, 12 Jul 2002 19:05:46 -0400 (EDT)


Common problem and totally not your fault.  This is because Steve and I
didn't use the same methods.  BlastHSP is going away anyways but of course
this confuses people to no end.

use $hsp->hsp_length('total')

=head2 length

 Title    : length
 Usage    : my $len = $hsp->length( ['query'|'hit'|'total'] );
 Function : Returns the length of the query or hit in the alignment
            (without gaps)
            or the aggregate length of the HSP (including gaps;
            this may be greater than either hit or query )
 Returns  : integer
 Args     : arg 1: 'query' = length of query seq (without gaps)
                   'hit'   = length of hit seq (without gaps)
                   'total' = length of alignment (with gaps)
                   default = 'total'
            arg 2: [optional] integer length value to set for specific
                   type


On Fri, 12 Jul 2002, Ken wrote:

> 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
>

-- 
Jason Stajich
Duke University
jason at cgt.mc.duke.edu