@datagrok/sequence-translator 1.10.8 → 1.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +452 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +2 -2
- package/src/demo/demo-st-ui.ts +1 -2
- package/src/polytool/const.ts +0 -1
- package/src/polytool/pt-enumerate-seq-dialog.ts +9 -96
- package/src/polytool/types.ts +0 -1
- package/test-console-output-1.log +82 -82
- package/test-record-1.mp4 +0 -0
- package/src/polytool/pt-monomer-selection-dialog.ts +0 -237
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
# SequenceTranslator Package - CLAUDE.md
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
**Package:** `@datagrok/sequence-translator` (v1.10.8)
|
|
6
|
+
**Category:** Bioinformatics
|
|
7
|
+
**Author:** Davit Rizhinashvili
|
|
8
|
+
**Description:** Translates oligonucleotide sequences between different representations (Axolabs, BioSpring, GCRS, Mermade, HELM, nucleotides, etc.). Also provides pattern design, structure visualization, and advanced polymer conversion (PolyTool).
|
|
9
|
+
|
|
10
|
+
## Quick Reference
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run build # grok api && grok check --soft && webpack
|
|
14
|
+
npm run build-all # Build all deps (chem-meta → js-api → utils → bio → tutorials → this)
|
|
15
|
+
npm run link-all # npm link chem-meta datagrok-api utils bio tutorials
|
|
16
|
+
npm run test # grok test
|
|
17
|
+
npm run test-local # grok test --host localhost
|
|
18
|
+
npm run lint # eslint ./src/**/*.ts
|
|
19
|
+
npm run lint-fix # eslint --fix
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Dependencies
|
|
23
|
+
|
|
24
|
+
| Dependency | Purpose |
|
|
25
|
+
|------------|---------|
|
|
26
|
+
| `datagrok-api` | Core Datagrok platform API |
|
|
27
|
+
| `@datagrok-libraries/bio` | HELM helper, sequence handler, macromolecule utils, monomer libraries |
|
|
28
|
+
| `@datagrok-libraries/chem-meta` | RDKit JS API, molfile parsing |
|
|
29
|
+
| `@datagrok-libraries/utils` | Error handling, common utilities |
|
|
30
|
+
| `@datagrok-libraries/tutorials` | Tutorial creation helpers |
|
|
31
|
+
| `openchemlib` | Chemical structure rendering |
|
|
32
|
+
| `lodash` | Utility functions |
|
|
33
|
+
| `save-svg-as-png` | SVG-to-PNG export in pattern app |
|
|
34
|
+
| `typeahead-standalone` | Autocomplete for monomer selection |
|
|
35
|
+
| `object-hash` | SHA1 hashing for pattern identity |
|
|
36
|
+
|
|
37
|
+
**Dev-only:** `@datagrok/bio`, `@datagrok/chem`, `@datagrok/helm` (for testing), `@datagrok-libraries/helm-web-editor`, `@datagrok-libraries/js-draw-lite`
|
|
38
|
+
|
|
39
|
+
## Package Property
|
|
40
|
+
|
|
41
|
+
- **MonomersPath** (string): Path to additional monomer libraries. Default: `System:AppData/SequenceTranslator/monomers`. Fallback: `System:AppData/SequenceTranslator/monomers-sample`.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Architecture
|
|
46
|
+
|
|
47
|
+
The package is organized into **four main applications** + a **PolyTool subsystem** + shared infrastructure:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
src/
|
|
51
|
+
├── package.ts # Main entry point, exports all Datagrok functions
|
|
52
|
+
├── package.g.ts # AUTO-GENERATED - do not edit
|
|
53
|
+
├── package-api.ts # AUTO-GENERATED - typed function wrappers
|
|
54
|
+
├── package-test.ts # Test orchestration
|
|
55
|
+
├── consts.ts # Package-level constants (PolyToolTags, PolyToolDataRole)
|
|
56
|
+
├── types.ts # ITranslationHelper interface
|
|
57
|
+
│
|
|
58
|
+
├── apps/
|
|
59
|
+
│ ├── common/ # Shared model, data loading, validation, UI base
|
|
60
|
+
│ │ ├── model/ # Core domain logic
|
|
61
|
+
│ │ └── view/ # Shared UI components
|
|
62
|
+
│ ├── translator/ # Format conversion app
|
|
63
|
+
│ │ ├── model/ # Conversion logic
|
|
64
|
+
│ │ └── view/ # Translator UI
|
|
65
|
+
│ ├── pattern/ # Pattern design app
|
|
66
|
+
│ │ ├── model/ # Pattern state, persistence, translation
|
|
67
|
+
│ │ └── view/ # Pattern editor UI + SVG rendering
|
|
68
|
+
│ └── structure/ # Molecular structure app
|
|
69
|
+
│ ├── model/ # Molfile generation, V3000 manipulation
|
|
70
|
+
│ └── view/ # Structure builder UI
|
|
71
|
+
│
|
|
72
|
+
├── polytool/ # Advanced polymer conversion subsystem
|
|
73
|
+
│ ├── conversion/ # Core algorithms (chain, rules, reactions)
|
|
74
|
+
│ ├── *.ts # Dialogs, enumeration, handlers
|
|
75
|
+
│
|
|
76
|
+
├── plugins/ # External plugin integration (MerMade)
|
|
77
|
+
├── utils/ # Cyclized/dimerized notation providers, error handling
|
|
78
|
+
├── demo/ # Demo entry points
|
|
79
|
+
└── tests/ # Test suite
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Entry Point: package.ts
|
|
85
|
+
|
|
86
|
+
Central `PackageFunctions` class exposes all Datagrok-registered functions. Key instance:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
export const _package: OligoToolkitPackage = new OligoToolkitPackage({debug: true});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Initialization Flow
|
|
93
|
+
|
|
94
|
+
1. `init()` → gets HELM helper from bio library, calls `completeInit()`
|
|
95
|
+
2. `completeInit()` → sets up monomer library wrapper
|
|
96
|
+
3. `initLibData()` → lazy-loads JSON data files (called on app open)
|
|
97
|
+
|
|
98
|
+
### Registered Functions
|
|
99
|
+
|
|
100
|
+
| Function | Type | Description |
|
|
101
|
+
|----------|------|-------------|
|
|
102
|
+
| `oligoToolkitApp()` | app | Combined tabbed app (all 3 sub-apps + plugins) |
|
|
103
|
+
| `oligoTranslatorApp()` | app | Standalone translator |
|
|
104
|
+
| `oligoPatternApp()` | app | Standalone pattern designer |
|
|
105
|
+
| `oligoStructureApp()` | app | Standalone structure viewer |
|
|
106
|
+
| `getTranslationHelper()` | func | Returns `ITranslationHelper` for external consumers |
|
|
107
|
+
| `validateSequence(seq)` | func | Boolean validation |
|
|
108
|
+
| `translateOligonucleotideSequence(seq, src, tgt)` | func | Format-to-format conversion |
|
|
109
|
+
| `getMolfileFromGcrsSequence(seq, invert)` | func | GCRS → V3000 molfile |
|
|
110
|
+
| `linkStrands(strands)` | func | Multi-strand assembly |
|
|
111
|
+
| `polyToolConvert2()` | func | Bulk PolyTool conversion |
|
|
112
|
+
| `polyToolEnumerateHelmTopMenu()` | dialog | HELM enumeration |
|
|
113
|
+
| `polyToolEnumerateChemTopMenu()` | dialog | Chemical enumeration |
|
|
114
|
+
| `enumerateSingleHelmSequence()` | func | Single HELM enumeration API |
|
|
115
|
+
| `enumerateSingleHelmSequenceWithNaturalAAs()` | func | Enumerate with natural amino acids |
|
|
116
|
+
| `getPolyToolCombineDialog()` | dialog | Combine sequences from columns |
|
|
117
|
+
| `applyNotationProviderForCyclized()` | func | Register custom notation |
|
|
118
|
+
| `createMonomerLibraryForPolyTool()` | func | CSV → JSON monomer library |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Module Details
|
|
123
|
+
|
|
124
|
+
### apps/common/model/ — Core Domain Model
|
|
125
|
+
|
|
126
|
+
**`oligo-toolkit-package.ts`** — `OligoToolkitPackage` class (extends `DG.Package`, implements `ITranslationHelper`)
|
|
127
|
+
- Central facade managing initialization, monomer libraries, JSON data
|
|
128
|
+
- Factory for `SequenceValidator`, `FormatConverter`, `FormatDetector`
|
|
129
|
+
- Lazy init with promise caching
|
|
130
|
+
|
|
131
|
+
**`data-loader/json-loader.ts`** — `JsonData` class
|
|
132
|
+
- Loads 4 JSON files in parallel from `MonomersPath`:
|
|
133
|
+
- `monomer-lib.json` — full monomer library with molfiles
|
|
134
|
+
- `formats-to-helm.json` — format code → HELM mappings
|
|
135
|
+
- `codes-to-symbols.json` — format code → monomer symbol mappings
|
|
136
|
+
- `pattern-app-data.json` — color maps for pattern app
|
|
137
|
+
- `linkers.json` — monomers with phosphate groups
|
|
138
|
+
|
|
139
|
+
**`monomer-lib/lib-wrapper.ts`** — `MonomerLibWrapper` class
|
|
140
|
+
- Adapter between `IMonomerLib` (from bio library) and the application
|
|
141
|
+
- Lookups: by symbol, by format, by code
|
|
142
|
+
- Molecular weight aggregation, DataFrame generation for viewer
|
|
143
|
+
|
|
144
|
+
**`parsing-validation/format-detector.ts`** — `FormatDetector` class
|
|
145
|
+
- Infers sequence format from content (checks HELM prefix, then scans for matching codes)
|
|
146
|
+
- Validates candidates using `SequenceValidator`
|
|
147
|
+
|
|
148
|
+
**`parsing-validation/format-handler.ts`** — `FormatHandler` class
|
|
149
|
+
- Bidirectional mapping between source formats and HELM notation
|
|
150
|
+
- Regex generation with negative lookaround for accurate code matching
|
|
151
|
+
- Phosphate linkage extraction
|
|
152
|
+
|
|
153
|
+
**`parsing-validation/sequence-validator.ts`** — `SequenceValidator` class
|
|
154
|
+
- Greedy longest-match-first validation
|
|
155
|
+
- Returns index of first invalid code or -1 for valid
|
|
156
|
+
|
|
157
|
+
**`helpers.ts`** — Utility functions: `sortByReverseLength()`, `download()`, `tryCatch()`
|
|
158
|
+
|
|
159
|
+
**`const.ts`** — `NUCLEOTIDES` array `['A','G','C','U']`, `TECHNOLOGIES`, `DEFAULT_FORMATS` enum
|
|
160
|
+
|
|
161
|
+
### apps/common/view/ — Shared UI
|
|
162
|
+
|
|
163
|
+
**`app-ui-base.ts`** — `AppUIBase` abstract class with loading progress indicators
|
|
164
|
+
|
|
165
|
+
**`combined-app-ui.ts`** — `CombinedAppUI` — Multi-tab view (Translator + Pattern + Structure + external plugins)
|
|
166
|
+
|
|
167
|
+
**`isolated-app-ui.ts`** — `IsolatedAppUIBase` — Container for standalone app UIs
|
|
168
|
+
|
|
169
|
+
**`monomer-lib-viewer.ts`** — `MonomerLibViewer` — Interactive monomer library table with molecule rendering
|
|
170
|
+
|
|
171
|
+
**`components/colored-input/`** — `ColoredTextInput` — Textarea with syntax highlighting overlay
|
|
172
|
+
- `input-painters.ts` — `highlightInvalidSubsequence()` painter (red for invalid portions)
|
|
173
|
+
|
|
174
|
+
**`components/molecule-img.ts`** — `MoleculeImage` — Canvas-based V3000 molfile renderer
|
|
175
|
+
|
|
176
|
+
**`components/draw-molecule.ts`** — Molecule drawing utilities
|
|
177
|
+
|
|
178
|
+
**`components/router.ts`** — URL routing for combined app tabs
|
|
179
|
+
|
|
180
|
+
**`components/app-info-dialog.ts`** — App metadata dialog
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### apps/translator/ — Format Conversion App
|
|
185
|
+
|
|
186
|
+
**Model:**
|
|
187
|
+
- `format-converter.ts` — `FormatConverter` class — Converts between formats using HELM as pivot
|
|
188
|
+
- `convertTo(targetFormat)` → helmToFormat / formatToHelm / format→HELM→format
|
|
189
|
+
- `conversion-utils.ts` — `getTranslatedSequences()` — Translates to ALL supported formats at once
|
|
190
|
+
- `getNucleotidesSequence()` — Extracts nucleotides from HELM
|
|
191
|
+
- `convert()` — Legacy single-conversion wrapper
|
|
192
|
+
- `const.ts` — `GROUP_TYPE` (NUCLEOSIDE/LINKAGE), `PHOSPHATE_SYMBOL` ('p'), `UNKNOWN_SYMBOL` ('<?>')
|
|
193
|
+
|
|
194
|
+
**View:**
|
|
195
|
+
- `ui.ts` — `OligoTranslatorUI` + `TranslatorAppLayout`
|
|
196
|
+
- **Single mode:** Text input → format detection → all-format output table with copy buttons
|
|
197
|
+
- **Bulk mode:** Table/column selection → batch conversion → new column added
|
|
198
|
+
- `EventBus` (local) — RxJS BehaviorSubjects for table/column/format state
|
|
199
|
+
- Debounced input (300ms), real-time validation via `ColoredTextInput`
|
|
200
|
+
- SDF export and SMILES conversion support
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
### apps/pattern/ — Pattern Design App
|
|
205
|
+
|
|
206
|
+
**Model:**
|
|
207
|
+
- `event-bus.ts` — `EventBus` — Central RxJS state manager for entire pattern app
|
|
208
|
+
- BehaviorSubjects: pattern name, nucleotide sequences, PTO flags, terminal modifications, table selection, etc.
|
|
209
|
+
- Computed observables: `patternStateChanged$`, `strandsUpdated$`, `uniqueNucleotidesChanged$()`
|
|
210
|
+
- Change tracking (last-loaded config vs current)
|
|
211
|
+
- `data-manager.ts` — `DataManager` (singleton) — Pattern CRUD via Datagrok user storage
|
|
212
|
+
- SHA1 hashing for pattern identity
|
|
213
|
+
- Current user vs other users pattern management
|
|
214
|
+
- Pattern uniqueness validation
|
|
215
|
+
- `translator.ts` — `bulkTranslate()` — Applies pattern to table columns
|
|
216
|
+
- `applyPatternToRawSequence()` — Single-sequence pattern application
|
|
217
|
+
- `router.ts` — `URLRouter` — URL ↔ EventBus synchronization (shareable pattern links)
|
|
218
|
+
- `subscription-manager.ts` — `SubscriptionManager` — RxJS subscription cleanup
|
|
219
|
+
- `types.ts` — `PatternConfiguration`, `PatternConfigRecord`, error classes
|
|
220
|
+
- `const.ts` — Strands (SENSE/ANTISENSE), termini (5'/3'), `MAX_SEQUENCE_LENGTH = 34`, storage name
|
|
221
|
+
- `utils.ts` — Nucleotide analysis, strand truncation/extension helpers
|
|
222
|
+
|
|
223
|
+
**View:**
|
|
224
|
+
- `ui.ts` — `OligoPatternUI` — Main orchestrator (DI wiring, layout composition)
|
|
225
|
+
- Left section: Load/Edit controls, table selection for bulk conversion
|
|
226
|
+
- Right section: SVG visualization, save/download/share buttons
|
|
227
|
+
- `components/left-section.ts` — Load controls, edit controls, bulk convert controls
|
|
228
|
+
- `components/edit-block-controls.ts` — Strand length, nucleobase choice, name/comment editing
|
|
229
|
+
- `components/load-block-controls.ts` — Author/pattern dropdowns, delete button
|
|
230
|
+
- `components/strand-editor/dialog.ts` — Per-position nucleotide + PTO editing
|
|
231
|
+
- `components/terminal-modification-editor.ts` — 5'/3' terminal modification editing
|
|
232
|
+
- `components/bulk-convert/` — Table + column selection for batch pattern application
|
|
233
|
+
- `components/numeric-label-visibility-controls.ts` — Toggle numeric labels per nucleotide
|
|
234
|
+
- `components/translation-examples-block.ts` — Live input→output examples
|
|
235
|
+
|
|
236
|
+
**SVG Rendering (`view/svg-utils/`):**
|
|
237
|
+
- `svg-renderer.ts` — `NucleotidePatternSVGRenderer` — Orchestrates SVG generation
|
|
238
|
+
- Composes: `TitleBlock` + `StrandsBlock` + `LegendBlock`
|
|
239
|
+
- `strands-block.ts` — Nucleotide circles, PTO stars, terminal mods, strand labels
|
|
240
|
+
- `title-block.ts` — Pattern name + strand lengths
|
|
241
|
+
- `legend-block.ts` — Color-coded legend with PTO indicator
|
|
242
|
+
- `svg-element-factory.ts` — SVG element creation (circles, text, stars, rectangles)
|
|
243
|
+
- `svg-display-manager.ts` — Debounced (100ms) SVG updates + PNG export
|
|
244
|
+
- `text-dimensions-calculator.ts` — Canvas-based text measurement
|
|
245
|
+
- `const.ts` — Radii, fonts, colors, Y-positions, dimension constants
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### apps/structure/ — Molecular Structure App
|
|
250
|
+
|
|
251
|
+
**Model:**
|
|
252
|
+
- `sequence-to-molfile.ts` — `SequenceToMolfileConverter` — Parses sequence → retrieves monomer molfiles → links → V3000 molfile
|
|
253
|
+
- `monomer-code-parser.ts` — `MonomerSequenceParser` — Greedy longest-match parsing, auto-inserts phosphate linkers
|
|
254
|
+
- `mol-transformations.ts` — V3000 molfile manipulation:
|
|
255
|
+
- `linkStrandsV3000()` — Links sense/antisense strands with coordinate transformation
|
|
256
|
+
- `getNucleotidesMol()` — Combines nucleotide molblocks with linkage
|
|
257
|
+
- Rotation, reflection, inversion functions for strand alignment
|
|
258
|
+
- Atom/bond renumbering, stereo configuration handling
|
|
259
|
+
- `oligo-structure.ts` — High-level API:
|
|
260
|
+
- `getMolfileForStrand()` — Single strand molfile
|
|
261
|
+
- `getLinkedMolfile()` — Multi-strand assembly
|
|
262
|
+
- `saveSdf()` — SDF file download with metadata
|
|
263
|
+
|
|
264
|
+
**View:**
|
|
265
|
+
- `ui.ts` — `OligoStructureUI` + `StructureAppLayout`
|
|
266
|
+
- Three strand inputs (sense, antisense, antisense2) with direction choice (5'→3' / 3'→5')
|
|
267
|
+
- Chirality toggle, SDF save, real-time molecule visualization
|
|
268
|
+
- Canvas rendering (650x150) with 300ms debounce
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### polytool/ — Advanced Polymer Conversion Subsystem
|
|
273
|
+
|
|
274
|
+
The PolyTool handles complex polymer sequence operations: notation conversion, rules-based transformations, enumeration, and chemical synthesis.
|
|
275
|
+
|
|
276
|
+
#### Core Conversion (`conversion/`)
|
|
277
|
+
|
|
278
|
+
**`pt-chain.ts`** — `Chain` class — Central data model
|
|
279
|
+
- `fromSeparator(notation)` — Parse separator notation (e.g., "A-B-{C}-D")
|
|
280
|
+
- `fromHelm(helm)` — Parse HELM notation
|
|
281
|
+
- `getNotation()` — Output harmonized notation
|
|
282
|
+
- `getHelm()` — Output HELM string
|
|
283
|
+
- `applyRules(rules)` — Apply link/reaction rules, create position mappings
|
|
284
|
+
|
|
285
|
+
**`pt-conversion.ts`** — `doPolyToolConvert()` — Main conversion engine
|
|
286
|
+
- Parses separator notation → applies rules → outputs HELM
|
|
287
|
+
- Returns `[helms[], isLinear[], positionMaps[]]`
|
|
288
|
+
|
|
289
|
+
**`pt-tools-parse.ts`** — Parsing functions
|
|
290
|
+
- `parseSeparator()` — Handles inline chains with curly-brace fragments
|
|
291
|
+
- `parseHelm()` — Extracts peptide definitions and linkages
|
|
292
|
+
- `fromObjectsToHelm()` — Serializes monomers + linkages → HELM
|
|
293
|
+
- `handleDuplicated()` — Homo/hetero dimer expansion
|
|
294
|
+
- `handleLinkRules()` / `handleReactionRules()` — Rule application
|
|
295
|
+
|
|
296
|
+
**`pt-tools-helmmol.ts`** — `getHelmMol()` / `helmMolToNotation()` — Bidirectional HELM mol ↔ notation
|
|
297
|
+
|
|
298
|
+
**`pt-atomic.ts`** — `helmToMol()` — HELM → molfile with linearization and chirality
|
|
299
|
+
|
|
300
|
+
**`pt-synthetic.ts`** — `getOverriddenLibrary()` — RDKit-based reaction execution for synthetic monomers
|
|
301
|
+
|
|
302
|
+
**`pt-rules.ts`** — `Rules` class, `RuleInputs` class — Rule data model and file I/O
|
|
303
|
+
- `RuleLink` type — Linkage rules (monomer pairs, R-groups)
|
|
304
|
+
- `RuleReaction` type — Synthesis rules (monomer pairs, SMARTS reactions)
|
|
305
|
+
|
|
306
|
+
**`pt-rule-cards.ts`** — `RuleCards` — Visual rule preview with monomer card gallery
|
|
307
|
+
|
|
308
|
+
**`rule-manager.ts`** — `RulesManager` (singleton) — UI-driven rule editing and persistence
|
|
309
|
+
|
|
310
|
+
**`rule-reaction-editor.ts`** — Reaction editing dialog with molecule sketchers
|
|
311
|
+
|
|
312
|
+
**`pt-misc.ts`** — `Linkage` type, `getInnerIdx()` / `getOuterIdx()` — Index translation for multi-chain
|
|
313
|
+
|
|
314
|
+
#### Dialogs
|
|
315
|
+
|
|
316
|
+
**`pt-dialog.ts`** — Main conversion dialog and chem enumeration dialog
|
|
317
|
+
- `getPolyToolConvertDialog()` — Column selector, flags, rule file, history
|
|
318
|
+
- `polyToolConvert()` — Execution: validates → applies rules → generates HELM → converts to molfiles
|
|
319
|
+
|
|
320
|
+
**`pt-enumerate-seq-dialog.ts`** — HELM enumeration dialog
|
|
321
|
+
- `getPolyToolEnumerateDialog()` — HELM editor, placeholder grids, enumeration type selector
|
|
322
|
+
- `polyToolEnumerateSeq()` — Execution with single/parallel/matrix/breadth strategies
|
|
323
|
+
|
|
324
|
+
**`pt-enumeration-helm.ts`** — `doPolyToolEnumerateHelm()` — Core enumeration engine
|
|
325
|
+
- Single, Parallel, Matrix, Breadth strategies
|
|
326
|
+
|
|
327
|
+
**`pt-enumeration-chem.ts`** — `getEnumerationChem()` — Chemical library enumeration via RDKit
|
|
328
|
+
|
|
329
|
+
**`pt-combine-dialog.ts`** — `getPTCombineDialog()` — Cartesian product of sequences from columns
|
|
330
|
+
|
|
331
|
+
**`pt-monomer-selection-dialog.ts`** — Autocomplete monomer picker with tag-based display
|
|
332
|
+
|
|
333
|
+
**`pt-placeholders-input.ts`** — Grid input for point placeholders (position + monomers)
|
|
334
|
+
|
|
335
|
+
**`pt-placeholders-breadth-input.ts`** — Grid input for range placeholders (start/end + monomers)
|
|
336
|
+
|
|
337
|
+
**`pt-unrule.ts` / `pt-unrule-dialog.ts`** — HELM → harmonized notation reversal
|
|
338
|
+
|
|
339
|
+
**`pt-convert-editor.ts`** — `PolyToolConvertFuncEditor` — Function call editor
|
|
340
|
+
|
|
341
|
+
#### Handlers
|
|
342
|
+
|
|
343
|
+
**`monomer-lib-handler.ts`** — `PolyToolMonomerLibHandler` — Validates and converts monomer libraries
|
|
344
|
+
**`csv-to-json-monomer-lib-converter.ts`** — `PolyToolCsvLibHandler` — CSV → JSON conversion
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
### utils/ — Notation Providers & Error Handling
|
|
349
|
+
|
|
350
|
+
**`cyclized.ts`** — `CyclizedNotationProvider` (implements `INotationProvider`)
|
|
351
|
+
- Custom separator-based notation for cyclized peptides
|
|
352
|
+
- Converts to HELM via `Chain.fromSeparator()`
|
|
353
|
+
|
|
354
|
+
**`dimerized.ts`** — `DimerizedNotationProvider` (extends `CyclizedNotationProvider`)
|
|
355
|
+
|
|
356
|
+
**`cell-renderer-cyclized.ts`** — `CyclizedCellRendererBack` — Grid cell rendering for cyclized sequences
|
|
357
|
+
|
|
358
|
+
**`err-info.ts`** — `defaultErrorHandler()` — Centralized error logging
|
|
359
|
+
|
|
360
|
+
### plugins/ — External Plugin Integration
|
|
361
|
+
|
|
362
|
+
**`mermade.ts`** — `getExternalAppViewFactories()` — Loads MerMade synthesis plugin dynamically via `grok.functions.call()`
|
|
363
|
+
|
|
364
|
+
### demo/
|
|
365
|
+
|
|
366
|
+
**`demo-st-ui.ts`** — Demo functions for all three apps (translator, pattern, structure)
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Tests
|
|
371
|
+
|
|
372
|
+
Test entry: `package-test.ts` → `tests/` directory
|
|
373
|
+
|
|
374
|
+
| Test File | Category | What It Tests |
|
|
375
|
+
|-----------|----------|---------------|
|
|
376
|
+
| `formats-to-helm.ts` | Formats to HELM / HELM to Formats | Bidirectional format↔HELM conversion |
|
|
377
|
+
| `formats-support.ts` | Formats support | All expected formats available |
|
|
378
|
+
| `helm-to-nucleotides.ts` | HELM to Nucleotides | HELM → nucleotide string |
|
|
379
|
+
| `files-tests.ts` | files | CSV file-based integration tests |
|
|
380
|
+
| `polytool-chain-from-notation-tests.ts` | PolyTool: Chain | Chain parsing, HELM conversion, rule application |
|
|
381
|
+
| `polytool-chain-parse-notation-tests.ts` | PolyTool: Chain: parseNotation | Index translation, monomer counts |
|
|
382
|
+
| `polytool-convert-tests.ts` | PolyTool: Convert | End-to-end conversion pipeline |
|
|
383
|
+
| `polytool-detectors-custom-notation-test.ts` | PolyTool: detectors | Semantic type detection |
|
|
384
|
+
| `polytool-enumerate-tests.ts` | PolyTool: Enumerate | Single/Parallel/Matrix enumeration |
|
|
385
|
+
| `polytool-enumerate-breadth-tests.ts` | PolyTool: Enumerate | Breadth range enumeration |
|
|
386
|
+
| `polytool-unrule-tests.ts` | PolyTool: Unrule | HELM → harmonized notation |
|
|
387
|
+
| `toAtomicLevel-tests.ts` | toAtomicLevel | Synthetic monomer generation via RDKit |
|
|
388
|
+
| `const.ts` | — | Test data: formatsToHelm, helmToNucleotides |
|
|
389
|
+
| `utils/` | — | Test helpers: detection utils, format conversion |
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Data Files
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
files/
|
|
397
|
+
├── monomers-sample/
|
|
398
|
+
│ ├── monomer-lib.json # Monomer library (molfiles, SMILES, metadata)
|
|
399
|
+
│ ├── codes-to-symbols.json # Format code → monomer symbol mappings
|
|
400
|
+
│ ├── formats-to-helm.json # Format code → HELM notation mappings
|
|
401
|
+
│ ├── linkers.json # Monomers with phosphate groups
|
|
402
|
+
│ ├── pattern-app-data.json # Color maps for pattern app SVG
|
|
403
|
+
│ └── README.md
|
|
404
|
+
├── polytool-rules/
|
|
405
|
+
│ └── rules_example.json # Link/reaction rule definitions
|
|
406
|
+
├── samples/
|
|
407
|
+
│ ├── HELM.csv # HELM format examples
|
|
408
|
+
│ ├── cyclized.csv # Cyclized peptide samples
|
|
409
|
+
│ ├── cyclized_MSA.csv # MSA of cyclized variants
|
|
410
|
+
│ └── bulk-translation-axolabs.csv
|
|
411
|
+
└── tests/
|
|
412
|
+
├── axolabs1.csv # Axolabs format test data
|
|
413
|
+
├── polytool-reaction-lib.json # Reaction library for tests
|
|
414
|
+
└── README.md
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Key Design Patterns
|
|
418
|
+
|
|
419
|
+
1. **HELM as Pivot Format** — All format conversions go through HELM as intermediate representation
|
|
420
|
+
2. **EventBus (RxJS BehaviorSubjects)** — Central state management in pattern app; decouples UI components
|
|
421
|
+
3. **Singleton Managers** — `DataManager`, `RulesManager`, `TextDimensionsCalculator`
|
|
422
|
+
4. **IsolatedAppUIBase** — Each sub-app is a standalone view that can be used in combined or isolated mode
|
|
423
|
+
5. **Lazy Initialization** — Promise caching for monomer library and JSON data loading
|
|
424
|
+
6. **Greedy Longest-Match** — Sequence parsing always tries longest codes first
|
|
425
|
+
7. **SVG Composable Blocks** — `TitleBlock`, `StrandsBlock`, `LegendBlock` extend `SVGBlockBase`
|
|
426
|
+
8. **Dialog Singletons** — Strand/terminal editors prevent multiple instances
|
|
427
|
+
|
|
428
|
+
## Key Data Flow
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
User Input (sequence string)
|
|
432
|
+
→ FormatDetector.getFormat() # Infer source format
|
|
433
|
+
→ SequenceValidator.isValidSequence() # Validate
|
|
434
|
+
→ FormatConverter.convertTo(target) # Convert via HELM pivot
|
|
435
|
+
→ Output (translated sequence)
|
|
436
|
+
|
|
437
|
+
PolyTool:
|
|
438
|
+
Separator notation → parseSeparator() → Chain
|
|
439
|
+
→ Chain.applyRules() → handleLinkRules/handleReactionRules
|
|
440
|
+
→ Chain.getHelm() → HELM string
|
|
441
|
+
→ helmToMol() → V3000 molfile (optional)
|
|
442
|
+
|
|
443
|
+
Pattern:
|
|
444
|
+
Raw sequence + PatternConfig
|
|
445
|
+
→ applyPatternToRawSequence() → modified nucleotides
|
|
446
|
+
→ SVGRenderer.renderPattern() → visual output
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Scripts
|
|
450
|
+
|
|
451
|
+
- `scripts/build-monomer-lib.py` — Python script (RDKit) to build monomer library JSON from source files
|
|
452
|
+
- `link-bio` — Bash script to build and link `@datagrok-libraries/bio` locally
|