Invntr
Source

All instruments

phylo_tree

Evolutionary distances from aligned DNA (p-distance, Jukes-Cantor 1969, Kimura two-parameter 1980, with large-sample standard errors) or a distance matrix given directly, and trees from them by neighbour joining (Saitou-Nei, Studier-Keppler form) and UPGMA: Newick text, branch lengths, tree-against-input residuals, cophenetic correlation, and the three-point (ultrametric) and four-point (additive) tests.

Field
Genomics
Version
0.1.0
Runs as
Compiled (Rust)
Typical run
0.05 s

Compiled from source: run sh packs/install.sh once before admitting it.

Known answers it must pass

Admission replayphylo_tree 0.1.0 · files 089916c3cadf…da52
  1. r0001Jukes-Cantor 1969 closed form: 3 of 10 sites differ, p = 0.3, d = -(3/4) ln(0.6) = 0.383119; SE = sqrt(p(1-p)/n)/(1-4p/3) = 0.241523 (rel 1e-9, exact formula)passed

    max_distance0.383119 ± 3.8e-100.383119lockedunder 0.01 % of the tolerance used
    pairs.s1|s2.p_distance{"value": 0.3, "rel_tol": 1e-12}
    pairs.s1|s2.standard_error{"value": 0.24152294576982397, "rel_tol": 1e-09}
    nj_tree_length0.383119 ± 3.8e-100.383119lockedunder 0.01 % of the tolerance used
  2. r0002Kimura 1980 two-parameter closed form: P = Q = 0.1 over 20 sites, d = -(1/2) ln 0.7 - (1/4) ln 0.8 = 0.234123; Kimura variance gives SE = 0.123863; ts/tv = 1 (rel 1e-9, exact formula)passed

    max_distance0.234123 ± 2.3e-100.234123lockedunder 0.01 % of the tolerance used
    pairs.s1|s2.standard_error{"value": 0.12386281190684065, "rel_tol": 1e-09}
    pairs.s1|s2.transitions= 2misseddiffers
    pairs.s1|s2.transversions= 2misseddiffers
    ts_tv_ratio1 ± 1e-121lockedunder 0.01 % of the tolerance used
  3. r0003Neighbour joining, five-taxon textbook example (Saitou-Nei method; Wikipedia 'Neighbor joining'): ab 5 ... de 3 gives branches a 2, b 3, c 4, d 2, e 1, internal 3 and 2; additive, so residual 0 (abs 1e-9, exact arithmetic)passed

    leaves.a.nj_branch{"value": 2.0, "abs_tol": 1e-09}
    leaves.b.nj_branch{"value": 3.0, "abs_tol": 1e-09}
    leaves.c.nj_branch{"value": 4.0, "abs_tol": 1e-09}
    leaves.d.nj_branch{"value": 2.0, "abs_tol": 1e-09}
    leaves.e.nj_branch{"value": 1.0, "abs_tol": 1e-09}
    nj_internal_branches.0{"value": 3.0, "abs_tol": 1e-09}
    nj_internal_branches.1{"value": 2.0, "abs_tol": 1e-09}
    nj_tree_length17 ± 1e-0917lockedunder 0.01 % of the tolerance used
    nj_max_abs_residual0 ± 1e-090lockedunder 0.01 % of the tolerance used
    nj_cophenetic_r1 ± 1e-121lockedunder 0.01 % of the tolerance used
    additive= truetruelockedexact match
    ultrametric= falsefalselockedexact match
  4. r0004UPGMA recovers an ultrametric matrix exactly: the tree ((a:1,b:1):2,(c:2,d:2):1) gives ab 2, cd 4, others 6; merges at heights 1, 2, 3, tree length 9, residual 0, cophenetic r = 1 (abs 1e-12, exact arithmetic)passed

    upgma_merge_heights.0{"value": 1.0, "abs_tol": 1e-12}
    upgma_merge_heights.1{"value": 2.0, "abs_tol": 1e-12}
    upgma_root_height3 ± 1e-123lockedunder 0.01 % of the tolerance used
    upgma_tree_length9 ± 1e-129lockedunder 0.01 % of the tolerance used
    upgma_max_abs_residual0 ± 1e-120lockedunder 0.01 % of the tolerance used
    upgma_cophenetic_r1 ± 1e-121lockedunder 0.01 % of the tolerance used
    ultrametric= truetruelockedexact match
    upgma_newick= ((a:1,b:1):2,(c:2,d:2):1);((a:1,b:1):2,(c:2,d:2):1);lockedexact match
  5. r0005Neighbour joining recovers an additive, non-ultrametric six-taxon matrix exactly: path lengths on the tree ((a:1,b:4):2,(c:3,d:1):5,(e:2,f:6):1) give leaf branches 1,4,3,1,2,6, internal 5,2,1, length 25, residual 0 (abs 1e-9, exact arithmetic)passed

    leaves.a.nj_branch{"value": 1.0, "abs_tol": 1e-09}
    leaves.b.nj_branch{"value": 4.0, "abs_tol": 1e-09}
    leaves.c.nj_branch{"value": 3.0, "abs_tol": 1e-09}
    leaves.d.nj_branch{"value": 1.0, "abs_tol": 1e-09}
    leaves.e.nj_branch{"value": 2.0, "abs_tol": 1e-09}
    leaves.f.nj_branch{"value": 6.0, "abs_tol": 1e-09}
    nj_internal_branches.0{"value": 5.0, "abs_tol": 1e-09}
    nj_internal_branches.1{"value": 2.0, "abs_tol": 1e-09}
    nj_internal_branches.2{"value": 1.0, "abs_tol": 1e-09}
    nj_tree_length25 ± 1e-0925lockedunder 0.01 % of the tolerance used
    nj_max_abs_residual0 ± 1e-090lockedunder 0.01 % of the tolerance used
    additive= truetruelockedexact match
    ultrametric= falsefalselockedexact match
5 of 5 cases passed · sandbox macos-seatbeltrecorded from the kernel in a fresh lab

Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.

Inputs

NameUnitDefaultMeaning
modeljc69Distance from sequences: "p" proportion of differing sites, "jc69" Jukes-Cantor d = -(3/4) ln(1 - 4p/3), "k2p" Kimura two-parameter d = -(1/2) ln(1 - 2P - Q) - (1/4) ln(1 - 2Q). Ignored for a matrix.
gapspairwiseMissing sites ('-', '?', N, IUPAC ambiguity letters): "pairwise" skips a site only for the pairs where it is missing; "complete" skips a site missing in any sequence for all pairs.
sequences{}Aligned DNA as {"name": "ACGT..."}; all the same length. Note: names are taken in sorted order. Give this, or fasta / fasta_file, or a matrix.
fastaAligned DNA as FASTA text ('>name' lines, then the bases).
fasta_fileAn aligned FASTA file.
names[]Taxon names, one per row of 'distances' (t1, t2, ... if left out).
distances1[]A square symmetric distance matrix with a zero diagonal, 2 to 200 taxa (substitutions per site or any one unit; the tree's branch lengths come out in the same unit).

Readings

NameUnitMeaning
taxa_count1
site_count1Alignment length (sequences only).
sites_compared_min1
ts_tv_ratio1Transitions over transversions, summed over all pairs (null with no transversion).
distance_matrix1
min_distance1
max_distance1
mean_distance1
ultrametricThree-point condition holds (to 1e-9 of the largest distance).
three_point_max_violation1
additiveFour-point condition holds (to 1e-9 of the largest distance).
four_point_max_violation1
triangle_violations1
nj_newickNeighbour-joining tree, unrooted (the last three nodes meet at the top level).
nj_tree_length1
nj_internal_branches1Internal branch lengths, largest first.
nj_min_branch1
nj_negative_branches1
nj_max_abs_residual1
nj_rms_residual1
nj_cophenetic_r1
upgma_newickUPGMA tree, rooted, ultrametric.
upgma_tree_length1
upgma_root_height1
upgma_merge_heights1
upgma_merges
upgma_max_abs_residual1
upgma_rms_residual1
upgma_cophenetic_r1
leaves
pairs
better_fit"nj", "upgma" or "tie": the smaller rms residual.
tree_okNo negative neighbour-joining branch and no broken triangle inequality.
warnings

Try the call

Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.

Terminal
MCP call