Skip to content

Commit d0ea604

Browse files
committed
formatting
1 parent d3a9154 commit d0ea604

File tree

11 files changed

+37
-18
lines changed

11 files changed

+37
-18
lines changed

src/smftools/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""smftools"""
2+
23
from __future__ import annotations
34

45
import logging
@@ -13,8 +14,17 @@
1314
__version__ = version(package_name)
1415

1516
if TYPE_CHECKING:
16-
from smftools import cli, config, datasets, hmm, informatics, machine_learning, plotting
17-
from smftools import preprocessing, tools
17+
from smftools import (
18+
cli,
19+
config,
20+
datasets,
21+
hmm,
22+
informatics,
23+
machine_learning,
24+
plotting,
25+
preprocessing,
26+
tools,
27+
)
1828

1929
_LAZY_MODULES = {
2030
"cli": "smftools.cli",

src/smftools/cli/load_adata.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from pathlib import Path
55
from typing import Iterable, Union
66

7+
import numpy as np
8+
79
from smftools.logging_utils import get_logger
810

911
from .helpers import AdataPaths
@@ -107,9 +109,6 @@ def load_adata_core(cfg, paths: AdataPaths, config_path: str | None = None):
107109
cfg : ExperimentConfig
108110
(Same object, possibly with some fields updated, e.g. fasta path.)
109111
"""
110-
from pathlib import Path
111-
112-
import numpy as np
113112

114113
from ..informatics.bam_functions import (
115114
align_and_sort_BAM,

src/smftools/hmm/call_hmm_peaks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
# FILE: smftools/hmm/call_hmm_peaks.py
4-
54
from pathlib import Path
65
from typing import Any, Dict, Optional, Sequence, Union
76

src/smftools/hmm/hmm_readwrite.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
34
def load_hmm(model_path, device="cpu"):
45
"""
56
Reads in a pretrained HMM.

src/smftools/informatics/bam_functions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import glob
44
import os
55
import re
6+
import shutil
67
import subprocess
78
import time
89
from collections import Counter, defaultdict, deque
910
from concurrent.futures import ThreadPoolExecutor, as_completed
1011
from itertools import zip_longest
1112
from pathlib import Path
12-
import shutil
13-
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, TYPE_CHECKING
13+
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Union
1414

1515
import numpy as np
1616
from tqdm import tqdm
@@ -173,9 +173,7 @@ def _index_bam_with_pysam(bam_path: Union[str, Path], threads: Optional[int] = N
173173
pysam_mod.index(bam_path)
174174

175175

176-
def _bam_to_fastq_with_samtools(
177-
bam_path: Union[str, Path], fastq_path: Union[str, Path]
178-
) -> None:
176+
def _bam_to_fastq_with_samtools(bam_path: Union[str, Path], fastq_path: Union[str, Path]) -> None:
179177
"""Convert BAM to FASTQ using samtools."""
180178
if not shutil.which("samtools"):
181179
raise RuntimeError("samtools is required but not available in PATH.")

src/smftools/informatics/bed_functions.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING
1010

11-
import matplotlib.pyplot as plt
1211
import numpy as np
1312
import pandas as pd
1413

@@ -58,13 +57,17 @@ def _require_pysam() -> "pysam_types":
5857
return require("pysam", extra="pysam", purpose="FASTA indexing")
5958

6059

61-
def _resolve_backend(backend: str | None, *, tool: str, python_available: bool, cli_name: str) -> str:
60+
def _resolve_backend(
61+
backend: str | None, *, tool: str, python_available: bool, cli_name: str
62+
) -> str:
6263
choice = (backend or "auto").strip().lower()
6364
if choice not in {"auto", "python", "cli"}:
6465
raise ValueError(f"{tool}_backend must be one of: auto, python, cli")
6566
if choice == "python":
6667
if not python_available:
67-
raise RuntimeError(f"{tool}_backend=python requires the Python package to be installed.")
68+
raise RuntimeError(
69+
f"{tool}_backend=python requires the Python package to be installed."
70+
)
6871
return "python"
6972
if choice == "cli":
7073
if not shutil.which(cli_name):
@@ -143,7 +146,10 @@ def _bed_to_bigwig(
143146

144147
# 1) Compute coverage → bedGraph
145148
bedtools_choice = _resolve_backend(
146-
bedtools_backend, tool="bedtools", python_available=pybedtools is not None, cli_name="bedtools"
149+
bedtools_backend,
150+
tool="bedtools",
151+
python_available=pybedtools is not None,
152+
cli_name="bedtools",
147153
)
148154
if bedtools_choice == "python":
149155
logger.debug(f"[pybedtools] generating coverage bedgraph from {bed}")
@@ -172,7 +178,10 @@ def _bed_to_bigwig(
172178

173179
# 2) Convert bedGraph → BigWig via pyBigWig
174180
bigwig_choice = _resolve_backend(
175-
bigwig_backend, tool="bigwig", python_available=pyBigWig is not None, cli_name="bedGraphToBigWig"
181+
bigwig_backend,
182+
tool="bigwig",
183+
python_available=pyBigWig is not None,
184+
cli_name="bedGraphToBigWig",
176185
)
177186
if bigwig_choice == "python":
178187
logger.debug(f"[pyBigWig] converting bedgraph → bigwig: {bigwig}")
@@ -245,6 +254,8 @@ def _plot_bed_histograms(
245254
coordinate_mode : {"one_based","zero_based"}
246255
One-based, inclusive (your file) vs BED-standard zero-based, half-open.
247256
"""
257+
plt = require("matplotlib.pyplot", extra="plotting", purpose="plotting BED histograms")
258+
248259
os.makedirs(plotting_directory, exist_ok=True)
249260

250261
bed_basename = os.path.basename(bed_file).rsplit(".bed", 1)[0]

src/smftools/informatics/binarize_converted_base_identities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
34
def binarize_converted_base_identities(
45
base_identities,
56
strand,

src/smftools/plotting/position_stats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
34
def plot_volcano_relative_risk(
45
results_dict,
56
save_path=None,

src/smftools/preprocessing/binary_layers_to_ohe.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
## binary_layers_to_ohe
4-
54
from smftools.logging_utils import get_logger
65

76
logger = get_logger(__name__)

src/smftools/preprocessing/calculate_pairwise_hamming_distances.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## calculate_pairwise_hamming_distances
44

5+
56
## Conversion SMF Specific
67
def calculate_pairwise_hamming_distances(arrays):
78
"""

0 commit comments

Comments
 (0)