cucapra / pollen

generating hardware accelerators for pangenomic graph queries
MIT License
24 stars 1 forks source link

FlatGFA Python bindings: support more container-like operations #187

Closed sampsyo closed 1 month ago

sampsyo commented 1 month ago

This adds some ergonomics I was wishing for when using the various list-like containers in the Python bindings. The big feature is that you can now "slice" all the lists. For example, if you want to see the first few paths in a GFA:

for p in g.paths[:5]:
    print(str(p))

Recall that g.paths is not a real Python list object, so g.paths[:5] doesn't construct a new list or otherwise eagerly fetch any paths. It just does the index math to give you a narrower view such that, when you eventually access items, you get the selected subrange.