Codon Adaptation Index (CAI) of Sharp & Li (1987). A value-exact Rust port of
biopython's Bio.SeqUtils.CodonAdaptationIndex.
The CAI of a coding sequence is the geometric mean of the relative adaptiveness w(codon) of its codons:
CAI = exp( (1/L) · Σ ln w(codon) )
where w(codon) = count(codon) / max(count over its synonymous codons), measured on a reference set of (typically highly expressed) genes. Codons absent from the reference set get a pseudocount of 0.5. The single-codon amino acids Met (ATG) and Trp (TGG), and stop codons, are excluded from the geometric mean.
# Derive the weight table from a reference FASTA of CDS, then score a query:
rsomics-cai query.fasta --reference reference.fasta
# Or score against a precomputed codon weight table (codon<TAB>w per line):
rsomics-cai query.fasta --weights weights.tsv
# Read the query from stdin:
cat query.fasta | rsomics-cai - --reference reference.fastaOutput is one id<TAB>cai line per query sequence. --json emits a single
result envelope instead. Common flags (-t/--threads, -q/--quiet, --json)
follow the rsomics convention.
This crate is an independent Rust reimplementation based on:
- Sharp PM, Li WH. "The codon Adaptation Index — a measure of directional synonymous codon usage bias, and its potential applications." Nucleic Acids Research 15(3): 1281-1295 (1987). doi:10.1093/nar/15.3.1281
- The behaviour of biopython's
Bio.SeqUtils.CodonAdaptationIndexclass (biopython 1.87), which is BSD-3-Clause licensed. Its source was read to match the exact synonymous-codon grouping (the standard genetic code), the 0.5 pseudocount for unobserved codons, the exclusion of ATG/TGG and stop codons, and the geometric-mean normalisation by the number of scored codons.
Golden test fixtures were generated once from biopython 1.87 and are committed;
tests/compat.rs runs without python and asserts value-exactness (worst
relative error 0 across the committed goldens and a 1.2M-codon fixture).
License: MIT OR Apache-2.0. Upstream credit: biopython (BSD-3-Clause).