Spaces:
Sleeping
Plasmid: accept SnapGene .dna; fix button hover (black fill, both themes)
Browse filesTwo things:
1) Plasmid Editor now imports SnapGene .dna (binary) alongside GenBank/FASTA/
raw. Biopython 1.87 ships a SnapGene reader, so:
- plasmid.py: _record_to_plasmid() shared mapper; parse_snapgene(bytes) +
parse_binary() dispatcher (detects .dna by extension OR the 0x09+"SnapGene"
signature; size-bounded; filename fallback for unnamed records).
- server.py: /api/plasmid/import accepts a base64 `b64` payload (decodes,
bounds, parses) in addition to the existing `text` path.
- app.js: the Upload-file handler reads .dna/.snapgene/.xdna as bytes →
base64 → import; text formats still load into the box. Parsed sequence is
dropped into the editor so it's visible + editable.
- index.html: accept=".dna,…"; label now says "SnapGene .dna".
2) White/cream buttons now invert to a near-black rectangle with white text on
hover — in BOTH themes. The old hover used theme tokens that, in dark mode,
flipped to off-white-on-dark (the filled CTAs visibly did nothing — "flashed
then turned back to white"). New fixed --hover-fill/--hover-text tokens drive
.ghost/.primary/.primary-ghost/.primary-lg/.ghost-btn/.copy-btn/.plasmid-file-btn
hovers; removed the .primary lift to kill any micro-flicker.
Verified: 324 tests pass; .dna parses end-to-end (core, /api/import HTTP, and a
real browser File→change→map render); hover renders #0A0A0A/#FBFAF6 in dark.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- dee/core/plasmid.py +72 -5
- dee/server.py +17 -2
- dee/static/app.css +19 -8
- dee/static/app.js +49 -2
- dee/static/index.html +5 -5
|
@@ -117,12 +117,13 @@ def _label_from_qualifiers(q: Dict[str, Any]) -> str:
|
|
| 117 |
return ""
|
| 118 |
|
| 119 |
|
| 120 |
-
def
|
| 121 |
-
|
| 122 |
-
|
|
|
|
| 123 |
seq = str(rec.seq).upper()
|
| 124 |
topo = (rec.annotations.get("topology") or "").lower()
|
| 125 |
-
topology = "circular" if topo == "circular" else "linear"
|
| 126 |
feats: List[Dict[str, Any]] = []
|
| 127 |
for f in rec.features:
|
| 128 |
if f.type in ("source",):
|
|
@@ -149,10 +150,26 @@ def parse_genbank(text: str) -> Dict[str, Any]:
|
|
| 149 |
"name": (rec.name or rec.id or "plasmid")[:80],
|
| 150 |
"sequence": seq, "length": len(seq),
|
| 151 |
"topology": topology, "gc": gc_percent(seq),
|
| 152 |
-
"features": feats, "source":
|
| 153 |
}
|
| 154 |
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
def parse_fasta(text: str) -> Dict[str, Any]:
|
| 157 |
from Bio import SeqIO
|
| 158 |
rec = SeqIO.read(io.StringIO(text), "fasta")
|
|
@@ -206,6 +223,56 @@ def parse_plasmid(text: str, *, topology: Optional[str] = None) -> Dict[str, Any
|
|
| 206 |
return plasmid
|
| 207 |
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
# ── auto-annotation ──────────────────────────────────────────────────────
|
| 210 |
def find_orfs(seq: str, min_aa: int = 100, max_orfs: int = 500) -> List[Dict[str, Any]]:
|
| 211 |
"""ORFs (ATG→stop) ≥ ``min_aa`` on both strands. A single LINEAR pass per
|
|
|
|
| 117 |
return ""
|
| 118 |
|
| 119 |
|
| 120 |
+
def _record_to_plasmid(rec, source: str, *, default_topology: str = "linear") -> Dict[str, Any]:
|
| 121 |
+
"""Normalise a Biopython ``SeqRecord`` (GenBank / SnapGene / EMBL — anything
|
| 122 |
+
SeqIO hands back with features + a topology annotation) into the plasmid
|
| 123 |
+
model. Shared by every structured-format parser so they stay identical."""
|
| 124 |
seq = str(rec.seq).upper()
|
| 125 |
topo = (rec.annotations.get("topology") or "").lower()
|
| 126 |
+
topology = "circular" if topo == "circular" else ("linear" if topo == "linear" else default_topology)
|
| 127 |
feats: List[Dict[str, Any]] = []
|
| 128 |
for f in rec.features:
|
| 129 |
if f.type in ("source",):
|
|
|
|
| 150 |
"name": (rec.name or rec.id or "plasmid")[:80],
|
| 151 |
"sequence": seq, "length": len(seq),
|
| 152 |
"topology": topology, "gc": gc_percent(seq),
|
| 153 |
+
"features": feats, "source": source,
|
| 154 |
}
|
| 155 |
|
| 156 |
|
| 157 |
+
def parse_genbank(text: str) -> Dict[str, Any]:
|
| 158 |
+
from Bio import SeqIO
|
| 159 |
+
rec = SeqIO.read(io.StringIO(text), "genbank")
|
| 160 |
+
return _record_to_plasmid(rec, "genbank", default_topology="linear")
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def parse_snapgene(data: bytes) -> Dict[str, Any]:
|
| 164 |
+
"""Parse a SnapGene ``.dna`` binary (via Biopython's SnapGene reader). The
|
| 165 |
+
format carries its own sequence, topology, and rich feature track."""
|
| 166 |
+
from Bio import SeqIO
|
| 167 |
+
rec = SeqIO.read(io.BytesIO(data), "snapgene")
|
| 168 |
+
# SnapGene maps are circular far more often than not; honour the file's
|
| 169 |
+
# own topology annotation when present, else assume circular.
|
| 170 |
+
return _record_to_plasmid(rec, "snapgene", default_topology="circular")
|
| 171 |
+
|
| 172 |
+
|
| 173 |
def parse_fasta(text: str) -> Dict[str, Any]:
|
| 174 |
from Bio import SeqIO
|
| 175 |
rec = SeqIO.read(io.StringIO(text), "fasta")
|
|
|
|
| 223 |
return plasmid
|
| 224 |
|
| 225 |
|
| 226 |
+
_SNAPGENE_COOKIE = b"SnapGene"
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def parse_binary(data: bytes, *, filename: Optional[str] = None,
|
| 230 |
+
topology: Optional[str] = None) -> Dict[str, Any]:
|
| 231 |
+
"""Parse a *binary* sequence upload (currently SnapGene ``.dna``) into the
|
| 232 |
+
plasmid model. Detects SnapGene by the ``.dna`` extension or its file
|
| 233 |
+
signature (first byte 0x09 + a "SnapGene" cookie). Raises ``ValueError``
|
| 234 |
+
with a friendly message on unknown / oversize / corrupt input."""
|
| 235 |
+
if not data:
|
| 236 |
+
raise ValueError("The uploaded file is empty.")
|
| 237 |
+
if len(data) > MAX_INPUT_TEXT:
|
| 238 |
+
raise ValueError(f"File is larger than {MAX_INPUT_TEXT:,} bytes — upload "
|
| 239 |
+
"just the plasmid, not a whole dataset.")
|
| 240 |
+
name_l = (filename or "").lower()
|
| 241 |
+
is_snapgene = (
|
| 242 |
+
name_l.endswith(".dna")
|
| 243 |
+
or (len(data) > 14 and data[0] == 0x09 and _SNAPGENE_COOKIE in data[:64])
|
| 244 |
+
)
|
| 245 |
+
if not is_snapgene:
|
| 246 |
+
raise ValueError("Unrecognised file. Upload a SnapGene .dna, or paste / "
|
| 247 |
+
"upload a GenBank, FASTA, or EMBL text file.")
|
| 248 |
+
try:
|
| 249 |
+
plasmid = parse_snapgene(data)
|
| 250 |
+
except ValueError:
|
| 251 |
+
raise
|
| 252 |
+
except Exception as exc: # noqa: BLE001 — Bio raises a grab-bag on bad bytes
|
| 253 |
+
raise ValueError(f"Couldn't read the SnapGene file: {exc}") from exc
|
| 254 |
+
|
| 255 |
+
# SnapGene records are often unnamed ("Exported", or Biopython's
|
| 256 |
+
# "<unknown name>" placeholder) — fall back to the filename stem.
|
| 257 |
+
cur = (plasmid.get("name") or "").strip().lower()
|
| 258 |
+
if filename and (cur in ("", "plasmid", "exported", "untitled", "sequence")
|
| 259 |
+
or cur.startswith("<unknown")):
|
| 260 |
+
import os
|
| 261 |
+
stem = os.path.splitext(os.path.basename(filename))[0][:80]
|
| 262 |
+
if stem:
|
| 263 |
+
plasmid["name"] = stem
|
| 264 |
+
|
| 265 |
+
if plasmid["length"] == 0:
|
| 266 |
+
raise ValueError("The SnapGene file has no sequence.")
|
| 267 |
+
if plasmid["length"] > MAX_LEN:
|
| 268 |
+
raise ValueError(f"Sequence is longer than {MAX_LEN:,} bp — that's a "
|
| 269 |
+
"genome-scale tool's job, not a plasmid editor.")
|
| 270 |
+
# An explicit UI topology choice overrides the file's (parity with text imports).
|
| 271 |
+
if topology in ("circular", "linear"):
|
| 272 |
+
plasmid["topology"] = topology
|
| 273 |
+
return plasmid
|
| 274 |
+
|
| 275 |
+
|
| 276 |
# ── auto-annotation ──────────────────────────────────────────────────────
|
| 277 |
def find_orfs(seq: str, min_aa: int = 100, max_orfs: int = 500) -> List[Dict[str, Any]]:
|
| 278 |
"""ORFs (ATG→stop) ≥ ``min_aa`` on both strands. A single LINEAR pass per
|
|
@@ -1500,10 +1500,25 @@ def create_app() -> Flask:
|
|
| 1500 |
if denied:
|
| 1501 |
return denied
|
| 1502 |
body = request.get_json(force=True, silent=True) or {}
|
| 1503 |
-
text = body.get("text") or ""
|
| 1504 |
topology = body.get("topology") if body.get("topology") in ("circular", "linear") else None
|
|
|
|
| 1505 |
try:
|
| 1506 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1507 |
except ValueError as exc:
|
| 1508 |
return jsonify({"error": str(exc)}), 400
|
| 1509 |
if body.get("annotate", True):
|
|
|
|
| 1500 |
if denied:
|
| 1501 |
return denied
|
| 1502 |
body = request.get_json(force=True, silent=True) or {}
|
|
|
|
| 1503 |
topology = body.get("topology") if body.get("topology") in ("circular", "linear") else None
|
| 1504 |
+
b64 = body.get("b64")
|
| 1505 |
try:
|
| 1506 |
+
if b64:
|
| 1507 |
+
# Binary upload (e.g. SnapGene .dna) base64-encoded in the JSON
|
| 1508 |
+
# body. Bound the decoded size BEFORE handing to the parser.
|
| 1509 |
+
import base64
|
| 1510 |
+
import binascii
|
| 1511 |
+
if not isinstance(b64, str) or len(b64) > 4 * (_PL.MAX_INPUT_TEXT // 3 + 4):
|
| 1512 |
+
return jsonify({"error": "File too large."}), 400
|
| 1513 |
+
try:
|
| 1514 |
+
raw = base64.b64decode(b64, validate=True)
|
| 1515 |
+
except (binascii.Error, ValueError):
|
| 1516 |
+
return jsonify({"error": "Could not decode the uploaded file."}), 400
|
| 1517 |
+
filename = str(body.get("filename") or "")[:200]
|
| 1518 |
+
plasmid = _PL.parse_binary(raw, filename=filename, topology=topology)
|
| 1519 |
+
else:
|
| 1520 |
+
text = body.get("text") or ""
|
| 1521 |
+
plasmid = _PL.parse_plasmid(text, topology=topology)
|
| 1522 |
except ValueError as exc:
|
| 1523 |
return jsonify({"error": str(exc)}), 400
|
| 1524 |
if body.get("annotate", True):
|
|
@@ -92,6 +92,14 @@ html {
|
|
| 92 |
--ink-faint: var(--gray-6);
|
| 93 |
--ink-disabled: var(--gray-5);
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
--line: var(--gray-3);
|
| 96 |
--line-strong: var(--gray-4);
|
| 97 |
--line-bold: var(--gray-5);
|
|
@@ -972,8 +980,9 @@ input:focus, textarea:focus, select:focus {
|
|
| 972 |
box-shadow: var(--elev-1);
|
| 973 |
}
|
| 974 |
.primary:not(:disabled):hover {
|
| 975 |
-
background: var(--
|
| 976 |
-
|
|
|
|
| 977 |
box-shadow: var(--elev-3);
|
| 978 |
}
|
| 979 |
.primary:not(:disabled):active { transform: translateY(0); box-shadow: var(--elev-2); }
|
|
@@ -997,7 +1006,9 @@ input:focus, textarea:focus, select:focus {
|
|
| 997 |
box-shadow: 0 1px 2px rgba(20, 19, 16, 0.20), inset 0 1px 0 rgba(255,255,255,0.10);
|
| 998 |
}
|
| 999 |
.primary-lg:not(:disabled):hover {
|
| 1000 |
-
background: var(--
|
|
|
|
|
|
|
| 1001 |
box-shadow: 0 6px 16px rgba(20, 19, 16, 0.22), inset 0 1px 0 rgba(255,255,255,0.10);
|
| 1002 |
}
|
| 1003 |
.primary-lg:disabled {
|
|
@@ -3905,11 +3916,11 @@ h3, h4 {
|
|
| 3905 |
paper — black rect + white text in light mode, and the dark-mode inverse
|
| 3906 |
(parchment fill, dark text) so it stays high-contrast in either theme. */
|
| 3907 |
.ghost:hover, .primary-ghost:hover, .ghost-btn:hover, .copy-btn:hover {
|
| 3908 |
-
background: var(--
|
| 3909 |
-
border-color: var(--
|
| 3910 |
-
color: var(--
|
| 3911 |
}
|
| 3912 |
-
.ghost:hover svg, .ghost-btn:hover svg, .copy-btn:hover svg { color: var(--
|
| 3913 |
|
| 3914 |
/* ── Fold button on each variant row — a touch more presence than other
|
| 3915 |
ghosts, since it triggers a network call to ESMFold. Archival-blue text
|
|
@@ -5561,7 +5572,7 @@ h3, h4 {
|
|
| 5561 |
font-size: 13px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-3);
|
| 5562 |
background: var(--gray-1); cursor: pointer; white-space: nowrap;
|
| 5563 |
}
|
| 5564 |
-
.plasmid-file-btn:hover { border-color: var(--
|
| 5565 |
.plasmid-topo { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
|
| 5566 |
.plasmid-topo label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
|
| 5567 |
.plasmid-input-row .primary-lg { margin-left: auto; }
|
|
|
|
| 92 |
--ink-faint: var(--gray-6);
|
| 93 |
--ink-disabled: var(--gray-5);
|
| 94 |
|
| 95 |
+
/* Button-hover fill/text. Deliberately FIXED (not redefined in the dark
|
| 96 |
+
block) so an action button always inverts to a near-black rectangle with
|
| 97 |
+
warm-white text on hover, in BOTH themes — instead of the theme tokens,
|
| 98 |
+
which in dark mode flip to off-white-on-dark (looked like "nothing
|
| 99 |
+
happened / flashed back to white"). */
|
| 100 |
+
--hover-fill: #0A0A0A;
|
| 101 |
+
--hover-text: #FBFAF6;
|
| 102 |
+
|
| 103 |
--line: var(--gray-3);
|
| 104 |
--line-strong: var(--gray-4);
|
| 105 |
--line-bold: var(--gray-5);
|
|
|
|
| 980 |
box-shadow: var(--elev-1);
|
| 981 |
}
|
| 982 |
.primary:not(:disabled):hover {
|
| 983 |
+
background: var(--hover-fill);
|
| 984 |
+
border-color: var(--hover-fill);
|
| 985 |
+
color: var(--hover-text);
|
| 986 |
box-shadow: var(--elev-3);
|
| 987 |
}
|
| 988 |
.primary:not(:disabled):active { transform: translateY(0); box-shadow: var(--elev-2); }
|
|
|
|
| 1006 |
box-shadow: 0 1px 2px rgba(20, 19, 16, 0.20), inset 0 1px 0 rgba(255,255,255,0.10);
|
| 1007 |
}
|
| 1008 |
.primary-lg:not(:disabled):hover {
|
| 1009 |
+
background: var(--hover-fill);
|
| 1010 |
+
color: var(--hover-text);
|
| 1011 |
+
border-color: var(--hover-fill);
|
| 1012 |
box-shadow: 0 6px 16px rgba(20, 19, 16, 0.22), inset 0 1px 0 rgba(255,255,255,0.10);
|
| 1013 |
}
|
| 1014 |
.primary-lg:disabled {
|
|
|
|
| 3916 |
paper — black rect + white text in light mode, and the dark-mode inverse
|
| 3917 |
(parchment fill, dark text) so it stays high-contrast in either theme. */
|
| 3918 |
.ghost:hover, .primary-ghost:hover, .ghost-btn:hover, .copy-btn:hover {
|
| 3919 |
+
background: var(--hover-fill);
|
| 3920 |
+
border-color: var(--hover-fill);
|
| 3921 |
+
color: var(--hover-text);
|
| 3922 |
}
|
| 3923 |
+
.ghost:hover svg, .ghost-btn:hover svg, .copy-btn:hover svg { color: var(--hover-text); }
|
| 3924 |
|
| 3925 |
/* ── Fold button on each variant row — a touch more presence than other
|
| 3926 |
ghosts, since it triggers a network call to ESMFold. Archival-blue text
|
|
|
|
| 5572 |
font-size: 13px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-3);
|
| 5573 |
background: var(--gray-1); cursor: pointer; white-space: nowrap;
|
| 5574 |
}
|
| 5575 |
+
.plasmid-file-btn:hover { background: var(--hover-fill); border-color: var(--hover-fill); color: var(--hover-text); }
|
| 5576 |
.plasmid-topo { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--ink-soft); }
|
| 5577 |
.plasmid-topo label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
|
| 5578 |
.plasmid-input-row .primary-lg { margin-left: auto; }
|
|
@@ -6757,6 +6757,30 @@ function runOracle(opts){
|
|
| 6757 |
finally { importBtn.disabled = false; importBtn.textContent = orig; }
|
| 6758 |
}
|
| 6759 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6760 |
async function doDigest() {
|
| 6761 |
if (!plasmid) return;
|
| 6762 |
const enzymes = [...selected];
|
|
@@ -6889,9 +6913,32 @@ function runOracle(opts){
|
|
| 6889 |
importBtn.addEventListener('click', () => doImport(inputEl.value));
|
| 6890 |
if (fileEl) fileEl.addEventListener('change', (e) => {
|
| 6891 |
const f = e.target.files && e.target.files[0]; if (!f) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6892 |
const r = new FileReader();
|
| 6893 |
-
|
| 6894 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6895 |
});
|
| 6896 |
$('plasmidExample').addEventListener('click', () => {
|
| 6897 |
// Demo construct: recognizable motifs (T7/M13/lac → auto-annotated) +
|
|
|
|
| 6757 |
finally { importBtn.disabled = false; importBtn.textContent = orig; }
|
| 6758 |
}
|
| 6759 |
|
| 6760 |
+
// Import a binary sequence file (e.g. SnapGene .dna) — base64 payload, parsed
|
| 6761 |
+
// server-side. On success the parsed sequence is also dropped into the box so
|
| 6762 |
+
// it's visible + editable like every other import.
|
| 6763 |
+
async function doImportBinary(b64, filename) {
|
| 6764 |
+
clearErr();
|
| 6765 |
+
const orig = importBtn.textContent; importBtn.disabled = true; importBtn.textContent = 'Importing…';
|
| 6766 |
+
try {
|
| 6767 |
+
const res = await fetch('/api/plasmid/import', {
|
| 6768 |
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
| 6769 |
+
body: JSON.stringify({ b64, filename, annotate: true }),
|
| 6770 |
+
});
|
| 6771 |
+
const data = await res.json();
|
| 6772 |
+
if (res.status === 403 && signin403(data)) {
|
| 6773 |
+
window.dispatchEvent(new Event('td:signin-required'));
|
| 6774 |
+
showErr('The Plasmid Editor is free with an account — sign in to import.'); return;
|
| 6775 |
+
}
|
| 6776 |
+
if (!res.ok) { showErr(data.error || 'Import failed.'); return; }
|
| 6777 |
+
plasmid = data.plasmid;
|
| 6778 |
+
if (inputEl) inputEl.value = plasmid.sequence || '';
|
| 6779 |
+
showResults();
|
| 6780 |
+
} catch (e) { showErr('Could not reach the importer. Check your connection and retry.'); }
|
| 6781 |
+
finally { importBtn.disabled = false; importBtn.textContent = orig; }
|
| 6782 |
+
}
|
| 6783 |
+
|
| 6784 |
async function doDigest() {
|
| 6785 |
if (!plasmid) return;
|
| 6786 |
const enzymes = [...selected];
|
|
|
|
| 6913 |
importBtn.addEventListener('click', () => doImport(inputEl.value));
|
| 6914 |
if (fileEl) fileEl.addEventListener('change', (e) => {
|
| 6915 |
const f = e.target.files && e.target.files[0]; if (!f) return;
|
| 6916 |
+
const name = (f.name || '').toLowerCase();
|
| 6917 |
+
// SnapGene .dna (and kin) are BINARY — read as bytes, base64, and let the
|
| 6918 |
+
// server parse them. Text formats (GenBank/FASTA/raw) load into the box.
|
| 6919 |
+
const isBinary = /\.(dna|snapgene|xdna)$/.test(name);
|
| 6920 |
const r = new FileReader();
|
| 6921 |
+
if (isBinary) {
|
| 6922 |
+
r.onload = () => {
|
| 6923 |
+
try {
|
| 6924 |
+
const bytes = new Uint8Array(r.result);
|
| 6925 |
+
let bin = '';
|
| 6926 |
+
const CH = 0x8000; // chunk to avoid arg-count limits on big files
|
| 6927 |
+
for (let i = 0; i < bytes.length; i += CH) {
|
| 6928 |
+
bin += String.fromCharCode.apply(null, bytes.subarray(i, i + CH));
|
| 6929 |
+
}
|
| 6930 |
+
doImportBinary(btoa(bin), f.name);
|
| 6931 |
+
} catch (err) { showErr('Could not read that file.'); }
|
| 6932 |
+
};
|
| 6933 |
+
r.onerror = () => showErr('Could not read that file.');
|
| 6934 |
+
r.readAsArrayBuffer(f);
|
| 6935 |
+
} else {
|
| 6936 |
+
r.onload = () => { inputEl.value = String(r.result || ''); doImport(inputEl.value); };
|
| 6937 |
+
r.onerror = () => showErr('Could not read that file.');
|
| 6938 |
+
r.readAsText(f);
|
| 6939 |
+
}
|
| 6940 |
+
// Reset so re-selecting the SAME file fires "change" again.
|
| 6941 |
+
e.target.value = '';
|
| 6942 |
});
|
| 6943 |
$('plasmidExample').addEventListener('click', () => {
|
| 6944 |
// Demo construct: recognizable motifs (T7/M13/lac → auto-annotated) +
|
|
@@ -28,7 +28,7 @@
|
|
| 28 |
<!-- ?v= query bumps invalidate browser + iframe asset caches when app.css /
|
| 29 |
app.js change. Bump these numbers whenever you ship a frontend update —
|
| 30 |
without them, users keep getting the stale file for up to a week. -->
|
| 31 |
-
<link rel="stylesheet" href="/static/app.css?v=20260609-
|
| 32 |
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg?v=2" />
|
| 33 |
<link rel="apple-touch-icon" href="/static/favicon.svg?v=2" />
|
| 34 |
<!-- Mol* (PDBe) 3-D viewer is ~4.9 MB. We do NOT eager-load it on every
|
|
@@ -1164,7 +1164,7 @@
|
|
| 1164 |
|
| 1165 |
<section class="card plasmid-input-card" id="plasmidInputCard">
|
| 1166 |
<div class="plasmid-input-head">
|
| 1167 |
-
<label class="field-label" for="plasmidInput">Sequence · GenBank / FASTA / raw DNA</label>
|
| 1168 |
<div class="plasmid-input-actions">
|
| 1169 |
<button class="ghost" type="button" id="plasmidLibraryBtn">My plasmids</button>
|
| 1170 |
<button class="ghost" type="button" id="plasmidExample" title="Loads a demo construct with real promoters, an AmpR gene and cut sites">Try an example</button>
|
|
@@ -1174,7 +1174,7 @@
|
|
| 1174 |
placeholder="Paste a GenBank record (LOCUS…), a FASTA (>name), or raw DNA…"></textarea>
|
| 1175 |
<div class="plasmid-input-row">
|
| 1176 |
<label class="plasmid-file-btn">
|
| 1177 |
-
Upload file<input type="file" id="plasmidFile" accept=".gb,.gbk,.genbank,.fasta,.fa,.fna,.txt,.seq" hidden />
|
| 1178 |
</label>
|
| 1179 |
<div class="plasmid-topo">
|
| 1180 |
<span class="field-hint">Topology (raw/FASTA):</span>
|
|
@@ -1859,10 +1859,10 @@
|
|
| 1859 |
Authorization header on every same-origin /api/* call. Without
|
| 1860 |
this, signed-in users would still hit the anonymous-quota
|
| 1861 |
gate. -->
|
| 1862 |
-
<script src="/static/auth.js?v=20260609-
|
| 1863 |
<!-- Cloning reference data must load before app.js so the Designer
|
| 1864 |
can read VECTORS / ENZYMES / CLONING_METHODS / TAGS / LINKERS. -->
|
| 1865 |
<script src="/static/cloning_db.js?v=20260530-ui-polish" defer></script>
|
| 1866 |
-
<script src="/static/app.js?v=20260609-
|
| 1867 |
</body>
|
| 1868 |
</html>
|
|
|
|
| 28 |
<!-- ?v= query bumps invalidate browser + iframe asset caches when app.css /
|
| 29 |
app.js change. Bump these numbers whenever you ship a frontend update —
|
| 30 |
without them, users keep getting the stale file for up to a week. -->
|
| 31 |
+
<link rel="stylesheet" href="/static/app.css?v=20260609-dna" />
|
| 32 |
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg?v=2" />
|
| 33 |
<link rel="apple-touch-icon" href="/static/favicon.svg?v=2" />
|
| 34 |
<!-- Mol* (PDBe) 3-D viewer is ~4.9 MB. We do NOT eager-load it on every
|
|
|
|
| 1164 |
|
| 1165 |
<section class="card plasmid-input-card" id="plasmidInputCard">
|
| 1166 |
<div class="plasmid-input-head">
|
| 1167 |
+
<label class="field-label" for="plasmidInput">Sequence · GenBank / FASTA / SnapGene .dna / raw DNA</label>
|
| 1168 |
<div class="plasmid-input-actions">
|
| 1169 |
<button class="ghost" type="button" id="plasmidLibraryBtn">My plasmids</button>
|
| 1170 |
<button class="ghost" type="button" id="plasmidExample" title="Loads a demo construct with real promoters, an AmpR gene and cut sites">Try an example</button>
|
|
|
|
| 1174 |
placeholder="Paste a GenBank record (LOCUS…), a FASTA (>name), or raw DNA…"></textarea>
|
| 1175 |
<div class="plasmid-input-row">
|
| 1176 |
<label class="plasmid-file-btn">
|
| 1177 |
+
Upload file<input type="file" id="plasmidFile" accept=".dna,.gb,.gbk,.genbank,.fasta,.fa,.fna,.txt,.seq" hidden />
|
| 1178 |
</label>
|
| 1179 |
<div class="plasmid-topo">
|
| 1180 |
<span class="field-hint">Topology (raw/FASTA):</span>
|
|
|
|
| 1859 |
Authorization header on every same-origin /api/* call. Without
|
| 1860 |
this, signed-in users would still hit the anonymous-quota
|
| 1861 |
gate. -->
|
| 1862 |
+
<script src="/static/auth.js?v=20260609-dna"></script>
|
| 1863 |
<!-- Cloning reference data must load before app.js so the Designer
|
| 1864 |
can read VECTORS / ENZYMES / CLONING_METHODS / TAGS / LINKERS. -->
|
| 1865 |
<script src="/static/cloning_db.js?v=20260530-ui-polish" defer></script>
|
| 1866 |
+
<script src="/static/app.js?v=20260609-dna" defer></script>
|
| 1867 |
</body>
|
| 1868 |
</html>
|