Skip Menu |

This queue is for tickets about the Bio-SamTools CPAN distribution.

Report information
The Basics
Id: 81949
Status: open
Priority: 0/
Queue: Bio-SamTools

Owner: Nobody in particular
Requestors: miker [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)

Subject: Documentation bug
Date: Thu, 13 Dec 2012 12:02:06 -0800
To: bug-Bio-SamTools [...]
From: Michael Rogoff <miker [...]>
In the pileup example at I believe the example code is incorrect. my $depth = 0; my $positions = 0; my $callback = sub { my ($seqid,$pos,$pileup) = @_; next unless $pos >= 501 && $pos <= 600; $positions++; $depth += @$pileup; } $sam->pileup('seq1:501-600',$callback); print "coverage = ",$depth/$positions; Specifically, the callback method. I think the 'next' is out of context and will cause unexpected results if the callback is defined in a loop. I think the callback should simply do nothing if the reported position is outside the requested range, as shown below. As a side note a semi-colon is needed after the callback definition. my $depth = 0; my $positions = 0; my $callback = sub { my ($seqid,$pos,$pileup) = @_; if ($pos >= 501 && $pos <= 600) { $positions++; $depth += @$pileup; } }; $sam->pileup('seq1:501-600',$callback); print "coverage = ",$depth/$positions;
Download (untitled) / with headers
text/html 11.4k
From: dan.bolser [...]
Is the code in GitHub or similar? You could submit this as a patch.
From: dan.bolser [...]
Download (untitled) / with headers
text/plain 252b
On Thu Aug 20 08:32:35 2015, dan.bolser wrote: Show quoted text
> Is the code in GitHub or similar? You could submit this as a patch.
Finally found it here: Can you submit a pull request there (else I can do it for you)? Ta,

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to