pangenome/spodgi

Best way to turn for_each_handle into a generator instead of an internal iterator

Opened this issue · 3 comments

for_each_handle and for_each_path are the two key methods that need efficient implementation.
However, these are C++ internal iterators while the librdf would like to see a generator.

I would love to see some help on how to best convert from the one into the other.

For now we can just do a loop in a range

def nodes:
  nodeId = og.min_node_id
  maxNodeId = og.max_node_id
  while (nodeId <= maxNodeId):
    if(og.has_node(nodeId):
      yield og.get_node(nodeId)
      nodeId+1

But this will cost in efficiency and long run needs to be fixed.

This approach works for node handles. Unfortunately it will not work for path_handles. As there is no easy way to get a set of path_handles. This either means loading a set of them on open, or figuring out how to do this.

I opened an issue at libhandlegraph