Skip to content

Add ReadXgroup() for TNT character-partition blocks#267

Closed
ms609 wants to merge 2 commits into
mainfrom
xgroup
Closed

Add ReadXgroup() for TNT character-partition blocks#267
ms609 wants to merge 2 commits into
mainfrom
xgroup

Conversation

@ms609

@ms609 ms609 commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • New ReadXgroup(filepath, encoding = "UTF8") parses the xgroup character-partition block of a TNT file, returning a named integer vector mapping each character (1-indexed) to its partition.
  • Returns NULL when no xread block is present; returns rep(NA_integer_, nChar) when xread is present but xgroup is not.
  • Joins the ReadCharacters doc family via @describeIn; exports .UTFLines-style encoding handling for consistency with ReadTntCharacters.
  • Sourced from a prototype that lived briefly in AutoPart; moved upstream so AutoPart and other downstream packages share a single implementation.

Bumps version to 2.3.0.9001 and adds a NEWS entry.

Test plan

  • New fixture inst/extdata/tests/tnt-xgroup.tnt (6 chars, 4 taxa, two xgroup lines)
  • 4 new tests in tests/testthat/test-ReadTntTree.R covering: well-formed xgroup parsing, NULL on missing xread, all-NA when xgroup absent, range-expansion helper .ExpandTntRange (A.B, A., A.A forms)
  • devtools::load_all() + testthat::test_file('tests/testthat/test-ReadTntTree.R') — 42 dots, no failures

🤖 Generated with Claude Code

Parses the xgroup block of a TNT file into a named integer vector mapping
each character (1-indexed) to its partition; returns NULL when no xread
block is present, all-NA when xread is present but xgroup is not. Joins
the ReadCharacters family via @describeIn.

Sourced from a prototype in AutoPart, where the function originally lived;
moved upstream so AutoPart and other downstream packages can share a single
implementation. Closes that duplication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.02%. Comparing base (4e5af7a) to head (ee8bec1).

Files with missing lines Patch % Lines
R/parse_files.R 91.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
- Coverage   96.06%   96.02%   -0.04%     
==========================================
  Files          80       80              
  Lines        5890     5938      +48     
==========================================
+ Hits         5658     5702      +44     
- Misses        232      236       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented May 15, 2026

Copy link
Copy Markdown

⚠️ This benchmark result is outdated. See the latest comment below.

Performance benchmark results

Call Status Change Time (ms)
as.Splits(bigTrees) ⚪ NSD 3.04% 23 →
22.4, 21.2
as.Splits(someTrees) ⚪ NSD -1.51% 11 →
11.2, 11.2
Consensus(forest1k.888, check = FALSE) ⚪ NSD 3.89% 104 →
100, 97.2
Consensus(forest201.80, check = FALSE) ⚪ NSD 0.05% 4.08 →
4.12, 4.02
Consensus(forest21.260, 0.5, FALSE) ⚪ NSD 1.09% 1.26 →
1.26, 1.24
Consensus(forest21.260) ⚪ NSD 1.55% 1.28 →
1.27, 1.25
Consensus(forestMaj, 0.5, FALSE) ⚪ NSD -0.01% 2.98 →
3, 2.93
DropTip(tr2000, 5) ⚪ NSD -0.37% 16.6 →
16.5, 16.8
DropTip(tr80, 5) ⚪ NSD 0% 0.104 →
0.104, 0.104
DropTip(unlen2k, 5) ⚪ NSD 2.04% 0.215 →
0.206, 0.214
DropTip(unlen80, 5) ⚪ NSD 1.32% 0.041 →
0.0397, 0.0411
lapply(bigSplits, as.phylo) ⚪ NSD -0.33% 29.3 →
29.3, 29.6
lapply(someSplits, as.phylo) ⚪ NSD -0.37% 13.6 →
13.7, 13.7
PathLengths(tr2000, full = TRUE) ⚪ NSD 0.66% 16 →
15.8, 15.9
PathLengths(tr80, full = TRUE) ⚪ NSD -1.39% 0.0982 →
0.0982, 0.102
PathLengths(tr80Unif, full = TRUE) ⚪ NSD -0.55% 0.101 →
0.1, 0.104
RootTree(tr2000, 5) ⚪ NSD -0.54% 0.394 →
0.397, 0.395
RootTree(tr80, c("t3", "t36")) ⚪ NSD 0.39% 0.0715 →
0.071, 0.0714
RootTree(tr80, "t3") ⚪ NSD 0.71% 0.0505 →
0.0502, 0.0502
RootTree(tr80, "t30") ⚪ NSD 0.43% 0.0507 →
0.0503, 0.0508
RootTree(unlen2k, 5) ⚪ NSD 2.67% 0.351 →
0.33, 0.349
RootTree(unlen80, c("t3", "t36")) ⚪ NSD 0.09% 0.067 →
0.0652, 0.0682
RootTree(unlen80, "t3") ⚪ NSD 1.95% 0.0448 →
0.0429, 0.0446
RootTree(unlen80, "t30") ⚪ NSD 0.84% 0.0451 →
0.0434, 0.0457
TreeDist::RobinsonFoulds(forest201.80) ⚪ NSD 3.76% 17 →
16.1, 16.7
TreeDist::RobinsonFoulds(forest21.888) ⚪ NSD 1.56% 3.54 →
3.39, 3.53
TreeTools:::path_lengths(tr80$edge, tr80$edge.length, FALSE) ⚪ NSD -3.56% 0.0874 →
0.089, 0.0922
TreeTools:::postorder_order(bal40) ⚪ NSD -0.59% 0.00166 →
0.00166, 0.00168
TreeTools:::postorder_order(bal40k) ⚪ NSD 0.18% 0.429 →
0.428, 0.429
TreeTools:::postorder_order(dbal40) ⚪ NSD -1.68% 0.00171 →
0.00174, 0.00174
TreeTools:::postorder_order(dbal40k) ⚪ NSD -1.08% 2 →
2.02, 2.02
TreeTools:::postorder_order(dpec40) ⚪ NSD -0.43% 0.00253 →
0.00254, 0.00255
TreeTools:::postorder_order(dpec40k) 🟣 ~same -0.47% 3300 →
3310, 3310
TreeTools:::postorder_order(drnd80) ⚪ NSD 0.27% 0.00405 →
0.00407, 0.00402
TreeTools:::postorder_order(nbal40) ⚪ NSD -0.49% 0.00206 →
0.00207, 0.00206
TreeTools:::postorder_order(nbal40k) ⚪ NSD -0.7% 2.18 →
2.19, 2.2
TreeTools:::postorder_order(npec40) ⚪ NSD -0.31% 0.00286 →
0.00286, 0.00288
TreeTools:::postorder_order(npec40k) ⚪ NSD -0.15% 3320 →
3320, 3330
TreeTools:::postorder_order(nrnd80) ⚪ NSD -0.66% 0.00458 →
0.00462, 0.0046
TreeTools:::postorder_order(pec40) ⚪ NSD -1.84% 0.00164 →
0.00166, 0.00168
TreeTools:::postorder_order(pec40k) ⚪ NSD -0.58% 0.428 →
0.428, 0.431
TreeTools:::postorder_order(rnd80) ⚪ NSD -2.01% 0.00209 →
0.00214, 0.00213

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ms609 ms609 closed this May 15, 2026
@ms609 ms609 deleted the xgroup branch May 15, 2026 12:59
@github-actions

Copy link
Copy Markdown

Performance benchmark results

Call Status Change Time (ms)
as.Splits(bigTrees) ⚪ NSD -3.15% 32.4 →
38.2, 31.6
as.Splits(someTrees) ⚪ NSD 2.06% 10.9 →
10.8, 10.6
Consensus(forest1k.888, check = FALSE) 🟣 ~same 3.08% 97.8 →
94.9, 94.7
Consensus(forest201.80, check = FALSE) ⚪ NSD 1.93% 4.33 →
4.3, 4.2
Consensus(forest21.260, 0.5, FALSE) ⚪ NSD 0.96% 1.18 →
1.17, 1.17
Consensus(forest21.260) ⚪ NSD 1.18% 1.19 →
1.17, 1.18
Consensus(forestMaj, 0.5, FALSE) ⚪ NSD 0.43% 2.98 →
2.98, 2.96
DropTip(tr2000, 5) ⚪ NSD -0.38% 16 →
16, 16.1
DropTip(tr80, 5) ⚪ NSD 0.25% 0.0879 →
0.0878, 0.0875
DropTip(unlen2k, 5) ⚪ NSD -10.07% 0.187 →
0.277, 0.185
DropTip(unlen80, 5) ⚪ NSD -0.17% 0.0361 →
0.0359, 0.0364
lapply(bigSplits, as.phylo) 🟣 ~same -2.49% 29.3 →
30.2, 29.7
lapply(someSplits, as.phylo) ⚪ NSD 0.06% 13.6 →
13.7, 13.6
PathLengths(tr2000, full = TRUE) ⚪ NSD 0.35% 15.3 →
15.2, 15.3
PathLengths(tr80, full = TRUE) ⚪ NSD -3.33% 0.0971 →
0.1, 0.101
PathLengths(tr80Unif, full = TRUE) ⚪ NSD -2.95% 0.0998 →
0.103, 0.103
RootTree(tr2000, 5) ⚪ NSD -0.49% 0.344 →
0.342, 0.35
RootTree(tr80, c("t3", "t36")) ⚪ NSD -0.11% 0.0608 →
0.0606, 0.0612
RootTree(tr80, "t3") ⚪ NSD -0.27% 0.0444 →
0.0441, 0.0448
RootTree(tr80, "t30") ⚪ NSD -0.71% 0.044 →
0.044, 0.0446
RootTree(unlen2k, 5) ⚪ NSD 2.43% 0.304 →
0.298, 0.295
RootTree(unlen80, c("t3", "t36")) ⚪ NSD 0.68% 0.0564 →
0.056, 0.0561
RootTree(unlen80, "t3") ⚪ NSD -0.21% 0.0383 →
0.0383, 0.0384
RootTree(unlen80, "t30") ⚪ NSD 0.59% 0.0387 →
0.0383, 0.0387
TreeDist::RobinsonFoulds(forest201.80) ⚪ NSD 1.46% 17.4 →
17.2, 16.6
TreeDist::RobinsonFoulds(forest21.888) ⚪ NSD -0.21% 3.19 →
3.22, 3.17
TreeTools:::path_lengths(tr80$edge, tr80$edge.length, FALSE) ⚪ NSD 0.93% 0.093 →
0.0921, 0.0923
TreeTools:::postorder_order(bal40) ⚪ NSD 0.01% 0.00162 →
0.00163, 0.00161
TreeTools:::postorder_order(bal40k) ⚪ NSD 0.17% 0.37 →
0.37, 0.368
TreeTools:::postorder_order(dbal40) ⚪ NSD 0.59% 0.00171 →
0.00173, 0.00166
TreeTools:::postorder_order(dbal40k) ⚪ NSD -0.58% 2.12 →
2.14, 2.13
TreeTools:::postorder_order(dpec40) ⚪ NSD -1.18% 0.00254 →
0.0026, 0.00253
TreeTools:::postorder_order(dpec40k) ⚪ NSD 0.3% 2870 →
2860, 2860
TreeTools:::postorder_order(drnd80) ⚪ NSD 0.76% 0.00394 →
0.00391, 0.00391
TreeTools:::postorder_order(nbal40) ⚪ NSD -0.99% 0.00201 →
0.00205, 0.002
TreeTools:::postorder_order(nbal40k) ⚪ NSD -0.53% 2.32 →
2.34, 2.32
TreeTools:::postorder_order(npec40) ⚪ NSD -1.1% 0.00282 →
0.00288, 0.00282
TreeTools:::postorder_order(npec40k) ⚪ NSD 0.05% 2860 →
2860, 2860
TreeTools:::postorder_order(nrnd80) ⚪ NSD -1.1% 0.00452 →
0.0046, 0.00453
TreeTools:::postorder_order(pec40) ⚪ NSD 0.01% 0.00162 →
0.00165, 0.00159
TreeTools:::postorder_order(pec40k) ⚪ NSD -2.11% 0.37 →
0.392, 0.371
TreeTools:::postorder_order(rnd80) ⚪ NSD 3.46% 0.00205 →
0.00197, 0.00201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant