Skip to content

Conversation

manzt
Copy link
Member

@manzt manzt commented Feb 12, 2025

The register naming is not very clear, and also the meta-programming
in the previous approach erased type information. By having a shared
based class, implementing a custom tileset is much nicer:

from dataclasses import dataclass

import higlass as hg
from clodius.tiles import cooler

@dataclass
class MyCustomCoolerTileset(hg.Tileset):
    path: str
    datatype = "matrix"

    def tiles(self, tile_ids):
        return cooler.tiles(self.path, tile_ids)

    def info(self):
        return cooler.tileset_info(self.path)

ts = MyCustomCoolerTileset("test.mcool")
hg.view(ts.track())

Description

What was changed in this pull request?

Why is it necessary?

Fixes #___

Checklist

  • Clear PR title (used for generating release notes).
    • Prefer using prefixes like fix: or feat: to help organize auto-generated
      notes.
  • Unit tests added or updated.
  • Documentation added or updated.

The `register` naming is not very clear, and also the meta-programming
in the previous approach erased type information. By having a shared
based class, implementing a custom tileset is much nicer:

```py
from dataclasses import dataclass

import higlass as hg
from clodius.tiles import cooler

@DataClass
class MyCustomCoolerTileset(hg.Tileset):
    path: str
    datatype = "matrix"

    def tiles(self, tile_ids):
        return cooler.tiles(self.path, tile_ids)

    def info(self):
        return cooler.tileset_info(self.path)

ts = MyCustomCoolerTileset("test.mcool")
hg.view(ts.track())
```
@manzt manzt force-pushed the manzt/tileset-base-class branch from 48b0a8e to 36200bf Compare February 12, 2025 20:52
@manzt manzt merged commit b4afd99 into main Feb 12, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant