@aleph-ai/tinyaleph 1.2.0 → 1.3.0
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/README.md +187 -2
- package/backends/bioinformatics/binding.js +503 -0
- package/backends/bioinformatics/dna-computing.js +664 -0
- package/backends/bioinformatics/encoding.js +339 -0
- package/backends/bioinformatics/folding.js +454 -0
- package/backends/bioinformatics/genetic-code.js +269 -0
- package/backends/bioinformatics/index.js +522 -0
- package/backends/bioinformatics/transcription.js +221 -0
- package/backends/bioinformatics/translation.js +264 -0
- package/backends/index.js +25 -1
- package/core/compound.js +532 -0
- package/core/hilbert.js +454 -1
- package/core/index.js +106 -12
- package/core/inference.js +605 -0
- package/core/resonance.js +245 -616
- package/core/symbols/archetypes.js +478 -0
- package/core/symbols/base.js +302 -0
- package/core/symbols/elements.js +487 -0
- package/core/symbols/hieroglyphs.js +303 -0
- package/core/symbols/iching.js +471 -0
- package/core/symbols/index.js +77 -0
- package/core/symbols/tarot.js +211 -0
- package/core/symbols.js +22 -0
- package/docs/design/BIOINFORMATICS_BACKEND_DESIGN.md +493 -0
- package/docs/guide/06-symbolic-ai.md +370 -0
- package/docs/guide/README.md +2 -1
- package/docs/reference/05-symbolic-ai.md +570 -0
- package/docs/reference/06-bioinformatics.md +546 -0
- package/docs/reference/README.md +32 -2
- package/docs/theory/11-prgraph-memory.md +559 -0
- package/docs/theory/12-resonant-attention.md +661 -0
- package/modular.js +33 -1
- package/package.json +1 -1
- package/physics/index.js +16 -0
- package/physics/kuramoto-coupled-ladder.js +603 -0
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
# Bioinformatics Backend Reference
|
|
2
|
+
|
|
3
|
+
The Bioinformatics Backend provides DNA computing, protein folding simulation, and molecular biology operations through the tinyaleph prime-resonant computing framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The bioinformatics module encodes biological sequences (DNA, RNA, proteins) as prime number signatures, enabling:
|
|
8
|
+
|
|
9
|
+
- **DNA/RNA/Protein encoding** as prime sequences
|
|
10
|
+
- **Central Dogma transforms** (transcription, translation)
|
|
11
|
+
- **Protein folding** via Kuramoto oscillator dynamics
|
|
12
|
+
- **DNA computing** with logic gates and circuits
|
|
13
|
+
- **Molecular binding** affinity calculations
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const {
|
|
19
|
+
BioinformaticsBackend,
|
|
20
|
+
DNACircuit,
|
|
21
|
+
ANDGate, ORGate, NOTGate, NANDGate
|
|
22
|
+
} = require('@aleph-ai/tinyaleph');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## BioinformaticsBackend
|
|
26
|
+
|
|
27
|
+
Main class implementing the Backend interface for biological computation.
|
|
28
|
+
|
|
29
|
+
### Constructor
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const backend = new BioinformaticsBackend(options);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Options:**
|
|
36
|
+
| Option | Type | Default | Description |
|
|
37
|
+
|--------|------|---------|-------------|
|
|
38
|
+
| `couplingStrength` | number | 0.1 | Kuramoto coupling for folding |
|
|
39
|
+
| `foldingSteps` | number | 100 | Oscillator evolution steps |
|
|
40
|
+
| `foldingDt` | number | 0.01 | Integration timestep |
|
|
41
|
+
|
|
42
|
+
### Core Methods
|
|
43
|
+
|
|
44
|
+
#### `encode(input)`
|
|
45
|
+
|
|
46
|
+
Encode a biological sequence to prime numbers.
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
const primes = backend.encode('ATGCGATC');
|
|
50
|
+
// Returns: [7, 2, 11, 3, 11, 7, 2, 3]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Input types:**
|
|
54
|
+
- DNA string (A, T, G, C)
|
|
55
|
+
- RNA string (A, U, G, C)
|
|
56
|
+
- Protein string (single-letter amino acid codes)
|
|
57
|
+
- Array of nucleotides or amino acids
|
|
58
|
+
|
|
59
|
+
**Nucleotide Prime Mapping:**
|
|
60
|
+
| Base | Prime | Meaning |
|
|
61
|
+
|------|-------|---------|
|
|
62
|
+
| A | 7 | Adenine |
|
|
63
|
+
| T | 2 | Thymine |
|
|
64
|
+
| U | 5 | Uracil (RNA) |
|
|
65
|
+
| G | 11 | Guanine |
|
|
66
|
+
| C | 3 | Cytosine |
|
|
67
|
+
|
|
68
|
+
#### `decode(primes)`
|
|
69
|
+
|
|
70
|
+
Decode prime numbers back to a biological sequence.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
const seq = backend.decode([7, 2, 11, 3]);
|
|
74
|
+
// Returns: 'ATGC'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### `primesToState(primes)`
|
|
78
|
+
|
|
79
|
+
Convert primes to a Hypercomplex (sedenion) state.
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const state = backend.primesToState([7, 2, 11, 3]);
|
|
83
|
+
console.log(state.norm()); // State magnitude
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### `primesToFrequencies(primes)`
|
|
87
|
+
|
|
88
|
+
Convert primes to oscillator frequencies.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
const freqs = backend.primesToFrequencies([7, 2, 11]);
|
|
92
|
+
// Returns: [Math.log(7), Math.log(2), Math.log(11)]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### `applyTransform(state, transform)`
|
|
96
|
+
|
|
97
|
+
Apply a named transform to a state.
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const rnaState = backend.applyTransform(dnaState, 'transcription');
|
|
101
|
+
const proteinState = backend.applyTransform(rnaState, 'translation');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Available transforms:** `transcription`, `translation`, `folding`
|
|
105
|
+
|
|
106
|
+
#### `getTransforms()`
|
|
107
|
+
|
|
108
|
+
Get list of available transforms.
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
const transforms = backend.getTransforms();
|
|
112
|
+
// Returns: ['transcription', 'translation', 'folding', 'complementation']
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Biological Operations
|
|
116
|
+
|
|
117
|
+
#### `transcribe(dnaPrimes, options)`
|
|
118
|
+
|
|
119
|
+
Transcribe DNA to RNA (T → U substitution).
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
const result = backend.transcribe(dnaPrimes);
|
|
123
|
+
// Returns: { rna: [...], success: boolean, message: string }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Options:**
|
|
127
|
+
| Option | Type | Default | Description |
|
|
128
|
+
|--------|------|---------|-------------|
|
|
129
|
+
| `force` | boolean | false | Process even without promoter |
|
|
130
|
+
|
|
131
|
+
#### `translate(rnaPrimes, options)`
|
|
132
|
+
|
|
133
|
+
Translate RNA to protein using the genetic code.
|
|
134
|
+
|
|
135
|
+
```javascript
|
|
136
|
+
const result = backend.translate(rnaPrimes);
|
|
137
|
+
// Returns: { protein: [...], sequence: string, success: boolean }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Options:**
|
|
141
|
+
| Option | Type | Default | Description |
|
|
142
|
+
|--------|------|---------|-------------|
|
|
143
|
+
| `includeStop` | boolean | false | Include stop codon in output |
|
|
144
|
+
|
|
145
|
+
#### `express(dnaPrimes, options)`
|
|
146
|
+
|
|
147
|
+
Full gene expression: DNA → RNA → Protein.
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
const result = backend.express(dnaPrimes);
|
|
151
|
+
// Returns: { protein: [...], sequence: string, rna: [...], ... }
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### `foldProtein(proteinPrimes, options)`
|
|
155
|
+
|
|
156
|
+
Simulate protein folding using Kuramoto oscillators.
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
const result = backend.foldProtein(proteinPrimes, {
|
|
160
|
+
steps: 200,
|
|
161
|
+
coupling: 0.2
|
|
162
|
+
});
|
|
163
|
+
// Returns: {
|
|
164
|
+
// phases: [...], // Final oscillator phases
|
|
165
|
+
// orderParameter: 0.85, // Synchronization (0-1)
|
|
166
|
+
// contactMap: [...], // Residue-residue contacts
|
|
167
|
+
// state: Hypercomplex, // Final sedenion state
|
|
168
|
+
// entropy: number // Final entropy
|
|
169
|
+
// }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Options:**
|
|
173
|
+
| Option | Type | Default | Description |
|
|
174
|
+
|--------|------|---------|-------------|
|
|
175
|
+
| `steps` | number | 100 | Evolution steps |
|
|
176
|
+
| `coupling` | number | 0.1 | Coupling strength |
|
|
177
|
+
| `dt` | number | 0.01 | Timestep |
|
|
178
|
+
| `threshold` | number | 0.5 | Contact threshold |
|
|
179
|
+
|
|
180
|
+
#### `bindingAffinity(primes1, primes2)`
|
|
181
|
+
|
|
182
|
+
Calculate molecular binding affinity between two sequences.
|
|
183
|
+
|
|
184
|
+
```javascript
|
|
185
|
+
const result = backend.bindingAffinity(dnaSeq, proteinSeq);
|
|
186
|
+
// Returns: {
|
|
187
|
+
// affinity: 0.75, // Affinity score
|
|
188
|
+
// coherence: 0.82, // Spectral coherence
|
|
189
|
+
// complementarity: 0.6 // Sequence complementarity
|
|
190
|
+
// }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### `dock(ligandPrimes, receptorPrimes, options)`
|
|
194
|
+
|
|
195
|
+
Perform molecular docking simulation.
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
const result = backend.dock(ligand, receptor);
|
|
199
|
+
// Returns: {
|
|
200
|
+
// affinity: number,
|
|
201
|
+
// bindingSite: [...],
|
|
202
|
+
// score: number
|
|
203
|
+
// }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Amino Acid Encoding
|
|
207
|
+
|
|
208
|
+
20 standard amino acids are mapped to primes ordered by hydrophobicity:
|
|
209
|
+
|
|
210
|
+
| Amino Acid | Code | Prime | Property |
|
|
211
|
+
|------------|------|-------|----------|
|
|
212
|
+
| Leucine | L | 23 | Hydrophobic |
|
|
213
|
+
| Isoleucine | I | 29 | Hydrophobic |
|
|
214
|
+
| Valine | V | 31 | Hydrophobic |
|
|
215
|
+
| Phenylalanine | F | 37 | Hydrophobic |
|
|
216
|
+
| Methionine | M | 41 | Hydrophobic |
|
|
217
|
+
| Alanine | A | 43 | Hydrophobic |
|
|
218
|
+
| Glycine | G | 47 | Small |
|
|
219
|
+
| Cysteine | C | 53 | Sulfur |
|
|
220
|
+
| Tyrosine | Y | 59 | Aromatic |
|
|
221
|
+
| Tryptophan | W | 61 | Aromatic |
|
|
222
|
+
| Proline | P | 67 | Rigid |
|
|
223
|
+
| Threonine | T | 71 | Polar |
|
|
224
|
+
| Serine | S | 73 | Polar |
|
|
225
|
+
| Histidine | H | 79 | Charged+ |
|
|
226
|
+
| Asparagine | N | 83 | Polar |
|
|
227
|
+
| Glutamine | Q | 89 | Polar |
|
|
228
|
+
| Aspartic Acid | D | 97 | Charged- |
|
|
229
|
+
| Lysine | K | 101 | Charged+ |
|
|
230
|
+
| Arginine | R | 103 | Charged+ |
|
|
231
|
+
| Glutamic Acid | E | 107 | Charged- |
|
|
232
|
+
|
|
233
|
+
## Genetic Code
|
|
234
|
+
|
|
235
|
+
The complete 64-codon genetic code is implemented:
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
const { GENETIC_CODE } = require('@aleph-ai/tinyaleph/backends/bioinformatics/genetic-code');
|
|
239
|
+
|
|
240
|
+
console.log(GENETIC_CODE['AUG']); // 'M' (Methionine - Start)
|
|
241
|
+
console.log(GENETIC_CODE['UAA']); // '*' (Stop)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## DNA Computing
|
|
245
|
+
|
|
246
|
+
### Logic Gates
|
|
247
|
+
|
|
248
|
+
All gates implement a standard interface:
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
class DNAGate {
|
|
252
|
+
evaluate(...inputs) // Evaluate gate with concentration inputs
|
|
253
|
+
truthTable() // Get complete truth table
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### ANDGate
|
|
258
|
+
|
|
259
|
+
Both inputs must be present (concentration ≥ threshold).
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
const gate = new ANDGate({ name: 'and1' });
|
|
263
|
+
gate.evaluate(1, 1); // { output: true, ... }
|
|
264
|
+
gate.evaluate(0, 1); // { output: false, ... }
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### ORGate
|
|
268
|
+
|
|
269
|
+
Either input triggers output.
|
|
270
|
+
|
|
271
|
+
```javascript
|
|
272
|
+
const gate = new ORGate({ name: 'or1' });
|
|
273
|
+
gate.evaluate(0, 1); // { output: true, ... }
|
|
274
|
+
gate.evaluate(0, 0); // { output: false, ... }
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### NOTGate
|
|
278
|
+
|
|
279
|
+
Inverts input signal.
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
const gate = new NOTGate({ name: 'not1' });
|
|
283
|
+
gate.evaluate(0); // { output: true, ... }
|
|
284
|
+
gate.evaluate(1); // { output: false, ... }
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### NANDGate
|
|
288
|
+
|
|
289
|
+
NAND operation (NOT AND).
|
|
290
|
+
|
|
291
|
+
```javascript
|
|
292
|
+
const gate = new NANDGate({ name: 'nand1' });
|
|
293
|
+
gate.evaluate(1, 1); // { output: false, ... }
|
|
294
|
+
gate.evaluate(0, 1); // { output: true, ... }
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### DNACircuit
|
|
298
|
+
|
|
299
|
+
Build complex circuits from gates.
|
|
300
|
+
|
|
301
|
+
```javascript
|
|
302
|
+
const circuit = new DNACircuit('my-circuit');
|
|
303
|
+
|
|
304
|
+
// Add gates
|
|
305
|
+
circuit.addGate('and1', new ANDGate({ name: 'and1' }));
|
|
306
|
+
circuit.addGate('not1', new NOTGate({ name: 'not1' }));
|
|
307
|
+
circuit.addGate('or1', new ORGate({ name: 'or1' }));
|
|
308
|
+
|
|
309
|
+
// Connect gates (source → target, input number)
|
|
310
|
+
circuit.connect('and1', 'or1', 1);
|
|
311
|
+
circuit.connect('not1', 'or1', 2);
|
|
312
|
+
|
|
313
|
+
// Set inputs and evaluate
|
|
314
|
+
circuit.setInput('and1', 1, 1); // Gate, input#, value
|
|
315
|
+
circuit.setInput('and1', 2, 0);
|
|
316
|
+
circuit.setInput('not1', 1, 1);
|
|
317
|
+
|
|
318
|
+
const result = circuit.evaluate();
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### DNA Strand Classes
|
|
322
|
+
|
|
323
|
+
```javascript
|
|
324
|
+
const { DNAStrand, DNADuplex, StrandDisplacementReaction } = require('@aleph-ai/tinyaleph');
|
|
325
|
+
|
|
326
|
+
// Create strands
|
|
327
|
+
const strand1 = new DNAStrand('ATGC', { toehold: 'AAA' });
|
|
328
|
+
const strand2 = new DNAStrand('GCAT');
|
|
329
|
+
|
|
330
|
+
// Create duplex (hybridized strands)
|
|
331
|
+
const duplex = new DNADuplex(strand1, strand2);
|
|
332
|
+
|
|
333
|
+
// Strand displacement reaction
|
|
334
|
+
const invader = new DNAStrand('AAAGCAT');
|
|
335
|
+
const reaction = new StrandDisplacementReaction(duplex, invader);
|
|
336
|
+
const result = reaction.react();
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### SeesawGate
|
|
340
|
+
|
|
341
|
+
Advanced seesaw-style DNA logic gate.
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
const { SeesawGate } = require('@aleph-ai/tinyaleph');
|
|
345
|
+
|
|
346
|
+
const gate = new SeesawGate({
|
|
347
|
+
name: 'seesaw1',
|
|
348
|
+
threshold: 0.5,
|
|
349
|
+
gain: 2.0
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const result = gate.evaluate(0.3, 0.7);
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Folding Dynamics
|
|
356
|
+
|
|
357
|
+
The folding system uses Kuramoto oscillators with biologically-motivated coupling:
|
|
358
|
+
|
|
359
|
+
### Contact Propensity
|
|
360
|
+
|
|
361
|
+
Residue-residue interaction strength is computed from:
|
|
362
|
+
|
|
363
|
+
1. **Hydrophobic interaction**: Hydrophobic residues (low primes) attract
|
|
364
|
+
2. **Electrostatic interaction**: Opposite charges attract (K, R, H vs D, E)
|
|
365
|
+
3. **Prime resonance**: Similar prime factors resonate
|
|
366
|
+
|
|
367
|
+
```javascript
|
|
368
|
+
// Contact propensity between residues i and j
|
|
369
|
+
propensity(i, j) = hydrophobic(i,j) + electrostatic(i,j) + resonance(i,j)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Order Parameter
|
|
373
|
+
|
|
374
|
+
The Kuramoto order parameter measures folding completion:
|
|
375
|
+
|
|
376
|
+
```
|
|
377
|
+
r = |1/N Σ exp(i·θⱼ)|
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
- `r ≈ 0`: Disordered (unfolded)
|
|
381
|
+
- `r ≈ 1`: Synchronized (folded)
|
|
382
|
+
|
|
383
|
+
### Contact Map
|
|
384
|
+
|
|
385
|
+
The contact map records which residues are in proximity:
|
|
386
|
+
|
|
387
|
+
```javascript
|
|
388
|
+
result.contactMap[i][j] = true; // Residues i,j in contact
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## Integration with AlephEngine
|
|
392
|
+
|
|
393
|
+
Create a bioinformatics-configured engine:
|
|
394
|
+
|
|
395
|
+
```javascript
|
|
396
|
+
const { createEngine } = require('@aleph-ai/tinyaleph');
|
|
397
|
+
|
|
398
|
+
// These all work:
|
|
399
|
+
const engine = createEngine('bioinformatics');
|
|
400
|
+
const engine = createEngine('bio');
|
|
401
|
+
const engine = createEngine('dna');
|
|
402
|
+
const engine = createEngine('protein');
|
|
403
|
+
|
|
404
|
+
// Process biological sequences
|
|
405
|
+
const result = engine.run('ATGCGATCGATCGATCG');
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Examples
|
|
409
|
+
|
|
410
|
+
### DNA Encoding
|
|
411
|
+
|
|
412
|
+
```javascript
|
|
413
|
+
const backend = new BioinformaticsBackend();
|
|
414
|
+
|
|
415
|
+
// Encode DNA
|
|
416
|
+
const dna = 'ATGCGATCG';
|
|
417
|
+
const primes = backend.encode(dna);
|
|
418
|
+
console.log(primes); // [7, 2, 11, 3, 11, 7, 2, 3, 11]
|
|
419
|
+
|
|
420
|
+
// Get hypercomplex state
|
|
421
|
+
const state = backend.primesToState(primes);
|
|
422
|
+
console.log('Norm:', state.norm());
|
|
423
|
+
console.log('Entropy:', backend.stateEntropy(state));
|
|
424
|
+
|
|
425
|
+
// Decode back
|
|
426
|
+
const decoded = backend.decode(primes);
|
|
427
|
+
console.log(decoded); // 'ATGCGATCG'
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Central Dogma
|
|
431
|
+
|
|
432
|
+
```javascript
|
|
433
|
+
const backend = new BioinformaticsBackend();
|
|
434
|
+
|
|
435
|
+
// DNA sequence with start codon
|
|
436
|
+
const dna = 'ATGAAAGGG'; // ATG = start, AAA = Lys, GGG = Gly
|
|
437
|
+
const dnaPrimes = backend.encode(dna);
|
|
438
|
+
|
|
439
|
+
// Transcription: DNA → RNA
|
|
440
|
+
const rnaResult = backend.transcribe(dnaPrimes, { force: true });
|
|
441
|
+
console.log('mRNA:', backend.decode(rnaResult.rna)); // 'AUGAAAGGG'
|
|
442
|
+
|
|
443
|
+
// Translation: RNA → Protein
|
|
444
|
+
const proteinResult = backend.translate(rnaResult.rna);
|
|
445
|
+
console.log('Protein:', proteinResult.sequence); // 'MKG'
|
|
446
|
+
|
|
447
|
+
// Or full expression
|
|
448
|
+
const expressed = backend.express(dnaPrimes);
|
|
449
|
+
console.log('Protein:', expressed.sequence);
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Protein Folding
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
const backend = new BioinformaticsBackend();
|
|
456
|
+
|
|
457
|
+
// Small peptide
|
|
458
|
+
const peptide = 'MWLKFVIER'; // Mix of hydrophobic and charged
|
|
459
|
+
const primes = backend.encode(peptide);
|
|
460
|
+
|
|
461
|
+
// Fold with custom parameters
|
|
462
|
+
const result = backend.foldProtein(primes, {
|
|
463
|
+
steps: 200,
|
|
464
|
+
coupling: 0.15,
|
|
465
|
+
dt: 0.01
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
console.log('Order parameter:', result.orderParameter);
|
|
469
|
+
console.log('Contact count:', result.contactMap.filter(row =>
|
|
470
|
+
row.some(x => x)).length);
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### DNA Circuit
|
|
474
|
+
|
|
475
|
+
```javascript
|
|
476
|
+
const { DNACircuit, ANDGate, ORGate, NOTGate } = require('@aleph-ai/tinyaleph');
|
|
477
|
+
|
|
478
|
+
// Build (A AND B) OR (NOT C)
|
|
479
|
+
const circuit = new DNACircuit('logic');
|
|
480
|
+
|
|
481
|
+
circuit.addGate('and1', new ANDGate({ name: 'and1' }));
|
|
482
|
+
circuit.addGate('not1', new NOTGate({ name: 'not1' }));
|
|
483
|
+
circuit.addGate('or1', new ORGate({ name: 'or1' }));
|
|
484
|
+
|
|
485
|
+
circuit.connect('and1', 'or1', 1);
|
|
486
|
+
circuit.connect('not1', 'or1', 2);
|
|
487
|
+
|
|
488
|
+
// Test
|
|
489
|
+
for (const [a, b, c] of [[0,0,0], [1,1,0], [1,1,1]]) {
|
|
490
|
+
const result = (a && b) || !c;
|
|
491
|
+
console.log(`${a} AND ${b} OR NOT ${c} = ${result ? 1 : 0}`);
|
|
492
|
+
}
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Binding Affinity
|
|
496
|
+
|
|
497
|
+
```javascript
|
|
498
|
+
const backend = new BioinformaticsBackend();
|
|
499
|
+
|
|
500
|
+
// DNA binding site
|
|
501
|
+
const dna = backend.encode('ATGCGATC');
|
|
502
|
+
|
|
503
|
+
// Transcription factor
|
|
504
|
+
const protein = backend.encode('MKVLR');
|
|
505
|
+
|
|
506
|
+
// Check affinity
|
|
507
|
+
const result = backend.bindingAffinity(dna, protein);
|
|
508
|
+
console.log('Affinity:', result.affinity.toFixed(4));
|
|
509
|
+
console.log('Coherence:', result.coherence.toFixed(4));
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
## Theory
|
|
513
|
+
|
|
514
|
+
### Prime Encoding Rationale
|
|
515
|
+
|
|
516
|
+
Primes are chosen for biological molecules based on:
|
|
517
|
+
|
|
518
|
+
1. **Uniqueness**: Each molecule maps to a unique prime signature
|
|
519
|
+
2. **Factorization**: Composite information decomposes into primes
|
|
520
|
+
3. **Resonance**: Related primes (e.g., base pairs) have harmonic relationships
|
|
521
|
+
4. **Ordering**: Hydrophobicity ordering creates meaningful prime relationships
|
|
522
|
+
|
|
523
|
+
### Folding as Synchronization
|
|
524
|
+
|
|
525
|
+
Protein folding is modeled as Kuramoto synchronization because:
|
|
526
|
+
|
|
527
|
+
1. Residues are oscillators with characteristic frequencies
|
|
528
|
+
2. Interactions create coupling between oscillators
|
|
529
|
+
3. Folding = synchronization to a coherent phase pattern
|
|
530
|
+
4. Native state = high order parameter (r → 1)
|
|
531
|
+
|
|
532
|
+
### DNA Computing as Prime Operations
|
|
533
|
+
|
|
534
|
+
DNA computation maps to prime arithmetic:
|
|
535
|
+
|
|
536
|
+
1. **Strand hybridization** = prime compatibility check
|
|
537
|
+
2. **Strand displacement** = prime sequence comparison
|
|
538
|
+
3. **Logic gates** = prime threshold operations
|
|
539
|
+
4. **Circuits** = composed prime transformations
|
|
540
|
+
|
|
541
|
+
## See Also
|
|
542
|
+
|
|
543
|
+
- [Core Module](./01-core.md) - Hypercomplex algebra
|
|
544
|
+
- [Physics Module](./02-physics.md) - Kuramoto oscillators
|
|
545
|
+
- [Backends](./03-backends.md) - Backend interface
|
|
546
|
+
- [Design Document](../design/BIOINFORMATICS_BACKEND_DESIGN.md) - Full architecture
|
package/docs/reference/README.md
CHANGED
|
@@ -35,6 +35,20 @@ Domain-specific computation engines:
|
|
|
35
35
|
- **SemanticBackend** - Natural language and concept processing
|
|
36
36
|
- **CryptographicBackend** - Hashing and key derivation
|
|
37
37
|
- **ScientificBackend** - Quantum-inspired computation
|
|
38
|
+
- **BioinformaticsBackend** - DNA/RNA/Protein computation
|
|
39
|
+
|
|
40
|
+
### [Bioinformatics Module](./06-bioinformatics.md)
|
|
41
|
+
|
|
42
|
+
DNA computing and molecular biology:
|
|
43
|
+
|
|
44
|
+
- **BioinformaticsBackend** - DNA/RNA/Protein encoding and operations
|
|
45
|
+
- **Transcription** - DNA to RNA conversion (Central Dogma)
|
|
46
|
+
- **Translation** - RNA to Protein via genetic code
|
|
47
|
+
- **FoldingTransform** - Protein folding via Kuramoto oscillators
|
|
48
|
+
- **DNACircuit** - DNA logic circuit construction
|
|
49
|
+
- **ANDGate / ORGate / NOTGate / NANDGate** - DNA logic gates
|
|
50
|
+
- **StrandDisplacementReaction** - Toehold-mediated displacement
|
|
51
|
+
- **BindingAffinityCalculator** - Molecular binding scoring
|
|
38
52
|
|
|
39
53
|
### [Engine Module](./04-engine.md)
|
|
40
54
|
|
|
@@ -44,7 +58,16 @@ High-level orchestration:
|
|
|
44
58
|
- **createEngine** - Factory function for engine creation
|
|
45
59
|
- **registerBackend** - Backend registration system
|
|
46
60
|
|
|
47
|
-
### [
|
|
61
|
+
### [Symbolic AI Module](./05-symbolic-ai.md)
|
|
62
|
+
|
|
63
|
+
Symbol inference and resonance attention:
|
|
64
|
+
|
|
65
|
+
- **SymbolDatabase** - 184+ emoji symbols with prime assignments and cultural tags
|
|
66
|
+
- **SemanticInference** - Pattern matching and resonance-enhanced text→symbol mapping
|
|
67
|
+
- **CompoundBuilder** - Multi-symbol concept composition
|
|
68
|
+
- **ResonanceCalculator** - Golden ratio-based harmony measurement
|
|
69
|
+
|
|
70
|
+
### [Formal Semantics Module](./06-formal-semantics.md)
|
|
48
71
|
|
|
49
72
|
Formal type system and reduction semantics:
|
|
50
73
|
|
|
@@ -55,7 +78,7 @@ Formal type system and reduction semantics:
|
|
|
55
78
|
- **LambdaEvaluator** - β-reduction and normalization
|
|
56
79
|
- **Semantics** - Model-theoretic interpretation
|
|
57
80
|
|
|
58
|
-
### [Enochian Module](./
|
|
81
|
+
### [Enochian Module](./07-enochian.md)
|
|
59
82
|
|
|
60
83
|
The angelic language system:
|
|
61
84
|
|
|
@@ -269,6 +292,10 @@ console.assert(coherence >= 0 && coherence <= 1);
|
|
|
269
292
|
| types | `core/types.js` | Formal type system |
|
|
270
293
|
| reduction | `core/reduction.js` | Reduction semantics |
|
|
271
294
|
| lambda | `core/lambda.js` | λ-calculus translation |
|
|
295
|
+
| symbols | `core/symbols.js` | Symbol database |
|
|
296
|
+
| inference | `core/inference.js` | Semantic inference |
|
|
297
|
+
| compound | `core/compound.js` | Compound builder |
|
|
298
|
+
| resonance | `core/resonance.js` | Resonance calculator |
|
|
272
299
|
| oscillator | `physics/oscillator.js` | Oscillator creation |
|
|
273
300
|
| kuramoto | `physics/kuramoto.js` | Synchronization |
|
|
274
301
|
| entropy | `physics/entropy.js` | Information theory |
|
|
@@ -277,6 +304,9 @@ console.assert(coherence >= 0 && coherence <= 1);
|
|
|
277
304
|
| semantic | `backends/semantic/index.js` | Semantic backend |
|
|
278
305
|
| cryptographic | `backends/cryptographic/index.js` | Crypto backend |
|
|
279
306
|
| scientific | `backends/scientific/index.js` | Science backend |
|
|
307
|
+
| bioinformatics | `backends/bioinformatics/index.js` | Bioinformatics backend |
|
|
308
|
+
| dna-computing | `backends/bioinformatics/dna-computing.js` | DNA logic gates/circuits |
|
|
309
|
+
| folding | `backends/bioinformatics/folding.js` | Protein folding dynamics |
|
|
280
310
|
| engine | `engine/aleph.js` | Main engine |
|
|
281
311
|
| enochian | `apps/sentient/lib/enochian-vocabulary.js` | Enochian language |
|
|
282
312
|
|