Skip to content

Add tsk_tree_seek_index #2659

Closed
Closed

Description

@jeromekelleher

We never added a method in the C API to seek efficiently to the tree at the kth index. The implementation in the Python API is currently quite naive:

def seek_index(self, index):

Activity

  1. added
    C API
    on Dec 11, 2022
  2. molpopgen commented on Dec 11, 2022

    @molpopgen
    Member

    This can probably be rolled into a PR adding constant-time seeking to a tree. I think it will make sense to use this function to advance to a tree by position, one we have the indexes, etc., in place.

  3. jeromekelleher commented on Dec 14, 2022

    @jeromekelleher
    MemberAuthor

    We can implement this straightforwardly by using the breakpoints array, i.e.,

    int tsk_tree_seek_index(self, index)
    {
          double pos = self->tree_sequence->breakpoints[index]; /* or maybe +1? */
          return tsk_tree_seek(self, pos);
    }

    We can focus our efforts then on making the "seek to position" efficient.

  4. molpopgen commented on Dec 14, 2022

    @molpopgen
    Member

    We can implement this straightforwardly by using the breakpoints array, i.e.,

    int tsk_tree_seek_index(self, index)
    {
          double pos = self->tree_sequence->breakpoints[index]; /* or maybe +1? */
          return tsk_tree_seek(self, pos);
    }

    We can focus our efforts then on making the "seek to position" efficient.

    Dammit -- I wish I knew that that existed.

  5. added a commit that references this issue on Apr 21, 2023
    edb3df2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C API

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions