[Bioperl-l] undef query_len error with Bio::Search::Hit::GenericHit::num_unaligned_query
Sendu Bala
sb at mrc-dunn.cam.ac.uk
Fri Jun 9 08:08:18 UTC 2006
Freimuth, Robert wrote:
> Hi,
>
> I'm trying to use the Bio::Search::Hit::GenericHit
[snip]
> while( my $result_obj = $blast_obj->next_result() )
> {
> while( my $hit_obj = $result_obj->next_hit() )
> {
> my $generic_hit_obj = Bio::Search::Hit::GenericHit->new( -name
> => $hit_obj->name() );
> $generic_hit_obj->overlap( 0 ); # tile any hsps that overlap >
> this number of bp
>
> while( my $hsp_obj = $hit_obj->next_hsp() )
> {
> # add all HSPs to a GenericHit object so they can be tiled
> together
> $generic_hit_obj->add_hsp( $hsp_obj );
> }
>
> my $num_unaligned_query =
> $generic_hit_obj->num_unaligned_query();
> my $num_unaligned_hit = $generic_hit_obj->num_unaligned_hit();
>
> ------------- EXCEPTION -------------
> MSG: Must have defined query_len
> STACK Bio::Search::Hit::GenericHit::logical_length
[snip]
> I looked through the docs to try to find an explanation or some mention
> of how to set query_len, but I didn't find anything.
As Jason asked, why are you essentially recreating the hit object?
The problem you are seeing is that the query length is normally set via
SearchIO stream via ResultI when it internally creates a new hit object.
When you created your own hit object you didn't supply -query_len as an
option to new(), nor did you later use the query_length() method to set it.
If you really do need your $generic_hit_obj (instead of just using
$hit_obj), do $generic_hit_obj->query_length($hit_obj->query_length);
(Or if you know the length of your query sequence, supply that directly.)
More information about the Bioperl-l
mailing list