From 97e7041d78b686b5c591ba5fd9b3cf249daa73e6 Mon Sep 17 00:00:00 2001 From: jtklein-agents Date: Fri, 27 Nov 2026 23:15:43 +0100 Subject: [PATCH 1/3] Pin the generated commands for every analysis (#420) (#423) One table of cases in src/test/commandPins.ts, run by two test files: the host the test setup installs, and a Windows host with C: paths. Each pin builds a real Run and snapshots run.args; run.command and run.settingsFileContent are pinned once per binary. Binaries the host's list lacks (ASTRAL, RAxML-NG on Windows, and a PTHREADS-named RAxML-NG stand-in for the --threads branch) are added to the list by the table. Co-authored-by: Claude Fable 5.2 --- src/app/store/Run.pins.test.ts | 7 + src/app/store/Run.pins.windows.test.ts | 14 + .../store/__snapshots__/Run.pins.test.ts.snap | 1511 ++++++++++++++++ .../Run.pins.windows.test.ts.snap | 1516 +++++++++++++++++ src/test/commandPins.ts | 251 +++ 5 files changed, 3299 insertions(+) create mode 100644 src/app/store/Run.pins.test.ts create mode 100644 src/app/store/Run.pins.windows.test.ts create mode 100644 src/app/store/__snapshots__/Run.pins.test.ts.snap create mode 100644 src/app/store/__snapshots__/Run.pins.windows.test.ts.snap create mode 100644 src/test/commandPins.ts diff --git a/src/app/store/Run.pins.test.ts b/src/app/store/Run.pins.test.ts new file mode 100644 index 00000000..a0073787 --- /dev/null +++ b/src/app/store/Run.pins.test.ts @@ -0,0 +1,7 @@ +// Command pins on the host the test setup installs: not Windows, paths like /out. +import { pinBridge, pinCommands } from '../../test/commandPins'; +import { installBridge } from '../../test/setup'; + +installBridge( pinBridge ); + +await pinCommands( { windows: false } ); diff --git a/src/app/store/Run.pins.windows.test.ts b/src/app/store/Run.pins.windows.test.ts new file mode 100644 index 00000000..42f1538a --- /dev/null +++ b/src/app/store/Run.pins.windows.test.ts @@ -0,0 +1,14 @@ +// Command pins on a Windows host with paths like C:\out. +import { vi } from 'vitest'; + +import { pinBridge, pinCommands } from '../../test/commandPins'; +import { installBridge } from '../../test/setup'; + +installBridge( { + ...pinBridge, + host: { windows: true, release: '10.0.19045', arch: 'x64', cpuModel: 'Intel' }, +} ); +// Run.ts and RunOptions.ts read the host once at import, so the store loads again after the host is set. +vi.resetModules(); + +await pinCommands( { windows: true } ); diff --git a/src/app/store/__snapshots__/Run.pins.test.ts.snap b/src/app/store/__snapshots__/Run.pins.test.ts.snap new file mode 100644 index 00000000..d815681c --- /dev/null +++ b/src/app/store/__snapshots__/Run.pins.test.ts.snap @@ -0,0 +1,1511 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`ASTRAL args > with a loaded tree 1`] = ` +[ + [ + "-i", + "/in/genes.tre", + "-o", + "/out/ASTRAL_pin.tre", + ], +] +`; + +exports[`ASTRAL args > without a tree 1`] = ` +[ + [ + "-o", + "/out/ASTRAL_pin.tre", + ], +] +`; + +exports[`ModelTest-NG args > binary 1`] = ` +[ + [ + "-i", + "/in/a.fasta", + "-o", + "/out/RAxML_GUI_ModelTest_pin", + "--force", + "-p", + 3, + ], +] +`; + +exports[`ModelTest-NG args > nucleotide 1`] = ` +[ + [ + "-d", + "nt", + "-i", + "/in/a.fasta", + "-o", + "/out/RAxML_GUI_ModelTest_pin", + "--force", + "-p", + 3, + ], +] +`; + +exports[`ModelTest-NG args > protein 1`] = ` +[ + [ + "-d", + "aa", + "-i", + "/in/a.fasta", + "-o", + "/out/RAxML_GUI_ModelTest_pin", + "--force", + "-p", + 3, + ], +] +`; + +exports[`RAxML args > AS alternate 1`] = ` +[ + [ + "-f", + "A", + "-t", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > AS bare 1`] = ` +[ + [ + "-f", + "A", + "-t", + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > AS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "A", + "-t", + "/in/start.tre", + "-m", + "GTRGAMMA", + "--HKY85", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], +] +`; + +exports[`RAxML args > BS+con alternate 1`] = ` +[ + [ + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-J", + "MR", + "-w", + "/out", + "-z", + "/out/RAxML_bootstrap.pin.tre", + "-n", + "consensus.pin.tre", + ], +] +`; + +exports[`RAxML args > BS+con bare 1`] = ` +[ + [ + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-m", + "GTRGAMMA", + "-J", + "MR", + "-w", + "/out", + "-z", + "/out/RAxML_bootstrap.pin.tre", + "-n", + "consensus.pin.tre", + ], +] +`; + +exports[`RAxML args > BS+con full 1`] = ` +[ + [ + "-T", + 3, + "-k", + "-x", + 123, + "-p", + 123, + "-N", + 200, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], + [ + "-T", + 3, + "-m", + "GTRGAMMA", + "--HKY85", + "-J", + "MR", + "-w", + "/out", + "-z", + "/out/RAxML_bootstrap.pin.tre", + "-n", + "consensus.pin.tre", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML args > FT alternate 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + "/out/RAxML_fastTree.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > FT bare 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > FT full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + "/out/RAxML_fastTree.pin.tre", + "-n", + "brL.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + "/out/RAxML_result.brL.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], +] +`; + +exports[`RAxML args > ML alternate 1`] = ` +[ + [ + "-f", + "d", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-N", + 1, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + "/out/RAxML_bestTree.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > ML bare 1`] = ` +[ + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-N", + 1, + "-p", + 123, + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > ML full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "d", + "-m", + "GTRGAMMA", + "--HKY85", + "-N", + 10, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-o", + "t1,t2", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + "/out/RAxML_bestTree.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], +] +`; + +exports[`RAxML args > ML+rBS alternate 1`] = ` +[ + [ + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > ML+rBS bare 1`] = ` +[ + [ + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > ML+rBS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 200, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML args > ML+tBS alternate 1`] = ` +[ + [ + "-b", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-p", + 123, + "-N", + 100, + "-O", + "-n", + "pinR.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "d", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-p", + 123, + "-N", + 1, + "-O", + "-n", + "pinB.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "b", + "-t", + "/out/RAxML_bestTree.pinB.tre", + "-z", + "/out/RAxML_bootstrap.pinR.tre", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > ML+tBS bare 1`] = ` +[ + [ + "-b", + 123, + "-m", + "GTRGAMMA", + "-p", + 123, + "-N", + 100, + "-n", + "pinR.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-p", + 123, + "-N", + 1, + "-n", + "pinB.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-f", + "b", + "-t", + "/out/RAxML_bestTree.pinB.tre", + "-z", + "/out/RAxML_bootstrap.pinR.tre", + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > ML+tBS full 1`] = ` +[ + [ + "-T", + 3, + "-b", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-p", + 123, + "-N", + 200, + "-O", + "-o", + "t1,t2", + "-n", + "pinR.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], + [ + "-T", + 3, + "-f", + "d", + "-m", + "GTRGAMMA", + "--HKY85", + "-p", + 123, + "-N", + 10, + "-O", + "-o", + "t1,t2", + "-n", + "pinB.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], + [ + "-T", + 3, + "-f", + "b", + "-t", + "/out/RAxML_bestTree.pinB.tre", + "-z", + "/out/RAxML_bootstrap.pinR.tre", + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > PD alternate 1`] = ` +[ + [ + "-f", + "x", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > PD bare 1`] = ` +[ + [ + "-f", + "x", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > PD full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "x", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-t", + "/in/start.tre", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + ], +] +`; + +exports[`RAxML args > RBS alternate 1`] = ` +[ + [ + "-f", + "D", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`RAxML args > RBS bare 1`] = ` +[ + [ + "-f", + "D", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`RAxML args > RBS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "D", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-o", + "t1,t2", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/parts.txt", + "-r", + "/in/backbone.tre", + "-g", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML-NG args > AS alternate 1`] = ` +[ + [ + "--ancestral", + "--msa", + "/in/a.fasta", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--tree", + ], +] +`; + +exports[`RAxML-NG args > AS bare 1`] = ` +[ + [ + "--ancestral", + "--msa", + "/in/a.fasta", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--tree", + ], +] +`; + +exports[`RAxML-NG args > AS full 1`] = ` +[ + [ + "--ancestral", + "--msa", + "/in/a.fasta", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--tree", + "/in/start.tre", + ], +] +`; + +exports[`RAxML-NG args > CC alternate 1`] = ` +[ + [ + "--parse", + "--model", + "/in/RAxML_pin.part.txt", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + ], +] +`; + +exports[`RAxML-NG args > CC bare 1`] = ` +[ + [ + "--parse", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + ], +] +`; + +exports[`RAxML-NG args > CC full 1`] = ` +[ + [ + "--parse", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + "--tree-constraint", + "/in/backbone.tre", + "--tree-constraint", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con alternate 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "/in/RAxML_pin.part.txt", + "--prefix", + "/out/pin", + "--seed", + 123, + "--bs-metric", + "tbe", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con bare 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--seed", + 123, + "--bs-metric", + "tbe", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con full 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--seed", + 123, + "--threads", + 3, + "--outgroup", + "t1,t2", + "--bs-metric", + "tbe", + "--tree", + "rand{10}", + "--bs-trees", + "autoMRE", + "--tree-constraint", + "/in/backbone.tre", + "--tree-constraint", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con alternate 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "/in/RAxML_pin.part.txt", + "--prefix", + "/out/pin", + "--seed", + 123, + "--bs-metric", + "fbp", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con bare 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--seed", + 123, + "--bs-metric", + "fbp", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con full 1`] = ` +[ + [ + "--all", + "--msa", + "/in/a.fasta", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--seed", + 123, + "--threads", + 3, + "--outgroup", + "t1,t2", + "--bs-metric", + "fbp", + "--tree", + "rand{10}", + "--bs-trees", + "autoMRE", + "--tree-constraint", + "/in/backbone.tre", + "--tree-constraint", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML-NG args > SC alternate 1`] = ` +[ + [ + "--check", + "--model", + "/in/RAxML_pin.part.txt", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + ], +] +`; + +exports[`RAxML-NG args > SC bare 1`] = ` +[ + [ + "--check", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + ], +] +`; + +exports[`RAxML-NG args > SC full 1`] = ` +[ + [ + "--check", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--msa", + "/in/a.fasta", + "--tree-constraint", + "/in/backbone.tre", + "--tree-constraint", + "/in/multifurcating.tre", + ], +] +`; + +exports[`RAxML-NG args > TI alternate 1`] = ` +[ + [ + "--msa", + "/in/a.fasta", + "--model", + "/in/RAxML_pin.part.txt", + "--prefix", + "/out/pin", + "--seed", + 123, + "--tree", + "rand{1}", + ], +] +`; + +exports[`RAxML-NG args > TI bare 1`] = ` +[ + [ + "--msa", + "/in/a.fasta", + "--model", + "GTR+G", + "--prefix", + "/out/pin", + "--seed", + 123, + "--tree", + "rand{1}", + ], +] +`; + +exports[`RAxML-NG args > TI full 1`] = ` +[ + [ + "--msa", + "/in/a.fasta", + "--model", + "/in/parts.txt", + "--prefix", + "/out/pin", + "--threads", + 3, + "--seed", + 123, + "--outgroup", + "t1,t2", + "--tree", + "rand{10}", + "--tree-constraint", + "/in/backbone.tre", + "--tree-constraint", + "/in/multifurcating.tre", + ], +] +`; + +exports[`args for an analysis the builder does not know > RAxML 1`] = `[]`; + +exports[`args for an analysis the builder does not know > RAxML-NG 1`] = `[]`; + +exports[`args, branches the three variants miss > RAxML FT alternate with branch lengths 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + "/out/RAxML_fastTree.pin.tre", + "-n", + "brL.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + "/out/RAxML_result.brL.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + "-q", + "/in/RAxML_pin.part.txt", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML FT with branch lengths and SH-like values on a default partition 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "-O", + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + "/out/RAxML_fastTree.pin.tre", + "-n", + "brL.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + "/out/RAxML_result.brL.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML ML with SH-like values on a default partition 1`] = ` +[ + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-N", + 1, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + "/out/RAxML_bestTree.pin.tre", + "-n", + "sh.pin.tre", + "-s", + "/in/a.fasta", + "-w", + "/out", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML-NG AS with two alignments 1`] = ` +[ + [ + "--ancestral", + "--msa", + "/out/RAxML_pin_concat.txt", + "--model", + "/out/RAxML_pin_concat.part.txt", + "--prefix", + "/out/pin", + "--tree", + ], +] +`; + +exports[`command and settings file > ASTRAL > command 1`] = `"java -jar astral.5.7.8.jar -i /in/genes.tre -o /out/ASTRAL_pin.tre"`; + +exports[`command and settings file > ASTRAL > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + rapid bootstrap +Binary: astral.5.7.8.jar version 5.7.8 +Results saved to: /out +RAxML was called with these arguments: +1.) -i /in/genes.tre -o /out/ASTRAL_pin.tre +" +`; + +exports[`command and settings file > ModelTest-NG > command 1`] = `"modeltest-ng -d nt -i /in/a.fasta -o /out/RAxML_GUI_ModelTest_pin --force -p 3"`; + +exports[`command and settings file > ModelTest-NG > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + rapid bootstrap +Binary: modeltest-ng version 0.1.7 +Results saved to: /out +RAxML was called with these arguments: +1.) -d nt -i /in/a.fasta -o /out/RAxML_GUI_ModelTest_pin --force -p 3 +" +`; + +exports[`command and settings file > RAxML > command 1`] = ` +"raxmlHPC-PTHREADS-SSE3 -T 3 -b 123 -m GTRGAMMA --HKY85 -k -p 123 -N 200 -O -o t1,t2 -n pinR.tre -s /in/a.fasta -w /out -q /in/parts.txt -r /in/backbone.tre -g /in/multifurcating.tre &&\\ +raxmlHPC-PTHREADS-SSE3 -T 3 -f d -m GTRGAMMA --HKY85 -p 123 -N 10 -O -o t1,t2 -n pinB.tre -s /in/a.fasta -w /out -q /in/parts.txt -r /in/backbone.tre -g /in/multifurcating.tre &&\\ +raxmlHPC-PTHREADS-SSE3 -T 3 -f b -t /out/RAxML_bestTree.pinB.tre -z /out/RAxML_bootstrap.pinR.tre -m GTRGAMMA --HKY85 -O -n pin.tre -s /in/a.fasta -w /out" +`; + +exports[`command and settings file > RAxML > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + thorough bootstrap +Binary: raxmlHPC-PTHREADS-SSE3 version 8.2.12 +Results saved to: /out +RAxML was called with these arguments: +1.) -T 3 -b 123 -m GTRGAMMA --HKY85 -k -p 123 -N 200 -O -o t1,t2 -n pinR.tre -s /in/a.fasta -w /out -q /in/parts.txt -r /in/backbone.tre -g /in/multifurcating.tre +2.) -T 3 -f d -m GTRGAMMA --HKY85 -p 123 -N 10 -O -o t1,t2 -n pinB.tre -s /in/a.fasta -w /out -q /in/parts.txt -r /in/backbone.tre -g /in/multifurcating.tre +3.) -T 3 -f b -t /out/RAxML_bestTree.pinB.tre -z /out/RAxML_bootstrap.pinR.tre -m GTRGAMMA --HKY85 -O -n pin.tre -s /in/a.fasta -w /out +" +`; + +exports[`command and settings file > RAxML-NG > command 1`] = `"raxml-ng --all --msa /in/a.fasta --model /in/parts.txt --prefix /out/pin --seed 123 --outgroup t1,t2 --bs-metric tbe --tree rand{10} --bs-trees autoMRE --tree-constraint /in/backbone.tre --tree-constraint /in/multifurcating.tre"`; + +exports[`command and settings file > RAxML-NG > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + transfer bootstrap expectation + consensus +Binary: raxml-ng version 1.2.2 +Results saved to: /out +RAxML was called with these arguments: +1.) --all --msa /in/a.fasta --model /in/parts.txt --prefix /out/pin --seed 123 --outgroup t1,t2 --bs-metric tbe --tree rand{10} --bs-trees autoMRE --tree-constraint /in/backbone.tre --tree-constraint /in/multifurcating.tre +" +`; diff --git a/src/app/store/__snapshots__/Run.pins.windows.test.ts.snap b/src/app/store/__snapshots__/Run.pins.windows.test.ts.snap new file mode 100644 index 00000000..9e1f8eed --- /dev/null +++ b/src/app/store/__snapshots__/Run.pins.windows.test.ts.snap @@ -0,0 +1,1516 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`ASTRAL args > with a loaded tree 1`] = ` +[ + [ + "-i", + ""C:\\in\\genes.tre"", + "-o", + ""C:\\out\\ASTRAL_pin.tre"", + ], +] +`; + +exports[`ASTRAL args > without a tree 1`] = ` +[ + [ + "-o", + ""C:\\out\\ASTRAL_pin.tre"", + ], +] +`; + +exports[`ModelTest-NG args > binary 1`] = ` +[ + [ + "-i", + ""C:\\in\\a.fasta"", + "-o", + ""C:\\out\\RAxML_GUI_ModelTest_pin"", + "--force", + "-p", + 3, + ], +] +`; + +exports[`ModelTest-NG args > nucleotide 1`] = ` +[ + [ + "-d", + "nt", + "-i", + ""C:\\in\\a.fasta"", + "-o", + ""C:\\out\\RAxML_GUI_ModelTest_pin"", + "--force", + "-p", + 3, + ], +] +`; + +exports[`ModelTest-NG args > protein 1`] = ` +[ + [ + "-d", + "aa", + "-i", + ""C:\\in\\a.fasta"", + "-o", + ""C:\\out\\RAxML_GUI_ModelTest_pin"", + "--force", + "-p", + 3, + ], +] +`; + +exports[`RAxML args > AS alternate 1`] = ` +[ + [ + "-f", + "A", + "-t", + """", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > AS bare 1`] = ` +[ + [ + "-f", + "A", + "-t", + """", + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > AS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "A", + "-t", + ""C:\\in\\start.tre"", + "-m", + "GTRGAMMA", + "--HKY85", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], +] +`; + +exports[`RAxML args > BS+con alternate 1`] = ` +[ + [ + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-J", + "MR", + "-w", + ""C:\\out"", + "-z", + ""C:\\out\\RAxML_bootstrap.pin.tre"", + "-n", + "consensus.pin.tre", + ], +] +`; + +exports[`RAxML args > BS+con bare 1`] = ` +[ + [ + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-m", + "GTRGAMMA", + "-J", + "MR", + "-w", + ""C:\\out"", + "-z", + ""C:\\out\\RAxML_bootstrap.pin.tre"", + "-n", + "consensus.pin.tre", + ], +] +`; + +exports[`RAxML args > BS+con full 1`] = ` +[ + [ + "-T", + 3, + "-k", + "-x", + 123, + "-p", + 123, + "-N", + 200, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], + [ + "-T", + 3, + "-m", + "GTRGAMMA", + "--HKY85", + "-J", + "MR", + "-w", + ""C:\\out"", + "-z", + ""C:\\out\\RAxML_bootstrap.pin.tre"", + "-n", + "consensus.pin.tre", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML args > FT alternate 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + ""C:\\out\\RAxML_fastTree.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > FT bare 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > FT full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + ""C:\\out\\RAxML_fastTree.pin.tre"", + "-n", + "brL.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + ""C:\\out\\RAxML_result.brL.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], +] +`; + +exports[`RAxML args > ML alternate 1`] = ` +[ + [ + "-f", + "d", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-N", + 1, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + ""C:\\out\\RAxML_bestTree.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > ML bare 1`] = ` +[ + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-N", + 1, + "-p", + 123, + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > ML full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "d", + "-m", + "GTRGAMMA", + "--HKY85", + "-N", + 10, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-o", + "t1,t2", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], + [ + "-T", + 3, + "-f", + "e", + "-m", + "GTRGAMMA", + "--HKY85", + "-t", + ""C:\\out\\RAxML_bestTree.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], +] +`; + +exports[`RAxML args > ML+rBS alternate 1`] = ` +[ + [ + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > ML+rBS bare 1`] = ` +[ + [ + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 100, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > ML+rBS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "a", + "-x", + 123, + "-p", + 123, + "-N", + 200, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-O", + "-o", + "t1,t2", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML args > ML+tBS alternate 1`] = ` +[ + [ + "-b", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-p", + 123, + "-N", + 100, + "-O", + "-n", + "pinR.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "d", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-p", + 123, + "-N", + 1, + "-O", + "-n", + "pinB.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "b", + "-t", + ""C:\\out\\RAxML_bestTree.pinB.tre"", + "-z", + ""C:\\out\\RAxML_bootstrap.pinR.tre"", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > ML+tBS bare 1`] = ` +[ + [ + "-b", + 123, + "-m", + "GTRGAMMA", + "-p", + 123, + "-N", + 100, + "-n", + "pinR.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-p", + 123, + "-N", + 1, + "-n", + "pinB.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-f", + "b", + "-t", + ""C:\\out\\RAxML_bestTree.pinB.tre"", + "-z", + ""C:\\out\\RAxML_bootstrap.pinR.tre"", + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > ML+tBS full 1`] = ` +[ + [ + "-T", + 3, + "-b", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-p", + 123, + "-N", + 200, + "-O", + "-o", + "t1,t2", + "-n", + "pinR.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], + [ + "-T", + 3, + "-f", + "d", + "-m", + "GTRGAMMA", + "--HKY85", + "-p", + 123, + "-N", + 10, + "-O", + "-o", + "t1,t2", + "-n", + "pinB.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], + [ + "-T", + 3, + "-f", + "b", + "-t", + ""C:\\out\\RAxML_bestTree.pinB.tre"", + "-z", + ""C:\\out\\RAxML_bootstrap.pinR.tre"", + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > PD alternate 1`] = ` +[ + [ + "-f", + "x", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > PD bare 1`] = ` +[ + [ + "-f", + "x", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > PD full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "x", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-O", + "-t", + ""C:\\in\\start.tre"", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + ], +] +`; + +exports[`RAxML args > RBS alternate 1`] = ` +[ + [ + "-f", + "D", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`RAxML args > RBS bare 1`] = ` +[ + [ + "-f", + "D", + "-p", + 123, + "-m", + "GTRGAMMA", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`RAxML args > RBS full 1`] = ` +[ + [ + "-T", + 3, + "-f", + "D", + "-p", + 123, + "-m", + "GTRGAMMA", + "--HKY85", + "-k", + "-o", + "t1,t2", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\parts.txt"", + "-r", + ""C:\\in\\backbone.tre"", + "-g", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML-NG args > AS alternate 1`] = ` +[ + [ + "--ancestral", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--tree", + """", + ], +] +`; + +exports[`RAxML-NG args > AS bare 1`] = ` +[ + [ + "--ancestral", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--tree", + """", + ], +] +`; + +exports[`RAxML-NG args > AS full 1`] = ` +[ + [ + "--ancestral", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--tree", + ""C:\\in\\start.tre"", + ], +] +`; + +exports[`RAxML-NG args > CC alternate 1`] = ` +[ + [ + "--parse", + "--model", + ""C:\\in\\RAxML_pin.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + ], +] +`; + +exports[`RAxML-NG args > CC bare 1`] = ` +[ + [ + "--parse", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + ], +] +`; + +exports[`RAxML-NG args > CC full 1`] = ` +[ + [ + "--parse", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + "--tree-constraint", + ""C:\\in\\backbone.tre"", + "--tree-constraint", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con alternate 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\RAxML_pin.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--bs-metric", + "tbe", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con bare 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--bs-metric", + "tbe", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+TBE+con full 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--threads", + 3, + "--outgroup", + "t1,t2", + "--bs-metric", + "tbe", + "--tree", + "rand{10}", + "--bs-trees", + "autoMRE", + "--tree-constraint", + ""C:\\in\\backbone.tre"", + "--tree-constraint", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con alternate 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\RAxML_pin.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--bs-metric", + "fbp", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con bare 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--bs-metric", + "fbp", + "--tree", + "rand{1}", + "--bs-trees", + 100, + ], +] +`; + +exports[`RAxML-NG args > ML+tBS+con full 1`] = ` +[ + [ + "--all", + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--threads", + 3, + "--outgroup", + "t1,t2", + "--bs-metric", + "fbp", + "--tree", + "rand{10}", + "--bs-trees", + "autoMRE", + "--tree-constraint", + ""C:\\in\\backbone.tre"", + "--tree-constraint", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML-NG args > SC alternate 1`] = ` +[ + [ + "--check", + "--model", + ""C:\\in\\RAxML_pin.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + ], +] +`; + +exports[`RAxML-NG args > SC bare 1`] = ` +[ + [ + "--check", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + ], +] +`; + +exports[`RAxML-NG args > SC full 1`] = ` +[ + [ + "--check", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--msa", + ""C:\\in\\a.fasta"", + "--tree-constraint", + ""C:\\in\\backbone.tre"", + "--tree-constraint", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`RAxML-NG args > TI alternate 1`] = ` +[ + [ + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\RAxML_pin.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--tree", + "rand{1}", + ], +] +`; + +exports[`RAxML-NG args > TI bare 1`] = ` +[ + [ + "--msa", + ""C:\\in\\a.fasta"", + "--model", + "GTR+G", + "--prefix", + ""C:\\out\\pin"", + "--seed", + 123, + "--tree", + "rand{1}", + ], +] +`; + +exports[`RAxML-NG args > TI full 1`] = ` +[ + [ + "--msa", + ""C:\\in\\a.fasta"", + "--model", + ""C:\\in\\parts.txt"", + "--prefix", + ""C:\\out\\pin"", + "--threads", + 3, + "--seed", + 123, + "--outgroup", + "t1,t2", + "--tree", + "rand{10}", + "--tree-constraint", + ""C:\\in\\backbone.tre"", + "--tree-constraint", + ""C:\\in\\multifurcating.tre"", + ], +] +`; + +exports[`args for an analysis the builder does not know > RAxML 1`] = `[]`; + +exports[`args for an analysis the builder does not know > RAxML-NG 1`] = `[]`; + +exports[`args, branches the three variants miss > RAxML FT alternate with branch lengths 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + ""C:\\out\\RAxML_fastTree.pin.tre"", + "-n", + "brL.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], + [ + "-f", + "e", + "-m", + "ASC_MULTIGAMMA", + "--asc-corr=lewis", + "-K", + "MK", + "-t", + ""C:\\out\\RAxML_result.brL.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + "-q", + ""C:\\in\\RAxML_pin.part.txt"", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML FT with branch lengths and SH-like values on a default partition 1`] = ` +[ + [ + "-f", + "E", + "-p", + 123, + "-m", + "GTRGAMMA", + "-O", + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + ""C:\\out\\RAxML_fastTree.pin.tre"", + "-n", + "brL.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + ""C:\\out\\RAxML_result.brL.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML ML with SH-like values on a default partition 1`] = ` +[ + [ + "-f", + "d", + "-m", + "GTRGAMMA", + "-N", + 1, + "-O", + "-p", + 123, + "-n", + "pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], + [ + "-f", + "e", + "-m", + "GTRGAMMA", + "-t", + ""C:\\out\\RAxML_bestTree.pin.tre"", + "-n", + "sh.pin.tre", + "-s", + ""C:\\in\\a.fasta"", + "-w", + ""C:\\out"", + ], +] +`; + +exports[`args, branches the three variants miss > RAxML-NG AS with two alignments 1`] = ` +[ + [ + "--ancestral", + "--msa", + ""C:\\out\\RAxML_pin_concat.txt"", + "--model", + ""C:\\out\\RAxML_pin_concat.part.txt"", + "--prefix", + ""C:\\out\\pin"", + "--tree", + """", + ], +] +`; + +exports[`command and settings file > ASTRAL > command 1`] = `"java -jar astral.5.7.8.jar -i "C:\\in\\genes.tre" -o "C:\\out\\ASTRAL_pin.tre""`; + +exports[`command and settings file > ASTRAL > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + rapid bootstrap +Binary: astral.5.7.8.jar version 5.7.8 +Results saved to: C:\\out +RAxML was called with these arguments: +1.) -i "C:\\in\\genes.tre" -o "C:\\out\\ASTRAL_pin.tre" +" +`; + +exports[`command and settings file > ModelTest-NG > command 1`] = `"modeltest-ng.exe -d nt -i "C:\\in\\a.fasta" -o "C:\\out\\RAxML_GUI_ModelTest_pin" --force -p 3"`; + +exports[`command and settings file > ModelTest-NG > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + rapid bootstrap +Binary: modeltest-ng.exe version 0.1.7 +Results saved to: C:\\out +RAxML was called with these arguments: +1.) -d nt -i "C:\\in\\a.fasta" -o "C:\\out\\RAxML_GUI_ModelTest_pin" --force -p 3 +" +`; + +exports[`command and settings file > RAxML > command 1`] = ` +"raxmlHPC-PTHREADS-SSE3.exe -T 3 -b 123 -m GTRGAMMA --HKY85 -k -p 123 -N 200 -O -o t1,t2 -n pinR.tre -s "C:\\in\\a.fasta" -w "C:\\out" -q "C:\\in\\parts.txt" -r "C:\\in\\backbone.tre" -g "C:\\in\\multifurcating.tre" &&\\ +raxmlHPC-PTHREADS-SSE3.exe -T 3 -f d -m GTRGAMMA --HKY85 -p 123 -N 10 -O -o t1,t2 -n pinB.tre -s "C:\\in\\a.fasta" -w "C:\\out" -q "C:\\in\\parts.txt" -r "C:\\in\\backbone.tre" -g "C:\\in\\multifurcating.tre" &&\\ +raxmlHPC-PTHREADS-SSE3.exe -T 3 -f b -t "C:\\out\\RAxML_bestTree.pinB.tre" -z "C:\\out\\RAxML_bootstrap.pinR.tre" -m GTRGAMMA --HKY85 -O -n pin.tre -s "C:\\in\\a.fasta" -w "C:\\out"" +`; + +exports[`command and settings file > RAxML > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + thorough bootstrap +Binary: raxmlHPC-PTHREADS-SSE3.exe version 8.2.12 +Results saved to: C:\\out +RAxML was called with these arguments: +1.) -T 3 -b 123 -m GTRGAMMA --HKY85 -k -p 123 -N 200 -O -o t1,t2 -n pinR.tre -s "C:\\in\\a.fasta" -w "C:\\out" -q "C:\\in\\parts.txt" -r "C:\\in\\backbone.tre" -g "C:\\in\\multifurcating.tre" +2.) -T 3 -f d -m GTRGAMMA --HKY85 -p 123 -N 10 -O -o t1,t2 -n pinB.tre -s "C:\\in\\a.fasta" -w "C:\\out" -q "C:\\in\\parts.txt" -r "C:\\in\\backbone.tre" -g "C:\\in\\multifurcating.tre" +3.) -T 3 -f b -t "C:\\out\\RAxML_bestTree.pinB.tre" -z "C:\\out\\RAxML_bootstrap.pinR.tre" -m GTRGAMMA --HKY85 -O -n pin.tre -s "C:\\in\\a.fasta" -w "C:\\out" +" +`; + +exports[`command and settings file > RAxML-NG > command 1`] = `"raxml-ng.exe --all --msa "C:\\in\\a.fasta" --model "C:\\in\\parts.txt" --prefix "C:\\out\\pin" --seed 123 --outgroup t1,t2 --bs-metric tbe --tree rand{10} --bs-trees autoMRE --tree-constraint "C:\\in\\backbone.tre" --tree-constraint "C:\\in\\multifurcating.tre""`; + +exports[`command and settings file > RAxML-NG > settingsFileContent 1`] = ` +"The analysis was run using raxmlGUI 2.0 (version 2.0.0) as follows: +Analysis: ML + transfer bootstrap expectation + consensus +Binary: raxml-ng.exe version 1.2.2 +Results saved to: C:\\out +RAxML was called with these arguments: +1.) --all --msa "C:\\in\\a.fasta" --model "C:\\in\\parts.txt" --prefix "C:\\out\\pin" --seed 123 --outgroup t1,t2 --bs-metric tbe --tree rand{10} --bs-trees autoMRE --tree-constraint "C:\\in\\backbone.tre" --tree-constraint "C:\\in\\multifurcating.tre" +" +`; diff --git a/src/test/commandPins.ts b/src/test/commandPins.ts new file mode 100644 index 00000000..4f220199 --- /dev/null +++ b/src/test/commandPins.ts @@ -0,0 +1,251 @@ +// The command pins: the exact argument lists today's Run builds, one table for both platform test files. +// The store is imported inside pinCommands, so the Windows file can set the host first. +// This file must not import ./setup: after vi.resetModules that would install a second default bridge. +import { afterEach, describe, expect, it } from 'vitest'; + +import type Alignment from '../app/store/Alignment'; +import type AstralTree from '../app/store/AstralTree'; +import type Run from '../app/store/Run'; +import type { RendererBridge } from '../common/rendererBridge'; + +type RunParent = ConstructorParameters[0]; +type Variant = 'bare' | 'full' | 'alternate'; + +// The output name check resolves to the name it was asked for, and the app version is fixed. +export const pinBridge: Partial = { + checkOutput: ( { outputDir, outputName } ) => + Promise.resolve( { outputDir, outputName, ok: true, notice: '', outputNameUnused: outputName, resultFilenames: [] } ), + getVersion: () => Promise.resolve( '2.0.0' ), +}; + +export async function pinCommands( { windows }: { windows: boolean } ): Promise { + const { autorun, runInAction } = await import( 'mobx' ); + const { default: RunStore } = await import( '../app/store/Run' ); + const { analysisOptions, raxmlNgAnalysisOptions, binaries } = await import( '../app/store/RunOptions' ); + + const file = ( ...parts: string[] ): string => ( windows + ? `C:\\${parts.join( '\\' )}` + : `/${parts.join( '/' )}` ); + const exe = ( name: string ): string => ( windows + ? `${name}.exe` + : name ); + // The binary list depends on the host's platform, arch and CPU count, and ASTRAL is commented out of it. + // A binary the list lacks is added, so every pin runs on every machine. + const binary = ( name: string, type: string, version: string ): string => { + if ( !binaries.some( ( b ) => b.name === name ) ) { + binaries.push( { name, type, version } ); + } + return name; + }; + const names = { + raxml: binary( exe( 'raxmlHPC' ), 'raxml', '8.2.12' ), + raxmlThreads: binary( exe( 'raxmlHPC-PTHREADS-SSE3' ), 'raxml', '8.2.12' ), + raxmlNg: binary( exe( 'raxml-ng' ), 'raxml', '1.2.2' ), + // No shipped RAxML-NG binary has PTHREADS in its name, so only this stand-in reaches the --threads branch. + raxmlNgThreads: binary( exe( 'raxml-ng-PTHREADS' ), 'raxml', '1.2.2' ), + modeltest: binary( exe( 'modeltest-ng' ), 'modeltest', '0.1.7' ), + astral: binary( 'astral.5.7.8.jar', 'astral', '5.7.8' ), + }; + + const alignment = ( dataType = 'nucleotide', over: Record = {} ): Alignment => ( { + name: 'a', + path: file( 'in', 'a.fasta' ), + filename: 'a.fasta', + dir: file( 'in' ), + taxons: ['t1', 't2', 't3', 't4'], + length: 10, + dataType, + hasInvariantSites: false, + modeltestLoading: false, + ngSubstitutionModelCmd: 'GTR+G', + aaMatrixName: 'BLOSUM62', + partition: { isDefault: true, isComplete: true }, + ...over, + } as unknown as Alignment ); + + const variants: Record Alignment[]; set: ( run: Run ) => void }> = { + bare: { + alignments: () => [alignment()], + set: ( run ) => { + run.disableCheckUndeterminedSequence = false; + }, + }, + full: { + alignments: () => [alignment()], + set: ( run ) => { + run.partitionFile = file( 'in', 'parts.txt' ); + run.outGroup.setValue( ['t1', 't2'] ); + run.useBackboneConstraint = true; + run.useMultifurcatingConstraint = true; + run.backboneConstraint.setFilePath( file( 'in', 'backbone.tre' ) ); + run.multifurcatingConstraint.setFilePath( file( 'in', 'multifurcating.tre' ) ); + run.branchLength.setValue( true ); + run.sHlike.setValue( true ); + run.startingTree.setValue( 'User defined' ); + run.tree.setFilePath( file( 'in', 'start.tre' ) ); + run.substitutionMatrix.setValue( 'HKY' ); + run.numRuns.setValue( 10 ); + run.numRepetitions.setValue( 200 ); + run.numRepetitionsNg.setValue( 'autoMRE' ); + }, + }, + alternate: { + alignments: () => [alignment( 'multistate', { partition: { isDefault: false, isComplete: true } } )], + set: ( run ) => { + run.sHlike.setValue( true ); + run.multistateModel.setValue( 'MK' ); + run.substitutionAscertainment.setValue( "Lewis' method" ); + }, + }, + }; + + const stops: ( () => void )[] = []; + afterEach( () => { + while ( stops.length ) { + stops.pop()?.(); + } + } ); + + async function build( + binaryName: string, + analysis: string | undefined, + alignments: Alignment[], + set?: ( run: Run ) => void, + ): Promise { + const run = new RunStore( {} as RunParent, 1 ); + runInAction( () => { + run.binary.value = binaryName; + run.outputDir = file( 'out' ); + run.outputName = 'pin'; + run.alignments = alignments; + } ); + // analysis is a computed that builds its option; keep it observed so a set value sticks. + stops.push( autorun( () => run.analysis ) ); + // The output name check is async and only computes while observed. + stops.push( autorun( () => run.outputNameAvailable.get() ) ); + runInAction( () => { + if ( analysis ) { + run.analysis.setValue( analysis ); + } + run.setRandomSeed( 123 ); + run.numThreads.setValue( 3 ); + set?.( run ); + } ); + // Lets the output name check and the app version settle. + await new Promise( ( resolve ) => setTimeout( resolve, 0 ) ); + return run; + } + + // The output name only reads as settled inside a reaction. + function read( fn: () => T ): T { + let value!: T; + autorun( () => { + value = fn(); + } )(); + return value; + } + + const families = [ + { title: 'RAxML', options: analysisOptions, plain: names.raxml, threaded: names.raxmlThreads }, + { title: 'RAxML-NG', options: raxmlNgAnalysisOptions, plain: names.raxmlNg, threaded: names.raxmlNgThreads }, + ]; + for ( const { title, options, plain, threaded } of families ) { + describe( `${title} args`, () => { + for ( const { value } of options ) { + for ( const variant of ['bare', 'full', 'alternate'] as const ) { + it( `${value} ${variant}`, async () => { + const { alignments, set } = variants[variant]; + const run = await build( variant === 'full' + ? threaded + : plain, value, alignments(), set ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + } + } + } ); + } + + describe( 'args, branches the three variants miss', () => { + // The follow-up commands of fast tree search and ML search copy the first command's branches. + it( 'RAxML FT alternate with branch lengths', async () => { + const run = await build( names.raxml, 'FT', variants.alternate.alignments(), ( r ) => { + variants.alternate.set( r ); + r.branchLength.setValue( true ); + } ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + + it( 'RAxML FT with branch lengths and SH-like values on a default partition', async () => { + const run = await build( names.raxml, 'FT', [alignment()], ( r ) => { + r.branchLength.setValue( true ); + r.sHlike.setValue( true ); + } ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + + it( 'RAxML ML with SH-like values on a default partition', async () => { + const run = await build( names.raxml, 'ML', [alignment()], ( r ) => r.sHlike.setValue( true ) ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + + // RAxML-NG ancestral states chooses its partition by "more than one alignment", not by a non-default partition. + it( 'RAxML-NG AS with two alignments', async () => { + const second = alignment( 'nucleotide', { path: file( 'in', 'b.fasta' ), filename: 'b.fasta' } ); + const run = await build( names.raxmlNg, 'AS', [alignment(), second] ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + } ); + + // The empty default arm of each builder's switch. + describe( 'args for an analysis the builder does not know', () => { + for ( const [title, binaryName] of [['RAxML', names.raxml], ['RAxML-NG', names.raxmlNg]] ) { + it( title, async () => { + const run = await build( binaryName, 'unknown', [alignment()] ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + } + } ); + + describe( 'ModelTest-NG args', () => { + for ( const dataType of ['nucleotide', 'protein', 'binary'] ) { + it( dataType, async () => { + const run = await build( names.modeltest, undefined, [alignment( dataType )] ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + } + } ); + + const withAstralTree = ( run: Run ): void => { + run.astralTree = { path: file( 'in', 'genes.tre' ) } as AstralTree; + }; + + describe( 'ASTRAL args', () => { + it( 'with a loaded tree', async () => { + const run = await build( names.astral, undefined, [], withAstralTree ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + + it( 'without a tree', async () => { + const run = await build( names.astral, undefined, [] ); + expect( read( () => run.args ) ).toMatchSnapshot(); + } ); + } ); + + describe( 'command and settings file', () => { + const cases: [string, () => Promise][] = [ + // Thorough bootstrap is three commands, so the pin shows how they are joined. + ['RAxML', () => build( names.raxmlThreads, 'ML+tBS', variants.full.alignments(), variants.full.set )], + // The shipped binary: the full variant's stand-in name would be pinned into the command text. + ['RAxML-NG', () => build( names.raxmlNg, 'ML+TBE+con', variants.full.alignments(), variants.full.set )], + ['ModelTest-NG', () => build( names.modeltest, undefined, [alignment()] )], + ['ASTRAL', () => build( names.astral, undefined, [], withAstralTree )], + ]; + for ( const [title, make] of cases ) { + it( title, async () => { + const run = await make(); + expect( read( () => run.command ) ).toMatchSnapshot( 'command' ); + expect( read( () => run.settingsFileContent ) ).toMatchSnapshot( 'settingsFileContent' ); + } ); + } + } ); +} From 1a13b32027f70897a5c70ea7a282ba5149466b41 Mon Sep 17 00:00:00 2001 From: jtklein-agents Date: Sat, 28 Nov 2026 00:00:37 +0100 Subject: [PATCH 2/3] Move the ASTRAL and ModelTest-NG command builders out of Run.ts (#421) (#424) Co-authored-by: Claude Fable 5.2 --- src/app/store/Run.ts | 78 ++++------------------- src/app/store/command/astral.test.ts | 17 +++++ src/app/store/command/astral.ts | 20 ++++++ src/app/store/command/index.ts | 42 ++++++++++++ src/app/store/command/modeltestNg.test.ts | 29 +++++++++ src/app/store/command/modeltestNg.ts | 35 ++++++++++ 6 files changed, 157 insertions(+), 64 deletions(-) create mode 100644 src/app/store/command/astral.test.ts create mode 100644 src/app/store/command/astral.ts create mode 100644 src/app/store/command/index.ts create mode 100644 src/app/store/command/modeltestNg.test.ts create mode 100644 src/app/store/command/modeltestNg.ts diff --git a/src/app/store/Run.ts b/src/app/store/Run.ts index 6b55b8ca..e80b5d03 100644 --- a/src/app/store/Run.ts +++ b/src/app/store/Run.ts @@ -7,6 +7,10 @@ import FinalAlignment from './FinalAlignment'; import AstralTree from './AstralTree'; import StoreBase, { runEvents } from './StoreBase'; import { host } from './host'; +import { commandText, settingsText } from './command'; +import type { CmdArg } from './command'; +import { astralArgs } from './command/astral'; +import { modeltestNgArgs } from './command/modeltestNg'; import { binaries, analysisOptions, @@ -56,8 +60,6 @@ interface RunParent { interface FilePathEntry { path: string; } -// A CLI argument: seeds and thread counts are pushed as numbers. -type CmdArg = string | number; class Run extends StoreBase { parent: RunParent; @@ -484,10 +486,10 @@ class Run extends StoreBase { get args(): CmdArg[][] { if ( this.usesAstral ) { - return this.astralArgs(); + return astralArgs( this, { windows } ); } if ( this.usesModeltestNg ) { - return this.modeltestNgArgs(); + return modeltestNgArgs( this, { windows } ); } if ( this.usesRaxmlNg ) { return this.raxmlNgArgs(); @@ -570,43 +572,6 @@ class Run extends StoreBase { return model; } - astralArgs = (): string[][] => { - const first: string[] = []; - if ( this.astralTree ) { - first.push( '-i', quote( this.astralTree.path, { windows } ) ); - } - first.push( - '-o', - quote( join( this.outputDir, `ASTRAL_${this.outputNameSafe}.tre` ), { windows } ), - ); - return [first]; - }; - - modeltestNgArgs = (): CmdArg[][] => { - const first: CmdArg[] = []; - // data type - if ( this.dataType === 'nucleotide' ) { - first.push( '-d', 'nt' ); - } else if ( this.dataType === 'protein' ) { - first.push( '-d', 'aa' ); - } - // alignment file - first.push( '-i', quote( this.finalAlignment.path, { windows } ) ); - // output file, modeltest errors if this file already exists - first.push( - '-o', - quote( join( this.outputDir, `RAxML_GUI_ModelTest_${this.outputNameSafe}` ), { windows } ), - ); - // modeltest throws errors if the output file already exists - first.push( '--force' ); - // Number of processors - first.push( '-p', this.numThreads.value ); - // TODO: in able to support partitioned modeltest we need to change the partition file text - // https://github.com/ddarriba/modeltest/wiki/Input-Data#partition-files - // partition scheme - return [first]; - }; - raxmlNgArgs = (): CmdArg[][] => { const first: CmdArg[] = []; const second: CmdArg[] = []; @@ -1303,32 +1268,17 @@ class Run extends StoreBase { }; get command(): string { - if ( this.usesAstral ) { - return this.args - .map( ( cmdArgs ) => `java -jar ${this.binary.value} ${cmdArgs.join( ' ' )}` ) - .join( ' &&\\\n' ); - } - return this.args - .map( ( cmdArgs ) => `${this.binary.value} ${cmdArgs.join( ' ' )}` ) - .join( ' &&\\\n' ); + return commandText( this.binary.value, this.args, this.usesAstral ); } get settingsFileContent(): string { - let text = `The analysis was run using raxmlGUI 2.0 (version ${this.version}) as follows: -Analysis: ${this.analysisOption.title} -Binary: ${this.binary.value} version ${this.binary.version} -Results saved to: ${this.outputDir} -`; - let argumentext = 'RAxML was called with these arguments:\n'; - this.args.map( - ( arg, index ) => ( argumentext += `${index + 1}.) ${arg.join( ' ' )}\n` ), - ); - text += argumentext; - // TODO: should we be more precise about what the single params mean? - // text += `To repeat the analysis use the following seeds: - // Bootstrap seed: ${this.seedBootstrap} - // Parsimony seed: ${this.seedParsimony}`; - return text; + return settingsText( { + appVersion: this.version, + analysisTitle: this.analysisOption.title, + binary: this.binary, + outputDir: this.outputDir, + args: this.args, + } ); } get settingsFilePath(): string { diff --git a/src/app/store/command/astral.test.ts b/src/app/store/command/astral.test.ts new file mode 100644 index 00000000..6de5d880 --- /dev/null +++ b/src/app/store/command/astral.test.ts @@ -0,0 +1,17 @@ +import { expect, it } from 'vitest'; + +import { astralArgs } from './astral'; + +it( 'astralArgs quotes paths on Windows', () => { + const run = { astralTree: { path: 'C:\\in\\genes.tre' }, outputDir: 'C:\\out', outputNameSafe: 'run1' }; + expect( astralArgs( run, { windows: true } ) ).toEqual( [ + ['-i', '"C:\\in\\genes.tre"', '-o', '"C:\\out\\ASTRAL_run1.tre"'], + ] ); +} ); + +it( 'astralArgs leaves paths bare off Windows', () => { + const run = { astralTree: { path: '/in/genes.tre' }, outputDir: '/out', outputNameSafe: 'run1' }; + expect( astralArgs( run, { windows: false } ) ).toEqual( [ + ['-i', '/in/genes.tre', '-o', '/out/ASTRAL_run1.tre'], + ] ); +} ); diff --git a/src/app/store/command/astral.ts b/src/app/store/command/astral.ts new file mode 100644 index 00000000..9f9ede31 --- /dev/null +++ b/src/app/store/command/astral.ts @@ -0,0 +1,20 @@ +import { join, quote } from '../../paths'; +import type { Platform } from './index'; + +export interface AstralInput { + outputDir: string; + outputNameSafe: string; + astralTree: { path: string } | null | undefined; +} + +export const astralArgs = ( run: AstralInput, { windows }: Platform ): string[][] => { + const first: string[] = []; + if ( run.astralTree ) { + first.push( '-i', quote( run.astralTree.path, { windows } ) ); + } + first.push( + '-o', + quote( join( run.outputDir, `ASTRAL_${run.outputNameSafe}.tre` ), { windows } ), + ); + return [first]; +}; diff --git a/src/app/store/command/index.ts b/src/app/store/command/index.ts new file mode 100644 index 00000000..40e960af --- /dev/null +++ b/src/app/store/command/index.ts @@ -0,0 +1,42 @@ +// A CLI argument: seeds and thread counts are pushed as numbers. +export type CmdArg = string | number; + +// Shaped like the second argument `quote` takes. +export interface Platform { + windows: boolean; +} + +export const commandText = ( binary: string, args: CmdArg[][], usesAstral: boolean ): string => { + if ( usesAstral ) { + return args + .map( ( cmdArgs ) => `java -jar ${binary} ${cmdArgs.join( ' ' )}` ) + .join( ' &&\\\n' ); + } + return args + .map( ( cmdArgs ) => `${binary} ${cmdArgs.join( ' ' )}` ) + .join( ' &&\\\n' ); +}; + +export const settingsText = ( { appVersion, analysisTitle, binary, outputDir, args }: { + appVersion: string | undefined; + analysisTitle: string; + binary: { value: string; version: string | undefined }; + outputDir: string; + args: CmdArg[][]; +} ): string => { + let text = `The analysis was run using raxmlGUI 2.0 (version ${appVersion}) as follows: +Analysis: ${analysisTitle} +Binary: ${binary.value} version ${binary.version} +Results saved to: ${outputDir} +`; + let argumentext = 'RAxML was called with these arguments:\n'; + args.map( + ( arg, index ) => ( argumentext += `${index + 1}.) ${arg.join( ' ' )}\n` ), + ); + text += argumentext; + // TODO: should we be more precise about what the single params mean? + // text += `To repeat the analysis use the following seeds: + // Bootstrap seed: ${this.seedBootstrap} + // Parsimony seed: ${this.seedParsimony}`; + return text; +}; diff --git a/src/app/store/command/modeltestNg.test.ts b/src/app/store/command/modeltestNg.test.ts new file mode 100644 index 00000000..14bb9bf6 --- /dev/null +++ b/src/app/store/command/modeltestNg.test.ts @@ -0,0 +1,29 @@ +import { expect, it } from 'vitest'; + +import { modeltestNgArgs } from './modeltestNg'; + +it( 'modeltestNgArgs quotes paths on Windows', () => { + const run = { + dataType: 'protein', + finalAlignment: { path: 'C:\\in\\aln.phy' }, + outputDir: 'C:\\out', + outputNameSafe: 'run1', + numThreads: { value: 4 }, + }; + expect( modeltestNgArgs( run, { windows: true } ) ).toEqual( [ + ['-d', 'aa', '-i', '"C:\\in\\aln.phy"', '-o', '"C:\\out\\RAxML_GUI_ModelTest_run1"', '--force', '-p', 4], + ] ); +} ); + +it( 'modeltestNgArgs leaves paths bare off Windows', () => { + const run = { + dataType: 'nucleotide', + finalAlignment: { path: '/in/aln.phy' }, + outputDir: '/out', + outputNameSafe: 'run1', + numThreads: { value: 2 }, + }; + expect( modeltestNgArgs( run, { windows: false } ) ).toEqual( [ + ['-d', 'nt', '-i', '/in/aln.phy', '-o', '/out/RAxML_GUI_ModelTest_run1', '--force', '-p', 2], + ] ); +} ); diff --git a/src/app/store/command/modeltestNg.ts b/src/app/store/command/modeltestNg.ts new file mode 100644 index 00000000..80a188b2 --- /dev/null +++ b/src/app/store/command/modeltestNg.ts @@ -0,0 +1,35 @@ +import { join, quote } from '../../paths'; +import type { CmdArg, Platform } from './index'; + +export interface ModeltestNgInput { + outputDir: string; + outputNameSafe: string; + dataType: string | undefined; + finalAlignment: { path: string }; + numThreads: { value: number }; +} + +export const modeltestNgArgs = ( run: ModeltestNgInput, { windows }: Platform ): CmdArg[][] => { + const first: CmdArg[] = []; + // data type + if ( run.dataType === 'nucleotide' ) { + first.push( '-d', 'nt' ); + } else if ( run.dataType === 'protein' ) { + first.push( '-d', 'aa' ); + } + // alignment file + first.push( '-i', quote( run.finalAlignment.path, { windows } ) ); + // output file, modeltest errors if this file already exists + first.push( + '-o', + quote( join( run.outputDir, `RAxML_GUI_ModelTest_${run.outputNameSafe}` ), { windows } ), + ); + // modeltest throws errors if the output file already exists + first.push( '--force' ); + // Number of processors + first.push( '-p', run.numThreads.value ); + // TODO: in able to support partitioned modeltest we need to change the partition file text + // https://github.com/ddarriba/modeltest/wiki/Input-Data#partition-files + // partition scheme + return [first]; +}; From 966414f198d894c8f1d4d1a68a428da36300e193 Mon Sep 17 00:00:00 2001 From: jtklein-agents Date: Sat, 28 Nov 2026 00:15:03 +0100 Subject: [PATCH 3/3] Move the RAxML and RAxML-NG command builders out of Run.ts (#422) (#425) raxmlNgArgs and raxmlArgs move to command/raxmlNg.ts and command/raxml.ts with this. replaced by run. and no other edit. The args getter's dispatch moves to commandArgs in command/index.ts. One direct test per builder runs it on a plain object for both platforms. Co-authored-by: Claude Fable 5.2 --- src/app/store/Run.ts | 713 +------------------------- src/app/store/command/index.ts | 46 ++ src/app/store/command/raxml.test.ts | 96 ++++ src/app/store/command/raxml.ts | 521 +++++++++++++++++++ src/app/store/command/raxmlNg.test.ts | 60 +++ src/app/store/command/raxmlNg.ts | 218 ++++++++ 6 files changed, 944 insertions(+), 710 deletions(-) create mode 100644 src/app/store/command/raxml.test.ts create mode 100644 src/app/store/command/raxml.ts create mode 100644 src/app/store/command/raxmlNg.test.ts create mode 100644 src/app/store/command/raxmlNg.ts diff --git a/src/app/store/Run.ts b/src/app/store/Run.ts index e80b5d03..9a232252 100644 --- a/src/app/store/Run.ts +++ b/src/app/store/Run.ts @@ -7,10 +7,8 @@ import FinalAlignment from './FinalAlignment'; import AstralTree from './AstralTree'; import StoreBase, { runEvents } from './StoreBase'; import { host } from './host'; -import { commandText, settingsText } from './command'; +import { commandArgs, commandText, settingsText } from './command'; import type { CmdArg } from './command'; -import { astralArgs } from './command/astral'; -import { modeltestNgArgs } from './command/modeltestNg'; import { binaries, analysisOptions, @@ -41,8 +39,7 @@ import { } from './RunOptions'; import type { AnalysisChoice } from './RunOptions'; import type { DataType } from '../../common/typecheckAlignment'; -import { basename, join, quote } from '../paths'; -import remove from 'lodash/remove'; +import { basename, join } from '../paths'; import UserFixError from '../../common/errors'; import type { ErrorObject } from 'serialize-error'; import type { AstralSuccessPayload } from '../../main/astral'; @@ -485,16 +482,7 @@ class Run extends StoreBase { }; get args(): CmdArg[][] { - if ( this.usesAstral ) { - return astralArgs( this, { windows } ); - } - if ( this.usesModeltestNg ) { - return modeltestNgArgs( this, { windows } ); - } - if ( this.usesRaxmlNg ) { - return this.raxmlNgArgs(); - } - return this.raxmlArgs(); + return commandArgs( this, { windows } ); } get ngSubstitutionModelCmd(): string { @@ -572,701 +560,6 @@ class Run extends StoreBase { return model; } - raxmlNgArgs = (): CmdArg[][] => { - const first: CmdArg[] = []; - const second: CmdArg[] = []; - const third: CmdArg[] = []; - const cmdArgs = [first, second, third]; // Possibly empty ones removed in the end - switch ( this.analysis.value ) { - case 'SC': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#preparing-the-alignment - first.push( '--check' ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.backboneConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.backboneConstraint.filePath, { windows } ), - ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.multifurcatingConstraint.filePath, { windows } ), - ); - } - break; - case 'CC': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#preparing-the-alignment - first.push( '--parse' ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.backboneConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.backboneConstraint.filePath, { windows } ), - ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.multifurcatingConstraint.filePath, { windows } ), - ); - } - break; - case 'TI': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#tree-inference - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - if ( !this.numThreads.notAvailable ) { - first.push( '--threads', this.numThreads.value ); - } - first.push( '--seed', this.seedParsimony ); - if ( this.outGroup.cmdValue ) { - first.push( '--outgroup', this.outGroup.cmdValue ); - } - first.push( '--tree', `rand{${this.numRuns.value}}` ); - if ( this.backboneConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.backboneConstraint.filePath, { windows } ), - ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.multifurcatingConstraint.filePath, { windows } ), - ); - } - break; - case 'ML+tBS+con': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping - // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe - first.push( '--all' ); - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - first.push( '--seed', this.seedParsimony ); - if ( !this.numThreads.notAvailable ) { - first.push( '--threads', this.numThreads.value ); - } - if ( this.outGroup.cmdValue ) { - first.push( '--outgroup', this.outGroup.cmdValue ); - } - first.push( '--bs-metric', 'fbp' ); - first.push( '--tree', `rand{${this.numRuns.value}}` ); - first.push( '--bs-trees', this.numRepetitionsNg.value ); - if ( this.backboneConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.backboneConstraint.filePath, { windows } ), - ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.multifurcatingConstraint.filePath, { windows } ), - ); - } - break; - case 'ML+TBE+con': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping - // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe - first.push( '--all' ); - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - first.push( '--seed', this.seedParsimony ); - if ( !this.numThreads.notAvailable ) { - first.push( '--threads', this.numThreads.value ); - } - if ( this.outGroup.cmdValue ) { - first.push( '--outgroup', this.outGroup.cmdValue ); - } - first.push( '--bs-metric', 'tbe' ); - first.push( '--tree', `rand{${this.numRuns.value}}` ); - first.push( '--bs-trees', this.numRepetitionsNg.value ); - if ( this.backboneConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.backboneConstraint.filePath, { windows } ), - ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( - '--tree-constraint', - quote( this.multifurcatingConstraint.filePath, { windows } ), - ); - } - break; - case 'AS': - // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping - // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe - first.push( '--ancestral' ); - first.push( '--msa', quote( this.finalAlignment.path, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '--model', quote( this.partitionFile, { windows } ) ); - } else if ( this.alignments.length > 1 ) { - first.push( '--model', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } else { - first.push( '--model', this.ngSubstitutionModelCmd ); - } - first.push( - '--prefix', - quote( join( this.outputDir, this.outputNameSafe ), { windows } ), - ); - first.push( '--tree', quote( this.tree.filePath, { windows } ) ); - break; - default: - } - // Remove items that are only empty strings - cmdArgs.forEach( ( args ) => remove( args, ( n ) => n === '' ) ); - return cmdArgs.filter( ( args ) => args.length > 0 ); - }; - - raxmlArgs = (): CmdArg[][] => { - const first: CmdArg[] = []; - const second: CmdArg[] = []; - const third: CmdArg[] = []; - const cmdArgs = [first, second, third]; // Possibly empty ones removed in the end - - switch ( this.analysis.value ) { - case 'FT': // Fast tree search - // params: [params.brL, params.SHlike, params.outGroup], - // cmd= """cd %s %s &&%s %s -f E -p %s %s -n %s -s %s -O -w %s %s %s %s %s""" \ - // % (winD, raxml_path, K[0], pro, seed_1, mod, out_file, seq_file, path_dir, part_f, cmd_temp1,cmd_temp2, winEx) - //TODO: Where is outGroup? From line 1436 in original code, -o is unchecked - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'E' ); - first.push( '-p', this.seedParsimony ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.branchLength.value ) { - const treeFile1 = join( - this.outputDir, - `RAxML_fastTree.${this.outputFilenameSafe}`, - ); - const next: CmdArg[] = []; - if ( !this.numThreads.notAvailable ) { - next.push( '-T', this.numThreads.value ); - } - next.push( '-f', 'e' ); - next.push( '-m', this.raxmlSubstitutionModelCmd ); - next.push( this.substitutionMatrix.extraCmdValue ); - next.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - next.push( '-K', this.multistateModel.value ); - } - next.push( '-t', quote( treeFile1, { windows } ) ); - next.push( '-n', `brL.${this.outputFilenameSafe}` ); - next.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - next.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - next.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - next.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - cmdArgs.push( next ); - } - if ( this.sHlike.value ) { - const treeFile2 = this.branchLength.value - ? join( - this.outputDir, - `RAxML_result.brL.${this.outputFilenameSafe}`, - ) - : join( this.outputDir, `RAxML_fastTree.${this.outputFilenameSafe}` ); - const next: CmdArg[] = []; - if ( !this.numThreads.notAvailable ) { - next.push( '-T', this.numThreads.value ); - } - next.push( '-f', 'e' ); - next.push( '-m', this.raxmlSubstitutionModelCmd ); - next.push( this.substitutionMatrix.extraCmdValue ); - next.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - next.push( '-K', this.multistateModel.value ); - } - next.push( '-t', quote( treeFile2, { windows } ) ); - next.push( '-n', `sh.${this.outputFilenameSafe}` ); - next.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - next.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - next.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - next.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - cmdArgs.push( next ); - } - break; - case 'ML': // ML search - // params: [params.SHlike, params.combinedOutput, params.outGroup], - // cmd= """cd %s %s&&%s %s -f d %s -N %s -O -p %s %s -s %s -n %s %s -w %s %s %s %s %s %s""" \ - // % (winD, raxml_path, K[0], pro, mod, BSrep2.get(), random.randrange(1, 1000, 1), o, seq_file, out_file, part_f, path_dir, const_f, result2, cmd_temp2, combine_trees, winEx) - //TODO: Check conf_f (from line 754 in original source) - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'd' ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - first.push( '-N', this.numRuns.value ); - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - first.push( '-p', this.seedParsimony ); - first.push( '-n', this.outputFilenameSafe ); - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - first.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - if ( this.sHlike.value ) { - const treeFile = join( - this.outputDir, - `RAxML_bestTree.${this.outputFilenameSafe}`, - ); - const next: CmdArg[] = []; - if ( !this.numThreads.notAvailable ) { - next.push( '-T', this.numThreads.value ); - } - next.push( '-f', 'e' ); - next.push( '-m', this.raxmlSubstitutionModelCmd ); - next.push( this.substitutionMatrix.extraCmdValue ); - next.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - next.push( '-K', this.multistateModel.value ); - } - next.push( '-t', quote( treeFile, { windows } ) ); - next.push( '-n', `sh.${this.outputFilenameSafe}` ); - next.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - next.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - next.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - next.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - cmdArgs.push( next ); - } - break; - case 'ML+rBS': // ML + rapid bootstrap - // params: [params.reps, params.brL, params.outGroup], - // cmd= """cd %s %s&& %s %s %s -f a -x %s %s %s -p %s -N %s %s -s %s -n %s %s -O -w %s %s %s %s""" \ - // % (winD, raxml_path, runWin, K[0], pro, seed_1, save_brL.get(),mod, seed_2, BSrep.get(), o, seq_file, out_file, \ - // part_f, path_dir, const_f, result, winEx) - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'a' ); - first.push( '-x', this.seedRapidBootstrap ); - first.push( '-p', this.seedParsimony ); - first.push( '-N', this.numRepetitions.value ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.branchLength.value ) { - first.push( '-k' ); - } - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - first.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - break; - case 'ML+tBS': { // ML + thorough bootstrap - // params: [params.runs, params.reps, params.brL, params.outGroup], - // cmd= """cd %s %s \ - // &&%s %s -b %s %s %s -p %s -N %s %s -s %s -n %s %s -w %s %s -O && cd %s \ - // &&%s %s -f d %s %s -s %s -N %s -n %s %s -w %s %s -p %s -O && cd %s \ - // &&%s %s -f b -t %s -z %s %s -s %s -n %s -w %s %s -O %s""" \ - // % (winD, raxml_path, K[0], pro, seed_1, mod, save_brL.get(),seed_2, BSrep.get(), o, seq_file, out_file1, part_f, path_dir, const_f,\ - // raxml_path, K[0], pro, mod, o, seq_file, BSrep2.get(), out_file2, part_f, path_dir, const_f,random.randrange(1, 1000, 1), \ - // raxml_path, K[0], pro, MLtreeR, trees, mod, seq_file, out_file, path_dir, result, winEx) - // try: - // remove="RAxML_info.%s.tre" % (only_name) - // ... - const outputFilenameSafe1 = `${this.outputNameSafe}R.tre`; - const outputFilenameSafe2 = `${this.outputNameSafe}B.tre`; - const treeFile = join( - this.outputDir, - `RAxML_bestTree.${outputFilenameSafe2}`, - ); // MLtreeR - const treesFile = join( - this.outputDir, - `RAxML_bootstrap.${outputFilenameSafe1}`, - ); // trees - // first wrote RAxML_bootstrap.binary_8R.tre - // second wrote RAxML_bootstrap.binary_8B.tre - - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-b', this.seedBootstrap ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.branchLength.value ) { - first.push( '-k' ); - } - first.push( '-p', this.seedParsimony ); - first.push( '-N', this.numRepetitions.value ); - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - first.push( '-n', outputFilenameSafe1 ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - first.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - - if ( !this.numThreads.notAvailable ) { - second.push( '-T', this.numThreads.value ); - } - second.push( '-f', 'd' ); - second.push( '-m', this.raxmlSubstitutionModelCmd ); - second.push( this.substitutionMatrix.extraCmdValue ); - second.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - second.push( '-K', this.multistateModel.value ); - } - second.push( '-p', this.seedParsimony ); - second.push( '-N', this.numRuns.value ); - if ( this.disableCheckUndeterminedSequence ) { - second.push( '-O' ); - } - if ( this.outGroup.cmdValue ) { - second.push( '-o', this.outGroup.cmdValue ); - } - second.push( '-n', outputFilenameSafe2 ); - second.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - second.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - second.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - second.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - second.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - second.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - - if ( !this.numThreads.notAvailable ) { - third.push( '-T', this.numThreads.value ); - } - third.push( '-f', 'b' ); - third.push( '-t', quote( treeFile, { windows } ) ); - third.push( '-z', quote( treesFile, { windows } ) ); - third.push( '-m', this.raxmlSubstitutionModelCmd ); - third.push( this.substitutionMatrix.extraCmdValue ); - third.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - third.push( '-K', this.multistateModel.value ); - } - if ( this.disableCheckUndeterminedSequence ) { - third.push( '-O' ); - } - third.push( '-n', this.outputFilenameSafe ); - third.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - third.push( '-w', quote( this.outputDir, { windows } ) ); - - break; - } - case 'BS+con': { // Bootstrap + consensus - // params: [params.reps, params.brL, params.outGroup], - // BStrees_file= """ "%sRAxML_bootstrap.%s" """ % (path_dirsimple, out_file) - // cmd= """cd %s %s \ - // && %s %s %s %s -n %s -s %s %s -x %s -N %s -w %s %s %s -p %s -O && cd %s\ - // && %s %s %s -n con.%s -J MR -z %s -w %s %s - // """ \ - // % (winD, raxml_path, \ - // K[0], pro, mod, save_brL.get(), out_file, seq_file, o, seed_1, BSrep.get(), path_dir, part_f, const_f, random.randrange(1, 1000, 1), raxml_path, \ - // K[0], pro, mod, out_file, BStrees_file, path_dir, winEx) - - const bsTreeFile = join( - this.outputDir, - `RAxML_bootstrap.${this.outputFilenameSafe}`, - ); - const consensusOutput = `consensus.${this.outputFilenameSafe}`; - - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - if ( this.branchLength.value ) { - first.push( '-k' ); - } - first.push( '-x', this.seedRapidBootstrap ); - first.push( '-p', this.seedParsimony ); - first.push( '-N', this.numRepetitions.value ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - first.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - - if ( !this.numThreads.notAvailable ) { - second.push( '-T', this.numThreads.value ); - } - second.push( '-m', this.raxmlSubstitutionModelCmd ); - second.push( this.substitutionMatrix.extraCmdValue ); - second.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - second.push( '-K', this.multistateModel.value ); - } - second.push( '-J', 'MR' ); - second.push( '-w', quote( this.outputDir, { windows } ) ); - second.push( '-z', quote( bsTreeFile, { windows } ) ); - second.push( '-n', consensusOutput ); - if ( this.backboneConstraint.isSet ) { - second.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - second.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - break; - } - case 'AS': // Ancestral states - // params: [params.tree], - // cmd = """cd %s %s &&%s %s -f A -t "%s" -s %s %s -n %s -O -w %s %s %s""" \ - // % (winD, raxml_path, K[0], pro, rooted_tree, seq_file, mod, out_file, path_dir, part_f, winEx) - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'A' ); - first.push( '-t', quote( this.tree.filePath, { windows } ) ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - break; - case 'PD': // Pairwise distances - // params: [params.startingTree], - // # "./raxmlHPC -f x -m GTRGAMMA[I] -n NAME -s INPUT -p RANDOMNR [-q PARTFILE -o OUTGROUP]" - // cmd = """cd %s %s &&%s %s -f x -p %s %s -s %s %s -n %s %s -O -w %s %s %s""" \ - // % (winD, raxml_path, K[0], pro, seed_1, const_f, seq_file, mod, out_file, o, path_dir, part_f, winEx) - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'x' ); - first.push( '-p', this.seedParsimony ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - if ( !this.tree.notAvailable ) { - first.push( '-t', quote( this.tree.filePath, { windows } ) ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - break; - case 'RBS': // Rell bootstraps - // params: [params.reps, params.brL, params.outGroup], - // # "./raxmlHPC -f x -m GTRGAMMA[I] -n NAME -s INPUT -p RANDOMNR [-q PARTFILE -o OUTGROUP]" - // cmd = """cd %s %s &&%s %s -f D -p %s %s -s %s %s -n %s %s -O -w %s %s %s""" \ - // % (winD, raxml_path, K[0], pro, seed_1, const_f, seq_file, mod, out_file, o, path_dir, part_f, winEx) - if ( !this.numThreads.notAvailable ) { - first.push( '-T', this.numThreads.value ); - } - first.push( '-f', 'D' ); - first.push( '-p', this.seedParsimony ); - first.push( '-m', this.raxmlSubstitutionModelCmd ); - first.push( this.substitutionMatrix.extraCmdValue ); - first.push( this.substitutionAscertainment.extraCmdValue ); - if ( this.branchLength.value ) { - first.push( '-k' ); - } - if ( this.outGroup.cmdValue ) { - first.push( '-o', this.outGroup.cmdValue ); - } - if ( !this.multistateModel.notAvailable ) { - first.push( '-K', this.multistateModel.value ); - } - if ( this.disableCheckUndeterminedSequence ) { - first.push( '-O' ); - } - first.push( '-n', this.outputFilenameSafe ); - first.push( '-s', quote( this.finalAlignment.path, { windows } ) ); - // if (!this.tree.notAvailable) { - // first.push('-t', this.tree.filePath); - // } - first.push( '-w', quote( this.outputDir, { windows } ) ); - if ( this.havePartitionFile ) { - first.push( '-q', quote( this.partitionFile, { windows } ) ); - } else if ( !this.finalAlignment.partition.isDefault ) { - first.push( '-q', quote( this.finalAlignment.partitionFilePath, { windows } ) ); - } - if ( this.backboneConstraint.isSet ) { - first.push( '-r', quote( this.backboneConstraint.filePath, { windows } ) ); - } - if ( this.multifurcatingConstraint.isSet ) { - first.push( '-g', quote( this.multifurcatingConstraint.filePath, { windows } ) ); - } - break; - default: - } - // Remove items that are only empty strings - cmdArgs.forEach( ( args ) => remove( args, ( n ) => n === '' ) ); - return cmdArgs.filter( ( args ) => args.length > 0 ); - }; - get command(): string { return commandText( this.binary.value, this.args, this.usesAstral ); } diff --git a/src/app/store/command/index.ts b/src/app/store/command/index.ts index 40e960af..295a9fb2 100644 --- a/src/app/store/command/index.ts +++ b/src/app/store/command/index.ts @@ -1,3 +1,12 @@ +import { astralArgs } from './astral'; +import type { AstralInput } from './astral'; +import { modeltestNgArgs } from './modeltestNg'; +import type { ModeltestNgInput } from './modeltestNg'; +import { raxmlArgs } from './raxml'; +import type { RaxmlInput } from './raxml'; +import { raxmlNgArgs } from './raxmlNg'; +import type { RaxmlNgInput } from './raxmlNg'; + // A CLI argument: seeds and thread counts are pushed as numbers. export type CmdArg = string | number; @@ -6,6 +15,43 @@ export interface Platform { windows: boolean; } +// The partition choice, read by both RAxML builders. +export interface PartitionInput { + havePartitionFile: boolean; + partitionFile: string; + finalAlignment: { + path: string; + partitionFilePath: string; + partition: { isDefault: boolean }; + }; +} + +// The two constraint trees, read by both RAxML builders. +export interface ConstraintInput { + backboneConstraint: { isSet: boolean; filePath: string }; + multifurcatingConstraint: { isSet: boolean; filePath: string }; +} + +// An intersection, not `extends`: the builders read different parts of `tree`. +export type CommandInput = AstralInput & ModeltestNgInput & RaxmlNgInput & RaxmlInput & { + usesAstral: boolean; + usesModeltestNg: boolean; + usesRaxmlNg: boolean; +}; + +export const commandArgs = ( run: CommandInput, platform: Platform ): CmdArg[][] => { + if ( run.usesAstral ) { + return astralArgs( run, platform ); + } + if ( run.usesModeltestNg ) { + return modeltestNgArgs( run, platform ); + } + if ( run.usesRaxmlNg ) { + return raxmlNgArgs( run, platform ); + } + return raxmlArgs( run, platform ); +}; + export const commandText = ( binary: string, args: CmdArg[][], usesAstral: boolean ): string => { if ( usesAstral ) { return args diff --git a/src/app/store/command/raxml.test.ts b/src/app/store/command/raxml.test.ts new file mode 100644 index 00000000..440766a4 --- /dev/null +++ b/src/app/store/command/raxml.test.ts @@ -0,0 +1,96 @@ +import { expect, it } from 'vitest'; + +import { raxmlArgs } from './raxml'; + +const base = { + analysis: { value: 'PD' }, + outputNameSafe: 'run1', + outputFilenameSafe: 'run1.tre', + raxmlSubstitutionModelCmd: 'GTRGAMMA', + numThreads: { notAvailable: false, value: 2 }, + seedParsimony: 123, + seedRapidBootstrap: 456, + seedBootstrap: 789, + // Empty extra values are dropped from the command + substitutionMatrix: { extraCmdValue: '' }, + substitutionAscertainment: { extraCmdValue: '' }, + multistateModel: { notAvailable: true, value: '' }, + disableCheckUndeterminedSequence: true, + outGroup: { cmdValue: '' }, + branchLength: { value: false }, + sHlike: { value: false }, + numRuns: { value: 1 }, + numRepetitions: { value: 100 }, + backboneConstraint: { isSet: false, filePath: '' }, + multifurcatingConstraint: { isSet: false, filePath: '' }, +}; + +it( 'raxmlArgs quotes paths on Windows', () => { + const run = { + ...base, + havePartitionFile: true, + partitionFile: 'C:\\in\\my.part', + finalAlignment: { + path: 'C:\\in\\aln.phy', + partitionFilePath: 'C:\\in\\aln.part', + partition: { isDefault: true }, + }, + outputDir: 'C:\\out', + tree: { notAvailable: false, filePath: 'C:\\in\\start.tre' }, + }; + expect( raxmlArgs( run, { windows: true } ) ).toEqual( [[ + '-T', + 2, + '-f', + 'x', + '-p', + 123, + '-m', + 'GTRGAMMA', + '-O', + '-t', + '"C:\\in\\start.tre"', + '-n', + 'run1.tre', + '-s', + '"C:\\in\\aln.phy"', + '-w', + '"C:\\out"', + '-q', + '"C:\\in\\my.part"', + ]] ); +} ); + +it( 'raxmlArgs leaves paths bare off Windows', () => { + const run = { + ...base, + havePartitionFile: false, + partitionFile: '', + finalAlignment: { + path: '/in/aln.phy', + partitionFilePath: '/in/aln.part', + partition: { isDefault: false }, + }, + outputDir: '/out', + tree: { notAvailable: true, filePath: '' }, + }; + expect( raxmlArgs( run, { windows: false } ) ).toEqual( [[ + '-T', + 2, + '-f', + 'x', + '-p', + 123, + '-m', + 'GTRGAMMA', + '-O', + '-n', + 'run1.tre', + '-s', + '/in/aln.phy', + '-w', + '/out', + '-q', + '/in/aln.part', + ]] ); +} ); diff --git a/src/app/store/command/raxml.ts b/src/app/store/command/raxml.ts new file mode 100644 index 00000000..3d85896b --- /dev/null +++ b/src/app/store/command/raxml.ts @@ -0,0 +1,521 @@ +import remove from 'lodash/remove'; + +import { join, quote } from '../../paths'; +import type { CmdArg, ConstraintInput, PartitionInput, Platform } from './index'; + +export interface RaxmlInput extends PartitionInput, ConstraintInput { + outputDir: string; + outputNameSafe: string; + analysis: { value: string }; + outputFilenameSafe: string; + raxmlSubstitutionModelCmd: string; + numThreads: { notAvailable: boolean; value: number }; + seedParsimony: number; + seedRapidBootstrap: number; + seedBootstrap: number; + substitutionMatrix: { extraCmdValue: string }; + substitutionAscertainment: { extraCmdValue: string }; + multistateModel: { notAvailable: boolean; value: string }; + disableCheckUndeterminedSequence: boolean; + outGroup: { cmdValue: string }; + branchLength: { value: boolean }; + sHlike: { value: boolean }; + numRuns: { value: number }; + numRepetitions: { value: number | string }; + tree: { notAvailable: boolean; filePath: string }; +} + +export const raxmlArgs = ( run: RaxmlInput, { windows }: Platform ): CmdArg[][] => { + const first: CmdArg[] = []; + const second: CmdArg[] = []; + const third: CmdArg[] = []; + const cmdArgs = [first, second, third]; // Possibly empty ones removed in the end + + switch ( run.analysis.value ) { + case 'FT': // Fast tree search + // params: [params.brL, params.SHlike, params.outGroup], + // cmd= """cd %s %s &&%s %s -f E -p %s %s -n %s -s %s -O -w %s %s %s %s %s""" \ + // % (winD, raxml_path, K[0], pro, seed_1, mod, out_file, seq_file, path_dir, part_f, cmd_temp1,cmd_temp2, winEx) + //TODO: Where is outGroup? From line 1436 in original code, -o is unchecked + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'E' ); + first.push( '-p', run.seedParsimony ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.branchLength.value ) { + const treeFile1 = join( + run.outputDir, + `RAxML_fastTree.${run.outputFilenameSafe}`, + ); + const next: CmdArg[] = []; + if ( !run.numThreads.notAvailable ) { + next.push( '-T', run.numThreads.value ); + } + next.push( '-f', 'e' ); + next.push( '-m', run.raxmlSubstitutionModelCmd ); + next.push( run.substitutionMatrix.extraCmdValue ); + next.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + next.push( '-K', run.multistateModel.value ); + } + next.push( '-t', quote( treeFile1, { windows } ) ); + next.push( '-n', `brL.${run.outputFilenameSafe}` ); + next.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + next.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + next.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + next.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + cmdArgs.push( next ); + } + if ( run.sHlike.value ) { + const treeFile2 = run.branchLength.value + ? join( + run.outputDir, + `RAxML_result.brL.${run.outputFilenameSafe}`, + ) + : join( run.outputDir, `RAxML_fastTree.${run.outputFilenameSafe}` ); + const next: CmdArg[] = []; + if ( !run.numThreads.notAvailable ) { + next.push( '-T', run.numThreads.value ); + } + next.push( '-f', 'e' ); + next.push( '-m', run.raxmlSubstitutionModelCmd ); + next.push( run.substitutionMatrix.extraCmdValue ); + next.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + next.push( '-K', run.multistateModel.value ); + } + next.push( '-t', quote( treeFile2, { windows } ) ); + next.push( '-n', `sh.${run.outputFilenameSafe}` ); + next.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + next.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + next.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + next.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + cmdArgs.push( next ); + } + break; + case 'ML': // ML search + // params: [params.SHlike, params.combinedOutput, params.outGroup], + // cmd= """cd %s %s&&%s %s -f d %s -N %s -O -p %s %s -s %s -n %s %s -w %s %s %s %s %s %s""" \ + // % (winD, raxml_path, K[0], pro, mod, BSrep2.get(), random.randrange(1, 1000, 1), o, seq_file, out_file, part_f, path_dir, const_f, result2, cmd_temp2, combine_trees, winEx) + //TODO: Check conf_f (from line 754 in original source) + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'd' ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + first.push( '-N', run.numRuns.value ); + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + first.push( '-p', run.seedParsimony ); + first.push( '-n', run.outputFilenameSafe ); + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + first.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + if ( run.sHlike.value ) { + const treeFile = join( + run.outputDir, + `RAxML_bestTree.${run.outputFilenameSafe}`, + ); + const next: CmdArg[] = []; + if ( !run.numThreads.notAvailable ) { + next.push( '-T', run.numThreads.value ); + } + next.push( '-f', 'e' ); + next.push( '-m', run.raxmlSubstitutionModelCmd ); + next.push( run.substitutionMatrix.extraCmdValue ); + next.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + next.push( '-K', run.multistateModel.value ); + } + next.push( '-t', quote( treeFile, { windows } ) ); + next.push( '-n', `sh.${run.outputFilenameSafe}` ); + next.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + next.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + next.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + next.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + cmdArgs.push( next ); + } + break; + case 'ML+rBS': // ML + rapid bootstrap + // params: [params.reps, params.brL, params.outGroup], + // cmd= """cd %s %s&& %s %s %s -f a -x %s %s %s -p %s -N %s %s -s %s -n %s %s -O -w %s %s %s %s""" \ + // % (winD, raxml_path, runWin, K[0], pro, seed_1, save_brL.get(),mod, seed_2, BSrep.get(), o, seq_file, out_file, \ + // part_f, path_dir, const_f, result, winEx) + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'a' ); + first.push( '-x', run.seedRapidBootstrap ); + first.push( '-p', run.seedParsimony ); + first.push( '-N', run.numRepetitions.value ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.branchLength.value ) { + first.push( '-k' ); + } + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + first.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + break; + case 'ML+tBS': { // ML + thorough bootstrap + // params: [params.runs, params.reps, params.brL, params.outGroup], + // cmd= """cd %s %s \ + // &&%s %s -b %s %s %s -p %s -N %s %s -s %s -n %s %s -w %s %s -O && cd %s \ + // &&%s %s -f d %s %s -s %s -N %s -n %s %s -w %s %s -p %s -O && cd %s \ + // &&%s %s -f b -t %s -z %s %s -s %s -n %s -w %s %s -O %s""" \ + // % (winD, raxml_path, K[0], pro, seed_1, mod, save_brL.get(),seed_2, BSrep.get(), o, seq_file, out_file1, part_f, path_dir, const_f,\ + // raxml_path, K[0], pro, mod, o, seq_file, BSrep2.get(), out_file2, part_f, path_dir, const_f,random.randrange(1, 1000, 1), \ + // raxml_path, K[0], pro, MLtreeR, trees, mod, seq_file, out_file, path_dir, result, winEx) + // try: + // remove="RAxML_info.%s.tre" % (only_name) + // ... + const outputFilenameSafe1 = `${run.outputNameSafe}R.tre`; + const outputFilenameSafe2 = `${run.outputNameSafe}B.tre`; + const treeFile = join( + run.outputDir, + `RAxML_bestTree.${outputFilenameSafe2}`, + ); // MLtreeR + const treesFile = join( + run.outputDir, + `RAxML_bootstrap.${outputFilenameSafe1}`, + ); // trees + // first wrote RAxML_bootstrap.binary_8R.tre + // second wrote RAxML_bootstrap.binary_8B.tre + + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-b', run.seedBootstrap ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.branchLength.value ) { + first.push( '-k' ); + } + first.push( '-p', run.seedParsimony ); + first.push( '-N', run.numRepetitions.value ); + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + first.push( '-n', outputFilenameSafe1 ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + first.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + + if ( !run.numThreads.notAvailable ) { + second.push( '-T', run.numThreads.value ); + } + second.push( '-f', 'd' ); + second.push( '-m', run.raxmlSubstitutionModelCmd ); + second.push( run.substitutionMatrix.extraCmdValue ); + second.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + second.push( '-K', run.multistateModel.value ); + } + second.push( '-p', run.seedParsimony ); + second.push( '-N', run.numRuns.value ); + if ( run.disableCheckUndeterminedSequence ) { + second.push( '-O' ); + } + if ( run.outGroup.cmdValue ) { + second.push( '-o', run.outGroup.cmdValue ); + } + second.push( '-n', outputFilenameSafe2 ); + second.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + second.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + second.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + second.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + second.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + second.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + + if ( !run.numThreads.notAvailable ) { + third.push( '-T', run.numThreads.value ); + } + third.push( '-f', 'b' ); + third.push( '-t', quote( treeFile, { windows } ) ); + third.push( '-z', quote( treesFile, { windows } ) ); + third.push( '-m', run.raxmlSubstitutionModelCmd ); + third.push( run.substitutionMatrix.extraCmdValue ); + third.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + third.push( '-K', run.multistateModel.value ); + } + if ( run.disableCheckUndeterminedSequence ) { + third.push( '-O' ); + } + third.push( '-n', run.outputFilenameSafe ); + third.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + third.push( '-w', quote( run.outputDir, { windows } ) ); + + break; + } + case 'BS+con': { // Bootstrap + consensus + // params: [params.reps, params.brL, params.outGroup], + // BStrees_file= """ "%sRAxML_bootstrap.%s" """ % (path_dirsimple, out_file) + // cmd= """cd %s %s \ + // && %s %s %s %s -n %s -s %s %s -x %s -N %s -w %s %s %s -p %s -O && cd %s\ + // && %s %s %s -n con.%s -J MR -z %s -w %s %s + // """ \ + // % (winD, raxml_path, \ + // K[0], pro, mod, save_brL.get(), out_file, seq_file, o, seed_1, BSrep.get(), path_dir, part_f, const_f, random.randrange(1, 1000, 1), raxml_path, \ + // K[0], pro, mod, out_file, BStrees_file, path_dir, winEx) + + const bsTreeFile = join( + run.outputDir, + `RAxML_bootstrap.${run.outputFilenameSafe}`, + ); + const consensusOutput = `consensus.${run.outputFilenameSafe}`; + + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + if ( run.branchLength.value ) { + first.push( '-k' ); + } + first.push( '-x', run.seedRapidBootstrap ); + first.push( '-p', run.seedParsimony ); + first.push( '-N', run.numRepetitions.value ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + first.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + + if ( !run.numThreads.notAvailable ) { + second.push( '-T', run.numThreads.value ); + } + second.push( '-m', run.raxmlSubstitutionModelCmd ); + second.push( run.substitutionMatrix.extraCmdValue ); + second.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + second.push( '-K', run.multistateModel.value ); + } + second.push( '-J', 'MR' ); + second.push( '-w', quote( run.outputDir, { windows } ) ); + second.push( '-z', quote( bsTreeFile, { windows } ) ); + second.push( '-n', consensusOutput ); + if ( run.backboneConstraint.isSet ) { + second.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + second.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + break; + } + case 'AS': // Ancestral states + // params: [params.tree], + // cmd = """cd %s %s &&%s %s -f A -t "%s" -s %s %s -n %s -O -w %s %s %s""" \ + // % (winD, raxml_path, K[0], pro, rooted_tree, seq_file, mod, out_file, path_dir, part_f, winEx) + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'A' ); + first.push( '-t', quote( run.tree.filePath, { windows } ) ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + break; + case 'PD': // Pairwise distances + // params: [params.startingTree], + // # "./raxmlHPC -f x -m GTRGAMMA[I] -n NAME -s INPUT -p RANDOMNR [-q PARTFILE -o OUTGROUP]" + // cmd = """cd %s %s &&%s %s -f x -p %s %s -s %s %s -n %s %s -O -w %s %s %s""" \ + // % (winD, raxml_path, K[0], pro, seed_1, const_f, seq_file, mod, out_file, o, path_dir, part_f, winEx) + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'x' ); + first.push( '-p', run.seedParsimony ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + if ( !run.tree.notAvailable ) { + first.push( '-t', quote( run.tree.filePath, { windows } ) ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + break; + case 'RBS': // Rell bootstraps + // params: [params.reps, params.brL, params.outGroup], + // # "./raxmlHPC -f x -m GTRGAMMA[I] -n NAME -s INPUT -p RANDOMNR [-q PARTFILE -o OUTGROUP]" + // cmd = """cd %s %s &&%s %s -f D -p %s %s -s %s %s -n %s %s -O -w %s %s %s""" \ + // % (winD, raxml_path, K[0], pro, seed_1, const_f, seq_file, mod, out_file, o, path_dir, part_f, winEx) + if ( !run.numThreads.notAvailable ) { + first.push( '-T', run.numThreads.value ); + } + first.push( '-f', 'D' ); + first.push( '-p', run.seedParsimony ); + first.push( '-m', run.raxmlSubstitutionModelCmd ); + first.push( run.substitutionMatrix.extraCmdValue ); + first.push( run.substitutionAscertainment.extraCmdValue ); + if ( run.branchLength.value ) { + first.push( '-k' ); + } + if ( run.outGroup.cmdValue ) { + first.push( '-o', run.outGroup.cmdValue ); + } + if ( !run.multistateModel.notAvailable ) { + first.push( '-K', run.multistateModel.value ); + } + if ( run.disableCheckUndeterminedSequence ) { + first.push( '-O' ); + } + first.push( '-n', run.outputFilenameSafe ); + first.push( '-s', quote( run.finalAlignment.path, { windows } ) ); + // if (!run.tree.notAvailable) { + // first.push('-t', run.tree.filePath); + // } + first.push( '-w', quote( run.outputDir, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '-q', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '-q', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } + if ( run.backboneConstraint.isSet ) { + first.push( '-r', quote( run.backboneConstraint.filePath, { windows } ) ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( '-g', quote( run.multifurcatingConstraint.filePath, { windows } ) ); + } + break; + default: + } + // Remove items that are only empty strings + cmdArgs.forEach( ( args ) => remove( args, ( n ) => n === '' ) ); + return cmdArgs.filter( ( args ) => args.length > 0 ); +}; diff --git a/src/app/store/command/raxmlNg.test.ts b/src/app/store/command/raxmlNg.test.ts new file mode 100644 index 00000000..96fbdec7 --- /dev/null +++ b/src/app/store/command/raxmlNg.test.ts @@ -0,0 +1,60 @@ +import { expect, it } from 'vitest'; + +import { raxmlNgArgs } from './raxmlNg'; + +const base = { + analysis: { value: 'SC' }, + havePartitionFile: false, + partitionFile: '', + ngSubstitutionModelCmd: 'GTR+G', + numThreads: { notAvailable: false, value: 2 }, + seedParsimony: 123, + outGroup: { cmdValue: '' }, + numRuns: { value: 1 }, + numRepetitionsNg: { value: 100 }, + alignments: { length: 1 }, + tree: { filePath: '' }, + multifurcatingConstraint: { isSet: false, filePath: '' }, +}; + +it( 'raxmlNgArgs quotes paths on Windows', () => { + const run = { + ...base, + finalAlignment: { + path: 'C:\\in\\aln.phy', + partitionFilePath: 'C:\\in\\aln.part', + partition: { isDefault: true }, + }, + outputDir: 'C:\\out', + outputNameSafe: 'run1', + backboneConstraint: { isSet: true, filePath: 'C:\\in\\backbone.tre' }, + }; + expect( raxmlNgArgs( run, { windows: true } ) ).toEqual( [[ + '--check', + '--model', + 'GTR+G', + '--prefix', + '"C:\\out\\run1"', + '--msa', + '"C:\\in\\aln.phy"', + '--tree-constraint', + '"C:\\in\\backbone.tre"', + ]] ); +} ); + +it( 'raxmlNgArgs leaves paths bare off Windows', () => { + const run = { + ...base, + finalAlignment: { + path: '/in/aln.phy', + partitionFilePath: '/in/aln.part', + partition: { isDefault: false }, + }, + outputDir: '/out', + outputNameSafe: 'run1', + backboneConstraint: { isSet: false, filePath: '' }, + }; + expect( raxmlNgArgs( run, { windows: false } ) ).toEqual( [ + ['--check', '--model', '/in/aln.part', '--prefix', '/out/run1', '--msa', '/in/aln.phy'], + ] ); +} ); diff --git a/src/app/store/command/raxmlNg.ts b/src/app/store/command/raxmlNg.ts new file mode 100644 index 00000000..6025fd62 --- /dev/null +++ b/src/app/store/command/raxmlNg.ts @@ -0,0 +1,218 @@ +import remove from 'lodash/remove'; + +import { join, quote } from '../../paths'; +import type { CmdArg, ConstraintInput, PartitionInput, Platform } from './index'; + +export interface RaxmlNgInput extends PartitionInput, ConstraintInput { + outputDir: string; + outputNameSafe: string; + analysis: { value: string }; + ngSubstitutionModelCmd: string; + numThreads: { notAvailable: boolean; value: number }; + seedParsimony: number; + outGroup: { cmdValue: string }; + numRuns: { value: number }; + numRepetitionsNg: { value: number | string }; + alignments: { length: number }; + tree: { filePath: string }; +} + +export const raxmlNgArgs = ( run: RaxmlNgInput, { windows }: Platform ): CmdArg[][] => { + const first: CmdArg[] = []; + const second: CmdArg[] = []; + const third: CmdArg[] = []; + const cmdArgs = [first, second, third]; // Possibly empty ones removed in the end + switch ( run.analysis.value ) { + case 'SC': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#preparing-the-alignment + first.push( '--check' ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.backboneConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.backboneConstraint.filePath, { windows } ), + ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.multifurcatingConstraint.filePath, { windows } ), + ); + } + break; + case 'CC': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#preparing-the-alignment + first.push( '--parse' ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.backboneConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.backboneConstraint.filePath, { windows } ), + ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.multifurcatingConstraint.filePath, { windows } ), + ); + } + break; + case 'TI': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#tree-inference + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + if ( !run.numThreads.notAvailable ) { + first.push( '--threads', run.numThreads.value ); + } + first.push( '--seed', run.seedParsimony ); + if ( run.outGroup.cmdValue ) { + first.push( '--outgroup', run.outGroup.cmdValue ); + } + first.push( '--tree', `rand{${run.numRuns.value}}` ); + if ( run.backboneConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.backboneConstraint.filePath, { windows } ), + ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.multifurcatingConstraint.filePath, { windows } ), + ); + } + break; + case 'ML+tBS+con': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping + // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe + first.push( '--all' ); + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + first.push( '--seed', run.seedParsimony ); + if ( !run.numThreads.notAvailable ) { + first.push( '--threads', run.numThreads.value ); + } + if ( run.outGroup.cmdValue ) { + first.push( '--outgroup', run.outGroup.cmdValue ); + } + first.push( '--bs-metric', 'fbp' ); + first.push( '--tree', `rand{${run.numRuns.value}}` ); + first.push( '--bs-trees', run.numRepetitionsNg.value ); + if ( run.backboneConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.backboneConstraint.filePath, { windows } ), + ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.multifurcatingConstraint.filePath, { windows } ), + ); + } + break; + case 'ML+TBE+con': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping + // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe + first.push( '--all' ); + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( !run.finalAlignment.partition.isDefault ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + first.push( '--seed', run.seedParsimony ); + if ( !run.numThreads.notAvailable ) { + first.push( '--threads', run.numThreads.value ); + } + if ( run.outGroup.cmdValue ) { + first.push( '--outgroup', run.outGroup.cmdValue ); + } + first.push( '--bs-metric', 'tbe' ); + first.push( '--tree', `rand{${run.numRuns.value}}` ); + first.push( '--bs-trees', run.numRepetitionsNg.value ); + if ( run.backboneConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.backboneConstraint.filePath, { windows } ), + ); + } + if ( run.multifurcatingConstraint.isSet ) { + first.push( + '--tree-constraint', + quote( run.multifurcatingConstraint.filePath, { windows } ), + ); + } + break; + case 'AS': + // https://github.com/amkozlov/raxml-ng/wiki/Tutorial#bootstrapping + // raxml-ng --all --msa prim.phy --model GTR+G --prefix T15 --seed 2 --threads 2 --bs-metric fbp,tbe + first.push( '--ancestral' ); + first.push( '--msa', quote( run.finalAlignment.path, { windows } ) ); + if ( run.havePartitionFile ) { + first.push( '--model', quote( run.partitionFile, { windows } ) ); + } else if ( run.alignments.length > 1 ) { + first.push( '--model', quote( run.finalAlignment.partitionFilePath, { windows } ) ); + } else { + first.push( '--model', run.ngSubstitutionModelCmd ); + } + first.push( + '--prefix', + quote( join( run.outputDir, run.outputNameSafe ), { windows } ), + ); + first.push( '--tree', quote( run.tree.filePath, { windows } ) ); + break; + default: + } + // Remove items that are only empty strings + cmdArgs.forEach( ( args ) => remove( args, ( n ) => n === '' ) ); + return cmdArgs.filter( ( args ) => args.length > 0 ); +};