Skip to content

feat: emit reconstructed ancestral sequences from timetree - #939

Merged
ivan-aksamentov merged 3 commits into
rustfrom
feat/timetree-ancestral-sequence-output
Aug 31, 2026
Merged

feat: emit reconstructed ancestral sequences from timetree#939
ivan-aksamentov merged 3 commits into
rustfrom
feat/timetree-ancestral-sequence-output

Conversation

@ivan-aksamentov

@ivan-aksamentov ivan-aksamentov commented Aug 31, 2026

Copy link
Copy Markdown
Member

Resolve:

Update:

Depends on: #938, #937

The timetree command accepted --include-leaves, --impute-missing-data, and the --reconstruct-tip-states alias but emitted no sequences, so the flags were inert and TreeTime v0's ancestral_sequences.fasta had no v1 counterpart under timetree.

timetree now writes a reconstructed nucleotide FASTA, selected with --output-reconstructed-nuc-fasta [src] and produced by default under --output-all [src]. It reuses the marginal reconstruction the ancestral command runs rather than a second sequence path: after the pipeline settles the tree, a refreshed marginal pass materializes each node's flag-aware sequence and emits it [src]. Rerooting leaves a fresh unnamed root, so every unnamed internal node is named once before serialization, matching v0 and the ancestral command across the FASTA, the augur node data, and the tree outputs [src]. The timetree step's produced-output set in the pipeline resolver gains the reconstructed FASTA so a later step can chain it [src].

Reusing the ancestral reconstruction keeps timetree sequence output on the same numerically validated path: internal-node sequences come from the marginal MAP states already used for the tree mutations, non-imputed tips echo their observed input exactly, and --impute-missing-data resolves ambiguous tip states to the marginal argmax as approved in the tip-reconstruction decision. Refreshing the marginal posteriors before reconstruction ties the emitted sequences to the final branch lengths, the same ordering the ancestral command uses.

Work items

  • Add the reconstructed nucleotide FASTA to the timetree output surface, selectable and default under --output-all [src]
  • Add the --output-reconstructed-nuc-fasta path flag to timetree [src]
  • Emit the FASTA by reusing the ancestral marginal reconstruction, gated by the tip-state flags [src]
  • Register the reconstructed FASTA in the timetree resolve_outputs mapping so the pipeline can chain it [src]
  • Name the rerooted root before writing output so all timetree outputs carry NODE_<n> names [src]

Possible improvements

- Add the reconstructed nucleotide FASTA output to the timetree command, the v1 equivalent of v0's ancestral_sequences.fasta, reusing the ancestral command's marginal reconstruction rather than a second code path.
- Drive tip output with the already-threaded separated flags: --include-leaves emits reconstructed tips, --impute-missing-data resolves ambiguous tip states, --reconstruct-tip-states enables both.
- Refresh marginal posteriors before reconstruction so emitted sequences reflect the final branch lengths, matching the ancestral command's ordering.
- Name the rerooted root before serialization: rerooting introduces a fresh root the load-time naming pass never saw, so every internal node carries a NODE_<n> name across the FASTA, augur node data, and tree outputs, matching v0 and the ancestral command.
- Assert internal-only emission with named nodes, exact leaf echo under --include-leaves, and ambiguous-tip resolution under --reconstruct-tip-states.
- Smoke-cover --reconstruct-tip-states and the separated --include-leaves/--impute-missing-data on the CLI.
- Resolve the tip-state-flags-not-wired and ancestral-sequences-FASTA-unimplemented issues, now delivered.
- Mark both feature-inventory rows implemented.
- Narrow the unnamed-rerooted-root issue and its ticket to the clock command, since timetree now names nodes after its pipeline.
@ivan-aksamentov ivan-aksamentov changed the title feat/timetree ancestral sequence output feat: emit reconstructed ancestral sequences from timetree Aug 31, 2026
Base automatically changed from fix/ancestral-marginal-tip-reconstruction to rust August 31, 2026 17:39
@ivan-aksamentov
ivan-aksamentov merged commit a595bf0 into rust Aug 31, 2026
9 checks passed
@ivan-aksamentov
ivan-aksamentov deleted the feat/timetree-ancestral-sequence-output branch August 31, 2026 17:40
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