Skip to content

Commit 278ac31

Browse files
committed
Refactor complexity and QC modules: improve variable naming for clarity and streamline import order
1 parent affa0bc commit 278ac31

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/jsrc/seq/complexity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _linguistic_complexity(seq: str, max_k: int = 6) -> float:
2323
len({seq[i:i+k] for i in range(n - k + 1)})
2424
for k in range(1, min(max_k, n) + 1)
2525
)
26-
alphabet = len({c for c in seq})
26+
alphabet = len(set(seq))
2727
if alphabet <= 1:
2828
return 0.0
2929
possible = sum(
@@ -44,8 +44,8 @@ def _dust_score(seq: str, window: int = 64) -> float:
4444
from collections import Counter
4545
tri = Counter(sub[j:j+3] for j in range(len(sub) - 2))
4646
s = sum(c * (c - 1) // 2 for c in tri.values())
47-
l = len(sub) - 2
48-
scores.append(s / l if l > 0 else 0.0)
47+
sub_len = len(sub) - 2
48+
scores.append(s / sub_len if sub_len > 0 else 0.0)
4949
return round(sum(scores) / len(scores), 4) if scores else 0.0
5050

5151

src/jsrc/seq/kmer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from jsrc.core import progressbar
1010

11-
1211
_VALID_BASES = frozenset("ACGT")
1312

1413

src/jsrc/seq/qc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from Bio import SeqIO
77

8-
from jsrc.core import open_text, nxx, progressbar
8+
from jsrc.core import nxx, open_text, progressbar
99

1010
logger = logging.getLogger(__name__)
1111

0 commit comments

Comments
 (0)