Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [v1.0.2](https://github.com/higlass/higlass-python/compare/v1.0.2...v1.0.1)

- Calculate file pointer hash for track uids for tileset tracks

## [v1.0.1](https://github.com/higlass/higlass-python/compare/v1.0.1...v1.0.0)

- Pass kwargs in to Viewconf.widget() so that they can be passed on to the higlass widget and potentially make their way to the higlass component
Expand Down
14 changes: 11 additions & 3 deletions src/higlass/tilesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import typing
from dataclasses import dataclass
from typing import IO, Union

from ._utils import TrackType
from .api import track
Expand Down Expand Up @@ -74,10 +75,14 @@ def remote(uid: str, server: str = "https://higlass.io/api/v1", **kwargs):
def hash_absolute_filepath_as_default_uid(
fn: typing.Callable[[str, str], LocalTileset]
):
def wrapper(filepath: str, uid: None | str = None):
def wrapper(filepath: Union[str, IO[bytes]], uid: None | str = None):
if uid is None:
abspath = pathlib.Path(filepath).absolute()
uid = hashlib.md5(str(abspath).encode()).hexdigest()
if isinstance(filepath, str):
abspath = pathlib.Path(filepath).absolute()
uid = hashlib.md5(str(abspath).encode()).hexdigest()
else:
# File-like object likely provided
uid = hashlib.md5(str(hash(filepath)).encode()).hexdigest()
return fn(filepath, uid)

return wrapper
Expand Down Expand Up @@ -183,3 +188,6 @@ def bed2ddb(filepath: str, uid: str):
info=functools.partial(tileset_info, filepath),
uid=uid,
)


by_filetype = {"cooler": cooler, "bigwig": bigwig}
Loading