brittneybrinsfield / pysam

Automatically exported from code.google.com/p/pysam
0 stars 0 forks source link

End points in Python should be 1-based #77

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Read http://wwwfgu.anat.ox.ac.uk/~andreas/documentation/samtools/usage.html 
and http://wwwfgu.anat.ox.ac.uk/~andreas/documentation/samtools/api.html and 
observe line:

"Note Coordinates in pysam are always 0-based (following the python 
convention)."

2. Read 
http://wwwfgu.anat.ox.ac.uk/~andreas/documentation/samtools/api.html#pysam.Align
edRead and observe lines:

"send - end index of the aligned query portion of the sequence (0-based, 
exclusive)"

"send - end index of the aligned query portion of the sequence (0-based, 
exclusive)"

3. Read 
http://wwwfgu.anat.ox.ac.uk/~andreas/documentation/samtools/api.html#pysam.Samfi
le.pileup and notice:

"The region is specified by reference, start and end (using 0-based indexing)."

What is the expected output? What do you see instead?

Python indexing of a single entry is 0-based, but for ranges using slicing like 
seq[start:end] the start is 0-based and the end 1-based, such that 
len(seq[start:end]) == end-start (for the typical case 0 <= start <= end <= 
length).

It is unclear to me from the documentation if pysam uses Python style end 
points (1-based) in which case the documentation needs clarifying, or takes the 
surprising route of using 0-based end points which I think is a mistake.

Either way, a couple of examples in the documentation would be very 
illuminating.

What version of the product are you using? On what operating system?

pysam 0.5

Please provide any additional information below.

Original issue reported on code.google.com by p.j.a.c...@googlemail.com on 22 Oct 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Thanks.

pysam follows python indexing, which is 0-based, with open-closed 
indices for slicing.

Is this what you mean by 1-based end coordinates?

Please note the word "exclusive" in the documentation you quote.

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 27 Oct 2011 at 7:24

GoogleCodeExporter commented 9 years ago
So you're not going to add any examples or tex to the documentation to clarify 
this?

Original comment by p.j.a.c...@googlemail.com on 27 Oct 2011 at 11:25