-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add a function to extract the sort order from an AlignmentHeader
#193
Comments
@tfenne Any thoughts on how we should resolve (3) if an invalid/unknown sort-order value exists? |
fgpyo has the enum already (fgpyo/sam/init.py:1015) and there's an Unknown (which should probably be returned instead of "None") I'd leave special error throwing or raw-value-returning out of it, and keep it simple and predictable. |
so maybe we can add a |
Oh nice, I didn't know we already had that enum. In the course of resolving this issue we should also update that enum to improve its documentation (i.e. include the member attributes in the docstring so they show up in the rendered docs) and consider getting it inline with our usual enum conventions (all-caps member names). We should also consider whether to include sort orders that aren't part of htslib. I'm thinking of template-coordinate sort order, in particular. |
In an ideal world this would probably be a method on |
Re: returning "UNKNOWN" - this is an edge case in the SAM spec I'm not actually familiar with. Is there a distinction between an "unknown" sort order and an invalid sort order? i.e. is "unknown" reserved for SAMs with no specified If so, then our implementation should be consistent with that, and we should raise an error or otherwise distinguish the case where the SO tag contains an invalid value |
I think that there's an unofficial |
Requested by @yfarjoun
A new enum,
SortOrder
, should be added to enumerate the valid sort orders.A new function,
get_sort_order(header: pysam.AlignmentHeader) -> SortOrder | None
should be implemented.This function should extract the sort order from the
header
when possible. Specifically, the function should:HD
in the header. If it is absent, returnNone
.SO
in theHD
dictionary. If it is absent, returnNone
.SO
key. If it is valid, the correspondingSortOrder
member should be returned. If it is invalid, either raise aValueError
or return anSortOrder.UNKNOWN
member, possibly with the raw value somehow associated.The text was updated successfully, but these errors were encountered: