Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#3003)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.4.0 →
v4.6.0](pre-commit/pre-commit-hooks@v4.4.0...v4.6.0)
- [github.com/astral-sh/ruff-pre-commit: v0.2.0 →
v0.4.9](astral-sh/ruff-pre-commit@v0.2.0...v0.4.9)
- [github.com/tox-dev/tox-ini-fmt: 0.5.2 →
1.3.1](tox-dev/tox-ini-fmt@0.5.2...1.3.1)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: C. Titus Brown <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and ctb authored Jun 18, 2024
1 parent 0479afc commit 5bde7dc
Show file tree
Hide file tree
Showing 53 changed files with 93 additions and 85 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand All @@ -10,16 +10,16 @@ repos:
- id: check-toml
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.4.9
hooks:
- id: ruff-format
- id: ruff
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "0.5.2"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix_lint"]
# - repo: https://github.com/tox-dev/tox-ini-fmt
# rev: "1.3.1"
# hooks:
# - id: tox-ini-fmt
# args: ["-p", "fix_lint"]
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class MinHash - hash sketch class
The sourmash code is available at github.com/sourmash-bio/sourmash/ under the
BSD 3-Clause license.
"""

from deprecation import deprecated
from importlib.metadata import version

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/command_compute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions implementing the 'compute' command and related functions.
"""

import os
import os.path
import sys
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/command_sketch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions implementing the 'sketch' subcommands and related functions.
"""

import sys
import os
from collections import defaultdict, Counter
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Functions implementing the main command-line subcommands.
"""

import csv
import os
import os.path
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/distance_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Equations from: https://github.com/KoslickiLab/mutation-rate-ci-calculator
Reference: https://doi.org/10.1101/2022.01.11.475870
"""

from dataclasses import dataclass, field
from scipy.optimize import brentq
from scipy.stats import norm as scipy_norm
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/fig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Make plots using the distance matrix+labels output by `sourmash compare`.
"""

from .logging import error, notify

try:
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/index/sqlite_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
should work fine for many simultaneous queries; just don't write :).
"""

import time
import os
import sqlite3
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/command_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Classify individual signature files down to deepest possible node.
"""

import sys
import csv

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/command_compare_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Compare two taxonomy spreadsheets.
"""

import sys
from collections import defaultdict

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/command_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Build a lowest-common-ancestor database with given taxonomy and genome sigs.
"""

import sys
import csv
import os
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/command_rankinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Summarize rank-specific information from LCAs in one or more databases.
"""

import sys
from collections import defaultdict

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/command_summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Summarize the taxonomic content of the given signatures, combined.
"""

import sys
import csv
from collections import defaultdict
Expand Down
9 changes: 3 additions & 6 deletions src/sourmash/lca/lca_db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"LCA database class and utilities."

import os
import json
import gzip
Expand Down Expand Up @@ -157,16 +158,12 @@ def insert(self, sig, ident=None, lineage=None):

if minhash.ksize != self.ksize:
raise ValueError(
"cannot insert signature with ksize {} into DB (ksize {})".format(
minhash.ksize, self.ksize
)
f"cannot insert signature with ksize {minhash.ksize} into DB (ksize {self.ksize})"
)

if minhash.moltype != self.moltype:
raise ValueError(
"cannot insert signature with moltype {} into DB (moltype {})".format(
minhash.moltype, self.moltype
)
f"cannot insert signature with moltype {minhash.moltype} into DB (moltype {self.moltype})"
)

# downsample to specified scaled; this has the side effect of
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/lca/lca_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utility functions for lowest-common-ancestor analysis tools.
"""

from os.path import exists
from collections import namedtuple, defaultdict, Counter

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/manifest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Manifests for collections of signatures.
"""

import csv
import ast
import gzip
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class MinHash - core MinHash class.
class FrozenMinHash - read-only MinHash class.
"""

from .distance_utils import (
jaccard_to_distance,
containment_to_distance,
Expand Down
4 changes: 2 additions & 2 deletions src/sourmash/nodegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ def calc_expected_collisions(graph, force=False, max_false_pos=0.2):
print("** Do not use these results!!", file=sys.stderr)
print("**", file=sys.stderr)
print(
"** (estimated false positive rate of %.3f;" % fp_all,
f"** (estimated false positive rate of {fp_all:.3f};",
file=sys.stderr,
end=" ",
)
print("max recommended %.3f)" % max_false_pos, file=sys.stderr)
print(f"max recommended {max_false_pos:.3f})", file=sys.stderr)
print("**", file=sys.stderr)

if not force:
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/picklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
and operate efficiently on manifests, so when used with e.g. zipfiles,
only the selected sketches are loaded.
"""

import csv
import os
from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
CTB TODO:
* consider replacing ValueError with IndexNotLoaded in the future.
"""

import sys
import os
import gzip
Expand Down
16 changes: 3 additions & 13 deletions src/sourmash/sbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
An implementation of sequence bloom trees, Solomon & Kingsford, 2015.
"""


from collections import namedtuple, Counter
from collections.abc import Mapping

Expand Down Expand Up @@ -103,7 +102,7 @@ def popitem(self):
# we just need to select the maximum key/node id
(key, _) = max(c for c in common if c[1] == count)
except IndexError:
msg = "%s is empty" % self.__class__.__name__
msg = f"{self.__class__.__name__} is empty"
raise KeyError(msg) from None
else:
value = self.pop(key)
Expand Down Expand Up @@ -1404,11 +1403,7 @@ def __init__(self, factory, name=None, path=None, storage=None):
self.metadata = {}

def __str__(self):
return "*Node:{name} [occupied: {nb}, fpr: {fpr:.2}]".format(
name=self.name,
nb=self.data.n_occupied(),
fpr=calc_expected_collisions(self.data, True, 1.1),
)
return f"*Node:{self.name} [occupied: {self.data.n_occupied()}, fpr: {calc_expected_collisions(self.data, True, 1.1):.2}]"

def save(self, path):
buf = self.data.to_bytes(compression=1)
Expand Down Expand Up @@ -1468,12 +1463,7 @@ def __init__(self, metadata, data=None, name=None, storage=None, path=None):
self._path = path

def __str__(self):
return "**Leaf:{name} [occupied: {nb}, fpr: {fpr:.2}] -> {metadata}".format(
name=self.name,
metadata=self.metadata,
nb=self.data.n_occupied(),
fpr=calc_expected_collisions(self.data, True, 1.1),
)
return f"**Leaf:{self.name} [occupied: {self.data.n_occupied()}, fpr: {calc_expected_collisions(self.data, True, 1.1):.2}] -> {self.metadata}"

def make_manifest_row(self, location):
return None
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Code for searching collections of signatures.
"""

import csv
import numpy as np
from enum import Enum
Expand Down
5 changes: 2 additions & 3 deletions src/sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Command-line entry point for 'python -m sourmash.sig'
"""

__all__ = [
"cat",
"split",
Expand Down Expand Up @@ -81,9 +82,7 @@
def _check_abundance_compatibility(sig1, sig2):
if sig1.minhash.track_abundance != sig2.minhash.track_abundance:
raise ValueError(
"incompatible signatures: track_abundance is {} in first sig, {} in second".format(
sig1.minhash.track_abundance, sig2.minhash.track_abundance
)
f"incompatible signatures: track_abundance is {sig1.minhash.track_abundance} in first sig, {sig2.minhash.track_abundance} in second"
)


Expand Down
1 change: 1 addition & 0 deletions src/sourmash/sig/grep.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Command-line entry point for 'python -m sourmash.sig grep'
"""

import sys
import re

Expand Down
3 changes: 2 additions & 1 deletion src/sourmash/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Save and load MinHash sketches in a JSON format, along with some metadata.
"""

import sys
import os
import weakref
Expand Down Expand Up @@ -367,7 +368,7 @@ def _detect_input_type(data):
except TypeError:
if data.find(b"sourmash_signature") > 0:
return SigInput.BUFFER
elif data.startswith(b"\x1F\x8B"): # gzip compressed
elif data.startswith(b"\x1f\x8b"): # gzip compressed
return SigInput.BUFFER

try:
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/sketchcomparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Sketch Comparison Classes
"""

import numpy as np
from dataclasses import dataclass

Expand Down
1 change: 1 addition & 0 deletions src/sourmash/sourmash_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
misc support:
* FileInputCSV - context manager for reading CSVs
"""

import sys
import os
import csv
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/sqlite_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common utility functions for handling sqlite3 databases.
"""

import os
import sqlite3
from .logging import debug_literal
Expand Down
1 change: 1 addition & 0 deletions src/sourmash/tax/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Command-line entry point for 'python -m sourmash.tax'
"""

import sys
import csv
import os
Expand Down
25 changes: 13 additions & 12 deletions src/sourmash/tax/tax_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utility functions for taxonomy analysis tools.
"""

import os
import csv
from collections import abc, defaultdict
Expand Down Expand Up @@ -1001,9 +1002,9 @@ def aggregate_by_lineage_at_rank(query_gather_results, rank, *, by_query=False):
for res in queryResult.summarized_lineage_results[rank]:
lineage = res.lineage.display_lineage(null_as_unclassified=True)
if by_query:
lineage_summary[lineage][
query_name
] = res.fraction # v5?: res.f_weighted_at_rank
lineage_summary[lineage][query_name] = (
res.fraction
) # v5?: res.f_weighted_at_rank
else:
lineage_summary[lineage] += res.fraction

Expand Down Expand Up @@ -2346,15 +2347,15 @@ def summarize_up_ranks(self, single_rank=None, force_resummarize=False):
rank in lininfo.filled_ranks
): # only store if this rank is filled.
lin_at_rank = lininfo.pop_to_rank(rank)
self.sum_uniq_weighted[rank][
lin_at_rank
] += taxres.f_unique_weighted
self.sum_uniq_to_query[rank][
lin_at_rank
] += taxres.f_unique_to_query
self.sum_uniq_bp[rank][
lin_at_rank
] += taxres.unique_intersect_bp
self.sum_uniq_weighted[rank][lin_at_rank] += (
taxres.f_unique_weighted
)
self.sum_uniq_to_query[rank][lin_at_rank] += (
taxres.f_unique_to_query
)
self.sum_uniq_bp[rank][lin_at_rank] += (
taxres.unique_intersect_bp
)
# reset ranks levels to the ones that were actually summarized + that we can access for summarized result
self.summarized_ranks = [
x for x in self.summarized_ranks if x in self.sum_uniq_bp.keys()
Expand Down
2 changes: 1 addition & 1 deletion src/sourmash/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RustObject:
_shared = False

def __init__(self):
raise TypeError("Cannot instanciate %r objects" % self.__class__.__name__)
raise TypeError(f"Cannot instanciate {self.__class__.__name__!r} objects")

@classmethod
def _from_objptr(cls, ptr, shared=False):
Expand Down
1 change: 1 addition & 0 deletions tests/sourmash_tst_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"Various utilities used by sourmash tests."

import sys
import os
import tempfile
Expand Down
Loading

0 comments on commit 5bde7dc

Please sign in to comment.