Skip to content

Add a function to extract the sort order from an AlignmentHeader #193

@msto

Description

@msto

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:

  1. Validate the presence of HD in the header. If it is absent, return None.
  2. Validate the presence of the key SO in the HD dictionary. If it is absent, return None.
  3. Attempt to parse the sort-order from the value associated with the SO key. If it is valid, the corresponding SortOrder member should be returned. If it is invalid, either raise a ValueError or return an SortOrder.UNKNOWN member, possibly with the raw value somehow associated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions