github-actions[bot] commited on
Commit
6c0aef4
·
1 Parent(s): 7b5897f

Deploy c0f4b8a

Browse files

Hygiene sweep: dead imports, dead locals, cosmetic f-strings, one stale type-hint

Source: https://github.com/WINTER4000/turingDNA/commit/c0f4b8a74488cfda0cd9a324c2a6ddc8c2ca2660

dee/auth.py CHANGED
@@ -43,7 +43,6 @@ from __future__ import annotations
43
  import hashlib
44
  import hmac
45
  import json
46
- import urllib.parse
47
  import logging
48
  import os
49
  import threading
@@ -51,7 +50,7 @@ import time
51
  from dataclasses import dataclass
52
  from typing import Any, Dict, Optional
53
 
54
- from flask import Flask, Response, g, jsonify, make_response, request
55
 
56
  logger = logging.getLogger("dee.auth")
57
 
 
43
  import hashlib
44
  import hmac
45
  import json
 
46
  import logging
47
  import os
48
  import threading
 
50
  from dataclasses import dataclass
51
  from typing import Any, Dict, Optional
52
 
53
+ from flask import Flask, Response, g, jsonify, request
54
 
55
  logger = logging.getLogger("dee.auth")
56
 
dee/core/agent_tools.py CHANGED
@@ -30,7 +30,7 @@ from __future__ import annotations
30
  import contextvars
31
  import logging
32
  import re
33
- from typing import Any, Callable, Dict, List, Optional
34
 
35
  logger = logging.getLogger("dee.agent_tools")
36
 
@@ -723,7 +723,7 @@ def _tool_design_primers(args: Dict[str, Any]) -> Dict[str, Any]:
723
 
724
  try:
725
  result = _P.design_primers(template, _oi(args.get("target_start")), _oi(args.get("target_end")))
726
- except Exception as exc: # noqa: BLE001 — mirrors the REST route's own catch-all
727
  logger.exception("design_primers tool call failed")
728
  return {"ok": False, "error": "Primer design failed — check the inputs."}
729
  if not result.get("ok"):
@@ -969,7 +969,7 @@ def _tool_design_variant_library(args: Dict[str, Any]) -> Dict[str, Any]:
969
  return {"ok": False, "kind": "busy", "error": (
970
  "The design engine is busy scoring another request right now — try again in a few seconds."
971
  )}
972
- except (ImportError, OSError) as exc:
973
  # The scorer itself couldn't start — torch missing, model weights not
974
  # downloaded, no disk, OOM loading. Nothing to do with the sequence,
975
  # so don't tell the scientist to go check it. Same disease as the
 
30
  import contextvars
31
  import logging
32
  import re
33
+ from typing import Any, Dict, List, Optional
34
 
35
  logger = logging.getLogger("dee.agent_tools")
36
 
 
723
 
724
  try:
725
  result = _P.design_primers(template, _oi(args.get("target_start")), _oi(args.get("target_end")))
726
+ except Exception: # noqa: BLE001 — mirrors the REST route's own catch-all
727
  logger.exception("design_primers tool call failed")
728
  return {"ok": False, "error": "Primer design failed — check the inputs."}
729
  if not result.get("ok"):
 
969
  return {"ok": False, "kind": "busy", "error": (
970
  "The design engine is busy scoring another request right now — try again in a few seconds."
971
  )}
972
+ except (ImportError, OSError):
973
  # The scorer itself couldn't start — torch missing, model weights not
974
  # downloaded, no disk, OOM loading. Nothing to do with the sequence,
975
  # so don't tell the scientist to go check it. Same disease as the
dee/core/benchmark.py CHANGED
@@ -21,7 +21,7 @@ from __future__ import annotations
21
 
22
  import re
23
  from dataclasses import dataclass
24
- from typing import Dict, List, Optional, Sequence
25
 
26
  import numpy as np
27
 
 
21
 
22
  import re
23
  from dataclasses import dataclass
24
+ from typing import List, Optional, Sequence
25
 
26
  import numpy as np
27
 
dee/core/cloning.py CHANGED
@@ -181,7 +181,7 @@ def gibson(fragments: List[Dict[str, Any]], *, circular: bool = True,
181
 
182
  primers = _gibson_primers(order, circular, design_overlap, min_overlap, max_overlap)
183
  # carry fragment spans as features on the assembled product
184
- feats, pos = [], 0
185
  palette = ["#6A89E4", "#5FA98A", "#E4B45F", "#B07ED9", "#C77E7E", "#D98C5F"]
186
  cursor = 0
187
  for i in range(n):
 
181
 
182
  primers = _gibson_primers(order, circular, design_overlap, min_overlap, max_overlap)
183
  # carry fragment spans as features on the assembled product
184
+ feats = []
185
  palette = ["#6A89E4", "#5FA98A", "#E4B45F", "#B07ED9", "#C77E7E", "#D98C5F"]
186
  cursor = 0
187
  for i in range(n):
dee/core/crispr.py CHANGED
@@ -405,7 +405,7 @@ class Guide:
405
  # highlight on the AlphaFold structure.
406
 
407
 
408
- def guide_to_dict(g: "GuideRNA") -> Dict[str, Any]:
409
  """Every field the CRISPR results table reads, in one place.
410
 
411
  POST /api/crispr/design and the agent's design_crispr_guides tool both
@@ -924,15 +924,14 @@ def _predict_indels(
924
  # roughly to 100.
925
  top_n = distribution[:_INDEL_TOP_N]
926
  rest_w = sum(w for (_, w, _) in distribution[_INDEL_TOP_N:])
927
- rest_fs_w = sum(w for (_, w, fs) in distribution[_INDEL_TOP_N:] if fs)
928
  predicted: List[Tuple[str, float]] = [(lbl, w) for (lbl, w, _) in top_n]
929
  if rest_w > 0.001:
930
  predicted.append(("other", rest_w))
931
 
932
  # Frameshift % across the FULL distribution (not just top N), since
933
- # KO probability depends on total non-multiple-of-3 fraction.
 
934
  fs_total = sum(w for (_, w, fs) in distribution if fs) + 0.0
935
- # rest_fs_w already included in fs_total via the `distribution` loop
936
 
937
  # Top-outcome dominance: the SINGLE most-likely repair outcome's
938
  # share of all events. Real biological signal: a guide where the
 
405
  # highlight on the AlphaFold structure.
406
 
407
 
408
+ def guide_to_dict(g: "Guide") -> Dict[str, Any]:
409
  """Every field the CRISPR results table reads, in one place.
410
 
411
  POST /api/crispr/design and the agent's design_crispr_guides tool both
 
924
  # roughly to 100.
925
  top_n = distribution[:_INDEL_TOP_N]
926
  rest_w = sum(w for (_, w, _) in distribution[_INDEL_TOP_N:])
 
927
  predicted: List[Tuple[str, float]] = [(lbl, w) for (lbl, w, _) in top_n]
928
  if rest_w > 0.001:
929
  predicted.append(("other", rest_w))
930
 
931
  # Frameshift % across the FULL distribution (not just top N), since
932
+ # KO probability depends on total non-multiple-of-3 fraction — the
933
+ # tail beyond top_n is included here, unlike `predicted` above.
934
  fs_total = sum(w for (_, w, fs) in distribution if fs) + 0.0
 
935
 
936
  # Top-outcome dominance: the SINGLE most-likely repair outcome's
937
  # share of all events. Real biological signal: a guide where the
dee/core/crispr_cloning.py CHANGED
@@ -40,7 +40,7 @@ References:
40
  from __future__ import annotations
41
 
42
  from dataclasses import dataclass
43
- from typing import Dict, List, Optional
44
 
45
 
46
  @dataclass
 
40
  from __future__ import annotations
41
 
42
  from dataclasses import dataclass
43
+ from typing import Dict, List
44
 
45
 
46
  @dataclass
dee/core/domains.py CHANGED
@@ -222,8 +222,8 @@ def domains(accession: str, positions: Optional[Iterable] = None) -> Dict[str, A
222
  "source": "InterPro (EMBL-EBI)",
223
  "summary": _summarize(acc, entries, architecture, protein_length),
224
  "numbering": (
225
- f"Positions are UniProt's, counted from residue 1 of the full "
226
- f"precursor"
227
  + (f" ({protein_length} aa)" if protein_length else "")
228
  + ", including any signal peptide or propeptide. If the user is "
229
  "working from mature-protein numbering, every boundary here is "
 
222
  "source": "InterPro (EMBL-EBI)",
223
  "summary": _summarize(acc, entries, architecture, protein_length),
224
  "numbering": (
225
+ "Positions are UniProt's, counted from residue 1 of the full "
226
+ "precursor"
227
  + (f" ({protein_length} aa)" if protein_length else "")
228
  + ", including any signal peptide or propeptide. If the user is "
229
  "working from mature-protein numbering, every boundary here is "
dee/core/exon.py CHANGED
@@ -36,7 +36,7 @@ import threading
36
  import time
37
  import urllib.error
38
  import urllib.request
39
- from dataclasses import dataclass, field
40
  from typing import Dict, List, Optional, Tuple
41
 
42
  logger = logging.getLogger("dee.exon")
 
36
  import time
37
  import urllib.error
38
  import urllib.request
39
+ from dataclasses import dataclass
40
  from typing import Dict, List, Optional, Tuple
41
 
42
  logger = logging.getLogger("dee.exon")
dee/core/harvest.py CHANGED
@@ -62,7 +62,7 @@ import re
62
  import time
63
  import urllib.error
64
  import urllib.request
65
- from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple
66
 
67
  from Bio.Data.IUPACData import protein_letters_3to1
68
 
 
62
  import time
63
  import urllib.error
64
  import urllib.request
65
+ from typing import Any, Dict, List, Optional, Sequence, Tuple
66
 
67
  from Bio.Data.IUPACData import protein_letters_3to1
68
 
dee/core/mutagenesis.py CHANGED
@@ -35,7 +35,7 @@ Which one a lab uses is a kit decision, so the caller says.
35
  from __future__ import annotations
36
 
37
  import re
38
- from typing import Any, Dict, List, Optional
39
 
40
  from dee.core.primers import gc_clamp, gc_percent, hairpin_score, revcomp
41
  from dee.core.primers import self_dimer_3p, tm_c
 
35
  from __future__ import annotations
36
 
37
  import re
38
+ from typing import Any, Dict, Optional
39
 
40
  from dee.core.primers import gc_clamp, gc_percent, hairpin_score, revcomp
41
  from dee.core.primers import self_dimer_3p, tm_c
dee/core/orchestrator.py CHANGED
@@ -2560,10 +2560,10 @@ def _model_note(model: str) -> str:
2560
  lines = [
2561
  "SCORING MODEL. Substitution scores on this workbench come from ESM-2, "
2562
  "and the two sizes carry product names:",
2563
- f" • ACHILLES 1.0 — ESM-2 35M. Runs on the workbench's own CPU. "
2564
- f"Seconds per protein, free, always available.",
2565
- f" • PROMETHEUS 1.0 — ESM-2 650M. Runs on a rented GPU, so the first "
2566
- f"call waits for a container to start. Larger, and the same method.",
2567
  f"This run is using {active}. Say so plainly if asked, and name the "
2568
  "underlying checkpoint too — the product name is a label on a public "
2569
  "model, not a proprietary one, and implying otherwise would overstate "
 
2560
  lines = [
2561
  "SCORING MODEL. Substitution scores on this workbench come from ESM-2, "
2562
  "and the two sizes carry product names:",
2563
+ " • ACHILLES 1.0 — ESM-2 35M. Runs on the workbench's own CPU. "
2564
+ "Seconds per protein, free, always available.",
2565
+ " • PROMETHEUS 1.0 — ESM-2 650M. Runs on a rented GPU, so the first "
2566
+ "call waits for a container to start. Larger, and the same method.",
2567
  f"This run is using {active}. Say so plainly if asked, and name the "
2568
  "underlying checkpoint too — the product name is a label on a public "
2569
  "model, not a proprietary one, and implying otherwise would overstate "
dee/core/outcomes.py CHANGED
@@ -25,7 +25,7 @@ numpy only; runs in milliseconds on CPU.
25
  from __future__ import annotations
26
 
27
  import datetime as _dt
28
- from dataclasses import dataclass, field
29
  from typing import Callable, Dict, List, Optional, Sequence, Tuple
30
 
31
  import numpy as np
 
25
  from __future__ import annotations
26
 
27
  import datetime as _dt
28
+ from dataclasses import dataclass
29
  from typing import Callable, Dict, List, Optional, Sequence, Tuple
30
 
31
  import numpy as np
dee/core/remote_scorer.py CHANGED
@@ -19,7 +19,7 @@ instead of quietly working badly.
19
  from __future__ import annotations
20
 
21
  import logging
22
- from typing import Any, Dict, List, Optional
23
 
24
  import pandas as pd
25
 
 
19
  from __future__ import annotations
20
 
21
  import logging
22
+ from typing import Dict, List
23
 
24
  import pandas as pd
25
 
dee/core/resolution_cache.py CHANGED
@@ -45,7 +45,7 @@ import re
45
  import threading
46
  import time
47
  from collections import OrderedDict
48
- from typing import Any, Dict, Optional, Tuple
49
 
50
  # Entries older than this are re-fetched. Sequence records are stable over
51
  # weeks; this is about eventually noticing a re-annotation, not about
 
45
  import threading
46
  import time
47
  from collections import OrderedDict
48
+ from typing import Any, Dict, Optional
49
 
50
  # Entries older than this are re-fetched. Sequence records are stable over
51
  # weeks; this is about eventually noticing a re-annotation, not about
dee/core/voice_vocab.py CHANGED
@@ -37,7 +37,7 @@ Nothing here commits the product to a vendor.
37
  from __future__ import annotations
38
 
39
  import re
40
- from typing import Any, Dict, Iterable, List, Optional
41
 
42
  # Vendor guidance converges on a few hundred; past that, accuracy on ordinary
43
  # speech starts to suffer as boosted terms pull neighbours toward them.
 
37
  from __future__ import annotations
38
 
39
  import re
40
+ from typing import Iterable, List, Optional
41
 
42
  # Vendor guidance converges on a few hundred; past that, accuracy on ordinary
43
  # speech starts to suffer as boosted terms pull neighbours toward them.
dee/optimizer/search.py CHANGED
@@ -25,7 +25,6 @@ import random
25
  from dataclasses import dataclass, field
26
  from typing import Dict, FrozenSet, List, Optional, Tuple
27
 
28
- import numpy as np
29
  import pandas as pd
30
 
31
  logger = logging.getLogger(__name__)
 
25
  from dataclasses import dataclass, field
26
  from typing import Dict, FrozenSet, List, Optional, Tuple
27
 
 
28
  import pandas as pd
29
 
30
  logger = logging.getLogger(__name__)
dee/server.py CHANGED
@@ -28,7 +28,6 @@ import re
28
  import tempfile
29
  import threading
30
  import time
31
- import traceback
32
  import uuid
33
  from collections import deque
34
  from dataclasses import dataclass, field
@@ -54,8 +53,8 @@ from dee.core.sequence import (
54
  list_cds_features,
55
  parse_input,
56
  )
57
- from dee.models.scorer import ESM2Scorer, ScorerConfig, top_percentile_pool
58
- from dee.optimizer.search import SearchConfig, apply_variant, evolve
59
 
60
  logger = logging.getLogger("dee.server")
61
 
@@ -3809,7 +3808,7 @@ def create_app() -> Flask:
3809
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
3810
  )
3811
  resp.headers["Content-Disposition"] = (
3812
- f'attachment; filename="turingdna_crispr_guides.xlsx"'
3813
  )
3814
  return resp
3815
 
@@ -4258,7 +4257,6 @@ def _compute_de_ll_maps(grouped_with_lib):
4258
  library) → only the opt-in rebuild calls it. Any failure for a library
4259
  yields None for that unit (its keys stay unbinned). Returns a list parallel
4260
  to grouped_with_lib."""
4261
- from dee.models.scorer import ESM2Scorer, ScorerConfig
4262
  cache: Dict[str, Any] = {}
4263
  scorer = None
4264
  maps = []
 
28
  import tempfile
29
  import threading
30
  import time
 
31
  import uuid
32
  from collections import deque
33
  from dataclasses import dataclass, field
 
53
  list_cds_features,
54
  parse_input,
55
  )
56
+ from dee.models.scorer import top_percentile_pool
57
+ from dee.optimizer.search import SearchConfig, evolve
58
 
59
  logger = logging.getLogger("dee.server")
60
 
 
3808
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
3809
  )
3810
  resp.headers["Content-Disposition"] = (
3811
+ 'attachment; filename="turingdna_crispr_guides.xlsx"'
3812
  )
3813
  return resp
3814
 
 
4257
  library) → only the opt-in rebuild calls it. Any failure for a library
4258
  yields None for that unit (its keys stay unbinned). Returns a list parallel
4259
  to grouped_with_lib."""
 
4260
  cache: Dict[str, Any] = {}
4261
  scorer = None
4262
  maps = []