-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent BAM flag accessor functions #16
Comments
@jakobnissen Did this get fixed to your satisfaction in your PR? I'm trying to figure if this can be closed or if it's still troubling you? |
So it turns out it's an operation a little larger than I expected - and I've been short on time due to work the past month or so. Feel free to close this issue or not; I'll create a PR some time when I have the time either way :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inconsistent BAM flag accessor functions
Currently, it's possible to create a spec-compliant BAM record with the following behaviour:
(on a related note, the function
BAM.hasnextrefname
simply doesn't work.)What's going on?
Well, for a subset (which subset, I'm not quite sure) of the flags, there is a corresponding flag accessor
isX
function and a functionhasX
. I'm not entirely sure what the purpose of thehasX
function are - some of them seem to be exported to BioCore. It might be I'm simply confused as to what the purpose of these functions are, if so, please tell me.Anyway, the behaviour of these functions are inconsistent and highly unintuitive. For example,
ismapped
,isprimary
andispositivestrand
all raise an error if the record is unfilled, else return a boolean. Howeverisnextmapped
returnsfalse
with an unfilled record.Furthermore,
hasrefid
,hasrefname
,hasnextrefid
returns whether the record is filled, NOT whether the record is aligned (i.e. actually has a refid etc.). So a valid, unmapped record can have an ID of -1 and still returntrue
when asked ifhasrefid
. The similar functionhasnextrefname
, however, actually does check whether it has a valid next reference name.Also,
refname
andnextrefname
checks for the validity of the corresponding IDs before fetching the name, whereashasrefname
does not (hence the error at the beginning of this issue).hasposition
returnstrue
if the Record is unmapped (i.e. has an invalid position), buthasrightposition
returnsfalse
in that case.hasflag
seem to me to be meaningless. All BAM records by definition has flags. Currently, it simply returnsisfilled(record)
, and is not used in any other code.This seems very unsystematic. I propose changing all these functions to follow the following rules:
hasX
returnstrue
, thenisX
will always return a boolean which is guaranteed to be correct.hasX
returnsfalse
, thenisX
will always throw an errorhasrefid
,hasrefname
,hasnextrefid
andhasnextrefname
will returnfalse
if the record is unfilled, or if the record/mate is unmapped, elsetrue
hasposition
,hasnextposition
andhasrightposition
returnsfalse
is the record is unfilled or the record/mate is unmapped, elsetrue
The text was updated successfully, but these errors were encountered: