Skip to content

Commit 7dc3da0

Browse files
committed
Add repeat motif functionality and enhance sequence input handling
- Introduced repeat motif management with read and write functions. - Updated SequenceInput to allow motif settings adjustments. - Enhanced SequenceAnnotator to utilize repeat motifs for auto-annotation. - Modified PartSwapper to exclude auto-annotated parts from the library. - Improved type definitions to support new features. - Adjusted Vite configuration for dynamic port assignment.
1 parent bed570f commit 7dc3da0

7 files changed

Lines changed: 451 additions & 35 deletions

File tree

frontend/src/App.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import SequenceAnnotator from './components/SequenceAnnotator';
55
import ResultsView from './components/ResultsView';
66
import PartSwapper from './components/PartSwapper';
77
import type { Region, ScrambleResult, WorkSession } from './types';
8+
import { readRepeatMotif, writeRepeatMotif } from './repeat';
89

910
const FAST_MODE_ENABLED = false
1011

@@ -15,6 +16,13 @@ export default function App() {
1516
const [result, setResult] = useState<ScrambleResult | null>(null);
1617
const [loadedSession, setLoadedSession] = useState<WorkSession | null>(null);
1718
const [fastMode, setFastMode] = useState(false);
19+
const [repeatMotif, setRepeatMotif] = useState<string>(() => readRepeatMotif());
20+
21+
const handleRepeatMotifChange = (motif: string) => {
22+
const m = motif.toUpperCase();
23+
setRepeatMotif(m);
24+
writeRepeatMotif(m);
25+
};
1826

1927
const handleSequenceNext = (seq: string) => {
2028
setSequence(seq);
@@ -79,14 +87,22 @@ export default function App() {
7987
</>}
8088

8189
{active === 0 && (
82-
<SequenceInput sequence={sequence} onNext={handleSequenceNext} onAssemble={handleAssembleNext} onLoadSession={handleLoadSession} />
90+
<SequenceInput
91+
sequence={sequence}
92+
onNext={handleSequenceNext}
93+
onAssemble={handleAssembleNext}
94+
onLoadSession={handleLoadSession}
95+
repeatMotif={repeatMotif}
96+
onRepeatMotifChange={handleRepeatMotifChange}
97+
/>
8398
)}
8499
{active === 1 && (
85100
<SequenceAnnotator
86101
sequence={sequence}
87102
regions={regions}
88103
onBack={() => setActive(0)}
89104
onNext={handleAnnotateNext}
105+
repeatMotif={repeatMotif}
90106
/>
91107
)}
92108
{active === 2 && (

frontend/src/components/PartSwapper.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ export default function PartSwapper({ sequence, regions, result, onResultChange,
241241

242242
useEffect(() => {
243243
if (!baseResult) return;
244+
// Parts annotated via auto-annotate are flagged to stay out of the library.
245+
const excluded = new Set(
246+
regions.filter(r => r.excludeFromLibrary).map(r => r.name)
247+
);
244248
for (const r of baseResult.regions) {
245-
if (r.type === 'part') addToLibrary(r.name, r.aa);
249+
if (r.type === 'part' && !excluded.has(r.name)) addToLibrary(r.name, r.aa);
246250
}
247251
}, []); // eslint-disable-line react-hooks/exhaustive-deps
248252

0 commit comments

Comments
 (0)