[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CVK9QH4BKJVVWFHRESN9RC":3,"skill-same:01M7CVK9QH4BKJVVWFHRESN9RC":63},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7CVK9QH4BKJVVWFHRESN9RC","bio-alignment-multiple",null,"Perform multiple sequence alignment using MAFFT, MUSCLE5, ClustalOmega, or T-Coffee. Guides tool and algorithm selection based on dataset size, sequence divergence, and downstream application. Use when aligning three or more homologous sequences for phylogenetics, conservation analysis, or evolutionary studies.","mrsonord2240\u002Fopenscience-specialists","mrsonord2240","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F76487430?v=4","01M7CTEM40S43GSJZ9A3YCCXZK","Samuel Nord","01M7CTEM4K69JD1GBYNHVJ9ZP4",2,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-alignment-multiple\ndescription: Perform multiple sequence alignment using MAFFT, MUSCLE5, ClustalOmega, or T-Coffee. Guides tool and algorithm selection based on dataset size, sequence divergence, and downstream application. Use when aligning three or more homologous sequences for phylogenetics, conservation analysis, or evolutionary studies.\ntool_type: mixed\nprimary_tool: MAFFT\n---\n\n## Version Compatibility\n\nReference examples tested with: MAFFT 7.520+, MUSCLE 5.1+, ClustalOmega 1.2.4+, T-Coffee 13+, PAL2NAL 14+, BioPython 1.83+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `mafft --version`, `muscle -version`, `clustalo --version`\n- Python: `pip show biopython` then `help(module.function)` to check signatures\n\nIf code throws errors, introspect the installed tool and adapt the example to match the actual CLI flags rather than retrying.\n\n# Multiple Sequence Alignment\n\n**\"Align multiple sequences\"** -> Compute an optimal alignment of three or more homologous sequences using progressive, iterative, or consistency-based methods.\n- CLI: `mafft` (most versatile), `muscle` (highest accuracy), `clustalo` (scales well), `t_coffee` (consistency-based)\n- Python: `subprocess.run()` wrapping CLI tools; BioPython `Bio.Align.Applications` was removed in BioPython 1.86 (verify with `pip show biopython`); use `subprocess` directly\n\n## MSA Algorithm Taxonomy\n\nWhen a tool is failing on a dataset, switch to a tool from a different algorithmic family rather than tuning flags. The six families and their characteristic failure modes:\n\n| Family | Representative tools | Best at | Fails when |\n|--------|---------------------|---------|-----------|\n| Progressive | ClustalW, MAFFT FFT-NS-2 | Fast, large datasets, similar lengths | Early-stage gap errors propagate; no recovery |\n| Iterative refinement | MAFFT L-INS-i, MUSCLE3, PRRN | Recovers from progressive errors at \u003C2000 seqs | Slow on >2000; still guide-tree dependent |\n| Consistency-based | T-Coffee, ProbCons | Highest accuracy \u003C100 seqs; integrates evidence | O(N^2 to N^4) scaling; heavy compute |\n| HMM-based | HMMER hmmalign, ClustalOmega (HHalign), UPP, WITCH | Adding sequences to a curated profile; fragmentary input | Needs an existing high-quality profile or backbone |\n| Divide-and-conquer | PASTA, MAGUS, MUSCLE5 super5 | Heterogeneous large datasets (>10k seqs) | Sub-alignment merges can introduce artefacts |\n| Structure or pLM-informed | Foldmason, PROMALS3D, vcMSA, 3D-Coffee | Dark proteome, \u003C15% identity, dataset has structures | Requires structures or a working pLM |\n\n## Tool Selection\n\nPick by dataset size and divergence; the default recommendations follow the table.\n\n| Tool | Best For | Max Sequences | Accuracy | Speed |\n|------|----------|---------------|----------|-------|\n| MAFFT L-INS-i | Highest accuracy, \u003C200 seqs | ~200 | Highest | Slow |\n| MAFFT FFT-NS-2 | Large datasets, good balance | ~50,000 | Good | Fast |\n| MAFFT E-INS-i | Sequences with long unalignable internal regions | ~200 | High | Slow |\n| MUSCLE5 (PPP `-align`) | Benchmarked highest accuracy on Balifam-10000 | ~1000 | Highest | Medium |\n| MUSCLE5 (`-super5`) | Large datasets via mBed clustering | ~100,000+ | Good | Medium |\n| ClustalOmega | Very large datasets, HMM-based profiles | ~190,000 in published benchmark (Sievers et al 2011 Mol Syst Biol) | Good | Fast |\n| T-Coffee (default) | Small datasets needing maximum accuracy | ~200 | Highest | Slowest |\n\n**Default recommendation**: MAFFT L-INS-i for \u003C200 sequences; MAFFT FFT-NS-2 or MUSCLE5 super5 for thousands; MUSCLE5 ensemble (`-stratified`) when alignment confidence estimates are needed.\n\n### Cross-Aligner Sensitivity Check\n\nWhen downstream analysis depends on a specific column (a candidate selection site, a contact-prediction position), run BOTH MAFFT L-INS-i and MUSCLE5 `-align` and verify that column is stable across the two outputs. If unstable, flag as low-confidence regardless of GUIDANCE2\u002FTCS scores. The MUSCLE5 ensemble (`-stratified`\u002F`-diversified`) accomplishes the same check directly within one tool and is preferred when ensemble output is acceptable downstream.\n\n### Beyond MAFFT and MUSCLE: Scale and Domain\n\nSome workloads exceed what the four main tools handle gracefully. Use the scale-and-domain table below to escape default-tool blind spots.\n\n| Scenario | Recommended tool | Why |\n|----------|------------------|-----|\n| 100k - millions of sequences (UniRef cluster reps) | FAMSA v2 (Deorowicz et al 2016 SREP, v2 2024) | Million-scale MSA in hours with Pareto-optimal accuracy |\n| Heterogeneous large dataset (variable length, divergence) | PASTA (Mirarab et al 2015 J Comp Biol) or MAGUS (Smirnov & Warnow 2021 Bioinf) | Divide-and-conquer plus iterative re-alignment |\n| Fragmentary input (metagenomics, eDNA, ancient DNA) | UPP (Nguyen et al 2015 Genome Biol) or WITCH (Shen et al 2022 J Comp Biol) | HMM backbone tolerates partial sequences |\n| Dark proteome \u002F \u003C15% identity | vcMSA (McWhite, Armour-Garb & Singh 2023 Genome Res; alpha-stage tool per its repo README; last release Oct 2023; test on representative inputs before pipeline use) or Foldmason (Gilchrist et al 2024) | pLM-embedding or structural alignment where sequence fails |\n| RNA with secondary structure | Infernal `cmalign` (Nawrocki & Eddy 2013), R-Coffee, MAFFT-Q-INS-i | Sequence + base-pair consistency |\n| Strand-unknown (Sanger, Nanopore raw) | `mafft --adjustdirection --globalpair` | Auto-detects and reverse-complements as needed |\n| Adding many sequences to a curated profile | HMMER `hmmalign` (Eddy 2011 PLOS CB) | Profile-driven; better than `mafft --add` for Pfam-style use |\n\n**vcMSA limitation:** Pre-filter input to within ~2x mean length; vcMSA degrades sharply on mixed full-length\u002Ffragment input because ProtT5 embeddings encode positional context. For mixed-length sets, segment long sequences via HHsearch domain decomposition before alignment, or use Foldmason on predicted structures.\n\n## Critical Concepts\n\n### Mitigate Guide-Tree Dependency\n\nAll major MSA tools build a guide tree, then align progressively along it; once a gap is inserted in the progressive phase, it is never removed, so early errors propagate. To mitigate: prefer iterative-refinement modes (MAFFT `-i`, MUSCLE5), use consistency scoring (T-Coffee) for small datasets, and quantify uncertainty with GUIDANCE2 bootstrapping or the MUSCLE5 ensemble before publishing column-specific conclusions.\n\n### Joint MSA-Phylogeny Co-estimation (Small Datasets Only)\n\nThe theoretically correct answer to guide-tree dependency is to estimate the alignment and tree jointly under a statistical evolutionary model rather than treating MSA as a fixed input to phylogenetic inference. BAli-Phy version 3 (Redelings 2021 Bioinf 37:3032) does this via MCMC, producing a posterior distribution over alignments and trees with insertion\u002Fdeletion rates as model parameters. Version 3 is O(n) instead of O(n^2) per likelihood evaluation, but the practical ceiling remains ~70-200 sequences before runtime becomes prohibitive (weeks for >100 sequences). When the dataset fits the cap, BAli-Phy gives the most defensible alignment+tree pair for publication; when it does not, the practical alternative is MUSCLE5 ensemble + IQ-TREE per-replicate (Edgar 2022) to approximate posterior alignment uncertainty without joint estimation.\n\n| Dataset size | Recommended approach |\n|--------------|----------------------|\n| \u003C 70 sequences | BAli-Phy v3 joint MSA+tree posterior; gold standard |\n| 70 - 200 sequences | BAli-Phy v3 if compute allows (weeks); else MUSCLE5 ensemble + IQ-TREE per replicate |\n| > 200 sequences | MUSCLE5 ensemble (`-stratified`) + IQ-TREE per replicate; BAli-Phy not feasible |\n| > 1000 sequences | Single MAFFT\u002FMUSCLE5 + standard bootstrap; ensemble methods become intractable |\n\n### Sequence Divergence Thresholds\n\n| Protein Identity | Signal Level | Recommendation |\n|-----------------|--------------|----------------|\n| >40% | Strong | Any MSA tool produces reliable alignment |\n| 25-40% | Moderate (twilight zone begins) | Use iterative methods (L-INS-i, MUSCLE5); validate with GUIDANCE2 |\n| 20-25% | Weak | Profile-profile methods (HHpred); consider structural alignment |\n| \u003C15-20% (length-dependent twilight) | Noise dominates signal | Sequence MSA is unreliable; switch to structural alignment (Foldseek, TM-align) or pLM aligners -- see `alignment\u002Fstructural-alignment` |\n\n## Running MAFFT\n\n### Algorithm Selection\n\nMAFFT offers multiple algorithms with explicit accuracy\u002Fspeed tradeoffs. Selecting the right mode is critical; the difference between L-INS-i and FFT-NS-1 can be the difference between a correct and incorrect downstream phylogeny.\n\n| Algorithm | Flag | Strategy | Best For |\n|-----------|------|----------|----------|\n| FFT-NS-1 | `--retree 1` | Progressive only | Quick look, >10,000 seqs |\n| FFT-NS-2 | `--retree 2` | Progressive + guide tree rebuild | Default balance, 200-10,000 seqs |\n| FFT-NS-i | `--maxiterate 1000` | Iterative refinement | Moderate improvement, 200-2,000 seqs |\n| G-INS-i | `--globalpair --maxiterate 1000` | Global pairwise + iterative | Sequences alignable over full length, \u003C200 |\n| L-INS-i | `--localpair --maxiterate 1000` | Local pairwise + iterative | Single alignable domain amid divergent flanks, \u003C200 |\n| E-INS-i | `--genafpair --maxiterate 1000` | Local with generalized affine gaps | Multiple conserved motifs separated by unalignable regions, \u003C200 |\n| Auto | `--auto` | Auto-selects based on dataset size | When unsure |\n\n**Decision guide**: If sequences share a single conserved domain (most common case), use L-INS-i. If sequences are globally similar (e.g., ortholog set of similar length), use G-INS-i. If sequences have multiple conserved blocks separated by highly variable linker regions (e.g., multi-domain proteins with variable interdomain regions), use E-INS-i.\n\n**G-INS-i failure mode:** When sequences have long divergent N\u002FC-terminal extensions (signal peptides, intrinsically-disordered regions, isoform-specific tails), the global pairwise distance G-INS-i uses for guide-tree construction is dominated by the extension's mismatch content. The guide tree then mis-clusters sequences by extension similarity rather than core homology. Symptom: the resulting alignment has core conserved domains poorly aligned despite high-identity flanks. Switch to L-INS-i (local pairwise; tolerant of divergent flanks) or pre-process to remove signal peptides\u002Fdisordered regions before alignment.\n\n### What `--auto` Picks (and Why to Specify Explicitly)\n\n`mafft --auto` silently downgrades the algorithm based on dataset size. The decision tree is roughly:\n\n| Sequences | `--auto` selects | Equivalent flags |\n|-----------|------------------|------------------|\n| \u003C 200 | L-INS-i | `--localpair --maxiterate 1000` |\n| 200 - 500 | FFT-NS-i | `--retree 2 --maxiterate 2` |\n| 500 - 2000 | FFT-NS-2 | `--retree 2 --maxiterate 0` |\n| 2000 - 50000 | FFT-NS-2 (one-pass) | `--retree 1 --maxiterate 0` |\n| > 50000 | PartTree | `--parttree --retree 1 --maxiterate 0` |\n\nThe transition at 200 sequences flips the alignment from \"iterative-refined accurate\" to \"single-pass progressive\". Note that `--auto` invokes FFT-NS-i with only `--maxiterate 2` in the 200-500 range (a truncated form of the full FFT-NS-i which uses `--maxiterate 1000`); for best accuracy in this range, specify `--retree 2 --maxiterate 1000` explicitly. For publication-quality phylogenetics, specify the algorithm explicitly so reproducibility audits do not rely on internal threshold heuristics.\n\n### Basic Usage\n\n**Goal:** Run MAFFT on a FASTA file with appropriate algorithm selection.\n\n**Approach:** Invoke MAFFT via command line or subprocess, selecting the algorithm based on dataset characteristics.\n\n```bash\n# Highest accuracy for \u003C200 sequences (local pairwise iterative)\nmafft --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Good balance for medium datasets\nmafft --retree 2 input.fasta > aligned.fasta\n\n# Auto-select algorithm based on dataset size\nmafft --auto input.fasta > aligned.fasta\n\n# Protein alignment with specific matrix (default BLOSUM62)\nmafft --amino --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# DNA alignment (auto-detected, but can be explicit)\nmafft --nuc --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Adjust gap penalties (op=gap open, ep=gap extension)\nmafft --op 1.53 --ep 0.123 --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Multithreaded\nmafft --thread 8 --localpair --maxiterate 1000 input.fasta > aligned.fasta\n```\n\n```python\nimport subprocess\n\ndef run_mafft(input_fasta, output_fasta, algorithm='linsi', threads=4):\n    algo_flags = {\n        'linsi': ['--localpair', '--maxiterate', '1000'],\n        'ginsi': ['--globalpair', '--maxiterate', '1000'],\n        'einsi': ['--genafpair', '--maxiterate', '1000'],\n        'fftns2': ['--retree', '2'],\n        'auto': ['--auto'],\n    }\n    cmd = ['mafft', '--thread', str(threads)] + algo_flags[algorithm] + [input_fasta]\n    with open(output_fasta, 'w') as out:\n        result = subprocess.run(cmd, stdout=out, stderr=subprocess.PIPE, text=True)\n    if result.returncode != 0:\n        raise RuntimeError(f'MAFFT failed (exit {result.returncode}):\\n{result.stderr}')\n\nrun_mafft('sequences.fasta', 'aligned.fasta', algorithm='linsi')\n```\n\nMAFFT writes its progress log and errors to stderr, not stdout. Capturing stderr and surfacing the failure message is essential when MAFFT exits non-zero (e.g. encountering ambiguous characters, oversized input, missing libraries) -- otherwise `check=True` raises a CalledProcessError without showing the actionable message.\n\n### Adding Sequences to an Existing Alignment\n\n**Goal:** Add new sequences to an existing MSA without realigning the entire dataset.\n\n**Approach:** Use MAFFT's `--add` for full-length sequences, `--addfragments` for partial \u002F surveillance \u002F metagenomic reads. The two flags are NOT interchangeable.\n\n| Flag | Use when | Behaviour |\n|------|----------|-----------|\n| `--add` | New sequences are full-length homologues | Each new sequence is profile-aligned end-to-end |\n| `--addfragments` | New sequences are partial (reads, contigs, surveillance amplicons) | Free terminal gaps; new sequences may align to a sub-region of the profile |\n| `--addprofile` | Adding an entire pre-aligned profile | Profile-profile alignment |\n| `--keeplength` | Output must have the same column count as input MSA | Insertions in new sequences are dropped (key for HMMER\u002FPfam-style use) |\n\n```bash\n# Full-length additions; may extend alignment with new columns\nmafft --add new_seqs.fasta existing_alignment.fasta > updated.fasta\n\n# Partial reads or fragments; common for SARS-CoV-2 surveillance\nmafft --addfragments new_reads.fasta --keeplength reference_msa.fasta > updated.fasta\n\n# Profile-profile merge\nmafft --addprofile second_msa.fasta first_msa.fasta > merged.fasta\n```\n\nFor HMM-curated families (Pfam, Rfam), `hmmalign --trim --outformat afa profile.hmm new_seqs.fa > out.fasta` is the canonical alternative; it constrains insertions to lowercase columns rather than introducing new alignment columns and is the format expected by downstream HMMER\u002FHHsuite tooling.\n\n## Running MUSCLE5\n\nPick `-align` (PPP) for peak-accuracy runs up to ~1000 sequences, or `-super5` (mBed clustering + chunked alignment) for thousands to millions. `-super5` is not a \"lower quality\" mode; both share the same HMM-perturbation ensemble machinery.\n\n| Command | Algorithm | Designed for | Output |\n|---------|-----------|--------------|--------|\n| `-align` (PPP) | Posterior probability progressive (HMM) | \u003C= ~1000 seqs, peak accuracy | Single MSA or .efa ensemble |\n| `-super5` | mBed-clustering + chunked alignment | Thousands to millions of seqs | Single MSA or .efa ensemble |\n\n### Basic Usage\n\n```bash\n# Peak accuracy PPP algorithm, \u003C1000 sequences\nmuscle -align input.fasta -output aligned.fasta -threads 8\n\n# super5 divide-and-conquer for thousands of sequences\nmuscle -super5 input.fasta -output aligned.fasta -threads 8\n```\n\n### Ensemble Mode for Alignment Confidence\n\n**Goal:** Quantify alignment uncertainty by generating multiple HMM-perturbed alignments and measuring column consistency.\n\n**Approach:** MUSCLE5 (Edgar 2022 Nat Comm) ships two ensemble modes: `-stratified` (16 replicates by default: the `-replicates` flag defaults to 4 HMM-perturbation seeds x 4 guide-tree permutations) and `-diversified` (100 replicates by default). Both write an Ensemble FASTA (.efa) file containing all replicates; column-level confidence is the fraction of replicates that place a given residue pair in the same column. `-perturb SEED` is a separate flag that sets the HMM-perturbation random seed, not an ensemble selector.\n\n```bash\n# Stratified ensemble: 16 replicates (4 HMM-perturbation seeds x 4 guide-tree permutations)\nmuscle -super5 input.fasta -stratified -output ensemble.efa\n\n# Diversified ensemble: 100 replicates exploring guide-tree and HMM space\nmuscle -super5 input.fasta -diversified -output ensemble.efa\n\n# Optional: change replicate count and HMM-perturbation seed\nmuscle -super5 input.fasta -stratified -replicates 8 -perturb 42 -output ensemble.efa\n```\n\nThe .efa output is consumed downstream to derive confidence-weighted bootstrap support: each replicate is fed to a tree builder and the resulting trees combined (Edgar 2022 supplement). Columns consistently aligned across replicates are reliable; high-divergence regions diverge between replicates and should be flagged before phylogenetic inference.\n\n## Running ClustalOmega\n\nUse ClustalOmega when datasets reach hundreds of thousands of sequences (the mBed guide tree scales O(N log N)) or for HMM-profile-driven alignment. Prefer MAFFT or MUSCLE5 below that scale.\n\n```bash\n# Basic alignment\nclustalo -i input.fasta -o aligned.fasta --auto\n\n# Force overwrite output\nclustalo -i input.fasta -o aligned.fasta --force\n\n# Specify output format\nclustalo -i input.fasta -o aligned.phy --outfmt=phylip\n\n# Use more iterations for better accuracy\nclustalo -i input.fasta -o aligned.fasta --iter=5\n\n# Profile-profile alignment (align two existing MSAs)\nclustalo --p1 profile1.fasta --p2 profile2.fasta -o merged.fasta\n\n# Add sequences to existing alignment\nclustalo -i new_seqs.fasta --profile1 existing.fasta -o updated.fasta\n\n# Multithreaded\nclustalo -i input.fasta -o aligned.fasta --threads=8\n```\n\n## Running T-Coffee\n\nUse T-Coffee for small datasets (\u003C50 sequences) where maximum accuracy matters or where structural templates exist (Expresso, 3D-Coffee). It is slower than progressive aligners but integrates diverse evidence via consistency-based library scoring.\n\n| Mode | Flag | What it does |\n|------|------|-------------|\n| Default | (none) | T-Coffee + Lalign pairwise library |\n| M-Coffee | `-mode mcoffee` | Combines libraries from MAFFT, MUSCLE, ClustalW, ProbCons, T-Coffee, etc. |\n| Expresso | `-mode expresso` | PSI-BLAST searches PDB for structural templates, runs SAP structural alignment (requires internet for PSI-BLAST and PDB lookups; offline alternative: 3D-Coffee with user-supplied templates) |\n| 3D-Coffee | `-mode 3dcoffee -template_file templates.txt` | User-supplied PDB templates; SAP \u002F TM-align pairwise structural library |\n| R-Coffee | `-mode rcoffee` | RNA: combines sequence alignment with consensus secondary structure (RNAplfold) |\n| Pro-Coffee | `-mode procoffee` | Promoter regions: enforces position-specific TF binding-site alignment |\n| Reliability | `-evaluate -output score_ascii` | TCS column reliability score for an existing alignment |\n\n```bash\nt_coffee input.fasta -output fasta_aln -outfile aligned.fasta\n\nt_coffee input.fasta -mode mcoffee -output fasta_aln -outfile aligned.fasta\n\nt_coffee input.fasta -mode expresso -output fasta_aln -outfile aligned.fasta\n\nt_coffee -infile aligned.fasta -evaluate -output score_ascii > tcs_scores.ascii\n```\n\n**When to use T-Coffee**: Small datasets (\u003C50 sequences) where maximum accuracy matters, especially when structural information (PDB templates) is available. Expresso (Armougom et al 2006 NAR) and 3D-Coffee modes (Poirot et al 2004; O'Sullivan et al 2004 JMB) substantially improve correct-column rate over sequence-only T-Coffee when structures exist; verify the latest benchmark numbers in the project documentation. Expresso requires internet access for PSI-BLAST + PDB lookups. The TCS reliability score (Chang et al 2014 MBE) flags individual columns as reliable\u002Funreliable for downstream filtering before phylogenetics.\n\n## Codon-Aware Alignment\n\n### When Codon Alignment Is Required\n\nCoding sequences destined for selection analysis (dN\u002FdS with PAML\u002Fcodeml, HyPhy BUSTED\u002FMEME\u002FaBSREL) **must** be aligned respecting codon boundaries. Standard nucleotide MSA tools do not preserve reading frames and produce systematically incorrect dN\u002FdS estimates -- Fletcher & Yang (2010 MBE) showed conventional aligners cause false-positive signals in the branch-site test of positive selection even on clean simulated data.\n\n### Codon-Alignment Tool Decision Tree\n\n| Input cleanliness | Recommended tool | Notes |\n|------------------|------------------|-------|\n| Clean orthologs (no frameshifts, no internal stops) | MAFFT-protein + PAL2NAL (Suyama, Torrents & Bork 2006 NAR) | Fastest; standard PAML pipeline input |\n| Recently duplicated paralogs (indel-rich) | PRANK +F codon (Loytynoja & Goldman 2008 Science) | Phylogeny-aware indel model; fewest false-positive selection calls (Fletcher & Yang 2010) |\n| Frameshifts, pseudogenes, error-prone assemblies | MACSE v2 `alignSequences -fs \u003Ccost>` (Ranwez et al 2018 MBE) | Frameshift-tolerant; preserves reading frame across sequencing errors |\n| Mixed dataset with some bad genes | OMM_MACSE pipeline (Scornavacca, Belkhir, Lopez et al 2019; Ranwez group) | MACSE non-homologous-fragment trimming + MAFFT prealignment + MACSE frameshift refinement + HMMcleaner |\n| HyPhy-grade quality (BUSTED, MEME, aBSREL input) | HyPhy `pre-msa.bf` \u002F `post-msa.bf` (Pond lab; Kosakovsky Pond et al) | Strips stop codons, runs MSA at protein level, threads back, validates frames |\n\n### PAL2NAL: Protein-Guided Codon Alignment\n\n**Goal:** Thread a nucleotide coding sequence alignment onto a protein alignment to preserve reading frame.\n\n**Approach:** Align protein sequences first (higher sensitivity), then use PAL2NAL to map the protein alignment back to codons. Suyama et al 2006 NAR; standard codeml input pipeline.\n\n```bash\nmafft --localpair --maxiterate 1000 proteins.fasta > proteins_aligned.fasta\npal2nal.pl proteins_aligned.fasta codons.fasta -output fasta > codons_aligned.fasta\npal2nal.pl proteins_aligned.fasta codons.fasta -output paml > codons_aligned.phy\n```\n\n**Non-standard genetic codes:** PAL2NAL by default uses the standard code (NCBI table 1). For mitochondrial (vertebrate=2, yeast=3, invertebrate=5), ciliate macronuclear (=6, UAA\u002FUAG=Gln), or other non-standard codes, the protein-to-codon mapping mismatches and PAL2NAL silently produces wrong codon assignments. Specify explicitly with `-codontable N`:\n\n```bash\npal2nal.pl proteins_aligned.fasta codons.fasta -output paml -codontable 2 > codons_mt.phy\n```\n\nFor datasets mixing genetic codes (e.g. nuclear + mitochondrial CDS in one tree), translate each lineage with its own code BEFORE protein alignment, never apply a single code globally. See NCBI Translation Tables for the full numbering.\n\n### PRANK +F Codon Mode\n\n**Goal:** Align coding sequences under a phylogeny-aware indel model that does not over-collapse insertions.\n\n**Approach:** PRANK +F (Loytynoja & Goldman 2008 Science) treats indels as evolutionary events on a tree, distinguishing insertions from deletions. Slower than MAFFT but recommended for selection-analysis prep.\n\n```bash\nprank -d=codons.fasta -o=prank_aligned -codon -F\n```\n\nThe `+F` flag enforces \"fewer false insertions\"; without it PRANK behaves more like a conventional aligner. For dN\u002FdS analysis under PAML M2a\u002FM8, PRANK +F is the most conservative input choice.\n\n### MACSE v2: Frameshift-Tolerant Codon Alignment\n\n**Goal:** Align coding sequences directly at the codon level while tolerating frameshifts and internal stops.\n\n**Approach:** MACSE scores based on amino acid translation while operating on DNA. The v2 toolbox (Ranwez et al 2018 MBE) ships a sub-program selector via `-prog`; the eight most-used sub-programs are listed below (run `macse -help` for the full set in the installed release):\n\n| Sub-program | Purpose |\n|-------------|---------|\n| `alignSequences` | Align coding sequences (`-fs \u003Ccost>` sets frameshift penalty) |\n| `enrichAlignment` | Add new sequences to existing codon alignment |\n| `refineAlignment` | Refine an alignment with MACSE scoring |\n| `splitAlignment` | Split into sub-alignments (e.g. by guide tree clades) |\n| `exportAlignment` | Convert between MACSE-internal and standard formats |\n| `trimAlignment` | Position-aware trimming preserving codon structure |\n| `trimNonHomologousFragments` | Detect and remove non-homologous regions per sequence |\n| `reportGapsAA2NT` | Map protein-level gap removals back to nucleotide alignment |\n\n```bash\njava -jar macse_v2.jar -prog alignSequences -seq coding_seqs.fasta \\\n    -out_NT aligned_nt.fasta -out_AA aligned_aa.fasta -fs 30\n\njava -jar macse_v2.jar -prog enrichAlignment -align existing.fasta \\\n    -seq new_seqs.fasta -out_NT updated.fasta\n```\n\n### OMM_MACSE: Recommended Pipeline Wrapper\n\nOMM_MACSE (Ranwez group, used in OrthoMaM v10+) chains: MACSE `trimNonHomologousFragments` to remove non-homologous fragments (annotation errors, retained introns\u002FUTRs), MAFFT pre-alignment for guide-tree, MACSE v2 frameshift-aware refinement, then soft HMMcleaner cleaning. This is the recommended pipeline for genome-scale ortholog datasets where some genes will contain frameshifts.\n\n```bash\nOMM_MACSE_v12.02.sif --in_seq_file orthogroup.fasta --out_dir omm_out --out_file_prefix orthogroup --genetic_code_number 1\n```\n\n### HyPhy pre-msa.bf \u002F post-msa.bf\n\nFor HyPhy-grade dN\u002FdS analyses (BUSTED, MEME, aBSREL, RELAX), Pond lab's standard workflow is:\n\n```bash\nhyphy pre-msa.bf --input cds.fasta\nmafft --auto cds.fasta_protein.fas > cds.fasta_protein.msa\nhyphy post-msa.bf --protein-msa cds.fasta_protein.msa --nucleotide-sequences cds.fasta_nuc.fas --output cds.codon.msa\n```\n\n`pre-msa.bf` strips internal stop codons and translates; `post-msa.bf` validates that all sequences remain in-frame after threading. Without this validation step, a single mis-aligned codon can cascade into a spurious episodic-selection call.\n\n### Confidence Assessment\n\nFor publication-grade phylogenetics or selection analysis, alignment uncertainty must be quantified per column and unreliable columns excluded BEFORE downstream inference -- not after.\n\n| Method | Tool | Output |\n|--------|------|--------|\n| Guide-tree perturbation | GUIDANCE2 (Sela et al 2015 NAR) | Per-column and per-residue reliability score (0-1); default cutoff 0.93. No GUIDANCE3 has been released; deep-learning successors are exploratory only. |\n| Library-consistency | T-Coffee TCS (Chang et al 2014 MBE) | Per-column reliability score via `-evaluate -output score_ascii` |\n| HMM ensemble | MUSCLE5 `-stratified` \u002F `-diversified` | EFA file; column confidence = fraction of replicates supporting it |\n| Co-optimal alignments | HoT (Landan & Graur 2007 MBE) | Heads-or-tails alternate optimal alignment for each column |\n\nMask columns below the reliability threshold before phylogenetic inference. Trees built from filtered alignments are markedly more stable to method choice.\n\n**GUIDANCE2 thresholds are tool-specific.** The 0.93 default cutoff is calibrated against MAFFT-LINSI in Sela et al 2015. Running GUIDANCE2 on top of MUSCLE5 or PRANK uses different perturbation distributions and produces scores on a slightly different scale. For non-MAFFT base aligners, calibrate the threshold empirically using a benchmark with known-correct columns or use the tool-native ensemble scoring (MUSCLE5 `-stratified`) instead.\n\n## Post-Alignment Validation Checklist\n\nBefore proceeding to downstream analysis, verify alignment quality:\n\n1. **Visual inspection**: Scan for columns of mostly gaps with scattered residues (hallmark of misalignment)\n2. **Gap distribution**: High gap fraction (>50% of columns with gaps) suggests problematic regions or inclusion of non-homologous sequences\n3. **Sequence identity**: If average pairwise identity is \u003C25% for proteins, alignment reliability is questionable\n4. **Outlier sequences**: Sequences with excessive gaps relative to others may be non-homologous or fragments; consider removing and re-aligning\n5. **Conservation pattern**: Functional domains should show clear conservation; absence of expected conserved motifs suggests alignment error or non-homology\n6. **Run GUIDANCE2 or MUSCLE5 ensemble**: Quantify alignment confidence per column before phylogenetic inference\n\n## When NOT to Run MSA\n\n- **Non-homologous sequences**: MSA tools always produce an alignment, even for unrelated sequences; verify homology first (e.g., BLAST E-value \u003C 1e-5)\n- **Sequences below the twilight zone**: Below ~20% protein identity, sequence signal is lost in noise; structural alignment is needed\n- **Different domain architectures**: Globally aligning multi-domain proteins with different domain orders produces meaningless results; align individual domains separately\n- **Very different lengths without shared homology**: Aligning a 50-residue fragment against 1000-residue proteins globally forces biologically meaningless gaps; use local alignment or fragment-aware modes (E-INS-i)\n- **Highly repetitive sequences**: Tandem repeats cause alignment ambiguity; specialized tools (e.g., TRUST for tandem repeats) may be needed\n\n## Quick Reference\n\n| Task | Command |\n|------|---------|\n| Best accuracy (\u003C200 seqs) | `mafft --localpair --maxiterate 1000 in.fa > out.fa` |\n| Large dataset | `mafft --retree 2 in.fa > out.fa` or `clustalo -i in.fa -o out.fa` |\n| Uncertainty estimation | `muscle -super5 in.fa -stratified -output out.efa` |\n| Codon-aware | Align protein first, then `pal2nal.pl prot.fa cds.fa -output fasta` |\n| Add to existing MSA | `mafft --add new.fa existing.fa > updated.fa` |\n| Profile merge | `clustalo --p1 msa1.fa --p2 msa2.fa -o merged.fa` |\n| With structure info | `t_coffee in.fa -mode expresso` |\n\n## Common Errors\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| MAFFT runs out of memory | L-INS-i on too many sequences | Switch to FFT-NS-2 or auto mode |\n| Alignment has many all-gap columns | Non-homologous sequences included | Filter input by BLAST hits first |\n| ClustalOmega crashes on large input | Memory limits | Increase `--MAC` RAM or use MAFFT |\n| PAL2NAL \"length mismatch\" | Protein\u002FDNA sequences not from same genes | Verify correspondence with sequence IDs |\n| MUSCLE5 slow on large datasets | Default algorithm not designed for >10K seqs | Use `-super5` mode |\n| Poor alignment despite high identity | Wrong sequence type detection | Explicitly specify `--amino` or `--nuc` |\n\n## Related Skills\n\n- alignment\u002Fpairwise-alignment - Compare two sequences using PairwiseAligner\n- alignment\u002Falignment-io - Read\u002Fwrite MSA files in various formats\n- alignment\u002Fmsa-parsing - Parse, filter, trim, and assess MSA quality\n- alignment\u002Fmsa-statistics - Calculate identity, conservation, entropy metrics\n- alignment\u002Fstructural-alignment - Foldseek, TM-align, Foldmason for the dark proteome\n- alignment\u002Falignment-trimming - ClipKIT, trimAl, BMGE post-MSA column filtering\n- phylogenetics\u002Fmodern-tree-inference - Build phylogenetic trees from MSAs\n- sequence-io\u002Fread-sequences - Read input sequences for alignment\n\n## References\n\n- Edgar RC. 2022. Muscle5: high-accuracy alignment ensembles enable unbiased assessments of sequence homology and phylogeny. Nat Comm 13:6968.\n- Katoh K, Standley DM. 2013. MAFFT multiple sequence alignment software version 7. MBE 30:772-780.\n- Sievers F et al. 2011. Fast, scalable generation of high-quality protein multiple sequence alignments using Clustal Omega. Mol Syst Biol 7:539.\n- Notredame C, Higgins DG, Heringa J. 2000. T-Coffee: a novel method for fast and accurate multiple sequence alignment. JMB 302:205-217.\n- Loytynoja A, Goldman N. 2008. Phylogeny-aware gap placement prevents errors in sequence alignment and evolutionary analysis. Science 320:1632-1635.\n- Ranwez V, Douzery EJP, Cambon C, Chantret N, Delsuc F. 2018. MACSE v2: toolkit for the alignment of coding sequences accounting for frameshifts and stop codons. MBE 35:2582-2584.\n- Suyama M, Torrents D, Bork P. 2006. PAL2NAL: robust conversion of protein sequence alignments into the corresponding codon alignments. NAR 34:W609-W612.\n- Sela I, Ashkenazy H, Katoh K, Pupko T. 2015. GUIDANCE2: accurate detection of unreliable alignment regions accounting for the uncertainty of multiple parameters. NAR 43:W7-W14.\n- Chang JM, Di Tommaso P, Notredame C. 2014. TCS: a new multiple sequence alignment reliability measure to estimate alignment accuracy and improve phylogenetic tree reconstruction. MBE 31:1625-1637.\n- Fletcher W, Yang Z. 2010. The effect of insertions, deletions, and alignment errors on the branch-site test of positive selection. MBE 27:2257-2267.\n- Armougom F, Moretti S, Poirot O, Audic S, Dumas P, Schaeli B, Keduas V, Notredame C. 2006. Expresso: automatic incorporation of structural information in multiple sequence alignments using 3D-Coffee. NAR 34:W604-W608.\n- McWhite CD, Armour-Garb I, Singh M. 2023. Leveraging protein language models for accurate multiple sequence alignments. Genome Res 33:1145-1153.\n- Redelings BD. 2021. BAli-Phy version 3: model-based co-estimation of alignment and phylogeny. Bioinf 37:3032-3034.\n","## Version Compatibility\n\nReference examples tested with: MAFFT 7.520+, MUSCLE 5.1+, ClustalOmega 1.2.4+, T-Coffee 13+, PAL2NAL 14+, BioPython 1.83+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `mafft --version`, `muscle -version`, `clustalo --version`\n- Python: `pip show biopython` then `help(module.function)` to check signatures\n\nIf code throws errors, introspect the installed tool and adapt the example to match the actual CLI flags rather than retrying.\n\n# Multiple Sequence Alignment\n\n**\"Align multiple sequences\"** -> Compute an optimal alignment of three or more homologous sequences using progressive, iterative, or consistency-based methods.\n- CLI: `mafft` (most versatile), `muscle` (highest accuracy), `clustalo` (scales well), `t_coffee` (consistency-based)\n- Python: `subprocess.run()` wrapping CLI tools; BioPython `Bio.Align.Applications` was removed in BioPython 1.86 (verify with `pip show biopython`); use `subprocess` directly\n\n## MSA Algorithm Taxonomy\n\nWhen a tool is failing on a dataset, switch to a tool from a different algorithmic family rather than tuning flags. The six families and their characteristic failure modes:\n\n| Family | Representative tools | Best at | Fails when |\n|--------|---------------------|---------|-----------|\n| Progressive | ClustalW, MAFFT FFT-NS-2 | Fast, large datasets, similar lengths | Early-stage gap errors propagate; no recovery |\n| Iterative refinement | MAFFT L-INS-i, MUSCLE3, PRRN | Recovers from progressive errors at \u003C2000 seqs | Slow on >2000; still guide-tree dependent |\n| Consistency-based | T-Coffee, ProbCons | Highest accuracy \u003C100 seqs; integrates evidence | O(N^2 to N^4) scaling; heavy compute |\n| HMM-based | HMMER hmmalign, ClustalOmega (HHalign), UPP, WITCH | Adding sequences to a curated profile; fragmentary input | Needs an existing high-quality profile or backbone |\n| Divide-and-conquer | PASTA, MAGUS, MUSCLE5 super5 | Heterogeneous large datasets (>10k seqs) | Sub-alignment merges can introduce artefacts |\n| Structure or pLM-informed | Foldmason, PROMALS3D, vcMSA, 3D-Coffee | Dark proteome, \u003C15% identity, dataset has structures | Requires structures or a working pLM |\n\n## Tool Selection\n\nPick by dataset size and divergence; the default recommendations follow the table.\n\n| Tool | Best For | Max Sequences | Accuracy | Speed |\n|------|----------|---------------|----------|-------|\n| MAFFT L-INS-i | Highest accuracy, \u003C200 seqs | ~200 | Highest | Slow |\n| MAFFT FFT-NS-2 | Large datasets, good balance | ~50,000 | Good | Fast |\n| MAFFT E-INS-i | Sequences with long unalignable internal regions | ~200 | High | Slow |\n| MUSCLE5 (PPP `-align`) | Benchmarked highest accuracy on Balifam-10000 | ~1000 | Highest | Medium |\n| MUSCLE5 (`-super5`) | Large datasets via mBed clustering | ~100,000+ | Good | Medium |\n| ClustalOmega | Very large datasets, HMM-based profiles | ~190,000 in published benchmark (Sievers et al 2011 Mol Syst Biol) | Good | Fast |\n| T-Coffee (default) | Small datasets needing maximum accuracy | ~200 | Highest | Slowest |\n\n**Default recommendation**: MAFFT L-INS-i for \u003C200 sequences; MAFFT FFT-NS-2 or MUSCLE5 super5 for thousands; MUSCLE5 ensemble (`-stratified`) when alignment confidence estimates are needed.\n\n### Cross-Aligner Sensitivity Check\n\nWhen downstream analysis depends on a specific column (a candidate selection site, a contact-prediction position), run BOTH MAFFT L-INS-i and MUSCLE5 `-align` and verify that column is stable across the two outputs. If unstable, flag as low-confidence regardless of GUIDANCE2\u002FTCS scores. The MUSCLE5 ensemble (`-stratified`\u002F`-diversified`) accomplishes the same check directly within one tool and is preferred when ensemble output is acceptable downstream.\n\n### Beyond MAFFT and MUSCLE: Scale and Domain\n\nSome workloads exceed what the four main tools handle gracefully. Use the scale-and-domain table below to escape default-tool blind spots.\n\n| Scenario | Recommended tool | Why |\n|----------|------------------|-----|\n| 100k - millions of sequences (UniRef cluster reps) | FAMSA v2 (Deorowicz et al 2016 SREP, v2 2024) | Million-scale MSA in hours with Pareto-optimal accuracy |\n| Heterogeneous large dataset (variable length, divergence) | PASTA (Mirarab et al 2015 J Comp Biol) or MAGUS (Smirnov & Warnow 2021 Bioinf) | Divide-and-conquer plus iterative re-alignment |\n| Fragmentary input (metagenomics, eDNA, ancient DNA) | UPP (Nguyen et al 2015 Genome Biol) or WITCH (Shen et al 2022 J Comp Biol) | HMM backbone tolerates partial sequences |\n| Dark proteome \u002F \u003C15% identity | vcMSA (McWhite, Armour-Garb & Singh 2023 Genome Res; alpha-stage tool per its repo README; last release Oct 2023; test on representative inputs before pipeline use) or Foldmason (Gilchrist et al 2024) | pLM-embedding or structural alignment where sequence fails |\n| RNA with secondary structure | Infernal `cmalign` (Nawrocki & Eddy 2013), R-Coffee, MAFFT-Q-INS-i | Sequence + base-pair consistency |\n| Strand-unknown (Sanger, Nanopore raw) | `mafft --adjustdirection --globalpair` | Auto-detects and reverse-complements as needed |\n| Adding many sequences to a curated profile | HMMER `hmmalign` (Eddy 2011 PLOS CB) | Profile-driven; better than `mafft --add` for Pfam-style use |\n\n**vcMSA limitation:** Pre-filter input to within ~2x mean length; vcMSA degrades sharply on mixed full-length\u002Ffragment input because ProtT5 embeddings encode positional context. For mixed-length sets, segment long sequences via HHsearch domain decomposition before alignment, or use Foldmason on predicted structures.\n\n## Critical Concepts\n\n### Mitigate Guide-Tree Dependency\n\nAll major MSA tools build a guide tree, then align progressively along it; once a gap is inserted in the progressive phase, it is never removed, so early errors propagate. To mitigate: prefer iterative-refinement modes (MAFFT `-i`, MUSCLE5), use consistency scoring (T-Coffee) for small datasets, and quantify uncertainty with GUIDANCE2 bootstrapping or the MUSCLE5 ensemble before publishing column-specific conclusions.\n\n### Joint MSA-Phylogeny Co-estimation (Small Datasets Only)\n\nThe theoretically correct answer to guide-tree dependency is to estimate the alignment and tree jointly under a statistical evolutionary model rather than treating MSA as a fixed input to phylogenetic inference. BAli-Phy version 3 (Redelings 2021 Bioinf 37:3032) does this via MCMC, producing a posterior distribution over alignments and trees with insertion\u002Fdeletion rates as model parameters. Version 3 is O(n) instead of O(n^2) per likelihood evaluation, but the practical ceiling remains ~70-200 sequences before runtime becomes prohibitive (weeks for >100 sequences). When the dataset fits the cap, BAli-Phy gives the most defensible alignment+tree pair for publication; when it does not, the practical alternative is MUSCLE5 ensemble + IQ-TREE per-replicate (Edgar 2022) to approximate posterior alignment uncertainty without joint estimation.\n\n| Dataset size | Recommended approach |\n|--------------|----------------------|\n| \u003C 70 sequences | BAli-Phy v3 joint MSA+tree posterior; gold standard |\n| 70 - 200 sequences | BAli-Phy v3 if compute allows (weeks); else MUSCLE5 ensemble + IQ-TREE per replicate |\n| > 200 sequences | MUSCLE5 ensemble (`-stratified`) + IQ-TREE per replicate; BAli-Phy not feasible |\n| > 1000 sequences | Single MAFFT\u002FMUSCLE5 + standard bootstrap; ensemble methods become intractable |\n\n### Sequence Divergence Thresholds\n\n| Protein Identity | Signal Level | Recommendation |\n|-----------------|--------------|----------------|\n| >40% | Strong | Any MSA tool produces reliable alignment |\n| 25-40% | Moderate (twilight zone begins) | Use iterative methods (L-INS-i, MUSCLE5); validate with GUIDANCE2 |\n| 20-25% | Weak | Profile-profile methods (HHpred); consider structural alignment |\n| \u003C15-20% (length-dependent twilight) | Noise dominates signal | Sequence MSA is unreliable; switch to structural alignment (Foldseek, TM-align) or pLM aligners -- see `alignment\u002Fstructural-alignment` |\n\n## Running MAFFT\n\n### Algorithm Selection\n\nMAFFT offers multiple algorithms with explicit accuracy\u002Fspeed tradeoffs. Selecting the right mode is critical; the difference between L-INS-i and FFT-NS-1 can be the difference between a correct and incorrect downstream phylogeny.\n\n| Algorithm | Flag | Strategy | Best For |\n|-----------|------|----------|----------|\n| FFT-NS-1 | `--retree 1` | Progressive only | Quick look, >10,000 seqs |\n| FFT-NS-2 | `--retree 2` | Progressive + guide tree rebuild | Default balance, 200-10,000 seqs |\n| FFT-NS-i | `--maxiterate 1000` | Iterative refinement | Moderate improvement, 200-2,000 seqs |\n| G-INS-i | `--globalpair --maxiterate 1000` | Global pairwise + iterative | Sequences alignable over full length, \u003C200 |\n| L-INS-i | `--localpair --maxiterate 1000` | Local pairwise + iterative | Single alignable domain amid divergent flanks, \u003C200 |\n| E-INS-i | `--genafpair --maxiterate 1000` | Local with generalized affine gaps | Multiple conserved motifs separated by unalignable regions, \u003C200 |\n| Auto | `--auto` | Auto-selects based on dataset size | When unsure |\n\n**Decision guide**: If sequences share a single conserved domain (most common case), use L-INS-i. If sequences are globally similar (e.g., ortholog set of similar length), use G-INS-i. If sequences have multiple conserved blocks separated by highly variable linker regions (e.g., multi-domain proteins with variable interdomain regions), use E-INS-i.\n\n**G-INS-i failure mode:** When sequences have long divergent N\u002FC-terminal extensions (signal peptides, intrinsically-disordered regions, isoform-specific tails), the global pairwise distance G-INS-i uses for guide-tree construction is dominated by the extension's mismatch content. The guide tree then mis-clusters sequences by extension similarity rather than core homology. Symptom: the resulting alignment has core conserved domains poorly aligned despite high-identity flanks. Switch to L-INS-i (local pairwise; tolerant of divergent flanks) or pre-process to remove signal peptides\u002Fdisordered regions before alignment.\n\n### What `--auto` Picks (and Why to Specify Explicitly)\n\n`mafft --auto` silently downgrades the algorithm based on dataset size. The decision tree is roughly:\n\n| Sequences | `--auto` selects | Equivalent flags |\n|-----------|------------------|------------------|\n| \u003C 200 | L-INS-i | `--localpair --maxiterate 1000` |\n| 200 - 500 | FFT-NS-i | `--retree 2 --maxiterate 2` |\n| 500 - 2000 | FFT-NS-2 | `--retree 2 --maxiterate 0` |\n| 2000 - 50000 | FFT-NS-2 (one-pass) | `--retree 1 --maxiterate 0` |\n| > 50000 | PartTree | `--parttree --retree 1 --maxiterate 0` |\n\nThe transition at 200 sequences flips the alignment from \"iterative-refined accurate\" to \"single-pass progressive\". Note that `--auto` invokes FFT-NS-i with only `--maxiterate 2` in the 200-500 range (a truncated form of the full FFT-NS-i which uses `--maxiterate 1000`); for best accuracy in this range, specify `--retree 2 --maxiterate 1000` explicitly. For publication-quality phylogenetics, specify the algorithm explicitly so reproducibility audits do not rely on internal threshold heuristics.\n\n### Basic Usage\n\n**Goal:** Run MAFFT on a FASTA file with appropriate algorithm selection.\n\n**Approach:** Invoke MAFFT via command line or subprocess, selecting the algorithm based on dataset characteristics.\n\n```bash\n# Highest accuracy for \u003C200 sequences (local pairwise iterative)\nmafft --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Good balance for medium datasets\nmafft --retree 2 input.fasta > aligned.fasta\n\n# Auto-select algorithm based on dataset size\nmafft --auto input.fasta > aligned.fasta\n\n# Protein alignment with specific matrix (default BLOSUM62)\nmafft --amino --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# DNA alignment (auto-detected, but can be explicit)\nmafft --nuc --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Adjust gap penalties (op=gap open, ep=gap extension)\nmafft --op 1.53 --ep 0.123 --localpair --maxiterate 1000 input.fasta > aligned.fasta\n\n# Multithreaded\nmafft --thread 8 --localpair --maxiterate 1000 input.fasta > aligned.fasta\n```\n\n```python\nimport subprocess\n\ndef run_mafft(input_fasta, output_fasta, algorithm='linsi', threads=4):\n    algo_flags = {\n        'linsi': ['--localpair', '--maxiterate', '1000'],\n        'ginsi': ['--globalpair', '--maxiterate', '1000'],\n        'einsi': ['--genafpair', '--maxiterate', '1000'],\n        'fftns2': ['--retree', '2'],\n        'auto': ['--auto'],\n    }\n    cmd = ['mafft', '--thread', str(threads)] + algo_flags[algorithm] + [input_fasta]\n    with open(output_fasta, 'w') as out:\n        result = subprocess.run(cmd, stdout=out, stderr=subprocess.PIPE, text=True)\n    if result.returncode != 0:\n        raise RuntimeError(f'MAFFT failed (exit {result.returncode}):\\n{result.stderr}')\n\nrun_mafft('sequences.fasta', 'aligned.fasta', algorithm='linsi')\n```\n\nMAFFT writes its progress log and errors to stderr, not stdout. Capturing stderr and surfacing the failure message is essential when MAFFT exits non-zero (e.g. encountering ambiguous characters, oversized input, missing libraries) -- otherwise `check=True` raises a CalledProcessError without showing the actionable message.\n\n### Adding Sequences to an Existing Alignment\n\n**Goal:** Add new sequences to an existing MSA without realigning the entire dataset.\n\n**Approach:** Use MAFFT's `--add` for full-length sequences, `--addfragments` for partial \u002F surveillance \u002F metagenomic reads. The two flags are NOT interchangeable.\n\n| Flag | Use when | Behaviour |\n|------|----------|-----------|\n| `--add` | New sequences are full-length homologues | Each new sequence is profile-aligned end-to-end |\n| `--addfragments` | New sequences are partial (reads, contigs, surveillance amplicons) | Free terminal gaps; new sequences may align to a sub-region of the profile |\n| `--addprofile` | Adding an entire pre-aligned profile | Profile-profile alignment |\n| `--keeplength` | Output must have the same column count as input MSA | Insertions in new sequences are dropped (key for HMMER\u002FPfam-style use) |\n\n```bash\n# Full-length additions; may extend alignment with new columns\nmafft --add new_seqs.fasta existing_alignment.fasta > updated.fasta\n\n# Partial reads or fragments; common for SARS-CoV-2 surveillance\nmafft --addfragments new_reads.fasta --keeplength reference_msa.fasta > updated.fasta\n\n# Profile-profile merge\nmafft --addprofile second_msa.fasta first_msa.fasta > merged.fasta\n```\n\nFor HMM-curated families (Pfam, Rfam), `hmmalign --trim --outformat afa profile.hmm new_seqs.fa > out.fasta` is the canonical alternative; it constrains insertions to lowercase columns rather than introducing new alignment columns and is the format expected by downstream HMMER\u002FHHsuite tooling.\n\n## Running MUSCLE5\n\nPick `-align` (PPP) for peak-accuracy runs up to ~1000 sequences, or `-super5` (mBed clustering + chunked alignment) for thousands to millions. `-super5` is not a \"lower quality\" mode; both share the same HMM-perturbation ensemble machinery.\n\n| Command | Algorithm | Designed for | Output |\n|---------|-----------|--------------|--------|\n| `-align` (PPP) | Posterior probability progressive (HMM) | \u003C= ~1000 seqs, peak accuracy | Single MSA or .efa ensemble |\n| `-super5` | mBed-clustering + chunked alignment | Thousands to millions of seqs | Single MSA or .efa ensemble |\n\n### Basic Usage\n\n```bash\n# Peak accuracy PPP algorithm, \u003C1000 sequences\nmuscle -align input.fasta -output aligned.fasta -threads 8\n\n# super5 divide-and-conquer for thousands of sequences\nmuscle -super5 input.fasta -output aligned.fasta -threads 8\n```\n\n### Ensemble Mode for Alignment Confidence\n\n**Goal:** Quantify alignment uncertainty by generating multiple HMM-perturbed alignments and measuring column consistency.\n\n**Approach:** MUSCLE5 (Edgar 2022 Nat Comm) ships two ensemble modes: `-stratified` (16 replicates by default: the `-replicates` flag defaults to 4 HMM-perturbation seeds x 4 guide-tree permutations) and `-diversified` (100 replicates by default). Both write an Ensemble FASTA (.efa) file containing all replicates; column-level confidence is the fraction of replicates that place a given residue pair in the same column. `-perturb SEED` is a separate flag that sets the HMM-perturbation random seed, not an ensemble selector.\n\n```bash\n# Stratified ensemble: 16 replicates (4 HMM-perturbation seeds x 4 guide-tree permutations)\nmuscle -super5 input.fasta -stratified -output ensemble.efa\n\n# Diversified ensemble: 100 replicates exploring guide-tree and HMM space\nmuscle -super5 input.fasta -diversified -output ensemble.efa\n\n# Optional: change replicate count and HMM-perturbation seed\nmuscle -super5 input.fasta -stratified -replicates 8 -perturb 42 -output ensemble.efa\n```\n\nThe .efa output is consumed downstream to derive confidence-weighted bootstrap support: each replicate is fed to a tree builder and the resulting trees combined (Edgar 2022 supplement). Columns consistently aligned across replicates are reliable; high-divergence regions diverge between replicates and should be flagged before phylogenetic inference.\n\n## Running ClustalOmega\n\nUse ClustalOmega when datasets reach hundreds of thousands of sequences (the mBed guide tree scales O(N log N)) or for HMM-profile-driven alignment. Prefer MAFFT or MUSCLE5 below that scale.\n\n```bash\n# Basic alignment\nclustalo -i input.fasta -o aligned.fasta --auto\n\n# Force overwrite output\nclustalo -i input.fasta -o aligned.fasta --force\n\n# Specify output format\nclustalo -i input.fasta -o aligned.phy --outfmt=phylip\n\n# Use more iterations for better accuracy\nclustalo -i input.fasta -o aligned.fasta --iter=5\n\n# Profile-profile alignment (align two existing MSAs)\nclustalo --p1 profile1.fasta --p2 profile2.fasta -o merged.fasta\n\n# Add sequences to existing alignment\nclustalo -i new_seqs.fasta --profile1 existing.fasta -o updated.fasta\n\n# Multithreaded\nclustalo -i input.fasta -o aligned.fasta --threads=8\n```\n\n## Running T-Coffee\n\nUse T-Coffee for small datasets (\u003C50 sequences) where maximum accuracy matters or where structural templates exist (Expresso, 3D-Coffee). It is slower than progressive aligners but integrates diverse evidence via consistency-based library scoring.\n\n| Mode | Flag | What it does |\n|------|------|-------------|\n| Default | (none) | T-Coffee + Lalign pairwise library |\n| M-Coffee | `-mode mcoffee` | Combines libraries from MAFFT, MUSCLE, ClustalW, ProbCons, T-Coffee, etc. |\n| Expresso | `-mode expresso` | PSI-BLAST searches PDB for structural templates, runs SAP structural alignment (requires internet for PSI-BLAST and PDB lookups; offline alternative: 3D-Coffee with user-supplied templates) |\n| 3D-Coffee | `-mode 3dcoffee -template_file templates.txt` | User-supplied PDB templates; SAP \u002F TM-align pairwise structural library |\n| R-Coffee | `-mode rcoffee` | RNA: combines sequence alignment with consensus secondary structure (RNAplfold) |\n| Pro-Coffee | `-mode procoffee` | Promoter regions: enforces position-specific TF binding-site alignment |\n| Reliability | `-evaluate -output score_ascii` | TCS column reliability score for an existing alignment |\n\n```bash\nt_coffee input.fasta -output fasta_aln -outfile aligned.fasta\n\nt_coffee input.fasta -mode mcoffee -output fasta_aln -outfile aligned.fasta\n\nt_coffee input.fasta -mode expresso -output fasta_aln -outfile aligned.fasta\n\nt_coffee -infile aligned.fasta -evaluate -output score_ascii > tcs_scores.ascii\n```\n\n**When to use T-Coffee**: Small datasets (\u003C50 sequences) where maximum accuracy matters, especially when structural information (PDB templates) is available. Expresso (Armougom et al 2006 NAR) and 3D-Coffee modes (Poirot et al 2004; O'Sullivan et al 2004 JMB) substantially improve correct-column rate over sequence-only T-Coffee when structures exist; verify the latest benchmark numbers in the project documentation. Expresso requires internet access for PSI-BLAST + PDB lookups. The TCS reliability score (Chang et al 2014 MBE) flags individual columns as reliable\u002Funreliable for downstream filtering before phylogenetics.\n\n## Codon-Aware Alignment\n\n### When Codon Alignment Is Required\n\nCoding sequences destined for selection analysis (dN\u002FdS with PAML\u002Fcodeml, HyPhy BUSTED\u002FMEME\u002FaBSREL) **must** be aligned respecting codon boundaries. Standard nucleotide MSA tools do not preserve reading frames and produce systematically incorrect dN\u002FdS estimates -- Fletcher & Yang (2010 MBE) showed conventional aligners cause false-positive signals in the branch-site test of positive selection even on clean simulated data.\n\n### Codon-Alignment Tool Decision Tree\n\n| Input cleanliness | Recommended tool | Notes |\n|------------------|------------------|-------|\n| Clean orthologs (no frameshifts, no internal stops) | MAFFT-protein + PAL2NAL (Suyama, Torrents & Bork 2006 NAR) | Fastest; standard PAML pipeline input |\n| Recently duplicated paralogs (indel-rich) | PRANK +F codon (Loytynoja & Goldman 2008 Science) | Phylogeny-aware indel model; fewest false-positive selection calls (Fletcher & Yang 2010) |\n| Frameshifts, pseudogenes, error-prone assemblies | MACSE v2 `alignSequences -fs \u003Ccost>` (Ranwez et al 2018 MBE) | Frameshift-tolerant; preserves reading frame across sequencing errors |\n| Mixed dataset with some bad genes | OMM_MACSE pipeline (Scornavacca, Belkhir, Lopez et al 2019; Ranwez group) | MACSE non-homologous-fragment trimming + MAFFT prealignment + MACSE frameshift refinement + HMMcleaner |\n| HyPhy-grade quality (BUSTED, MEME, aBSREL input) | HyPhy `pre-msa.bf` \u002F `post-msa.bf` (Pond lab; Kosakovsky Pond et al) | Strips stop codons, runs MSA at protein level, threads back, validates frames |\n\n### PAL2NAL: Protein-Guided Codon Alignment\n\n**Goal:** Thread a nucleotide coding sequence alignment onto a protein alignment to preserve reading frame.\n\n**Approach:** Align protein sequences first (higher sensitivity), then use PAL2NAL to map the protein alignment back to codons. Suyama et al 2006 NAR; standard codeml input pipeline.\n\n```bash\nmafft --localpair --maxiterate 1000 proteins.fasta > proteins_aligned.fasta\npal2nal.pl proteins_aligned.fasta codons.fasta -output fasta > codons_aligned.fasta\npal2nal.pl proteins_aligned.fasta codons.fasta -output paml > codons_aligned.phy\n```\n\n**Non-standard genetic codes:** PAL2NAL by default uses the standard code (NCBI table 1). For mitochondrial (vertebrate=2, yeast=3, invertebrate=5), ciliate macronuclear (=6, UAA\u002FUAG=Gln), or other non-standard codes, the protein-to-codon mapping mismatches and PAL2NAL silently produces wrong codon assignments. Specify explicitly with `-codontable N`:\n\n```bash\npal2nal.pl proteins_aligned.fasta codons.fasta -output paml -codontable 2 > codons_mt.phy\n```\n\nFor datasets mixing genetic codes (e.g. nuclear + mitochondrial CDS in one tree), translate each lineage with its own code BEFORE protein alignment, never apply a single code globally. See NCBI Translation Tables for the full numbering.\n\n### PRANK +F Codon Mode\n\n**Goal:** Align coding sequences under a phylogeny-aware indel model that does not over-collapse insertions.\n\n**Approach:** PRANK +F (Loytynoja & Goldman 2008 Science) treats indels as evolutionary events on a tree, distinguishing insertions from deletions. Slower than MAFFT but recommended for selection-analysis prep.\n\n```bash\nprank -d=codons.fasta -o=prank_aligned -codon -F\n```\n\nThe `+F` flag enforces \"fewer false insertions\"; without it PRANK behaves more like a conventional aligner. For dN\u002FdS analysis under PAML M2a\u002FM8, PRANK +F is the most conservative input choice.\n\n### MACSE v2: Frameshift-Tolerant Codon Alignment\n\n**Goal:** Align coding sequences directly at the codon level while tolerating frameshifts and internal stops.\n\n**Approach:** MACSE scores based on amino acid translation while operating on DNA. The v2 toolbox (Ranwez et al 2018 MBE) ships a sub-program selector via `-prog`; the eight most-used sub-programs are listed below (run `macse -help` for the full set in the installed release):\n\n| Sub-program | Purpose |\n|-------------|---------|\n| `alignSequences` | Align coding sequences (`-fs \u003Ccost>` sets frameshift penalty) |\n| `enrichAlignment` | Add new sequences to existing codon alignment |\n| `refineAlignment` | Refine an alignment with MACSE scoring |\n| `splitAlignment` | Split into sub-alignments (e.g. by guide tree clades) |\n| `exportAlignment` | Convert between MACSE-internal and standard formats |\n| `trimAlignment` | Position-aware trimming preserving codon structure |\n| `trimNonHomologousFragments` | Detect and remove non-homologous regions per sequence |\n| `reportGapsAA2NT` | Map protein-level gap removals back to nucleotide alignment |\n\n```bash\njava -jar macse_v2.jar -prog alignSequences -seq coding_seqs.fasta \\\n    -out_NT aligned_nt.fasta -out_AA aligned_aa.fasta -fs 30\n\njava -jar macse_v2.jar -prog enrichAlignment -align existing.fasta \\\n    -seq new_seqs.fasta -out_NT updated.fasta\n```\n\n### OMM_MACSE: Recommended Pipeline Wrapper\n\nOMM_MACSE (Ranwez group, used in OrthoMaM v10+) chains: MACSE `trimNonHomologousFragments` to remove non-homologous fragments (annotation errors, retained introns\u002FUTRs), MAFFT pre-alignment for guide-tree, MACSE v2 frameshift-aware refinement, then soft HMMcleaner cleaning. This is the recommended pipeline for genome-scale ortholog datasets where some genes will contain frameshifts.\n\n```bash\nOMM_MACSE_v12.02.sif --in_seq_file orthogroup.fasta --out_dir omm_out --out_file_prefix orthogroup --genetic_code_number 1\n```\n\n### HyPhy pre-msa.bf \u002F post-msa.bf\n\nFor HyPhy-grade dN\u002FdS analyses (BUSTED, MEME, aBSREL, RELAX), Pond lab's standard workflow is:\n\n```bash\nhyphy pre-msa.bf --input cds.fasta\nmafft --auto cds.fasta_protein.fas > cds.fasta_protein.msa\nhyphy post-msa.bf --protein-msa cds.fasta_protein.msa --nucleotide-sequences cds.fasta_nuc.fas --output cds.codon.msa\n```\n\n`pre-msa.bf` strips internal stop codons and translates; `post-msa.bf` validates that all sequences remain in-frame after threading. Without this validation step, a single mis-aligned codon can cascade into a spurious episodic-selection call.\n\n### Confidence Assessment\n\nFor publication-grade phylogenetics or selection analysis, alignment uncertainty must be quantified per column and unreliable columns excluded BEFORE downstream inference -- not after.\n\n| Method | Tool | Output |\n|--------|------|--------|\n| Guide-tree perturbation | GUIDANCE2 (Sela et al 2015 NAR) | Per-column and per-residue reliability score (0-1); default cutoff 0.93. No GUIDANCE3 has been released; deep-learning successors are exploratory only. |\n| Library-consistency | T-Coffee TCS (Chang et al 2014 MBE) | Per-column reliability score via `-evaluate -output score_ascii` |\n| HMM ensemble | MUSCLE5 `-stratified` \u002F `-diversified` | EFA file; column confidence = fraction of replicates supporting it |\n| Co-optimal alignments | HoT (Landan & Graur 2007 MBE) | Heads-or-tails alternate optimal alignment for each column |\n\nMask columns below the reliability threshold before phylogenetic inference. Trees built from filtered alignments are markedly more stable to method choice.\n\n**GUIDANCE2 thresholds are tool-specific.** The 0.93 default cutoff is calibrated against MAFFT-LINSI in Sela et al 2015. Running GUIDANCE2 on top of MUSCLE5 or PRANK uses different perturbation distributions and produces scores on a slightly different scale. For non-MAFFT base aligners, calibrate the threshold empirically using a benchmark with known-correct columns or use the tool-native ensemble scoring (MUSCLE5 `-stratified`) instead.\n\n## Post-Alignment Validation Checklist\n\nBefore proceeding to downstream analysis, verify alignment quality:\n\n1. **Visual inspection**: Scan for columns of mostly gaps with scattered residues (hallmark of misalignment)\n2. **Gap distribution**: High gap fraction (>50% of columns with gaps) suggests problematic regions or inclusion of non-homologous sequences\n3. **Sequence identity**: If average pairwise identity is \u003C25% for proteins, alignment reliability is questionable\n4. **Outlier sequences**: Sequences with excessive gaps relative to others may be non-homologous or fragments; consider removing and re-aligning\n5. **Conservation pattern**: Functional domains should show clear conservation; absence of expected conserved motifs suggests alignment error or non-homology\n6. **Run GUIDANCE2 or MUSCLE5 ensemble**: Quantify alignment confidence per column before phylogenetic inference\n\n## When NOT to Run MSA\n\n- **Non-homologous sequences**: MSA tools always produce an alignment, even for unrelated sequences; verify homology first (e.g., BLAST E-value \u003C 1e-5)\n- **Sequences below the twilight zone**: Below ~20% protein identity, sequence signal is lost in noise; structural alignment is needed\n- **Different domain architectures**: Globally aligning multi-domain proteins with different domain orders produces meaningless results; align individual domains separately\n- **Very different lengths without shared homology**: Aligning a 50-residue fragment against 1000-residue proteins globally forces biologically meaningless gaps; use local alignment or fragment-aware modes (E-INS-i)\n- **Highly repetitive sequences**: Tandem repeats cause alignment ambiguity; specialized tools (e.g., TRUST for tandem repeats) may be needed\n\n## Quick Reference\n\n| Task | Command |\n|------|---------|\n| Best accuracy (\u003C200 seqs) | `mafft --localpair --maxiterate 1000 in.fa > out.fa` |\n| Large dataset | `mafft --retree 2 in.fa > out.fa` or `clustalo -i in.fa -o out.fa` |\n| Uncertainty estimation | `muscle -super5 in.fa -stratified -output out.efa` |\n| Codon-aware | Align protein first, then `pal2nal.pl prot.fa cds.fa -output fasta` |\n| Add to existing MSA | `mafft --add new.fa existing.fa > updated.fa` |\n| Profile merge | `clustalo --p1 msa1.fa --p2 msa2.fa -o merged.fa` |\n| With structure info | `t_coffee in.fa -mode expresso` |\n\n## Common Errors\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| MAFFT runs out of memory | L-INS-i on too many sequences | Switch to FFT-NS-2 or auto mode |\n| Alignment has many all-gap columns | Non-homologous sequences included | Filter input by BLAST hits first |\n| ClustalOmega crashes on large input | Memory limits | Increase `--MAC` RAM or use MAFFT |\n| PAL2NAL \"length mismatch\" | Protein\u002FDNA sequences not from same genes | Verify correspondence with sequence IDs |\n| MUSCLE5 slow on large datasets | Default algorithm not designed for >10K seqs | Use `-super5` mode |\n| Poor alignment despite high identity | Wrong sequence type detection | Explicitly specify `--amino` or `--nuc` |\n\n## Related Skills\n\n- alignment\u002Fpairwise-alignment - Compare two sequences using PairwiseAligner\n- alignment\u002Falignment-io - Read\u002Fwrite MSA files in various formats\n- alignment\u002Fmsa-parsing - Parse, filter, trim, and assess MSA quality\n- alignment\u002Fmsa-statistics - Calculate identity, conservation, entropy metrics\n- alignment\u002Fstructural-alignment - Foldseek, TM-align, Foldmason for the dark proteome\n- alignment\u002Falignment-trimming - ClipKIT, trimAl, BMGE post-MSA column filtering\n- phylogenetics\u002Fmodern-tree-inference - Build phylogenetic trees from MSAs\n- sequence-io\u002Fread-sequences - Read input sequences for alignment\n\n## References\n\n- Edgar RC. 2022. Muscle5: high-accuracy alignment ensembles enable unbiased assessments of sequence homology and phylogeny. Nat Comm 13:6968.\n- Katoh K, Standley DM. 2013. MAFFT multiple sequence alignment software version 7. MBE 30:772-780.\n- Sievers F et al. 2011. Fast, scalable generation of high-quality protein multiple sequence alignments using Clustal Omega. Mol Syst Biol 7:539.\n- Notredame C, Higgins DG, Heringa J. 2000. T-Coffee: a novel method for fast and accurate multiple sequence alignment. JMB 302:205-217.\n- Loytynoja A, Goldman N. 2008. Phylogeny-aware gap placement prevents errors in sequence alignment and evolutionary analysis. Science 320:1632-1635.\n- Ranwez V, Douzery EJP, Cambon C, Chantret N, Delsuc F. 2018. MACSE v2: toolkit for the alignment of coding sequences accounting for frameshifts and stop codons. MBE 35:2582-2584.\n- Suyama M, Torrents D, Bork P. 2006. PAL2NAL: robust conversion of protein sequence alignments into the corresponding codon alignments. NAR 34:W609-W612.\n- Sela I, Ashkenazy H, Katoh K, Pupko T. 2015. GUIDANCE2: accurate detection of unreliable alignment regions accounting for the uncertainty of multiple parameters. NAR 43:W7-W14.\n- Chang JM, Di Tommaso P, Notredame C. 2014. TCS: a new multiple sequence alignment reliability measure to estimate alignment accuracy and improve phylogenetic tree reconstruction. MBE 31:1625-1637.\n- Fletcher W, Yang Z. 2010. The effect of insertions, deletions, and alignment errors on the branch-site test of positive selection. MBE 27:2257-2267.\n- Armougom F, Moretti S, Poirot O, Audic S, Dumas P, Schaeli B, Keduas V, Notredame C. 2006. Expresso: automatic incorporation of structural information in multiple sequence alignments using 3D-Coffee. NAR 34:W604-W608.\n- McWhite CD, Armour-Garb I, Singh M. 2023. Leveraging protein language models for accurate multiple sequence alignments. Genome Res 33:1145-1153.\n- Redelings BD. 2021. BAli-Phy version 3: model-based co-estimation of alignment and phylogeny. Bioinf 37:3032-3034.\n",{"name":5,"tool_type":24,"description":7,"primary_tool":25},"mixed","MAFFT","main","e0956dc9606356ab78468936b502e55a365282e2","specialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple",0,"https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists","https:\u002F\u002Fgithub.com\u002Fmrsonord2240","2026-10-12 03:19:04",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add mrsonord2240\u002Fopenscience-specialists --skill bio-alignment-multiple",{"tool":39,"command":40},"bunx","bunx skills add mrsonord2240\u002Fopenscience-specialists --skill bio-alignment-multiple",{"tool":42,"command":43},"pnpm","pnpm dlx skills add mrsonord2240\u002Fopenscience-specialists --skill bio-alignment-multiple","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple\u002FSKILL.md",true,[47,53,57],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"examples\u002Fcodon_alignment.py","SCRIPT","脚本",1417,"https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple\u002Fexamples\u002Fcodon_alignment.py",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"examples\u002Frun_msa.py",2955,"https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple\u002Fexamples\u002Frun_msa.py",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"usage-guide.md","REFERENCE","参考文档",4528,"https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Fmolecular-phylogenetics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-alignment-multiple\u002Fusage-guide.md",[64,71,78,85,92,99],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7CW36A6QAGWFE2C008M1XPG","bio-workflows-metabolomics-pipeline","Orchestrates the untargeted LC-MS metabolomics pipeline end-to-end (xcms 4.x feature extraction, QC\u002Fdrift\u002Fnormalization, confidence-stratified annotation, permutation-validated statistics, background-aware pathway mapping), naming what each stage decides and where it silently fails. Use when running a full LC-MS metabolomics study from raw mzML to enriched pathways and needing the honest handoffs between stages. Each stage defers to its component skill for parameters and traps; for stable-isotope flux (a separate branch, not this untargeted flow) see metabolomics\u002Fisotope-tracing.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-workflows-metabolomics-pipeline\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7CW2Y18623NA2S1Y30FRQW1","bio-metabolomics-xcms-preprocessing","Programmatic untargeted LC-MS feature extraction in R with the modern xcms 4.x MsExperiment\u002FXcmsExperiment API, taking raw mzML to a feature table via CentWave peak detection, retention-time alignment, peak-density correspondence, gap-filling, CAMERA redundancy collapse, and built-in QC feature filtering. Use when converting centroided LC-MS runs into a features-by-samples matrix and deciding centWave\u002Fgrouping\u002Falignment parameters. For drift correction and QC\u002FCV filtering execution see metabolomics\u002Fnormalization-qc; for metabolite identification see metabolomics\u002Fmetabolite-annotation; for the MS-DIAL GUI alternative with MS2Dec deconvolution see metabolomics\u002Fmsdial-preprocessing; for downstream statistics see metabolomics\u002Fstatistical-analysis.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-metabolomics-xcms-preprocessing\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CW2M364HVWPNQEKE2WP4PP","bio-metabolomics-statistical-analysis","Decision-grade statistical analysis for metabolomics intensity tables. Covers transformation and scaling (Pareto vs unit-variance as a hidden hypothesis), unsupervised structure (PCA\u002FHCA for QC), permutation-validated PLS-DA\u002FOPLS-DA (R2 vs Q2, double CV, VIP as heuristic), univariate testing (Welch\u002FMann-Whitney\u002FANOVA\u002FLMM with covariate adjustment), and dependence-aware multiple testing. Use when testing which metabolites differ, building or validating a discriminant model, choosing a scaling, or correcting many correlated tests. For sample-wise normalization\u002Fdrift correction see metabolomics\u002Fnormalization-qc; for ML classifiers and selection-inside-CV leakage see machine-learning\u002Fbiomarker-discovery and machine-learning\u002Fmodel-validation; for pathway interpretation see metabolomics\u002Fpathway-mapping; for design\u002Fpower\u002Fmultiplicity regime see experimental-design\u002Fmultiple-testing.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-metabolomics-statistical-analysis\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CW2BCBF851WYE03Z8XPEDQ","bio-metabolomics-pathway-mapping","Maps metabolomics results to biological pathways via over-representation (ORA), metabolite-set enrichment (MSEA\u002FQEA), mummichog\u002FPSEA on raw m\u002Fz peaks, and network-diffusion enrichment (FELLA), with correct background-set construction and honest interpretive ceilings. Use when interpreting differential metabolites or an untargeted LC-MS feature table in pathway context, choosing ORA vs MSEA vs mummichog vs topology, or setting the reference\u002Fbackground set. For annotation confidence levels feeding ORA see metabolomics\u002Fmetabolite-annotation; for gene-set concepts see pathway-analysis\u002Fgo-enrichment and pathway-analysis\u002Fgsea; for joint gene+metabolite pathways see multi-omics-integration\u002Fmofa-integration.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-metabolomics-pathway-mapping\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M7CW21NSZMCPMF7D9CHJM718","bio-metabolomics-normalization-qc","Designs QC, corrects signal drift, removes batch effects, filters features, normalizes samples, and imputes missing values for untargeted LC-MS\u002FGC-MS metabolomics, framing each step as a measurement model that can create or erase biological signal. Use when processing a peak\u002Ffeature table before statistical analysis, choosing a drift-correction or sample-normalization method, deciding QC RSD vs D-ratio filtering, or handling left-censored missing values. The feature table is produced by metabolomics\u002Fxcms-preprocessing or metabolomics\u002Fmsdial-preprocessing; transformation\u002Fscaling for modeling defers to metabolomics\u002Fstatistical-analysis; cross-study design issues link to experimental-design\u002Fbatch-design.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-metabolomics-normalization-qc\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":19},"01M7CW1SWVM0NYHVE6Q7MA3G7R","bio-metabolomics-msdial-preprocessing","Runs the MS-DIAL preprocessing workflow (peak picking, MS2Dec spectral deconvolution, alignment, gap-filling) and imports the alignment-result table into R or Python with honest filtering. Use when preprocessing LC-MS DDA\u002FDIA (SWATH) or GC-MS raw data with MS-DIAL, deciding MS-DIAL vs XCMS, configuring the MSDIALCUI console run, or parsing an MS-DIAL export into a clean feature matrix. For programmatic R peak detection and the feature-table-as-artifact framing see metabolomics\u002Fxcms-preprocessing; for lipid annotation mode see metabolomics\u002Flipidomics; for MSI-level confidence honesty see metabolomics\u002Fmetabolite-annotation; for drift correction and QC see metabolomics\u002Fnormalization-qc.","https:\u002F\u002Fgithub.com\u002Fmrsonord2240\u002Fopenscience-specialists\u002Fblob\u002Fmain\u002Fspecialists\u002Funtargeted-metabolomics-analyst\u002Fversions\u002F1.0.0\u002Fpackage\u002Fskills\u002Fbio-metabolomics-msdial-preprocessing\u002FSKILL.md",[],[]]