@pikaa-ai/pikaa 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
  2. package/assets/brand/orbit-logo.jpg +0 -0
  3. package/assets/brand/orbit-logo.png +0 -0
  4. package/assets/brand/orbit-logo.svg +3 -0
  5. package/dist/cli.js +448 -181
  6. package/dist/index.js +22 -2
  7. package/package.json +1 -2
  8. package/skills/adaptyv/SKILL.md +0 -240
  9. package/skills/aeon/SKILL.md +0 -402
  10. package/skills/analytical-method-validation/SKILL.md +0 -299
  11. package/skills/anndata/SKILL.md +0 -431
  12. package/skills/arbor/SKILL.md +0 -152
  13. package/skills/arboreto/SKILL.md +0 -267
  14. package/skills/astropy/SKILL.md +0 -353
  15. package/skills/autoskill/SKILL.md +0 -233
  16. package/skills/benchling-integration/SKILL.md +0 -229
  17. package/skills/bgpt-paper-search/SKILL.md +0 -75
  18. package/skills/bids/SKILL.md +0 -237
  19. package/skills/biopython/SKILL.md +0 -472
  20. package/skills/bioservices/SKILL.md +0 -399
  21. package/skills/bulk-rnaseq/SKILL.md +0 -198
  22. package/skills/cellxgene-census/SKILL.md +0 -283
  23. package/skills/cirq/SKILL.md +0 -370
  24. package/skills/citation-management/SKILL.md +0 -329
  25. package/skills/clinical-decision-support/SKILL.md +0 -238
  26. package/skills/clinical-decision-support/references/README.md +0 -62
  27. package/skills/clinical-reports/SKILL.md +0 -248
  28. package/skills/clinical-reports/references/README.md +0 -34
  29. package/skills/cobrapy/SKILL.md +0 -496
  30. package/skills/consciousness-council/SKILL.md +0 -151
  31. package/skills/dask/SKILL.md +0 -482
  32. package/skills/database-lookup/SKILL.md +0 -386
  33. package/skills/datamol/SKILL.md +0 -200
  34. package/skills/deepchem/SKILL.md +0 -244
  35. package/skills/deepspot-m/SKILL.md +0 -175
  36. package/skills/deeptools/SKILL.md +0 -412
  37. package/skills/depmap/SKILL.md +0 -301
  38. package/skills/dhdna-profiler/SKILL.md +0 -184
  39. package/skills/diffdock/SKILL.md +0 -488
  40. package/skills/dnanexus-integration/SKILL.md +0 -325
  41. package/skills/docx/SKILL.md +0 -99
  42. package/skills/esm/SKILL.md +0 -334
  43. package/skills/etetoolkit/SKILL.md +0 -327
  44. package/skills/exa-search/SKILL.md +0 -102
  45. package/skills/executing-plans/SKILL.md +0 -14
  46. package/skills/experimental-design/SKILL.md +0 -234
  47. package/skills/exploratory-data-analysis/SKILL.md +0 -280
  48. package/skills/flowio/SKILL.md +0 -310
  49. package/skills/fluidsim/SKILL.md +0 -279
  50. package/skills/frontend-design/SKILL.md +0 -100
  51. package/skills/generate-image/SKILL.md +0 -304
  52. package/skills/geniml/SKILL.md +0 -310
  53. package/skills/genomic-coordinates/SKILL.md +0 -189
  54. package/skills/genomic-intelligence/SKILL.md +0 -243
  55. package/skills/geomaster/README.md +0 -105
  56. package/skills/geomaster/SKILL.md +0 -366
  57. package/skills/geopandas/SKILL.md +0 -250
  58. package/skills/get-available-resources/SKILL.md +0 -260
  59. package/skills/gget/SKILL.md +0 -153
  60. package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
  61. package/skills/glycoengineering/SKILL.md +0 -339
  62. package/skills/gtars/SKILL.md +0 -282
  63. package/skills/guardian-rails/SKILL.md +0 -54
  64. package/skills/histolab/SKILL.md +0 -243
  65. package/skills/hugging-science/SKILL.md +0 -132
  66. package/skills/hypogenic/SKILL.md +0 -290
  67. package/skills/hypothesis-generation/SKILL.md +0 -264
  68. package/skills/imaging-data-commons/SKILL.md +0 -496
  69. package/skills/infographics/SKILL.md +0 -315
  70. package/skills/iso-standards-readiness/SKILL.md +0 -352
  71. package/skills/lab-hardware-cad/SKILL.md +0 -372
  72. package/skills/labarchive-integration/SKILL.md +0 -216
  73. package/skills/lamindb/SKILL.md +0 -408
  74. package/skills/latchbio-integration/SKILL.md +0 -227
  75. package/skills/latex-posters/SKILL.md +0 -369
  76. package/skills/latex-posters/references/README.md +0 -439
  77. package/skills/liteparse/SKILL.md +0 -295
  78. package/skills/literature-review/SKILL.md +0 -263
  79. package/skills/markdown-mermaid-writing/SKILL.md +0 -322
  80. package/skills/market-research-reports/SKILL.md +0 -337
  81. package/skills/markitdown/SKILL.md +0 -264
  82. package/skills/matchms/SKILL.md +0 -276
  83. package/skills/matlab/SKILL.md +0 -274
  84. package/skills/matplotlib/SKILL.md +0 -378
  85. package/skills/medchem/SKILL.md +0 -321
  86. package/skills/modal/SKILL.md +0 -468
  87. package/skills/molecular-dynamics/SKILL.md +0 -458
  88. package/skills/molfeat/SKILL.md +0 -348
  89. package/skills/ncats-arax/SKILL.md +0 -178
  90. package/skills/networkx/SKILL.md +0 -440
  91. package/skills/neurokit2/SKILL.md +0 -323
  92. package/skills/neuropixels-analysis/SKILL.md +0 -412
  93. package/skills/nextflow/SKILL.md +0 -195
  94. package/skills/omero-integration/SKILL.md +0 -222
  95. package/skills/onekgpd/SKILL.md +0 -371
  96. package/skills/ontology-term-resolution/SKILL.md +0 -147
  97. package/skills/open-notebook/SKILL.md +0 -297
  98. package/skills/openpiv/SKILL.md +0 -469
  99. package/skills/opentrons-integration/SKILL.md +0 -322
  100. package/skills/optimize-for-gpu/SKILL.md +0 -176
  101. package/skills/owasp-top10/SKILL.md +0 -48
  102. package/skills/pacsomatic/LICENSE +0 -21
  103. package/skills/pacsomatic/SKILL.md +0 -150
  104. package/skills/paper-lookup/SKILL.md +0 -263
  105. package/skills/paperclip/SKILL.md +0 -413
  106. package/skills/paperzilla/SKILL.md +0 -159
  107. package/skills/parallel-web/SKILL.md +0 -128
  108. package/skills/pathml/SKILL.md +0 -222
  109. package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
  110. package/skills/pathway-enrichment/SKILL.md +0 -194
  111. package/skills/pdf/SKILL.md +0 -322
  112. package/skills/peer-review/SKILL.md +0 -288
  113. package/skills/penetration-testing/SKILL.md +0 -31
  114. package/skills/pennylane/SKILL.md +0 -240
  115. package/skills/phylogenetics/SKILL.md +0 -409
  116. package/skills/pi-agent/SKILL.md +0 -83
  117. package/skills/pkpd-modeling/SKILL.md +0 -381
  118. package/skills/polars/SKILL.md +0 -393
  119. package/skills/polars-bio/SKILL.md +0 -379
  120. package/skills/ponytail/SKILL.md +0 -31
  121. package/skills/ponytail-audit/SKILL.md +0 -18
  122. package/skills/pptx/SKILL.md +0 -246
  123. package/skills/pptx-posters/SKILL.md +0 -258
  124. package/skills/primekg/SKILL.md +0 -99
  125. package/skills/protocolsio-integration/SKILL.md +0 -236
  126. package/skills/pufferlib/SKILL.md +0 -328
  127. package/skills/pydeseq2/SKILL.md +0 -369
  128. package/skills/pydicom/SKILL.md +0 -381
  129. package/skills/pyhealth/SKILL.md +0 -124
  130. package/skills/pylabrobot/SKILL.md +0 -216
  131. package/skills/pymatgen/SKILL.md +0 -404
  132. package/skills/pymc/SKILL.md +0 -310
  133. package/skills/pymoo/SKILL.md +0 -276
  134. package/skills/pyopenms/SKILL.md +0 -179
  135. package/skills/pysam/SKILL.md +0 -330
  136. package/skills/pytdc/SKILL.md +0 -297
  137. package/skills/pytorch-lightning/SKILL.md +0 -191
  138. package/skills/pyzotero/SKILL.md +0 -137
  139. package/skills/qiskit/SKILL.md +0 -259
  140. package/skills/qutip/SKILL.md +0 -317
  141. package/skills/rdkit/SKILL.md +0 -94
  142. package/skills/relsa-severity-assessment/SKILL.md +0 -354
  143. package/skills/research-grants/SKILL.md +0 -296
  144. package/skills/research-grants/references/README.md +0 -287
  145. package/skills/research-lookup/README.md +0 -106
  146. package/skills/research-lookup/SKILL.md +0 -338
  147. package/skills/rowan/SKILL.md +0 -398
  148. package/skills/scanpy/SKILL.md +0 -303
  149. package/skills/scholar-evaluation/SKILL.md +0 -296
  150. package/skills/scientific-brainstorming/SKILL.md +0 -282
  151. package/skills/scientific-critical-thinking/SKILL.md +0 -180
  152. package/skills/scientific-schematics/SKILL.md +0 -370
  153. package/skills/scientific-slides/SKILL.md +0 -379
  154. package/skills/scientific-visualization/SKILL.md +0 -285
  155. package/skills/scientific-writing/SKILL.md +0 -356
  156. package/skills/scikit-bio/SKILL.md +0 -470
  157. package/skills/scikit-learn/SKILL.md +0 -324
  158. package/skills/scikit-survival/SKILL.md +0 -313
  159. package/skills/scvelo/SKILL.md +0 -328
  160. package/skills/scvi-tools/SKILL.md +0 -201
  161. package/skills/seaborn/SKILL.md +0 -254
  162. package/skills/security-auditor/SKILL.md +0 -37
  163. package/skills/shap/SKILL.md +0 -282
  164. package/skills/simpy/SKILL.md +0 -283
  165. package/skills/stable-baselines3/SKILL.md +0 -325
  166. package/skills/statistical-analysis/SKILL.md +0 -446
  167. package/skills/statistical-power/SKILL.md +0 -200
  168. package/skills/statsmodels/SKILL.md +0 -238
  169. package/skills/sympy/SKILL.md +0 -354
  170. package/skills/systematic-debugging/SKILL.md +0 -35
  171. package/skills/tamarind/SKILL.md +0 -285
  172. package/skills/tdd/SKILL.md +0 -26
  173. package/skills/tiledbvcf/SKILL.md +0 -456
  174. package/skills/timesfm-forecasting/SKILL.md +0 -408
  175. package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
  176. package/skills/torch-geometric/SKILL.md +0 -458
  177. package/skills/torchdrug/SKILL.md +0 -241
  178. package/skills/transformers/SKILL.md +0 -195
  179. package/skills/treatment-plans/SKILL.md +0 -174
  180. package/skills/treatment-plans/references/README.md +0 -19
  181. package/skills/umap-learn/SKILL.md +0 -488
  182. package/skills/uncertainty-and-units/SKILL.md +0 -384
  183. package/skills/usfiscaldata/SKILL.md +0 -171
  184. package/skills/vaex/SKILL.md +0 -204
  185. package/skills/venue-templates/SKILL.md +0 -269
  186. package/skills/verification-before-completion/SKILL.md +0 -22
  187. package/skills/waypoint-bio/SKILL.md +0 -273
  188. package/skills/what-if-oracle/SKILL.md +0 -184
  189. package/skills/writing-plans/SKILL.md +0 -15
  190. package/skills/xlsx/SKILL.md +0 -110
  191. package/skills/zarr-python/SKILL.md +0 -241
@@ -1,409 +0,0 @@
1
- ---
2
- name: phylogenetics
3
- description: Build and analyze phylogenetic trees using MAFFT (multiple alignment), IQ-TREE 2 (maximum likelihood), and FastTree (fast NJ/ML). Visualize with ETE3 or FigTree. For evolutionary analysis, microbial genomics, viral phylodynamics, protein family analysis, and molecular clock studies.
4
- license: Unknown
5
- metadata:
6
- version: "1.2"
7
- skill-author: Kuan-lin Huang
8
- ---
9
-
10
- # Phylogenetics
11
-
12
- ## Overview
13
-
14
- Phylogenetic analysis reconstructs the evolutionary history of biological sequences (genes, proteins, genomes) by inferring the branching pattern of descent. This skill covers the standard pipeline:
15
-
16
- 1. **MAFFT** — Multiple sequence alignment
17
- 2. **IQ-TREE 2** — Maximum likelihood tree inference with model selection
18
- 3. **FastTree** — Fast approximate maximum likelihood (for large datasets)
19
- 4. **ETE3** — Python library for tree manipulation and visualization
20
-
21
- **Installation:**
22
- ```bash
23
- # Conda (recommended for CLI tools)
24
- conda install -c bioconda mafft iqtree fasttree
25
- uv pip install ete3
26
-
27
- # ete3's TreeStyle/NodeStyle rendering lives in its Qt backend, so image output
28
- # needs PyQt5 as well; tree parsing and statistics work without it.
29
- uv pip install PyQt5
30
- ```
31
-
32
- ## When to Use This Skill
33
-
34
- Use phylogenetics when:
35
-
36
- - **Evolutionary relationships**: Which organism/gene is most closely related to my sequence?
37
- - **Viral phylodynamics**: Trace outbreak spread and estimate transmission dates
38
- - **Protein family analysis**: Infer evolutionary relationships within a gene family
39
- - **Horizontal gene transfer detection**: Identify genes with discordant species/gene trees
40
- - **Ancestral sequence reconstruction**: Infer ancestral protein sequences
41
- - **Molecular clock analysis**: Estimate divergence dates using temporal sampling
42
- - **GWAS companion**: Place variants in evolutionary context (e.g., SARS-CoV-2 variants)
43
- - **Microbiology**: Species phylogeny from 16S rRNA or core genome phylogeny
44
-
45
- ## Standard Workflow
46
-
47
- ### 1. Multiple Sequence Alignment with MAFFT
48
-
49
- ```python
50
- import subprocess
51
- import os
52
-
53
- def run_mafft(input_fasta: str, output_fasta: str, method: str = "auto",
54
- n_threads: int = 4) -> str:
55
- """
56
- Align sequences with MAFFT.
57
-
58
- Args:
59
- input_fasta: Path to unaligned FASTA file
60
- output_fasta: Path for aligned output
61
- method: 'auto' (auto-select), 'einsi' (accurate), 'linsi' (accurate, slow),
62
- 'fftnsi' (medium), 'fftns' (fast), 'retree2' (fast)
63
- n_threads: Number of CPU threads
64
-
65
- Returns:
66
- Path to aligned FASTA file
67
- """
68
- methods = {
69
- "auto": ["mafft", "--auto"],
70
- "einsi": ["mafft", "--genafpair", "--maxiterate", "1000"],
71
- "linsi": ["mafft", "--localpair", "--maxiterate", "1000"],
72
- "fftnsi": ["mafft", "--fftnsi"],
73
- "fftns": ["mafft", "--fftns"],
74
- "retree2": ["mafft", "--retree", "2"],
75
- }
76
-
77
- cmd = methods.get(method, methods["auto"])
78
- cmd += ["--thread", str(n_threads), "--inputorder", input_fasta]
79
-
80
- with open(output_fasta, 'w') as out:
81
- result = subprocess.run(cmd, stdout=out, stderr=subprocess.PIPE, text=True)
82
-
83
- if result.returncode != 0:
84
- raise RuntimeError(f"MAFFT failed:\n{result.stderr}")
85
-
86
- # Count aligned sequences
87
- with open(output_fasta) as f:
88
- n_seqs = sum(1 for line in f if line.startswith('>'))
89
- print(f"MAFFT: aligned {n_seqs} sequences → {output_fasta}")
90
-
91
- return output_fasta
92
-
93
- # MAFFT method selection guide:
94
- # Few sequences (<200), accurate: linsi or einsi
95
- # Many sequences (<1000), moderate: fftnsi
96
- # Large datasets (>1000): fftns or auto
97
- # Ultra-fast (>10000): mafft --retree 1
98
- ```
99
-
100
- ### 2. Trim Alignment (Optional but Recommended)
101
-
102
- ```python
103
- def trim_alignment_trimal(aligned_fasta: str, output_fasta: str,
104
- method: str = "automated1") -> str:
105
- """
106
- Trim poorly aligned columns with TrimAl.
107
-
108
- Methods:
109
- - 'automated1': Automatic heuristic (recommended)
110
- - 'gappyout': Remove gappy columns
111
- - 'strict': Strict gap threshold
112
- """
113
- cmd = ["trimal", f"-{method}", "-in", aligned_fasta, "-out", output_fasta, "-fasta"]
114
- result = subprocess.run(cmd, capture_output=True, text=True)
115
- if result.returncode != 0:
116
- print(f"TrimAl warning: {result.stderr}")
117
- # Fall back to using the untrimmed alignment
118
- import shutil
119
- shutil.copy(aligned_fasta, output_fasta)
120
- return output_fasta
121
- ```
122
-
123
- ### 3. IQ-TREE 2 — Maximum Likelihood Tree
124
-
125
- ```python
126
- def run_iqtree(aligned_fasta: str, output_prefix: str,
127
- model: str = "TEST", bootstrap: int = 1000,
128
- n_threads: int = 4, extra_args: list = None) -> dict:
129
- """
130
- Build a maximum likelihood tree with IQ-TREE 2.
131
-
132
- Args:
133
- aligned_fasta: Aligned FASTA file
134
- output_prefix: Prefix for output files
135
- model: 'TEST' for automatic model selection, or specify (e.g., 'GTR+G' for DNA,
136
- 'LG+G4' for proteins, 'JTT+G' for proteins)
137
- bootstrap: Number of ultrafast bootstrap replicates (1000 recommended)
138
- n_threads: Number of threads ('AUTO' to auto-detect)
139
- extra_args: Additional IQ-TREE arguments
140
-
141
- Returns:
142
- Dict with paths to output files
143
- """
144
- cmd = [
145
- "iqtree2",
146
- "-s", aligned_fasta,
147
- "--prefix", output_prefix,
148
- "-m", model,
149
- "-B", str(bootstrap), # Ultrafast bootstrap
150
- "-T", str(n_threads),
151
- "--redo" # Overwrite existing results
152
- ]
153
-
154
- if extra_args:
155
- cmd.extend(extra_args)
156
-
157
- result = subprocess.run(cmd, capture_output=True, text=True)
158
-
159
- if result.returncode != 0:
160
- raise RuntimeError(f"IQ-TREE failed:\n{result.stderr}")
161
-
162
- # Print model selection result
163
- log_file = f"{output_prefix}.log"
164
- if os.path.exists(log_file):
165
- with open(log_file) as f:
166
- for line in f:
167
- if "Best-fit model" in line:
168
- print(f"IQ-TREE: {line.strip()}")
169
-
170
- output_files = {
171
- "tree": f"{output_prefix}.treefile",
172
- "log": f"{output_prefix}.log",
173
- "iqtree": f"{output_prefix}.iqtree", # Full report
174
- "model": f"{output_prefix}.model.gz",
175
- }
176
-
177
- print(f"IQ-TREE: Tree saved to {output_files['tree']}")
178
- return output_files
179
-
180
- # IQ-TREE model selection guide:
181
- # DNA: TEST → GTR+G, HKY+G, TrN+G
182
- # Protein: TEST → LG+G4, WAG+G, JTT+G, Q.pfam+G
183
- # Codon: TEST → MG+F3X4
184
-
185
- # For temporal (molecular clock) analysis, add:
186
- # extra_args = ["--date", "dates.txt", "--clock-test", "--date-CI", "95"]
187
- ```
188
-
189
- ### 4. FastTree — Fast Approximate ML
190
-
191
- For large datasets (>1000 sequences) where IQ-TREE is too slow:
192
-
193
- ```python
194
- def run_fasttree(aligned_fasta: str, output_tree: str,
195
- sequence_type: str = "nt", model: str = "gtr",
196
- n_threads: int = 4) -> str:
197
- """
198
- Build a fast approximate ML tree with FastTree.
199
-
200
- Args:
201
- sequence_type: 'nt' for nucleotide or 'aa' for amino acid
202
- model: For nt: 'gtr' (recommended) or 'jc'; for aa: 'lg', 'wag', 'jtt'
203
- """
204
- if sequence_type == "nt":
205
- cmd = ["FastTree", "-nt", "-gtr"]
206
- else:
207
- cmd = ["FastTree", f"-{model}"]
208
-
209
- cmd += [aligned_fasta]
210
-
211
- with open(output_tree, 'w') as out:
212
- result = subprocess.run(cmd, stdout=out, stderr=subprocess.PIPE, text=True)
213
-
214
- if result.returncode != 0:
215
- raise RuntimeError(f"FastTree failed:\n{result.stderr}")
216
-
217
- print(f"FastTree: Tree saved to {output_tree}")
218
- return output_tree
219
- ```
220
-
221
- ### 5. Tree Analysis and Visualization with ETE3
222
-
223
- ```python
224
- from ete3 import Tree, TreeStyle, NodeStyle, TextFace, PhyloTree
225
- import matplotlib.pyplot as plt
226
-
227
- def load_tree(tree_file: str) -> Tree:
228
- """Load a Newick tree file."""
229
- t = Tree(tree_file)
230
- print(f"Tree: {len(t)} leaves, {len(list(t.traverse()))} nodes")
231
- return t
232
-
233
- def basic_tree_stats(t: Tree) -> dict:
234
- """Compute basic tree statistics."""
235
- leaves = t.get_leaves()
236
- distances = [t.get_distance(l1, l2) for l1 in leaves[:min(50, len(leaves))]
237
- for l2 in leaves[:min(50, len(leaves))] if l1 != l2]
238
-
239
- stats = {
240
- "n_leaves": len(leaves),
241
- "n_internal_nodes": len(t) - len(leaves),
242
- "total_branch_length": sum(n.dist for n in t.traverse()),
243
- "max_leaf_distance": max(distances) if distances else 0,
244
- "mean_leaf_distance": sum(distances)/len(distances) if distances else 0,
245
- }
246
- return stats
247
-
248
- def find_mrca(t: Tree, leaf_names: list) -> Tree:
249
- """Find the most recent common ancestor of a set of leaves."""
250
- return t.get_common_ancestor(*leaf_names)
251
-
252
- def visualize_tree(t: Tree, output_file: str = "tree.png",
253
- show_branch_support: bool = True,
254
- color_groups: dict = None,
255
- width: int = 800) -> None:
256
- """
257
- Render phylogenetic tree to image.
258
-
259
- Args:
260
- t: ETE3 Tree object
261
- color_groups: Dict mapping leaf_name → color (for coloring taxa)
262
- show_branch_support: Show bootstrap values
263
- """
264
- ts = TreeStyle()
265
- ts.show_leaf_name = True
266
- ts.show_branch_support = show_branch_support
267
- ts.mode = "r" # 'r' = rectangular, 'c' = circular
268
-
269
- if color_groups:
270
- for node in t.traverse():
271
- if node.is_leaf() and node.name in color_groups:
272
- nstyle = NodeStyle()
273
- nstyle["fgcolor"] = color_groups[node.name]
274
- nstyle["size"] = 8
275
- node.set_style(nstyle)
276
-
277
- t.render(output_file, tree_style=ts, w=width, units="px")
278
- print(f"Tree saved to: {output_file}")
279
-
280
- def midpoint_root(t: Tree) -> Tree:
281
- """Root tree at midpoint (use when outgroup unknown)."""
282
- t.set_outgroup(t.get_midpoint_outgroup())
283
- return t
284
-
285
- def prune_tree(t: Tree, keep_leaves: list) -> Tree:
286
- """Prune tree to keep only specified leaves."""
287
- t.prune(keep_leaves, preserve_branch_length=True)
288
- return t
289
- ```
290
-
291
- ### 6. Complete Analysis Script
292
-
293
- ```python
294
- import subprocess, os
295
- from ete3 import Tree
296
-
297
- def full_phylogenetic_analysis(
298
- input_fasta: str,
299
- output_dir: str = "phylo_results",
300
- sequence_type: str = "nt",
301
- n_threads: int = 4,
302
- bootstrap: int = 1000,
303
- use_fasttree: bool = False
304
- ) -> dict:
305
- """
306
- Complete phylogenetic pipeline: align → trim → tree → visualize.
307
-
308
- Args:
309
- input_fasta: Unaligned FASTA
310
- sequence_type: 'nt' (nucleotide) or 'aa' (amino acid/protein)
311
- use_fasttree: Use FastTree instead of IQ-TREE (faster for large datasets)
312
- """
313
- os.makedirs(output_dir, exist_ok=True)
314
- prefix = os.path.join(output_dir, "phylo")
315
-
316
- print("=" * 50)
317
- print("Step 1: Multiple Sequence Alignment (MAFFT)")
318
- aligned = run_mafft(input_fasta, f"{prefix}_aligned.fasta",
319
- method="auto", n_threads=n_threads)
320
-
321
- print("\nStep 2: Tree Inference")
322
- if use_fasttree:
323
- tree_file = run_fasttree(
324
- aligned, f"{prefix}.tree",
325
- sequence_type=sequence_type,
326
- model="gtr" if sequence_type == "nt" else "lg"
327
- )
328
- else:
329
- model = "TEST" if sequence_type == "nt" else "TEST"
330
- iqtree_files = run_iqtree(
331
- aligned, prefix,
332
- model=model,
333
- bootstrap=bootstrap,
334
- n_threads=n_threads
335
- )
336
- tree_file = iqtree_files["tree"]
337
-
338
- print("\nStep 3: Tree Analysis")
339
- t = Tree(tree_file)
340
- t = midpoint_root(t)
341
-
342
- stats = basic_tree_stats(t)
343
- print(f"Tree statistics: {stats}")
344
-
345
- print("\nStep 4: Visualization")
346
- visualize_tree(t, f"{prefix}_tree.png", show_branch_support=True)
347
-
348
- # Save rooted tree
349
- rooted_tree_file = f"{prefix}_rooted.nwk"
350
- t.write(format=1, outfile=rooted_tree_file)
351
-
352
- results = {
353
- "aligned_fasta": aligned,
354
- "tree_file": tree_file,
355
- "rooted_tree": rooted_tree_file,
356
- "visualization": f"{prefix}_tree.png",
357
- "stats": stats
358
- }
359
-
360
- print("\n" + "=" * 50)
361
- print("Phylogenetic analysis complete!")
362
- print(f"Results in: {output_dir}/")
363
- return results
364
- ```
365
-
366
- ## IQ-TREE Model Guide
367
-
368
- ### DNA Models
369
-
370
- | Model | Description | Use case |
371
- |-------|-------------|---------|
372
- | `GTR+G4` | General Time Reversible + Gamma | Most flexible DNA model |
373
- | `HKY+G4` | Hasegawa-Kishino-Yano + Gamma | Two-rate model (common) |
374
- | `TrN+G4` | Tamura-Nei | Unequal transitions |
375
- | `JC` | Jukes-Cantor | Simplest; all rates equal |
376
-
377
- ### Protein Models
378
-
379
- | Model | Description | Use case |
380
- |-------|-------------|---------|
381
- | `LG+G4` | Le-Gascuel + Gamma | Best average protein model |
382
- | `WAG+G4` | Whelan-Goldman | Widely used |
383
- | `JTT+G4` | Jones-Taylor-Thornton | Classical model |
384
- | `Q.pfam+G4` | pfam-trained | For Pfam-like protein families |
385
- | `Q.bird+G4` | Bird-specific | Vertebrate proteins |
386
-
387
- **Tip:** Use `-m TEST` to let IQ-TREE automatically select the best model.
388
-
389
- ## Best Practices
390
-
391
- - **Alignment quality first**: Poor alignment → unreliable trees; check alignment manually
392
- - **Use `linsi` for small (<200 seq), `fftns` or `auto` for large alignments**
393
- - **Model selection**: Always use `-m TEST` for IQ-TREE unless you have a specific reason
394
- - **Bootstrap**: Use ≥1000 ultrafast bootstraps (`-B 1000`) for branch support
395
- - **Root the tree**: Unrooted trees can be misleading; use outgroup or midpoint rooting
396
- - **FastTree for >5000 sequences**: IQ-TREE becomes slow; FastTree is 10–100× faster
397
- - **Trim long alignments**: TrimAl removes unreliable columns; improves tree accuracy
398
- - **Check for recombination** in viral/bacterial sequences before building trees (`RDP4`, `GARD`)
399
-
400
- ## Additional Resources
401
-
402
- - **MAFFT**: https://mafft.cbrc.jp/alignment/software/
403
- - **IQ-TREE 2**: http://www.iqtree.org/ | Tutorial: https://www.iqtree.org/workshop/molevol2022
404
- - **FastTree**: http://www.microbesonline.org/fasttree/
405
- - **ETE3**: http://etetoolkit.org/
406
- - **FigTree** (GUI visualization): https://tree.bio.ed.ac.uk/software/figtree/
407
- - **iTOL** (web visualization): https://itol.embl.de/
408
- - **MUSCLE** (alternative aligner): https://www.drive5.com/muscle/
409
- - **TrimAl** (alignment trimming): https://vicfero.github.io/trimal/
@@ -1,83 +0,0 @@
1
- ---
2
- name: pi-agent
3
- description: Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers/models/settings/environment variables, creating Pi skills/extensions/packages/themes/prompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, running local models through the llama.cpp router, developing custom Pi providers and TUI components, or using ecosystem packages such as pi-subagents (delegation/orchestration), pi-mcp-adapter (MCP servers), pi-interview (interactive forms), and pi-web-access (web search, fetching, video understanding).
4
- license: MIT
5
- compatibility: Requires Node.js >= 22.19 and npm for Pi CLI and SDK usage. Pi package name is @earendil-works/pi-coding-agent.
6
- metadata:
7
- version: "1.3"
8
- skill-author: K-Dense Inc.
9
- ---
10
-
11
- # Pi Agent
12
-
13
- Use this skill when the user wants to operate Pi or build on top of Pi. Pi is a minimal terminal coding harness extended through TypeScript extensions, skills, prompt templates, themes, packages, custom models/providers, SDK integrations, RPC mode, JSON event streams, and TUI components.
14
-
15
- ## First Decision
16
-
17
- Pick the reference before answering or coding:
18
-
19
- | User intent | Read |
20
- |---|---|
21
- | What Pi is, docs map, install methods | `references/overview.md` |
22
- | Install, authenticate, first run | `references/quickstart.md` |
23
- | Day-to-day CLI usage, commands, modes, flags, project trust | `references/usage.md` |
24
- | Provider auth, API keys, cloud provider setup | `references/providers.md` |
25
- | Custom model entries, local models, proxies, compat flags | `references/models.md` |
26
- | Local llama.cpp router, `/llama`, model download/load | `references/llama-cpp.md` |
27
- | Settings keys and defaults | `references/settings.md` |
28
- | `PI_*` and other environment variables | `references/environment-variables.md` |
29
- | Extension development, custom tools, events, commands | `references/extensions.md` |
30
- | Custom provider implementation, OAuth, custom streaming | `references/custom-provider.md` |
31
- | Embed Pi in Node/TypeScript | `references/sdk.md` |
32
- | Integrate from another process/language | `references/rpc.md` |
33
- | Consume JSONL event output | `references/json.md` |
34
- | Build terminal UI components | `references/tui.md` |
35
- | Package extensions/skills/prompts/themes | `references/packages.md` |
36
- | Delegate to subagents, chains, parallel runs, orchestration | `references/pi-subagents.md` |
37
- | Connect MCP servers, MCP tool discovery/config | `references/pi-mcp-adapter.md` |
38
- | Interactive interview forms, structured user input | `references/pi-interview.md` |
39
- | Web search, URL/PDF/repo fetching, video understanding | `references/pi-web-access.md` |
40
- | Author Pi skills | `references/skills.md` |
41
- | Prompt templates or themes | `references/prompt-templates.md`, `references/themes.md` |
42
- | Sessions, branching, compaction, parsing JSONL | `references/sessions.md`, `references/compaction.md`, `references/session-format.md` |
43
- | Security, sandboxing, trust | `references/security.md`, `references/containerization.md` |
44
- | Keyboard or terminal issues | `references/keybindings.md`, `references/terminal-setup.md`, `references/tmux.md`, `references/windows.md`, `references/termux.md`, `references/shell-aliases.md` |
45
- | Working on Pi itself | `references/development.md` |
46
-
47
- ## Build-On-Pi Defaults
48
-
49
- Prefer the SDK for Node/TypeScript apps that need type safety, direct state access, in-process custom tools/extensions, or custom resource loading. Use `createAgentSession()` for a single stable session; use `createAgentSessionRuntime()` when the app must replace sessions through new/resume/fork/clone/import flows. Auth and model lookup go through `ModelRuntime.create()`.
50
-
51
- Prefer RPC mode when the client is not Node.js, needs process isolation, or wants a language-agnostic JSONL protocol. Start with `pi --mode rpc --no-session` for stateless subprocess integration, then add session flags when persistence matters. Split records on `\n` only — Node `readline` is not protocol-compliant.
52
-
53
- Prefer JSON mode for one-shot command-line pipelines that only need streamed events, not bidirectional control: `pi --mode json "prompt"`.
54
-
55
- Use extensions for Pi-native behavior: custom tools, command handlers, event hooks, provider registration, custom compaction, path protection, project trust policy, UI prompts, widgets, and TUI components.
56
-
57
- Use packages when sharing or installing reusable extensions, skills, prompt templates, or themes across machines or projects.
58
-
59
- ## Safety Defaults
60
-
61
- Pi is local and not sandboxed by default. Treat extensions, packages, skills, shell commands, and project-local `.pi` resources as code with the permissions of the Pi process. Project trust only guards which project inputs load — it is not a sandbox. For untrusted repos or unattended automation, isolate with Docker, OpenShell, Gondolin, a VM, or a remote sandbox.
62
-
63
- Do not store secrets in project files. Prefer env vars, `~/.pi/agent/auth.json`, OAuth via `/login`, or command-backed secret lookups in `models.json`/provider config.
64
-
65
- ## Common Commands
66
-
67
- ```bash
68
- npm install -g --ignore-scripts @earendil-works/pi-coding-agent
69
- pi
70
- pi -p "Summarize this codebase"
71
- pi --mode json "List files"
72
- pi --mode rpc --no-session
73
- pi --provider anthropic --model claude-sonnet-4-5
74
- pi --model sonnet:high "Solve this complex problem"
75
- pi --tools read,grep,find,ls -p "Review this repository"
76
- pi --tui-mode fullscreen
77
- pi install npm:pi-subagents
78
- pi update --all
79
- ```
80
-
81
- ## Source Coverage
82
-
83
- These references summarize the Pi documentation at `https://pi.dev/docs/latest` and every docs page found under it, as of Pi **0.84.2** (docs source: `packages/coding-agent/docs/` in `https://github.com/earendil-works/pi`, formerly `pi-mono`). They also cover the package pages for `pi-subagents`, `pi-mcp-adapter`, `pi-interview`, and `pi-web-access` at `https://pi.dev/packages/`, cross-checked against the published npm READMEs and package docs (`pi-web-access` 0.22.0, `pi-mcp-adapter` 2.25.0, `pi-subagents` 0.49.0, `pi-interview` 0.11.0). When exact API behavior matters, prefer the cited reference page and inspect installed TypeScript definitions under `node_modules/@earendil-works/pi-coding-agent/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.