Skip to content

Commit

Permalink
Merge pull request #2 from GavinHuttley/develop
Browse files Browse the repository at this point in the history
MAINT: merge develop changes
  • Loading branch information
GavinHuttley authored Jan 7, 2025
2 parents 7588554 + ee07d98 commit 1167646
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ venv/
working/
# vi
.*.swp

# test data installed via download
small-113/*
3 changes: 2 additions & 1 deletion .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ doc/draw*
dist/*
working/*
lcov*.info
.ruff_cache/*
.ruff_cache/*
small-113/*
4 changes: 4 additions & 0 deletions src/ensembl_tui/_align.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pathlib
import typing
import uuid
from collections import defaultdict
from dataclasses import dataclass

Expand Down Expand Up @@ -85,6 +86,9 @@ def __init__(
mode: str = "r",
in_memory: bool = False,
):
in_memory = in_memory or "memory" in str(source)
source = uuid.uuid4().hex if in_memory else source

self.source = pathlib.Path(source)
self.mode = "w-" if mode == "w" else mode
h5_kwargs = (
Expand Down
4 changes: 2 additions & 2 deletions src/ensembl_tui/_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class valid_compara_homology:
"""homology tsv files"""

def __init__(self) -> None:
self._valid = re.compile("([.]tsv[.]gz|README|MD5SUM)")
self._valid = re.compile("([.]tsv|[.]tsv[.]gz|README|MD5SUM)$")

def __call__(self, name: str) -> bool:
return self._valid.search(name) is not None
Expand Down Expand Up @@ -208,7 +208,7 @@ def download_homology(
elt_ftp.listdir(config.host, remote_path, valid_compara_homology()),
)
if verbose:
print(remote_paths)
print(f"{remote_path=}", f"{remote_paths=}", sep="\n")

if debug:
# we need the checksum files
Expand Down
19 changes: 10 additions & 9 deletions src/ensembl_tui/_genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import sqlite3
import typing
import uuid
from abc import ABC, abstractmethod
from typing import Any

Expand Down Expand Up @@ -799,25 +800,25 @@ def __init__(
in_memory: bool = False,
):
# note that species are converted into the Ensembl db prefix
in_memory = in_memory or "memory" in str(source)
source = uuid.uuid4().hex if in_memory else source
self.source = pathlib.Path(source)

source = pathlib.Path(source)
self.source = source

if mode == "r" and not source.exists():
if not in_memory and mode == "r" and not self.source.exists():
raise OSError(f"{self.source!s} not found")

species = (
elt_species.Species.get_ensembl_db_prefix(species) if species else None
)
self.mode = "w-" if mode == "w" else mode
if in_memory:
h5_kwargs = dict(
h5_kwargs = (
dict(
driver="core",
backing_store=False,
)
else:
h5_kwargs = {}

if in_memory
else {}
)
try:
self._file: h5py.File = h5py.File(source, mode=self.mode, **h5_kwargs)
except OSError:
Expand Down
2 changes: 1 addition & 1 deletion src/ensembl_tui/_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def local_install_homology(
dirnames = []
for sp in config.db_names:
path = config.staging_homologies / sp
dirnames.extend(list(path.glob("*.tsv.gz")))
dirnames.extend(list(path.glob("*.tsv*")))

if max_workers:
max_workers = min(len(dirnames) + 1, max_workers)
Expand Down

0 comments on commit 1167646

Please sign in to comment.