Files
obitools4/autodoc/docmd/pkg/obiphylo/tree.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

31 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# `obiphylo` Package: Semantic Description
The `obiphylo` package provides a minimal yet expressive data structure and utilities for representing **phylogenetic trees** in Go.
## Core Type: `PhyloNode`
- Represents a node (taxon or internal branch point) in a phylogeny.
- Fields:
- `Name`: Optional label (e.g., species name, OTU ID).
- `Children`: A map of child nodes to **branch lengths** (evolutionary distances).
- `Attributes`: A flexible key-value store for metadata (e.g., bootstrap support, posterior probability).
## Key Functionalities
- **Tree Construction**:
- `NewPhyloNode()`: Instantiates an empty node.
- `AddChild(child, distance)`: Appends a child with associated branch length (supports NaN for unlabeled branches).
- **Metadata Access**:
- `SetAttribute(key, value)` / `GetAttribute(key)`: Enables extensible node annotation.
- Supports arbitrary types (via `any`), ideal for dynamic metadata.
## Output: Newick Format
- Recursive method `Newick(level int)` generates a **human-readable, standard phylogenetic tree string**:
- Properly indented for readability.
- Supports branch lengths (`:distance`) on edges (skips if `NaN`).
- Terminates with semicolon (`;`) at root level.
- Designed for interoperability (e.g., export to tools like RAxML, FigTree).
## Design Notes
- Lightweight and dependency-free.
- Uses Gos idiomatic maps for efficient child lookup (O(1) average).
- Recursive Newick generation ensures correct nesting and formatting.