[Bioperl-l] help-> SearchIO

Roy Chaudhuri roy.chaudhuri at gmail.com
Mon Sep 19 16:29:41 UTC 2011


Hi Rondon,

The line where you populate your arrayref with 0 (starting "for 
(0..$tam)") is within the HSP loop, so the data from every successive 
HSP will overwrite the previous one in your hash. You will therefore 
only see the data for the last HSP from each query. If you move that 
line to execute once per result (i.e. just after the line starting 
"while (my result ="), then I think it should work as you intended.

Cheers,
Roy.

On 19/09/2011 14:46, Rondon Neto wrote:
> Hi guys! I need your help in a loop that I have in SearchIO. I need
> to check the nucleotide coverage of querys using BLAST. I'm using the
> script below. It's open the alignment, create arrays for each query
> with zeros in each nucleotide position but, when I adds values to the
> coverage of each nucleotide, the script does it once and passes to
> another query. Can you hek me? Thank you very much,
>
> Rondon a Brazilian friend.
>
> use Bio::SearchIO;
>
> my $alignment = new Bio::SearchIO ( -format =>  'blastXML',
>                               -file   =>  $alignment_file );
>
> my %positions;
> while (my $result = $alignment->next_result) {
> while (my $hit = $result->next_hit) {
> while (my $hsp = $hit->next_hsp) {
> my $query_name = $result->query_name();
> my $tam = $result ->  query_length();
> my @pos = $hsp->seq_inds('query','identical');
> for (0..$tam){ ${$positions{$query_name}}[$_] = 0 } # make arrays for each query and populate with 0 in each position
> foreach my $num (@pos) {
> ${$positions{$query_name}}[$num -1]++;    #This loop is where I believe that is an error.
> }
> }
> }
> }
>
> foreach my $key (keys %positions){
> print "$key\t@{$positions{$key}}\n";
> }
>
> exit;
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list