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

Report information
The Basics
Id:
81949
Status:
open
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
miker [...] htblis.com
Cc:
AdminCc:

BugTracker
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@rt.cpan.org
From: Michael Rogoff <miker@htblis.com>


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;



From: dan.bolser@gmail.com
Is the code in GitHub or similar? You could submit this as a patch.
From: dan.bolser@gmail.com
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: https://github.com/GMOD/GBrowse-Adaptors Can you submit a pull request there (else I can do it for you)? Ta,


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.