Skip to content

Add SegmentList object in Python, and return this rather than dict encoding #1681

Closed

Description

@jeromekelleher

Currently the IbdResult object returns a dictionary {"left": array, "right": array, "node": array} for each IBD pair to encode the segments. This isn't a great design, as it doesn't give any way of putting functionality on these segment lists.

  • Add a SegmentList object in the Python C API which we return from the lowlevel _get function. This is a front-end for the C segment_list_t struct. Keep a reference to the IbdResult object to ensure the memory accesses are safe.
  • This can have accessors left, right, array which return the corresponding arrays
  • Have some other accessors that give stats of the segment list.
  • The high-level Python interface can also support iteration (I guess implementing the Sequence protocol, or something) which would return a list of (left, right, node) namedtuples.

So, you'd be able to do stuff like

for key, value in ibd_result.items():
    print(key, value.left) # Array of left coordinates
    for seg in value:
       print(seg.left, seg.right, seg.node)

Document this in the high-level Python API as the result. (See #1657)

Do this before #1680

Activity

  1. added this to the Python 0.3.8 milestone on Sep 10, 2021
  2. added 4 commits that reference this issue on Sep 16, 2021
    182352e
    512cb74
    f2debea
    a9e7e7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions