cucapra / pollen

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

Use @dataclass magic to hash SegO #39

Closed sampsyo closed 1 year ago

sampsyo commented 1 year ago

This is a minuscule follow-up to #29, which introduced the mygfa.SegO class. As in #35, I noticed a place where we were doing things manually that the dataclasses library can do for us. Namely, based on a couple of rules, it can generate __hash__ for us; all you need to do is make the type immutable (frozen) and equatable (eq). Both make sense for this type, so I've done that.

I also made the docstring slightly more accurate: it's not that the segment has an orientation; it's that we're referring to one of its two orientations.

It also occurs to me that we could use SegO to define Link: https://github.com/cucapra/pollen/blob/fce54a3bfa62364612190594ad732e18ef4eb5ea/slow_odgi/mygfa.py#L67-L70

Instead of having two fields (segment orientation) for both "from" and "to", we could just have a "from" SegO and a "to" SegO.

anshumanmohan commented 1 year ago

Tested, works great, merging. Thanks for tolerating my baby Python!