- {labels.enzymes}
-
- {labels.selected}:{' '}
- {chosen.length
- ? chosen.map((e) => (
-
+
+
+ {c.chosen.length
+ ? c.chosen.map((e) => (
+
+ ))
+ : {labels.none}}
+
+
+
+
+
+
+ {labels.custom}
+
+
setCustomName(event.target.value)}
+ />
+
setCustomSite(event.target.value)}
+ />
+
- ))
- : labels.none}
-
-
-
-
-
-
-
- {labels.custom}
-
- setCustomName(event.target.value)}
+
+ {labels.customHint}
+ {customError && {customError}
}
+ {c.custom.length > 0 && (
+
+ {c.custom.map((enzyme) => (
+ -
+
+ {enzyme.name} {formatSite(enzyme)}
+
+
+
+ ))}
+
+ )}
+
+
+
+
+
+ {c.warnings.length > 0 && (
+
+
+ {c.warnings.map((warning) => (
+ - {warning}
+ ))}
+
+
+ )}
+
+
+ {labels.data(rebaseVersion)} {labels.privacy}
+
+
+
+
+
+
+ {c.resultSeq && (
+ ({
+ name: e.name,
+ rseq: e.site,
+ fcut: e.cut,
+ rcut: e.cutComplement,
+ color: colors.enzyme
+ }))}
+ primers={[]}
+ viewer='circular'
+ showComplement={false}
+ disableExternalFonts
+ selection={c.range ? { start: c.range.start, end: c.range.end, clockwise: true } : undefined}
+ onSelection={(selection) => {
+ const { start, end } = selection
+ if (start === undefined || end === undefined || start === end) return
+ c.select(selection.clockwise === false ? { start: end, end: start } : { start, end }, 'map')
+ }}
+ style={{ height: '100%', width: '100%' }}
+ />
+ )}
+
+
+ {c.resultSeq && (
+ c.select(next, 'fasta')}
+ label='FASTA'
+ />
+ )}
+
- {labels.customHint}
- {customError && {customError}
}
- {custom.length > 0 && (
-
- {custom.map((enzyme) => (
- -
-
- {enzyme.name} {formatSite(enzyme)}
-
+
+
+ {legend.map((item) => (
+ -
))}
- )}
-
-
-
-
-
-
-
- {labels.result}: {product ? labels.product : labels.vector}
-
- {!product && resultSeq && {labels.warnings.showingVector}
}
-
-
- {resultSeq && (
- {
- const { start, end } = selection
- if (start === undefined || end === undefined || start === end) return
- select(
- selection.clockwise === false ? { start: end, end: start } : { start, end },
- 'map'
- )
- }}
- style={{ height: '100%', width: '100%' }}
- />
- )}
-
-
-
-
-
-
- {resultSeq && (
-
select(next, 'fasta')}
- label='FASTA'
- />
- )}
- {range ? (
+ {c.range ? (
<>
- {labels.selection(range.start + 1, range.end || resultSeq.length, selectionLength)}
-
-
- {resultSeq && (
-
- {legend.map((item) => (
- -
- select(item.range, 'legend')}
- >
-
- {item.label}
-
-
- ))}
-
- )}
-
-
- {labels.data(rebaseVersion)} {labels.privacy}
-
+
+
)
}
-
-function FragmentList(props: {
- title: string
- name: string
- fragments: Fragment[]
- selected: number
- onSelect: (index: number) => void
- labels: Labels
-}) {
- const { title, name, fragments, selected, onSelect, labels } = props
- return (
-
- )
-}
diff --git a/src/ui/labels.ts b/src/ui/labels.ts
index 38ef7ac..ec59bdb 100644
--- a/src/ui/labels.ts
+++ b/src/ui/labels.ts
@@ -44,6 +44,15 @@ export interface Labels {
map: string
bp: string
noMatches: string
+ empty: string
+ edit: string
+ done: string
+ dropHint: string
+ vectorOnly: string
+ warningsCount: (n: number) => string
+ sequences: string
+ searchShortcut: string
+ construction: string
legend: string
selection: (from: number, to: number, length: number) => string
selectionHint: string
@@ -67,18 +76,18 @@ export const labelsEs: Labels = {
vector: 'Vector',
insert: 'Inserto',
pasteHint: 'Pega FASTA o secuencia; o carga GenBank, SnapGene o FASTA',
- upload: 'Cargar archivo',
- loadExample: 'Cargar ejemplo',
+ upload: 'Abrir archivo',
+ loadExample: 'Ejemplo: pUC19 + StSP6A',
clear: 'Limpiar',
circular: 'Circular',
linear: 'Lineal',
enzymes: 'Enzimas',
- search: 'Buscar enzima o sitio (p. ej. EcoRI, GAATTC)',
+ search: 'Enzima o sitio: EcoRI, GAATTC…',
supplier: 'Proveedor',
anySupplier: 'Cualquiera',
show: 'Mostrar',
- showCutsBoth: 'Cortan vector e inserto',
- showCutsVector: 'Cortan el vector',
+ showCutsBoth: 'Cortan ambos',
+ showCutsVector: 'Cortan vector',
showAll: 'Todas',
cutsVector: 'cortes en vector',
cutsInsert: 'cortes en inserto',
@@ -103,12 +112,21 @@ export const labelsEs: Labels = {
reverse: 'Inversa',
result: 'Resultado',
product: 'Plásmido resultante',
- copy: 'Copiar FASTA',
+ copy: 'Copiar',
copied: 'Copiado',
download: 'Descargar .fasta',
map: 'Mapa',
bp: 'pb',
noMatches: 'Sin coincidencias',
+ empty: 'Sin secuencia',
+ edit: 'Editar',
+ done: 'Listo',
+ dropHint: 'o suelta un archivo aquí',
+ vectorOnly: 'solo vector',
+ warningsCount: (n) => (n === 1 ? '1 aviso' : `${n} avisos`),
+ sequences: 'Secuencias',
+ searchShortcut: 'buscar',
+ construction: 'Construcción',
legend: 'Regiones y sitios',
selection: (from, to, length) => `Selección ${from}–${to} · ${length} pb`,
selectionHint:
@@ -135,18 +153,18 @@ export const labelsEn: Labels = {
vector: 'Vector',
insert: 'Insert',
pasteHint: 'Paste FASTA or a raw sequence; or load GenBank, SnapGene or FASTA',
- upload: 'Load file',
- loadExample: 'Load example',
+ upload: 'Open file',
+ loadExample: 'Example: pUC19 + StSP6A',
clear: 'Clear',
circular: 'Circular',
linear: 'Linear',
enzymes: 'Enzymes',
- search: 'Search enzyme or site (e.g. EcoRI, GAATTC)',
+ search: 'Enzyme or site: EcoRI, GAATTC…',
supplier: 'Supplier',
anySupplier: 'Any',
show: 'Show',
- showCutsBoth: 'Cut vector and insert',
- showCutsVector: 'Cut the vector',
+ showCutsBoth: 'Cut both',
+ showCutsVector: 'Cut vector',
showAll: 'All',
cutsVector: 'cuts in vector',
cutsInsert: 'cuts in insert',
@@ -171,12 +189,21 @@ export const labelsEn: Labels = {
reverse: 'Reverse',
result: 'Result',
product: 'Resulting plasmid',
- copy: 'Copy FASTA',
+ copy: 'Copy',
copied: 'Copied',
download: 'Download .fasta',
map: 'Map',
bp: 'bp',
noMatches: 'No matches',
+ empty: 'No sequence',
+ edit: 'Edit',
+ done: 'Done',
+ dropHint: 'or drop a file here',
+ vectorOnly: 'vector only',
+ warningsCount: (n) => (n === 1 ? '1 warning' : `${n} warnings`),
+ sequences: 'Sequences',
+ searchShortcut: 'search',
+ construction: 'Construction',
legend: 'Regions and sites',
selection: (from, to, length) => `Selection ${from}–${to} · ${length} bp`,
selectionHint: 'Select bases in the FASTA, or click the map or the legend, to see where each region lies.',
diff --git a/src/ui/styles.css b/src/ui/styles.css
index f9b11cb..1feb0cc 100644
--- a/src/ui/styles.css
+++ b/src/ui/styles.css
@@ -1,39 +1,57 @@
-/* Vector editor. Theme through these custom properties; defaults are neutral light. */
+/*
+ * Vector editor. Theme through the --ve-theme-* custom properties; the defaults
+ * are a neutral light theme. The map and the FASTA are the centre of the layout;
+ * construction controls live in a compact side panel.
+ */
.ve {
--ve-bg: var(--ve-theme-bg, #ffffff);
--ve-surface: var(--ve-theme-surface, #f6f7f6);
+ --ve-raised: var(--ve-theme-raised, #eef0ee);
--ve-ink: var(--ve-theme-ink, #1d2421);
--ve-muted: var(--ve-theme-muted, #5f6b65);
--ve-line: var(--ve-theme-line, #d6ddd8);
--ve-accent: var(--ve-theme-accent, #215f59);
+ --ve-accent-ink: var(--ve-theme-accent-ink, #ffffff);
--ve-warn: var(--ve-theme-warn, #8a6d00);
--ve-error: var(--ve-theme-error, #b3261e);
--ve-mono: var(--ve-theme-mono, ui-monospace, 'SFMono-Regular', monospace);
- /* Circular map palette; set these for a dark map. */
--ve-map-bg: var(--ve-theme-map-bg, #ffffff);
--ve-map-ink: var(--ve-theme-map-ink, #2a2a2a);
--ve-map-muted: var(--ve-theme-map-muted, #73777d);
--ve-map-cut: var(--ve-theme-map-cut, #73777d);
--ve-map-selection: var(--ve-theme-map-selection, rgb(222 246 255 / 0.9));
+ --ve-stage-height: 40rem;
display: grid;
/* minmax(0, …) lets wide content (FASTA lines) scroll inside instead of widening the page. */
grid-template-columns: minmax(0, 1fr);
- gap: 1rem;
+ grid-template-rows: auto minmax(0, 1fr);
color: var(--ve-ink);
+ background: var(--ve-surface);
+ border: 1px solid var(--ve-line);
+ border-radius: 12px;
+ overflow: hidden;
+ font-size: 0.9rem;
}
-.ve > *,
-.ve-result-grid > *,
-.ve-inputs > * {
- min-width: 0;
+.ve:focus {
+ outline: none;
}
.ve *,
.ve *::before,
.ve *::after {
box-sizing: border-box;
}
+.ve--app {
+ height: 100%;
+ border: 0;
+ border-radius: 0;
+}
.ve h3 {
- margin: 0 0 0.75rem;
- font-size: 1.1rem;
+ margin: 0;
+ font-size: 0.72rem;
+ font-weight: 700;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--ve-muted);
}
.ve-muted {
color: var(--ve-muted);
@@ -46,63 +64,73 @@
overflow: hidden;
clip-path: inset(50%);
}
-.ve-panel {
- padding: 1rem 1.1rem;
+.ve kbd {
+ padding: 0 0.3rem;
border: 1px solid var(--ve-line);
- border-radius: 10px;
- background: var(--ve-surface);
+ border-bottom-width: 2px;
+ border-radius: 4px;
+ font-family: var(--ve-mono);
+ font-size: 0.7rem;
+ color: var(--ve-muted);
}
-.ve-inputs {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
- gap: 1rem;
+.ve :focus-visible {
+ outline: 2px solid var(--ve-accent);
+ outline-offset: 2px;
}
-.ve-input-head {
+
+/* Toolbar: what you built, and what you can do with it. */
+.ve-toolbar {
display: flex;
- justify-content: space-between;
- gap: 1rem;
- margin-bottom: 0.4rem;
- font-weight: 650;
-}
-.ve textarea,
-.ve input[type='search'],
-.ve input:not([type]),
-.ve select {
- width: 100%;
- padding: 0.55rem 0.7rem;
- border: 1px solid var(--ve-line);
- border-radius: 6px;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 0.6rem 1.25rem;
+ padding: 0.6rem 1rem;
+ border-bottom: 1px solid var(--ve-line);
background: var(--ve-bg);
- color: var(--ve-ink);
- font: inherit;
}
-.ve textarea {
- min-height: 9rem;
- resize: vertical;
+.ve-product {
+ display: flex;
+ flex: 1;
+ flex-wrap: wrap;
+ align-items: baseline;
+ gap: 0.2rem 0.8rem;
+ min-width: 0;
+}
+.ve-product strong {
+ overflow: hidden;
+ max-width: 32ch;
font-family: var(--ve-mono);
- font-size: 0.78rem;
- line-height: 1.45;
- word-break: break-all;
+ font-size: 0.95rem;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.ve-warn-badge {
+ padding: 0.1rem 0.55rem;
+ border: 1px solid var(--ve-warn);
+ border-radius: 999px;
+ color: var(--ve-warn);
+ font-size: 0.75rem;
+ text-decoration: none;
}
-.ve-input-actions {
+.ve-actions {
display: flex;
flex-wrap: wrap;
- gap: 0.5rem;
- margin-top: 0.5rem;
+ gap: 0.4rem;
}
.ve-button {
display: inline-flex;
align-items: center;
- gap: 0.4rem;
- min-height: 2.75rem;
- padding: 0 0.9rem;
+ gap: 0.45rem;
+ min-height: 2.5rem;
+ padding: 0 0.85rem;
border: 1px solid var(--ve-line);
- border-radius: 6px;
- background: var(--ve-bg);
+ border-radius: 7px;
+ background: var(--ve-surface);
color: var(--ve-ink);
font: inherit;
- font-size: 0.85rem;
+ font-size: 0.82rem;
cursor: pointer;
+ transition: border-color 0.15s ease-out;
}
.ve-button:hover {
border-color: var(--ve-accent);
@@ -111,88 +139,153 @@
opacity: 0.5;
cursor: not-allowed;
}
-.ve-button input[type='file'] {
- position: absolute;
- width: 1px;
- height: 1px;
- opacity: 0;
-}
-.ve-button:focus-within {
- outline: 2px solid var(--ve-accent);
- outline-offset: 2px;
+.ve-primary {
+ border-color: var(--ve-accent);
+ background: var(--ve-accent);
+ color: var(--ve-accent-ink);
}
-.ve-example {
- justify-self: start;
+.ve-primary kbd {
+ border-color: currentColor;
+ color: inherit;
+ opacity: 0.75;
}
-.ve-selected {
- display: flex;
- flex-wrap: wrap;
+.ve-link {
+ display: inline-flex;
align-items: center;
- gap: 0.4rem;
- margin: 0 0 0.75rem;
-}
-.ve-chip {
- min-height: 2.25rem;
- padding: 0 0.7rem;
- border: 1px solid var(--ve-accent);
- border-radius: 999px;
- background: transparent;
+ gap: 0.3rem;
+ min-height: 2rem;
+ padding: 0;
+ border: 0;
+ background: none;
color: var(--ve-accent);
font: inherit;
- font-family: var(--ve-mono);
- font-size: 0.8rem;
+ font-size: 0.82rem;
+ text-decoration: underline;
+ text-underline-offset: 0.2em;
cursor: pointer;
}
-.ve-filters {
+
+/* Body: compact construction panel + large stage. */
+.ve-body {
+ display: grid;
+ grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
+ min-height: 0;
+}
+.ve-sidebar {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ max-height: calc(var(--ve-stage-height) + 3.5rem);
+ overflow: auto;
+ border-right: 1px solid var(--ve-line);
+ background: var(--ve-surface);
+}
+.ve--app .ve-sidebar {
+ max-height: none;
+}
+.ve-section {
display: grid;
- grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
gap: 0.6rem;
- align-items: end;
+ padding: 0.9rem 1rem;
+ border-bottom: 1px solid var(--ve-line);
}
-.ve-filters label {
+.ve-section-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.5rem;
+}
+
+/* Sequence cards. */
+.ve-card {
display: grid;
- gap: 0.25rem;
- font-size: 0.78rem;
+ gap: 0.35rem;
+ padding: 0.6rem 0.7rem;
+ border: 1px solid var(--ve-line);
+ border-radius: 8px;
+ background: var(--ve-bg);
+ transition: border-color 0.15s ease-out;
+}
+.ve-card[data-dragging='true'] {
+ border-style: dashed;
+ border-color: var(--ve-accent);
+}
+.ve-card-head {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr);
+ align-items: baseline;
+ gap: 0 0.6rem;
+}
+.ve-card-label {
+ font-size: 0.7rem;
+ font-weight: 700;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
color: var(--ve-muted);
}
-.ve-fragment-list label {
+.ve-card-name {
+ overflow: hidden;
+ font-family: var(--ve-mono);
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.ve-card-head .ve-muted {
+ grid-column: 2;
+}
+.ve-card textarea {
+ width: 100%;
+ min-height: 7rem;
+ padding: 0.5rem 0.6rem;
+ border: 1px solid var(--ve-line);
+ border-radius: 6px;
+ background: var(--ve-surface);
+ color: var(--ve-ink);
+ font-family: var(--ve-mono);
+ font-size: 0.72rem;
+ line-height: 1.45;
+ resize: vertical;
+ word-break: break-all;
+}
+.ve-card-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
- gap: 0.5rem;
- min-height: 2.75rem;
- padding: 0.3rem 0.6rem;
- border: 1px solid transparent;
- border-radius: 6px;
- cursor: pointer;
+ gap: 0 0.9rem;
}
-.ve-fragment-list label:hover {
- border-color: var(--ve-line);
+.ve-file {
+ position: relative;
}
-.ve-fragment-list label.is-on {
- border-color: var(--ve-accent);
+.ve-file input {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ opacity: 0;
}
-.ve-fragment-list input,
-.ve-orientation input {
- accent-color: var(--ve-accent);
+.ve-file:focus-within {
+ outline: 2px solid var(--ve-accent);
+ outline-offset: 2px;
+}
+.ve-drop-hint {
+ font-size: 0.75rem;
}
+
/* Enzyme search: a single input with a dropdown, instead of a long list. */
.ve-combobox {
position: relative;
}
-.ve-combobox input {
+.ve-combobox input,
+.ve-filters select,
+.ve-custom-form input {
width: 100%;
- min-height: 2.75rem;
- padding: 0.55rem 0.7rem;
+ min-height: 2.5rem;
+ padding: 0.45rem 0.65rem;
border: 1px solid var(--ve-line);
- border-radius: 6px;
+ border-radius: 7px;
background: var(--ve-bg);
color: var(--ve-ink);
font: inherit;
-}
-.ve-combobox input:focus {
- outline: 2px solid var(--ve-accent);
- outline-offset: 1px;
+ font-size: 0.85rem;
}
.ve-listbox {
position: absolute;
@@ -200,7 +293,7 @@
top: calc(100% + 4px);
left: 0;
right: 0;
- max-height: 18rem;
+ max-height: 20rem;
margin: 0;
padding: 0.3rem;
overflow: auto;
@@ -208,20 +301,19 @@
border: 1px solid var(--ve-line);
border-radius: 8px;
background: var(--ve-bg);
- box-shadow: 0 12px 30px -12px rgb(0 0 0 / 0.5);
+ box-shadow: 0 14px 34px -14px rgb(0 0 0 / 0.55);
}
.ve-listbox li {
display: flex;
align-items: center;
- gap: 0.6rem;
- min-height: 2.5rem;
- padding: 0.2rem 0.6rem;
+ gap: 0.55rem;
+ min-height: 2.35rem;
+ padding: 0.15rem 0.55rem;
border-radius: 5px;
cursor: pointer;
}
.ve-listbox li.is-active {
- background: var(--ve-surface);
- outline: 1px solid var(--ve-line);
+ background: var(--ve-raised);
}
.ve-listbox li[aria-selected='true'] strong {
color: var(--ve-accent);
@@ -229,10 +321,12 @@
.ve-listbox code {
color: var(--ve-muted);
font-family: var(--ve-mono);
- font-size: 0.78rem;
+ font-size: 0.75rem;
}
.ve-listbox .ve-muted {
margin-left: auto;
+ font-family: var(--ve-mono);
+ white-space: nowrap;
}
.ve-check {
width: 1ch;
@@ -248,28 +342,66 @@
font-size: 0.7rem;
color: var(--ve-muted);
}
-.ve-custom {
- margin-top: 0.75rem;
+.ve-chips {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.35rem;
+}
+.ve-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ min-height: 2rem;
+ padding: 0 0.6rem;
+ border: 1px solid var(--ve-accent);
+ border-radius: 999px;
+ background: transparent;
+ color: var(--ve-ink);
+ font: inherit;
+ font-size: 0.8rem;
+ font-weight: 600;
+ cursor: pointer;
+}
+.ve-chip code {
+ font-family: var(--ve-mono);
+ font-size: 0.72rem;
+ font-weight: 400;
+ color: var(--ve-muted);
+}
+.ve-filters {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
+ gap: 0.5rem;
+}
+.ve-filters label {
+ display: grid;
+ gap: 0.2rem;
+ font-size: 0.72rem;
+ color: var(--ve-muted);
}
.ve-custom summary {
- min-height: 2.75rem;
display: flex;
align-items: center;
+ min-height: 2rem;
+ font-size: 0.82rem;
cursor: pointer;
- font-weight: 650;
}
.ve-custom-form {
display: grid;
- grid-template-columns: 1fr 1.4fr auto;
- gap: 0.5rem;
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
+ gap: 0.4rem;
+ margin-top: 0.4rem;
}
.ve-custom-form input:nth-child(2) {
font-family: var(--ve-mono);
}
+.ve-custom p {
+ margin: 0.4rem 0 0;
+}
.ve-custom-list {
display: grid;
- gap: 0.3rem;
- margin: 0.5rem 0 0;
+ gap: 0.2rem;
+ margin: 0.4rem 0 0;
padding: 0;
list-style: none;
}
@@ -282,59 +414,119 @@
.ve-error {
color: var(--ve-error);
}
-.ve-fragments {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
- gap: 1rem;
-}
+
+/* Fragments. */
.ve fieldset {
+ min-width: 0;
margin: 0;
padding: 0;
border: 0;
- min-width: 0;
}
.ve legend {
- margin-bottom: 0.4rem;
+ margin-bottom: 0.2rem;
+ font-size: 0.78rem;
font-weight: 650;
}
+.ve-fragment-list label {
+ display: grid;
+ grid-template-columns: auto 5ch minmax(0, 1fr);
+ align-items: center;
+ gap: 0.5rem;
+ min-height: 2.25rem;
+ padding: 0.15rem 0.45rem;
+ border: 1px solid transparent;
+ border-radius: 6px;
+ cursor: pointer;
+}
+.ve-fragment-list label:hover {
+ border-color: var(--ve-line);
+}
+.ve-fragment-list label.is-on {
+ border-color: var(--ve-accent);
+ background: var(--ve-bg);
+}
+.ve-fragment-list strong {
+ font-family: var(--ve-mono);
+ font-size: 0.8rem;
+ text-align: right;
+}
+.ve-fragment-list .ve-muted {
+ overflow: hidden;
+ font-size: 0.75rem;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.ve-fragment-list input,
+.ve-orientation input {
+ accent-color: var(--ve-accent);
+}
.ve-orientation {
display: flex;
flex-wrap: wrap;
gap: 1rem;
- margin-top: 0.75rem !important;
}
.ve-orientation label {
display: inline-flex;
align-items: center;
gap: 0.4rem;
- min-height: 2.75rem;
+ min-height: 2.25rem;
}
.ve-warnings {
display: grid;
- gap: 0.3rem;
- margin: 0.75rem 0 0;
+ gap: 0.35rem;
+ margin: 0;
padding: 0;
list-style: none;
}
.ve-warnings li {
- padding: 0.4rem 0.7rem;
+ padding: 0.35rem 0.6rem;
border-left: 3px solid var(--ve-warn);
- color: var(--ve-ink);
- font-size: 0.88rem;
+ background: var(--ve-bg);
+ font-size: 0.82rem;
}
-.ve-result-grid {
+.ve-footnote {
+ margin: 0;
+ padding: 0.9rem 1rem;
+ font-size: 0.72rem;
+}
+
+/* Stage: the map and its FASTA, side by side, as large as the layout allows. */
+.ve-workspace {
display: grid;
- grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
- gap: 1rem;
+ grid-template-rows: minmax(0, 1fr) auto;
+ min-width: 0;
+ min-height: 0;
+ background: var(--ve-bg);
+}
+.ve-stage {
+ display: grid;
+ grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
+ height: var(--ve-stage-height);
+ min-height: 0;
+}
+.ve--app .ve-stage {
+ height: auto;
}
.ve-map {
- min-height: 26rem;
- height: 26rem;
- border: 1px solid var(--ve-line);
- border-radius: 8px;
+ position: relative;
+ min-height: 0;
+ border-right: 1px solid var(--ve-line);
background: var(--ve-map-bg);
overflow: hidden;
}
+.ve-fasta {
+ display: flex;
+ min-width: 0;
+ min-height: 0;
+}
+.ve-statusbar {
+ display: grid;
+ gap: 0.4rem;
+ padding: 0.6rem 1rem;
+ border-top: 1px solid var(--ve-line);
+ background: var(--ve-surface);
+}
+
/* SeqViz paints with inline styles, so the map theme needs !important. */
.ve-map .la-vz-viewer-circular text,
.ve-map .la-vz-viewer-circular tspan {
@@ -364,38 +556,31 @@
.ve-map text:has(> .la-vz-annotation-label) {
fill: #0b0f0d !important;
}
-.ve-fasta {
- display: flex;
- flex-direction: column;
-}
-.ve-fasta .ve-input-actions {
- margin: 0 0 0.5rem;
-}
+
/* Coloured FASTA linked to the map. */
.ve-fasta-view {
+ position: relative;
flex: 1;
- min-height: 20rem;
- max-height: 26rem;
+ min-width: 0;
+ min-height: 0;
overflow: auto;
- padding: 0.6rem 0.7rem;
- border: 1px solid var(--ve-line);
- border-radius: 6px;
+ padding: 0.75rem 0.9rem;
background: var(--ve-bg);
font-family: var(--ve-mono);
- font-size: 0.72rem;
- line-height: 1.6;
- position: relative;
+ font-size: 0.74rem;
+ line-height: 1.65;
}
.ve-fasta-view:focus-visible {
- outline: 2px solid var(--ve-accent);
+ outline-offset: -2px;
}
.ve-fasta-header {
+ margin-bottom: 0.3rem;
color: var(--ve-muted);
white-space: pre;
}
.ve-line {
display: flex;
- gap: 0.8rem;
+ gap: 0.9rem;
white-space: pre;
}
.ve-pos {
@@ -403,9 +588,7 @@
color: var(--ve-muted);
text-align: right;
user-select: none;
-}
-.ve-bases {
- letter-spacing: 0.02em;
+ opacity: 0.7;
}
.ve-bases .is-vector {
color: var(--ve-vector);
@@ -425,55 +608,37 @@
.ve-bases ::selection {
background: color-mix(in srgb, var(--ve-accent) 35%, transparent);
}
-.ve-selection {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 0.3rem 1rem;
- min-height: 2.75rem;
- margin: 0.4rem 0 0;
- color: var(--ve-muted);
- font-size: 0.82rem;
-}
-.ve-link {
- min-height: 2.25rem;
- padding: 0;
- border: 0;
- background: none;
- color: var(--ve-accent);
- font: inherit;
- text-decoration: underline;
- cursor: pointer;
-}
+
+/* Legend and selection. */
.ve-legend {
display: flex;
flex-wrap: wrap;
- gap: 0.4rem;
- margin: 0.9rem 0 0;
+ gap: 0.35rem;
+ margin: 0;
padding: 0;
list-style: none;
}
.ve-legend button {
display: inline-flex;
align-items: center;
- gap: 0.45rem;
- min-height: 2.25rem;
- padding: 0 0.7rem;
+ gap: 0.4rem;
+ min-height: 2rem;
+ padding: 0 0.65rem;
border: 1px solid var(--ve-line);
border-radius: 999px;
background: var(--ve-bg);
color: var(--ve-ink);
font: inherit;
font-family: var(--ve-mono);
- font-size: 0.75rem;
+ font-size: 0.74rem;
cursor: pointer;
}
.ve-legend button[aria-pressed='true'] {
border-color: var(--ve-accent);
}
.ve-swatch {
- width: 0.7rem;
- height: 0.7rem;
+ width: 0.65rem;
+ height: 0.65rem;
border-radius: 50%;
}
[data-kind='vector'] .ve-swatch {
@@ -485,17 +650,44 @@
[data-kind='site'] .ve-swatch {
background: var(--ve-site);
}
-.ve-footnote {
+.ve-selection {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 0.2rem 1rem;
+ min-height: 2rem;
margin: 0;
+ font-family: var(--ve-mono);
+ font-size: 0.78rem;
}
-@media (max-width: 760px) {
- .ve-filters,
- .ve-custom-form,
- .ve-result-grid {
+
+@media (max-width: 1100px) {
+ .ve-stage {
grid-template-columns: minmax(0, 1fr);
+ grid-template-rows: 26rem minmax(20rem, 1fr);
+ height: auto;
}
.ve-map {
- height: 22rem;
- min-height: 22rem;
+ border-right: 0;
+ border-bottom: 1px solid var(--ve-line);
+ }
+}
+@media (max-width: 760px) {
+ .ve-body {
+ grid-template-columns: minmax(0, 1fr);
+ }
+ .ve-sidebar {
+ max-height: none;
+ border-right: 0;
+ border-bottom: 1px solid var(--ve-line);
+ }
+ .ve-stage {
+ grid-template-rows: 22rem 24rem;
+ }
+ .ve-actions {
+ width: 100%;
+ }
+ .ve-custom-form {
+ grid-template-columns: minmax(0, 1fr);
}
}
diff --git a/src/ui/useCloning.ts b/src/ui/useCloning.ts
new file mode 100644
index 0000000..5ce1d55
--- /dev/null
+++ b/src/ui/useCloning.ts
@@ -0,0 +1,276 @@
+import { useEffect, useMemo, useState } from 'react'
+import {
+ canSelfLigate,
+ commercialEnzymes,
+ digest,
+ findAllCuts,
+ findCuts,
+ findSites,
+ fragmentLength,
+ ligate,
+ parseSequence,
+ toFasta,
+ toGenBank,
+ type Enzyme,
+ type Feature,
+ type Fragment,
+ type Site
+} from '../core'
+import { exampleEnzymes, exampleInsert, exampleVector } from '../data/examples'
+import type { RangeSource, Region, SeqRange } from './FastaView'
+import type { Labels } from './labels'
+
+export type Filter = 'both' | 'vector' | 'all'
+
+const DISCARD_WARNING_BP = 30
+
+export const fastaOf = (name: string, seq: string) => toFasta(name, seq)
+
+const loadCustom = (key: string | null): Enzyme[] => {
+ if (!key) return []
+ try {
+ const stored = JSON.parse(localStorage.getItem(key) ?? '[]') as Enzyme[]
+ return Array.isArray(stored) ? stored : []
+ } catch {
+ return []
+ }
+}
+
+const largestIndex = (fragments: Fragment[], accept: (f: Fragment) => boolean = () => true) => {
+ let best = -1
+ fragments.forEach((f, i) => {
+ if (!accept(f)) return
+ if (best < 0 || fragmentLength(f) > fragmentLength(fragments[best]!)) best = i
+ })
+ return best
+}
+
+/** All cloning state and derived results; the layout only renders what this returns. */
+export function useCloning(labels: Labels, storageKey: string | null) {
+ const [vectorText, setVectorText] = useState(() => fastaOf(exampleVector.name, exampleVector.seq))
+ const [insertText, setInsertText] = useState(() => fastaOf(exampleInsert.name, exampleInsert.seq))
+ const [selected, setSelected] = useState(exampleEnzymes)
+ const [custom, setCustom] = useState([])
+ const [supplier, setSupplier] = useState('')
+ const [filter, setFilter] = useState('both')
+ const [vectorChoice, setVectorChoice] = useState(null)
+ const [insertChoice, setInsertChoice] = useState(null)
+ const [orientation, setOrientation] = useState(0)
+ const [range, setRange] = useState(null)
+ const [rangeSource, setRangeSource] = useState(null)
+
+ useEffect(() => setCustom(loadCustom(storageKey)), [storageKey])
+ const saveCustom = (next: Enzyme[]) => {
+ setCustom(next)
+ if (!storageKey) return
+ try {
+ localStorage.setItem(storageKey, JSON.stringify(next))
+ } catch {
+ /* Storage is optional. */
+ }
+ }
+
+ const vector = useMemo(() => parseSequence(vectorText, 'vector'), [vectorText])
+ const insert = useMemo(() => parseSequence(insertText, 'insert'), [insertText])
+ const allEnzymes = useMemo(() => [...custom, ...commercialEnzymes], [custom])
+ const byName = useMemo(() => new Map(allEnzymes.map((e) => [e.name, e])), [allEnzymes])
+ const chosen = useMemo(
+ () => selected.map((name) => byName.get(name)).filter((e): e is Enzyme => Boolean(e)),
+ [selected, byName]
+ )
+
+ const counts = useMemo(() => {
+ const map = new Map()
+ for (const enzyme of allEnzymes) {
+ map.set(enzyme.name, {
+ vector: findCuts(vector.seq, enzyme, true).length,
+ insert: findCuts(insert.seq, enzyme, false).length
+ })
+ }
+ return map
+ }, [allEnzymes, vector.seq, insert.seq])
+
+ const options = useMemo(
+ () =>
+ allEnzymes.filter((enzyme) => {
+ const count = counts.get(enzyme.name)
+ if (filter === 'vector' && !count?.vector) return false
+ if (filter === 'both' && !(count?.vector && count.insert)) return false
+ return !supplier || enzyme.custom || enzyme.suppliers.includes(supplier)
+ }),
+ [allEnzymes, counts, filter, supplier]
+ )
+
+ const vectorFragments = useMemo(
+ () => (chosen.length ? digest(vector.seq, findAllCuts(vector.seq, chosen, true), true) : []),
+ [vector.seq, chosen]
+ )
+ const insertFragments = useMemo(
+ () => (chosen.length ? digest(insert.seq, findAllCuts(insert.seq, chosen, false), false) : []),
+ [insert.seq, chosen]
+ )
+ const autoVector = useMemo(() => largestIndex(vectorFragments), [vectorFragments])
+ const autoInsert = useMemo(
+ () => largestIndex(insertFragments, (f) => Boolean(f.left && f.right)),
+ [insertFragments]
+ )
+ useEffect(() => {
+ setVectorChoice(null)
+ setInsertChoice(null)
+ setOrientation(0)
+ }, [vector.seq, insert.seq, selected])
+
+ const vectorIndex = vectorChoice ?? autoVector
+ const insertIndex = insertChoice ?? autoInsert
+ const backbone = vectorFragments[vectorIndex]
+ const piece = insertFragments[insertIndex]
+ const products = useMemo(() => (backbone && piece ? ligate(backbone, piece) : []), [backbone, piece])
+ const product = products[Math.min(orientation, products.length - 1)]
+
+ const warnings: string[] = []
+ const invalid = [...new Set([...vector.invalid, ...insert.invalid])]
+ if (invalid.length) warnings.push(labels.warnings.invalid(invalid.join(' ')))
+ if (chosen.length && vector.seq && !vectorFragments.length) warnings.push(labels.warnings.noVectorCuts)
+ for (const enzyme of chosen) {
+ const n = counts.get(enzyme.name)?.vector ?? 0
+ if (n > 1) warnings.push(labels.warnings.vectorMultiCut(enzyme.name, n))
+ }
+ if (chosen.length && insert.seq && autoInsert < 0) warnings.push(labels.warnings.noInsertFragment)
+ // Flanking sites only trim a few bases; losing more means the enzymes cut inside the insert.
+ const discarded = piece ? insert.seq.length - fragmentLength(piece) : 0
+ if (discarded > DISCARD_WARNING_BP) warnings.push(labels.warnings.insertCutsInside(discarded))
+ if (backbone && piece && !products.length) warnings.push(labels.warnings.incompatible)
+ if (backbone && canSelfLigate(backbone)) warnings.push(labels.warnings.selfLigation)
+
+ const resultName = product ? `${vector.name}-${insert.name}` : vector.name
+ const resultSeq = product?.seq ?? vector.seq
+ const resultFasta = resultSeq ? toFasta(resultName, resultSeq, `circular ${resultSeq.length} ${labels.bp}`) : ''
+
+ const regions: Region[] = useMemo(
+ () =>
+ product
+ ? [
+ { kind: 'vector', start: 0, end: product.vectorLength },
+ { kind: 'insert', start: product.vectorLength, end: product.seq.length }
+ ]
+ : [{ kind: 'vector', start: 0, end: resultSeq.length }],
+ [product, resultSeq.length]
+ )
+ const sites: Site[] = useMemo(
+ () => chosen.flatMap((enzyme) => findSites(resultSeq, enzyme, true)),
+ [chosen, resultSeq]
+ )
+ useEffect(() => setRange(null), [resultSeq])
+
+ const select = (next: SeqRange | null, source: RangeSource) => {
+ setRange((current) =>
+ current && next && current.start === next.start && current.end === next.end ? current : next
+ )
+ setRangeSource(source)
+ }
+
+ const selectionLength = range
+ ? range.start <= range.end
+ ? range.end - range.start
+ : resultSeq.length - range.start + range.end
+ : 0
+ const selectedSeq = range
+ ? range.start <= range.end
+ ? resultSeq.slice(range.start, range.end)
+ : resultSeq.slice(range.start) + resultSeq.slice(0, range.end)
+ : ''
+
+ const genbank = () => {
+ const features: Feature[] = [
+ ...(product
+ ? [
+ {
+ type: 'misc_feature',
+ start: 0,
+ end: product.vectorLength,
+ strand: 1 as const,
+ label: vector.name,
+ note: 'vector backbone'
+ },
+ {
+ type: 'misc_feature',
+ start: product.vectorLength,
+ end: product.seq.length,
+ strand: product.orientation === 'forward' ? (1 as const) : (-1 as const),
+ label: insert.name,
+ note: `insert, ${product.orientation} orientation`
+ }
+ ]
+ : []),
+ ...sites.map((site) => ({
+ type: 'misc_feature',
+ start: site.start,
+ end: (site.start + site.length) % resultSeq.length,
+ strand: site.strand,
+ label: site.enzyme,
+ note: 'restriction site'
+ }))
+ ]
+ return toGenBank(resultName, resultSeq, features, {
+ definition: product
+ ? `${insert.name} cloned into ${vector.name} (${chosen.map((e) => e.name).join(', ')}).`
+ : `${vector.name}.`
+ })
+ }
+
+ const loadExample = () => {
+ setVectorText(fastaOf(exampleVector.name, exampleVector.seq))
+ setInsertText(fastaOf(exampleInsert.name, exampleInsert.seq))
+ setSelected(exampleEnzymes)
+ }
+
+ const toggle = (name: string) =>
+ setSelected((current) =>
+ current.includes(name) ? current.filter((n) => n !== name) : [...current, name]
+ )
+
+ return {
+ vectorText,
+ setVectorText,
+ insertText,
+ setInsertText,
+ vector,
+ insert,
+ selected,
+ setSelected,
+ toggle,
+ custom,
+ saveCustom,
+ byName,
+ chosen,
+ counts,
+ options,
+ supplier,
+ setSupplier,
+ filter,
+ setFilter,
+ vectorFragments,
+ insertFragments,
+ vectorIndex,
+ insertIndex,
+ setVectorChoice,
+ setInsertChoice,
+ products,
+ product,
+ orientation,
+ setOrientation,
+ warnings,
+ resultName,
+ resultSeq,
+ resultFasta,
+ regions,
+ sites,
+ range,
+ rangeSource,
+ select,
+ selectionLength,
+ selectedSeq,
+ genbank,
+ loadExample
+ }
+}
diff --git a/test/core.test.ts b/test/core.test.ts
index 81ec9cf..0dac031 100644
--- a/test/core.test.ts
+++ b/test/core.test.ts
@@ -16,6 +16,7 @@ import {
rightEnd,
topStrand,
toFasta,
+ toGenBank,
type Enzyme,
type Fragment
} from '../src/core'
@@ -164,3 +165,27 @@ describe('FASTA', () => {
expect(fasta.split('\n')).toEqual(['>p circular', 'A'.repeat(70), 'A'.repeat(70), 'A'.repeat(10), ''])
})
})
+
+describe('GenBank', () => {
+ const gb = toGenBank(
+ 'my plasmid',
+ 'ACGT'.repeat(20),
+ [
+ { type: 'misc_feature', start: 0, end: 70, strand: 1, label: 'backbone', note: 'vector' },
+ { type: 'misc_feature', start: 70, end: 10, strand: -1, label: 'insert' }
+ ],
+ { date: new Date(Date.UTC(2026, 9, 3)) }
+ )
+ const lines = gb.split('\n')
+ it('writes a LOCUS line with length, topology and date', () => {
+ expect(lines[0]).toBe('LOCUS my_plasmid 80 bp DNA circular SYN 03-OCT-2026')
+ })
+ it('writes features, including complement and origin-spanning joins', () => {
+ expect(gb).toContain(' misc_feature 1..70\n /label="backbone"\n /note="vector"')
+ expect(gb).toContain(' misc_feature complement(join(71..80,1..10))')
+ })
+ it('writes ORIGIN in numbered blocks of ten and ends with //', () => {
+ expect(gb).toContain(' 1 acgtacgtac gtacgtacgt acgtacgtac gtacgtacgt acgtacgtac gtacgtacgt\n 61 acgtacgtac gtacgtacgt')
+ expect(lines.at(-2)).toBe('//')
+ })
+})
diff --git a/tsconfig.json b/tsconfig.json
index ad49dcb..496d151 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -10,8 +10,16 @@
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
+ "lib": [
+ "ES2022",
+ "DOM",
+ "DOM.Iterable"
+ ],
"types": []
},
- "include": ["src", "test"]
+ "include": [
+ "src",
+ "test",
+ "app"
+ ]
}
diff --git a/vite.config.ts b/vite.config.ts
new file mode 100644
index 0000000..919efa3
--- /dev/null
+++ b/vite.config.ts
@@ -0,0 +1,10 @@
+import react from '@vitejs/plugin-react'
+import { defineConfig } from 'vite'
+
+// Standalone app served at vector-editor.oquinterol.com (GitHub Pages, custom domain).
+export default defineConfig({
+ root: 'app',
+ base: '/',
+ plugins: [react()],
+ build: { outDir: '../app-dist', emptyOutDir: true }
+})
diff --git a/vitest.config.ts b/vitest.config.ts
new file mode 100644
index 0000000..0d85643
--- /dev/null
+++ b/vitest.config.ts
@@ -0,0 +1,6 @@
+import { defineConfig } from 'vitest/config'
+
+// Separate from vite.config.ts, whose root is the standalone app.
+export default defineConfig({
+ test: { include: ['test/**/*.test.ts'] }
+})