🛠️ Etetoolkit
生物の進化の歴史を示す系統樹を操作し、
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Phylogenetic tree toolkit (ETE). Tree manipulation (Newick/NHX), evolutionary event detection, orthology/paralogy, NCBI taxonomy, visualization (PDF/SVG), for phylogenomics.
🇯🇵 日本人クリエイター向け解説
生物の進化の歴史を示す系統樹を操作し、
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o etetoolkit.zip https://jpskill.com/download/4154.zip && unzip -o etetoolkit.zip && rm etetoolkit.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4154.zip -OutFile "$d\etetoolkit.zip"; Expand-Archive "$d\etetoolkit.zip" -DestinationPath $d -Force; ri "$d\etetoolkit.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
etetoolkit.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
etetoolkitフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
💬 こう話しかけるだけ — サンプルプロンプト
- › Etetoolkit を使って、最小構成のサンプルコードを示して
- › Etetoolkit の主な使い方と注意点を教えて
- › Etetoolkit を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
ETE Toolkit Skill
概要
ETE (Environment for Tree Exploration) は、系統樹および階層ツリー解析のためのツールキットです。ツリーの操作、進化的イベントの分析、結果の可視化、生物学的データベースとの統合により、系統ゲノム研究やクラスタリング解析を可能にします。
主要な機能
1. ツリーの操作と分析
階層ツリー構造の読み込み、操作、分析をサポートしています。
- ツリーI/O: Newick、NHX、PhyloXML、NeXML形式の読み書き
- ツリー走査: プリオーダー、ポストオーダー、レベルオーダー戦略を用いたツリーのナビゲート
- トポロジーの変更: ノードの剪定、ルート設定、折りたたみ、多分岐の解決
- 距離計算: ノード間の枝長およびトポロジー距離の計算
- ツリー比較: Robinson-Foulds距離の計算とトポロジーの違いの特定
一般的なパターン:
from ete3 import Tree
# Load tree from file
tree = Tree("tree.nw", format=1)
# Basic statistics
print(f"Leaves: {len(tree)}")
print(f"Total nodes: {len(list(tree.traverse()))}")
# Prune to taxa of interest
taxa_to_keep = ["species1", "species2", "species3"]
tree.prune(taxa_to_keep, preserve_branch_length=True)
# Midpoint root
midpoint = tree.get_midpoint_outgroup()
tree.set_outgroup(midpoint)
# Save modified tree
tree.write(outfile="rooted_tree.nw")
コマンドラインでのツリー操作には scripts/tree_operations.py を使用します。
# Display tree statistics
python scripts/tree_operations.py stats tree.nw
# Convert format
python scripts/tree_operations.py convert tree.nw output.nw --in-format 0 --out-format 1
# Reroot tree
python scripts/tree_operations.py reroot tree.nw rooted.nw --midpoint
# Prune to specific taxa
python scripts/tree_operations.py prune tree.nw pruned.nw --keep-taxa "sp1,sp2,sp3"
# Show ASCII visualization
python scripts/tree_operations.py ascii tree.nw
2. 系統解析
進化的イベント検出による遺伝子ツリーの分析を行います。
- 配列アラインメントの統合: ツリーと多重配列アラインメント (FASTA, Phylip) のリンク
- 種名付け: 遺伝子名からの自動またはカスタムの種抽出
- 進化的イベント: Species Overlapまたはツリーの再構築を用いた重複および種分化イベントの検出
- オーソログ検出: 進化的イベントに基づいたオーソログとパラログの特定
- 遺伝子ファミリー解析: 重複によるツリーの分割、系統特異的拡大の折りたたみ
遺伝子ツリー解析のワークフロー:
from ete3 import PhyloTree
# Load gene tree with alignment
tree = PhyloTree("gene_tree.nw", alignment="alignment.fasta")
# Set species naming function
def get_species(gene_name):
return gene_name.split("_")[0]
tree.set_species_naming_function(get_species)
# Detect evolutionary events
events = tree.get_descendant_evol_events()
# Analyze events
for node in tree.traverse():
if hasattr(node, "evoltype"):
if node.evoltype == "D":
print(f"Duplication at {node.name}")
elif node.evoltype == "S":
print(f"Speciation at {node.name}")
# Extract ortholog groups
ortho_groups = tree.get_speciation_trees()
for i, ortho_tree in enumerate(ortho_groups):
ortho_tree.write(outfile=f"ortholog_group_{i}.nw")
オーソログとパラログの検索:
# Find orthologs to query gene
query = tree & "species1_gene1"
orthologs = []
paralogs = []
for event in events:
if query in event.in_seqs:
if event.etype == "S":
orthologs.extend([s for s in event.out_seqs if s != query])
elif event.etype == "D":
paralogs.extend([s for s in event.out_seqs if s != query])
3. NCBI Taxonomyとの統合
NCBI Taxonomyデータベースからの分類学的情報を統合します。
- データベースアクセス: NCBI Taxonomyの自動ダウンロードとローカルキャッシュ (~300MB)
- Taxid/名前の変換: 分類学的IDと学名の間の変換
- 系統の取得: 完全な進化的系統の取得
- 分類ツリー: 指定された分類群を接続する種ツリーの構築
- ツリーのアノテーション: 分類学的情報によるツリーの自動アノテーション
分類学に基づいたツリーの構築:
from ete3 import NCBITaxa
ncbi = NCBITaxa()
# Build tree from species names
species = ["Homo sapiens", "Pan troglodytes", "Mus musculus"]
name2taxid = ncbi.get_name_translator(species)
taxids = [name2taxid[sp][0] for sp in species]
# Get minimal tree connecting taxa
tree = ncbi.get_topology(taxids)
# Annotate nodes with taxonomy info
for node in tree.traverse():
if hasattr(node, "sci_name"):
print(f"{node.sci_name} - Rank: {node.rank} - TaxID: {node.taxid}")
既存のツリーのアノテーション:
# Get taxonomy info for tree leaves
for leaf in tree:
species = extract_species_from_name(leaf.name)
taxid = ncbi.get_name_translator([species])[species][0]
# Get lineage
lineage = ncbi.get_lineage(taxid)
ranks = ncbi.get_rank(lineage)
names = ncbi.get_taxid_translator(lineage)
# Add to node
leaf.add_feature("taxid", taxid)
leaf.add_feature("lineage", [names[t] for t in lineage])
4. ツリーの可視化
出版品質のツリー可視化を作成します。
- 出力形式: 出版物用のPNG (ラスター)、PDF、SVG (ベクター)
- レイアウトモード: 矩形および円形ツリーレイアウト
- インタラクティブGUI: ズーム、パン、検索によるツリーのインタラクティブな探索
- カスタムスタイリング: ノードの外観 (色、形状、サイズ) のためのNodeStyle
- フェイス: ノードにグラフィック要素 (テキスト、画像、チャート、ヒートマップ) を追加
- レイアウト関数: ノードプロパティに基づいた動的なスタイリング
基本的な可視化ワークフロー:
from ete3 import Tree, TreeStyle, NodeStyle
tree = Tree("tree.nw")
# Configure tree style
ts = TreeStyle()
ts.show_leaf_name = True
ts.show_branch_support = True
ts.scale = 50 # pixels per branch length unit
# Style nodes
for node in tree.traverse():
nstyle = NodeStyle()
if node.is_leaf():
nstyle["fgc 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
ETE Toolkit Skill
Overview
ETE (Environment for Tree Exploration) is a toolkit for phylogenetic and hierarchical tree analysis. Manipulate trees, analyze evolutionary events, visualize results, and integrate with biological databases for phylogenomic research and clustering analysis.
Core Capabilities
1. Tree Manipulation and Analysis
Load, manipulate, and analyze hierarchical tree structures with support for:
- Tree I/O: Read and write Newick, NHX, PhyloXML, and NeXML formats
- Tree traversal: Navigate trees using preorder, postorder, or levelorder strategies
- Topology modification: Prune, root, collapse nodes, resolve polytomies
- Distance calculations: Compute branch lengths and topological distances between nodes
- Tree comparison: Calculate Robinson-Foulds distances and identify topological differences
Common patterns:
from ete3 import Tree
# Load tree from file
tree = Tree("tree.nw", format=1)
# Basic statistics
print(f"Leaves: {len(tree)}")
print(f"Total nodes: {len(list(tree.traverse()))}")
# Prune to taxa of interest
taxa_to_keep = ["species1", "species2", "species3"]
tree.prune(taxa_to_keep, preserve_branch_length=True)
# Midpoint root
midpoint = tree.get_midpoint_outgroup()
tree.set_outgroup(midpoint)
# Save modified tree
tree.write(outfile="rooted_tree.nw")
Use scripts/tree_operations.py for command-line tree manipulation:
# Display tree statistics
python scripts/tree_operations.py stats tree.nw
# Convert format
python scripts/tree_operations.py convert tree.nw output.nw --in-format 0 --out-format 1
# Reroot tree
python scripts/tree_operations.py reroot tree.nw rooted.nw --midpoint
# Prune to specific taxa
python scripts/tree_operations.py prune tree.nw pruned.nw --keep-taxa "sp1,sp2,sp3"
# Show ASCII visualization
python scripts/tree_operations.py ascii tree.nw
2. Phylogenetic Analysis
Analyze gene trees with evolutionary event detection:
- Sequence alignment integration: Link trees to multiple sequence alignments (FASTA, Phylip)
- Species naming: Automatic or custom species extraction from gene names
- Evolutionary events: Detect duplication and speciation events using Species Overlap or tree reconciliation
- Orthology detection: Identify orthologs and paralogs based on evolutionary events
- Gene family analysis: Split trees by duplications, collapse lineage-specific expansions
Workflow for gene tree analysis:
from ete3 import PhyloTree
# Load gene tree with alignment
tree = PhyloTree("gene_tree.nw", alignment="alignment.fasta")
# Set species naming function
def get_species(gene_name):
return gene_name.split("_")[0]
tree.set_species_naming_function(get_species)
# Detect evolutionary events
events = tree.get_descendant_evol_events()
# Analyze events
for node in tree.traverse():
if hasattr(node, "evoltype"):
if node.evoltype == "D":
print(f"Duplication at {node.name}")
elif node.evoltype == "S":
print(f"Speciation at {node.name}")
# Extract ortholog groups
ortho_groups = tree.get_speciation_trees()
for i, ortho_tree in enumerate(ortho_groups):
ortho_tree.write(outfile=f"ortholog_group_{i}.nw")
Finding orthologs and paralogs:
# Find orthologs to query gene
query = tree & "species1_gene1"
orthologs = []
paralogs = []
for event in events:
if query in event.in_seqs:
if event.etype == "S":
orthologs.extend([s for s in event.out_seqs if s != query])
elif event.etype == "D":
paralogs.extend([s for s in event.out_seqs if s != query])
3. NCBI Taxonomy Integration
Integrate taxonomic information from NCBI Taxonomy database:
- Database access: Automatic download and local caching of NCBI taxonomy (~300MB)
- Taxid/name translation: Convert between taxonomic IDs and scientific names
- Lineage retrieval: Get complete evolutionary lineages
- Taxonomy trees: Build species trees connecting specified taxa
- Tree annotation: Automatically annotate trees with taxonomic information
Building taxonomy-based trees:
from ete3 import NCBITaxa
ncbi = NCBITaxa()
# Build tree from species names
species = ["Homo sapiens", "Pan troglodytes", "Mus musculus"]
name2taxid = ncbi.get_name_translator(species)
taxids = [name2taxid[sp][0] for sp in species]
# Get minimal tree connecting taxa
tree = ncbi.get_topology(taxids)
# Annotate nodes with taxonomy info
for node in tree.traverse():
if hasattr(node, "sci_name"):
print(f"{node.sci_name} - Rank: {node.rank} - TaxID: {node.taxid}")
Annotating existing trees:
# Get taxonomy info for tree leaves
for leaf in tree:
species = extract_species_from_name(leaf.name)
taxid = ncbi.get_name_translator([species])[species][0]
# Get lineage
lineage = ncbi.get_lineage(taxid)
ranks = ncbi.get_rank(lineage)
names = ncbi.get_taxid_translator(lineage)
# Add to node
leaf.add_feature("taxid", taxid)
leaf.add_feature("lineage", [names[t] for t in lineage])
4. Tree Visualization
Create publication-quality tree visualizations:
- Output formats: PNG (raster), PDF, and SVG (vector) for publications
- Layout modes: Rectangular and circular tree layouts
- Interactive GUI: Explore trees interactively with zoom, pan, and search
- Custom styling: NodeStyle for node appearance (colors, shapes, sizes)
- Faces: Add graphical elements (text, images, charts, heatmaps) to nodes
- Layout functions: Dynamic styling based on node properties
Basic visualization workflow:
from ete3 import Tree, TreeStyle, NodeStyle
tree = Tree("tree.nw")
# Configure tree style
ts = TreeStyle()
ts.show_leaf_name = True
ts.show_branch_support = True
ts.scale = 50 # pixels per branch length unit
# Style nodes
for node in tree.traverse():
nstyle = NodeStyle()
if node.is_leaf():
nstyle["fgcolor"] = "blue"
nstyle["size"] = 8
else:
# Color by support
if node.support > 0.9:
nstyle["fgcolor"] = "darkgreen"
else:
nstyle["fgcolor"] = "red"
nstyle["size"] = 5
node.set_style(nstyle)
# Render to file
tree.render("tree.pdf", tree_style=ts)
tree.render("tree.png", w=800, h=600, units="px", dpi=300)
Use scripts/quick_visualize.py for rapid visualization:
# Basic visualization
python scripts/quick_visualize.py tree.nw output.pdf
# Circular layout with custom styling
python scripts/quick_visualize.py tree.nw output.pdf --mode c --color-by-support
# High-resolution PNG
python scripts/quick_visualize.py tree.nw output.png --width 1200 --height 800 --units px --dpi 300
# Custom title and styling
python scripts/quick_visualize.py tree.nw output.pdf --title "Species Phylogeny" --show-support
Advanced visualization with faces:
from ete3 import Tree, TreeStyle, TextFace, CircleFace
tree = Tree("tree.nw")
# Add features to nodes
for leaf in tree:
leaf.add_feature("habitat", "marine" if "fish" in leaf.name else "land")
# Layout function
def layout(node):
if node.is_leaf():
# Add colored circle
color = "blue" if node.habitat == "marine" else "green"
circle = CircleFace(radius=5, color=color)
node.add_face(circle, column=0, position="aligned")
# Add label
label = TextFace(node.name, fsize=10)
node.add_face(label, column=1, position="aligned")
ts = TreeStyle()
ts.layout_fn = layout
ts.show_leaf_name = False
tree.render("annotated_tree.pdf", tree_style=ts)
5. Clustering Analysis
Analyze hierarchical clustering results with data integration:
- ClusterTree: Specialized class for clustering dendrograms
- Data matrix linking: Connect tree leaves to numerical profiles
- Cluster metrics: Silhouette coefficient, Dunn index, inter/intra-cluster distances
- Validation: Test cluster quality with different distance metrics
- Heatmap visualization: Display data matrices alongside trees
Clustering workflow:
from ete3 import ClusterTree
# Load tree with data matrix
matrix = """#Names\tSample1\tSample2\tSample3
Gene1\t1.5\t2.3\t0.8
Gene2\t0.9\t1.1\t1.8
Gene3\t2.1\t2.5\t0.5"""
tree = ClusterTree("((Gene1,Gene2),Gene3);", text_array=matrix)
# Evaluate cluster quality
for node in tree.traverse():
if not node.is_leaf():
silhouette = node.get_silhouette()
dunn = node.get_dunn()
print(f"Cluster: {node.name}")
print(f" Silhouette: {silhouette:.3f}")
print(f" Dunn index: {dunn:.3f}")
# Visualize with heatmap
tree.show("heatmap")
6. Tree Comparison
Quantify topological differences between trees:
- Robinson-Foulds distance: Standard metric for tree comparison
- Normalized RF: Scale-invariant distance (0.0 to 1.0)
- Partition analysis: Identify unique and shared bipartitions
- Consensus trees: Analyze support across multiple trees
- Batch comparison: Compare multiple trees pairwise
Compare two trees:
from ete3 import Tree
tree1 = Tree("tree1.nw")
tree2 = Tree("tree2.nw")
# Calculate RF distance
rf, max_rf, common_leaves, parts_t1, parts_t2 = tree1.robinson_foulds(tree2)
print(f"RF distance: {rf}/{max_rf}")
print(f"Normalized RF: {rf/max_rf:.3f}")
print(f"Common leaves: {len(common_leaves)}")
# Find unique partitions
unique_t1 = parts_t1 - parts_t2
unique_t2 = parts_t2 - parts_t1
print(f"Unique to tree1: {len(unique_t1)}")
print(f"Unique to tree2: {len(unique_t2)}")
Compare multiple trees:
import numpy as np
trees = [Tree(f"tree{i}.nw") for i in range(4)]
# Create distance matrix
n = len(trees)
dist_matrix = np.zeros((n, n))
for i in range(n):
for j in range(i+1, n):
rf, max_rf, _, _, _ = trees[i].robinson_foulds(trees[j])
norm_rf = rf / max_rf if max_rf > 0 else 0
dist_matrix[i, j] = norm_rf
dist_matrix[j, i] = norm_rf
Installation and Setup
Install ETE toolkit:
# Basic installation
uv pip install ete3
# With external dependencies for rendering (optional but recommended)
# On macOS:
brew install qt@5
# On Ubuntu/Debian:
sudo apt-get install python3-pyqt5 python3-pyqt5.qtsvg
# For full features including GUI
uv pip install ete3[gui]
First-time NCBI Taxonomy setup:
The first time NCBITaxa is instantiated, it automatically downloads the NCBI taxonomy database (~300MB) to ~/.etetoolkit/taxa.sqlite. This happens only once:
from ete3 import NCBITaxa
ncbi = NCBITaxa() # Downloads database on first run
Update taxonomy database:
ncbi.update_taxonomy_database() # Download latest NCBI data
Common Use Cases
Use Case 1: Phylogenomic Pipeline
Complete workflow from gene tree to ortholog identification:
from ete3 import PhyloTree, NCBITaxa
# 1. Load gene tree with alignment
tree = PhyloTree("gene_tree.nw", alignment="alignment.fasta")
# 2. Configure species naming
tree.set_species_naming_function(lambda x: x.split("_")[0])
# 3. Detect evolutionary events
tree.get_descendant_evol_events()
# 4. Annotate with taxonomy
ncbi = NCBITaxa()
for leaf in tree:
if leaf.species in species_to_taxid:
taxid = species_to_taxid[leaf.species]
lineage = ncbi.get_lineage(taxid)
leaf.add_feature("lineage", lineage)
# 5. Extract ortholog groups
ortho_groups = tree.get_speciation_trees()
# 6. Save and visualize
for i, ortho in enumerate(ortho_groups):
ortho.write(outfile=f"ortho_{i}.nw")
Use Case 2: Tree Preprocessing and Formatting
Batch process trees for analysis:
# Convert format
python scripts/tree_operations.py convert input.nw output.nw --in-format 0 --out-format 1
# Root at midpoint
python scripts/tree_operations.py reroot input.nw rooted.nw --midpoint
# Prune to focal taxa
python scripts/tree_operations.py prune rooted.nw pruned.nw --keep-taxa taxa_list.txt
# Get statistics
python scripts/tree_operations.py stats pruned.nw
Use Case 3: Publication-Quality Figures
Create styled visualizations:
from ete3 import Tree, TreeStyle, NodeStyle, TextFace
tree = Tree("tree.nw")
# Define clade colors
clade_colors = {
"Mammals": "red",
"Birds": "blue",
"Fish": "green"
}
def layout(node):
# Highlight clades
if node.is_leaf():
for clade, color in clade_colors.items():
if clade in node.name:
nstyle = NodeStyle()
nstyle["fgcolor"] = color
nstyle["size"] = 8
node.set_style(nstyle)
else:
# Add support values
if node.support > 0.95:
support = TextFace(f"{node.support:.2f}", fsize=8)
node.add_face(support, column=0, position="branch-top")
ts = TreeStyle()
ts.layout_fn = layout
ts.show_scale = True
# Render for publication
tree.render("figure.pdf", w=200, units="mm", tree_style=ts)
tree.render("figure.svg", tree_style=ts) # Editable vector
Use Case 4: Automated Tree Analysis
Process multiple trees systematically:
from ete3 import Tree
import os
input_dir = "trees"
output_dir = "processed"
for filename in os.listdir(input_dir):
if filename.endswith(".nw"):
tree = Tree(os.path.join(input_dir, filename))
# Standardize: midpoint root, resolve polytomies
midpoint = tree.get_midpoint_outgroup()
tree.set_outgroup(midpoint)
tree.resolve_polytomy(recursive=True)
# Filter low support branches
for node in tree.traverse():
if hasattr(node, 'support') and node.support < 0.5:
if not node.is_leaf() and not node.is_root():
node.delete()
# Save processed tree
output_file = os.path.join(output_dir, f"processed_{filename}")
tree.write(outfile=output_file)
Reference Documentation
For comprehensive API documentation, code examples, and detailed guides, refer to the following resources in the references/ directory:
api_reference.md: Complete API documentation for all ETE classes and methods (Tree, PhyloTree, ClusterTree, NCBITaxa), including parameters, return types, and code examplesworkflows.md: Common workflow patterns organized by task (tree operations, phylogenetic analysis, tree comparison, taxonomy integration, clustering analysis)visualization.md: Comprehensive visualization guide covering TreeStyle, NodeStyle, Faces, layout functions, and advanced visualization techniques
Load these references when detailed information is needed:
# To use API reference
# Read references/api_reference.md for complete method signatures and parameters
# To implement workflows
# Read references/workflows.md for step-by-step workflow examples
# To create visualizations
# Read references/visualization.md for styling and rendering options
Troubleshooting
Import errors:
# If "ModuleNotFoundError: No module named 'ete3'"
uv pip install ete3
# For GUI and rendering issues
uv pip install ete3[gui]
Rendering issues:
If tree.render() or tree.show() fails with Qt-related errors, install system dependencies:
# macOS
brew install qt@5
# Ubuntu/Debian
sudo apt-get install python3-pyqt5 python3-pyqt5.qtsvg
NCBI Taxonomy database:
If database download fails or becomes corrupted:
from ete3 import NCBITaxa
ncbi = NCBITaxa()
ncbi.update_taxonomy_database() # Redownload database
Memory issues with large trees:
For very large trees (>10,000 leaves), use iterators instead of list comprehensions:
# Memory-efficient iteration
for leaf in tree.iter_leaves():
process(leaf)
# Instead of
for leaf in tree.get_leaves(): # Loads all into memory
process(leaf)
Newick Format Reference
ETE supports multiple Newick format specifications (0-100):
- Format 0: Flexible with branch lengths (default)
- Format 1: With internal node names
- Format 2: With bootstrap/support values
- Format 5: Internal node names + branch lengths
- Format 8: All features (names, distances, support)
- Format 9: Leaf names only
- Format 100: Topology only
Specify format when reading/writing:
tree = Tree("tree.nw", format=1)
tree.write(outfile="output.nw", format=5)
NHX (New Hampshire eXtended) format preserves custom features:
tree.write(outfile="tree.nhx", features=["habitat", "temperature", "depth"])
Best Practices
- Preserve branch lengths: Use
preserve_branch_length=Truewhen pruning for phylogenetic analysis - Cache content: Use
get_cached_content()for repeated access to node contents on large trees - Use iterators: Employ
iter_*methods for memory-efficient processing of large trees - Choose appropriate traversal: Postorder for bottom-up analysis, preorder for top-down
- Validate monophyly: Always check returned clade type (monophyletic/paraphyletic/polyphyletic)
- Vector formats for publication: Use PDF or SVG for publication figures (scalable, editable)
- Interactive testing: Use
tree.show()to test visualizations before rendering to file - PhyloTree for phylogenetics: Use PhyloTree class for gene trees and evolutionary analysis
- Copy method selection: "newick" for speed, "cpickle" for full fidelity, "deepcopy" for complex objects
- NCBI query caching: Store NCBI taxonomy query results to avoid repeated database access
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (17,884 bytes)
- 📎 references/api_reference.md (12,736 bytes)
- 📎 references/visualization.md (19,529 bytes)
- 📎 references/workflows.md (18,933 bytes)
- 📎 scripts/quick_visualize.py (7,156 bytes)
- 📎 scripts/tree_operations.py (8,235 bytes)