|
1 | 1 | // Output PColumn specs emitted by sequence-properties. |
2 | 2 | // |
3 | | -// Two getters wrap a canonical column list and apply per-consumer annotations: |
| 3 | +// Public surface: |
4 | 4 | // |
5 | | -// - `forPropertiesPf(args)` — every column, `pl7.app/isOutput: "true"` |
6 | | -// added on top of the canonical annotations. |
7 | | -// - `forExport(args, blockId)` — filtered to `pl7.app/isScore: "true"` |
8 | | -// columns; domain cloned + `pl7.app/blockId` |
9 | | -// stamped on so downstream blocks can |
10 | | -// distinguish runs. |
| 5 | +// - `buildColumns(args)` — canonical scalar-property column list. |
| 6 | +// Returns `[{column, id, naRegex, |
| 7 | +// allowNA, spec}, ...]` with feature- |
| 8 | +// specific domains and annotations. |
| 9 | +// No blockId, no isOutput, no trace |
| 10 | +// — those are stamped on by the caller |
| 11 | +// at pframe-build time. |
| 12 | +// - `aaFractionColumn()` — 2-axis AA-fraction column descriptor |
| 13 | +// (peptide mode only). |
| 14 | +// - `cloneSpec(spec, dExtras, aExtras)` — spec-cloning helper used by the |
| 15 | +// caller to layer blockId / isOutput / |
| 16 | +// any other per-consumer overrides. |
11 | 17 | // |
12 | 18 | // `args` shape: |
13 | 19 | // { mode, receptor, chains, fullChains, hasFv } |
14 | | -// — identical to the relevant subset of `process.tpl.tengo`'s `params`. |
| 20 | +// — identical to the relevant subset of `main.tpl.tengo`'s plan. |
15 | 21 |
|
16 | 22 | ll := import("@platforma-sdk/workflow-tengo:ll") |
17 | 23 |
|
@@ -379,68 +385,86 @@ buildColumns := func(args) { |
379 | 385 |
|
380 | 386 | // --------------------------------------------------------------------------- |
381 | 387 | // Spec-cloning helper. Builds a fresh spec dict with optional domain and |
382 | | -// annotation extras. Used by both getters so the two outputs never share |
383 | | -// dict references. |
| 388 | +// annotation extras. Callers use this to layer per-consumer overrides |
| 389 | +// (e.g. `pl7.app/blockId` in domain, `pl7.app/isOutput` in annotations). |
384 | 390 | // --------------------------------------------------------------------------- |
385 | 391 |
|
386 | 392 | cloneSpec := func(spec, domainExtras, annotationExtras) { |
| 393 | + // Shallow-copy every top-level key (kind, name, valueType, axesSpec, ...) |
| 394 | + // so specs already filled in by xsv.importFile keep their kind + axesSpec. |
| 395 | + out := {} |
| 396 | + for k, v in spec { out[k] = v } |
| 397 | + |
| 398 | + // Overlay domain — always build a fresh dict so the result never aliases |
| 399 | + // the caller's input domain. |
387 | 400 | newDomain := {} |
388 | 401 | if spec.domain { |
389 | 402 | for k, v in spec.domain { newDomain[k] = v } |
390 | 403 | } |
391 | 404 | if domainExtras { |
392 | 405 | for k, v in domainExtras { newDomain[k] = v } |
393 | 406 | } |
| 407 | + out.domain = newDomain |
| 408 | + |
| 409 | + // Overlay annotations — same fresh-dict rule. |
394 | 410 | newAnnotations := {} |
395 | 411 | if spec.annotations { |
396 | 412 | for k, v in spec.annotations { newAnnotations[k] = v } |
397 | 413 | } |
398 | 414 | if annotationExtras { |
399 | 415 | for k, v in annotationExtras { newAnnotations[k] = v } |
400 | 416 | } |
401 | | - return { |
402 | | - name: spec.name, |
403 | | - valueType: spec.valueType, |
404 | | - domain: newDomain, |
405 | | - annotations: newAnnotations |
406 | | - } |
407 | | -} |
| 417 | + out.annotations = newAnnotations |
408 | 418 |
|
409 | | -wrap := func(col, newSpec) { |
410 | | - return { |
411 | | - column: col.column, |
412 | | - id: col.id, |
413 | | - naRegex: col.naRegex, |
414 | | - allowNA: col.allowNA, |
415 | | - spec: newSpec |
416 | | - } |
| 419 | + return out |
417 | 420 | } |
418 | 421 |
|
419 | 422 | // --------------------------------------------------------------------------- |
420 | | -// Public getters. |
| 423 | +// AA fraction (peptide mode) — single 2-axis column descriptor. |
| 424 | +// Lives here so the entire column inventory of the block is in one place. |
421 | 425 | // --------------------------------------------------------------------------- |
422 | 426 |
|
423 | | -forPropertiesPf := func(args) { |
424 | | - cols := buildColumns(args) |
425 | | - out := [] |
426 | | - for col in cols { |
427 | | - out += [wrap(col, cloneSpec(col.spec, undefined, { "pl7.app/isOutput": "true" }))] |
| 427 | +aaFractionColumn := func(keyAxisSpec) { |
| 428 | + return { |
| 429 | + axes: [ |
| 430 | + { column: "entity_key", spec: keyAxisSpec }, |
| 431 | + { |
| 432 | + column: "aminoAcid", |
| 433 | + spec: { |
| 434 | + name: "pl7.app/aminoAcid", |
| 435 | + type: "String", |
| 436 | + annotations: { "pl7.app/label": "Amino Acid" } |
| 437 | + } |
| 438 | + } |
| 439 | + ], |
| 440 | + column: { |
| 441 | + column: "value", |
| 442 | + id: "aaFraction", |
| 443 | + naRegex: "", |
| 444 | + allowNA: true, |
| 445 | + spec: { |
| 446 | + name: "pl7.app/aaFraction", |
| 447 | + valueType: "Double", |
| 448 | + domain: { "pl7.app/feature": "peptide" }, |
| 449 | + annotations: { |
| 450 | + "pl7.app/label": "AA Fraction", |
| 451 | + "pl7.app/format": ".3f", |
| 452 | + "pl7.app/min": "0", |
| 453 | + "pl7.app/max": "1", |
| 454 | + "pl7.app/table/visibility": "optional", |
| 455 | + "pl7.app/table/orderPriority": "69000" |
| 456 | + } |
| 457 | + } |
| 458 | + } |
428 | 459 | } |
429 | | - return out |
430 | 460 | } |
431 | 461 |
|
432 | | -forExport := func(args, blockId) { |
433 | | - cols := buildColumns(args) |
434 | | - out := [] |
435 | | - for col in cols { |
436 | | - if !col.spec.annotations { continue } |
437 | | - if col.spec.annotations["pl7.app/isScore"] != "true" { continue } |
438 | | - out += [wrap(col, cloneSpec(col.spec, { "pl7.app/blockId": blockId }, undefined))] |
439 | | - } |
440 | | - return out |
441 | | -} |
| 462 | +// --------------------------------------------------------------------------- |
| 463 | +// Public exports. |
| 464 | +// --------------------------------------------------------------------------- |
442 | 465 |
|
443 | 466 | export ll.toStrict({ |
444 | | - forPropertiesPf: forPropertiesPf, |
445 | | - forExport: forExport |
| 467 | + buildColumns: buildColumns, |
| 468 | + aaFractionColumn: aaFractionColumn, |
| 469 | + cloneSpec: cloneSpec |
446 | 470 | }) |
0 commit comments