---
name: phylogenetic-tree-toolkit-ete-normalizer
source: https://app.decimal.ai/s/phylogenetic-tree-toolkit-ete-normalizer@1/SKILL.md
source_sha256: dca59ef0a469
---

**ETE3 Library Standard Operating Procedure**

**PART 1: Core Tree Mechanics (`ete3.Tree`)**
*   **Initialization Requirements:** When loading a phylogeny from a string or file path, you must provide a `format` argument containing a single digit from 0 to 9. This digit dictates the specific interpretation of branch lengths, internal identifiers, and statistical support. 
*   **Structural Iteration:** To walk through the phylogeny, invoke the `.traverse()` method. You must supply a `strategy` argument set to exactly one of the following strings: `preorder`, `postorder`, or `levelorder`. 
*   **Tip Extraction:** To isolate only the outermost elements of the phylogeny, execute `.get_leaves()`.

**PART 2: Evolutionary Analysis (`ete3.PhyloTree`)**
*   **Class Requirement:** Ortholog and paralog identification cannot be performed on standard `Tree` objects. You are required to instantiate a `PhyloTree` for these tasks.
*   **Prerequisites for Event Detection:** Prior to invoking `.get_descendants_events()`, you must verify two conditions:
    1.  The phylogeny possesses a valid root.
    2.  All tip elements are explicitly associated with species identifiers (achievable via a custom mapping dictionary or specific string-matching conventions).

**PART 3: Taxonomic Mapping (`ete3.NCBITaxa`)**
*   **Database Generation:** Begin by instantiating `NCBITaxa()`. Be aware that the very first execution triggers an automatic download to construct an SQLite database on your local machine.
*   **Translation Commands:** Extract taxonomic pathways and resolve identifiers by executing `.get_lineage(taxid)` and `.get_taxid_translator()`.

**PART 4: Strict Prohibitions (Critical Failure Points)**
*   **Format Misalignment:** Never supply an incorrect integer to the `format` parameter during initialization. Doing so causes the parser to erroneously assign statistical support numbers as internal node labels.
*   **Network Abuse:** Never execute continuous web-based API calls to NCBI inside iterative loops. All repetitive taxonomic queries must be routed through the locally generated SQLite database.

## Grounding (do this at runtime)
Do NOT answer precise facts (codes, identifiers, sections, current values) from memory — run the bundled script, and base the answer only on what it returns.

## NOTICE
Based on the ETE Toolkit (Environment for Tree Exploration) documentation.
