Documentation of AlignmentFile.fetch
is unclear about the region
argument
#700
Labels
AlignmentFile.fetch
is unclear about the region
argument
#700
The API documentation says:
I don't see any documentation about such a
parse_region
method.The term "region" links to the glossary which says:
This doesn't really tell how the
region
argument is to be provided.Suppose I want to iterate over the alignments found within the first 100 positions of chromosome "I".
The above indications somehow hint me that
region
consists in three elements, so I naturally attempted using a (reference name, start, end) tuple:bamfile.fetch(region=("I", 0, 99))
but I got the following error:Same error if I use strings instead of ints for start and end.
I tried
bamfile.fetch(region="I:0:99")
and this resulted inValueError: start out of range (-1)
, so I assume this is interpreted as a "samtools compatible region string" (and I should instead use "I:1:100"). But the documentation seems to consider this as "an exception". What is the standard, non-exceptional, way to specify the region, using zero-based coordinates, and with the possibility to omit start and end, as the documentation tells ? Apparently not by the means of a tuple.Only after more careful inspection and experimentation did I realize that
start
andend
were actually supposed to be passed as separate parameters, andregion
being actually only the chromosome name:bamfile.fetch(start=0, end=99, region="I")
I guess one source of confusion was that the glossary uses the terms "start" and "end" as belonging to the specification of a "region", while the method documentation refers to the
end
parameter as something just here for backwards compatibility with an older way of specifying regions, using a reference name. If I understand correctly, the up-to-date and standard way of doing is to use thecontig
,start
andstop
parameters, and thatregion
is actually only intended to be used with a special "samtools compatible region string".Arguments would benefit from more explicit documentation. Only
until_eof
andmultiple_iterators
are currently explicitly documented. Another improvement could be to give usage examples in the API documentation, not just in the introduction: I'm quite sure I had already learned how to this by following the introduction a few years ago. Today, after some time without pysam practice, I directly went to the API documentation to get a refresher about the specific method I wanted to use, and that's how I got into all this confusion.The text was updated successfully, but these errors were encountered: