etetoolkit
etetoolkit is a phylogenetic tree analysis toolkit for manipulating tree files in Newick and NHX formats, detecting evolutionary events like duplications and speciations, and identifying orthologous and paralogous relationships. Use it for phylogenomic research requiring tree manipulation, visualization in PDF or SVG formats, integration with NCBI taxonomy databases, and automated analysis of gene family evolution across species.
git clone --depth 1 https://github.com/K-Dense-AI/scientific-agent-skills /tmp/etetoolkit && cp -r /tmp/etetoolkit/skills/etetoolkit ~/.claude/skills/etetoolkitSKILL.md
# ETE Toolkit 4
## Scope
Use ETE 4 to work with an existing tree:
- Read Newick/Nexus, then inspect, annotate, transform, root, prune, and write
Newick trees
- Compare topologies and calculate phylogenetic distances
- Find repeated subtree topologies with `TreePattern`
- Analyze gene trees with `PhyloTree`
- Query local NCBI or GTDB taxonomy databases
- Explore large trees interactively with SmartView
- Render PNG with SmartView or PNG/PDF/SVG with the optional Qt treeview
ETE does not replace sequence alignment or phylogenetic inference software. For
raw sequences, first use MAFFT or another aligner and IQ-TREE 2, FastTree, or
another inference tool; then load the resulting tree into ETE.
## Current Target
This skill targets **ETE 4.4.0**, released September 3, 2025 and verified as the
current PyPI release on July 23, 2026.
Use `https://etetoolkit.github.io/ete/` for ETE 4 documentation. The
`etetoolkit.org/docs/latest` pages are legacy ETE 3 documentation despite the
URL name.
Do not silently translate these examples back to ETE 3:
- Package and import: `ete4`, not `ete3`
- File input: pass an open file object; use strings for Newick text and do not
rely on path-string heuristics retained in ETE 4.4.0
- Newick selection: `parser=`, not `format=`
- Node metadata: `props`, `add_prop()`, and `add_props()`
- Iteration: `leaves()`, `descendants()`, and related methods return iterators
- Predicates: `node.is_leaf` and `node.is_root` are properties, not methods
- Node lookup: `tree["name"]`, not `tree & "name"`
For porting older code, load
[`references/migration-ete3-to-ete4.md`](references/migration-ete3-to-ete4.md).
## Installation
Install the pinned base package:
```bash
uv pip install "ete4==4.4.0"
```
Add only the visualization extra required by the workflow:
```bash
# SmartView static PNG screenshots
uv pip install "ete4[render-sm]==4.4.0"
# Legacy Qt renderer for PNG, PDF, and SVG
uv pip install "ete4[treeview]==4.4.0"
```
Confirm the active environment:
```bash
uv run --with "ete4==4.4.0" python -c "import ete4; print(ete4.__version__)"
```
No credentials are required. NCBI and GTDB workflows download public taxonomy
data and can consume substantial disk space; see
[`references/taxonomy.md`](references/taxonomy.md) before the first update.
## Quick Start
```python
from pathlib import Path
from ete4 import Tree
# Use an open file object for files; reserve strings for Newick text.
with Path("tree.nw").open(encoding="utf-8") as handle:
tree = Tree(handle, parser=1) # parser 1: internal node names
print(tree.to_str(props=["name", "dist"], compact=True))
print("Leaves:", list(tree.leaf_names()))
# Search and annotate.
focal = tree["species1"]
focal.add_props(host="human", status="focal")
# Keep selected tips while preserving pairwise branch-length distances.
tree.prune(
["species1", "species2", "species3"],
preserve_branch_length=True,
)
# Root and serialize explicitly.
tree.set_midpoint_outgroup()
tree.write(
outfile="processed.nw",
parser=1,
props=["host", "status"],
)
```
Choose the parser deliberately. A parser mismatch is the most common cause of
`NewickError`, lost internal labels, or support values being read as names.
See [`references/api_reference.md`](references/api_reference.md).
## Core Workflows
### Inspect and transform a tree
```python
from ete4 import Tree
tree = Tree("((A:1,B:1)CladeAB:0.4,C:2)Root;", parser=1)
for node in tree.traverse("preorder"):
label = node.name if node.name is not None else node.id
print(label, node.level, node.is_leaf, node.dist)
tree["A"].add_prop("group", "case")
tree["B"].add_prop("group", "control")
mrca = tree.common_ancestor("A", "B")
print(mrca.name)
tree.write(
outfile="annotated.nhx",
parser=1,
props=["group"],
format_root_node=True,
)
```
Node names need not be unique. `tree["A"]` returns the first match; use
`list(tree.search_nodes(name="A"))` and validate the count when duplicates are
possible.
### Compare two topologies
```python
from ete4 import Tree
tree_a = Tree("((A,B),(C,D));")
tree_b = Tree("((A,C),(B,D));")
(
rf,
max_rf,
common_leaves,
edges_a,
edges_b,
discarded_a,
discarded_b,
) = tree_a.robinson_foulds(tree_b)
normalized_rf = rf / max_rf if max_rf else 0.0
print(rf, max_rf, normalized_rf, sorted(common_leaves))
```
RF comparison uses shared leaf labels and requires meaningful, preferably
unique names. Decide explicitly whether rooted or unrooted comparison is
scientifically appropriate.
### Detect duplication and speciation events
```python
from ete4 import PhyloTree
gene_tree = PhyloTree(
"((Hsa|g1,Ptr|g1),(Hsa|g2,Mmu|g1));",
sp_naming_function=lambda name: name.split("|", 1)[0],
)
for event in gene_tree.get_descendant_evol_events(sos_thr=0.0):
relationship = "speciation/orthology" if event.etype == "S" else "duplication/paralogy"
print(relationship, sorted(event.in_seqs), sorted(event.out_seqs))
```
Species-overlap calls are inferences from the supplied topology and naming
function, not independent evidence of orthology. Pass the naming function
explicitly, and use a rooted, fully bifurcating gene tree. For strict
reconciliation, use a curated species tree and
`gene_tree.reconcile(species_tree)`.
### Query taxonomy
```python
from ete4 import NCBITaxa
ncbi = NCBITaxa()
names = ["Homo sapiens", "Pan troglodytes", "Mus musculus"]
name_to_taxids = ncbi.get_name_translator(names)
missing = [name for name in names if name not in name_to_taxids]
if missing:
raise ValueError(f"Names not resolved by NCBI taxonomy: {missing}")
taxids = [name_to_taxids[name][0] for name in names]
taxonomy_tree = ncbi.get_topology(taxids)
print(taxonomy_tree.to_str(props=["sci_name", "rank"]))
```
ETE 4 also provides `GTDBTaxa` for genome-centric bacterial and archaeal
taxonomy. Do not mix NCBI numeric TaxIDs and GTDB string identifiers.
### Visualize
Interactive SmartView:
```python
from ete4 impHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.
Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.
Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g. "get my model's eval score up", "improve this agent/harness", "tune this pipeline", "beat the baseline on this benchmark", "run a search over approaches and keep the best", "do an MLE-bench / Kaggle-style optimization", or any long-horizon "make this artifact better and don't just memorize the dev set" task. Trigger it even when the user doesn't say "Arbor" or "hypothesis tree" but describes repeated experiment-and-evaluate loops, branching exploration of competing ideas, or worries about a dev/test gap. Runs Claude itself as the coordinator with subagent executors in isolated git worktrees; for the standalone `arbor` CLI tool see references/arbor-upstream.md.
Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.
Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.
Observe the user's screen via screenpipe, detect repeated research workflows, match them against existing scientific-agent-skills, and draft new skills (or composition recipes that chain existing ones) for the patterns not yet covered. Use when the user asks to analyze their recent work and propose skills based on what they actually do. Requires the screenpipe daemon (https://github.com/screenpipe/screenpipe) running locally on port 3030 — the skill has no other data source and will refuse to run if screenpipe is unreachable. All detection runs locally; only redacted cluster summaries reach the LLM.