Skip to content
Computational Biology

computational-biology-ai999x

DNA and protein sequences, alignment, molecular weights, genetics and population genetics, phylogenetics, enzyme kinetics, metabolic and population models, and ecology.

83capabilities
10topics
83formulas typeset
8worked examples below
1.0.0version
About this model

What Computational Biology does

Computational Biology (computational-biology-ai999x) is an offline Python package for computational biology. It covers DNA and protein sequences, alignment, molecular weights, genetics and population genetics, phylogenetics, enzyme kinetics, metabolic and population models, and ecology.

It has 83 capabilities — 83 computational procedures — in 10 topics, the largest being Sequences, Population genetics, Ecology, Enzyme kinetics, Alignment and Phylogenetics. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.

When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.

Install

pip install computational-biology-ai999x
hf download AI999X/computational-biology-ai999x --local-dir computational-biology-ai999x

What it covers

Try it

Worked examples

Each question below was put to computational-biology-ai999x and the answer shown is the one it returned, with the steps it took.

Sequencesm.ask(…)

Reverse complement: seq = ATGCCGTA

revcomp = TACGGCAT
Show the steps
  1. Reverse complement of a DNA sequence
    5'\text{-}x_1\dots x_n\text{-}3' \mapsto 5'\text{-}\bar x_n\dots \bar x_1\text{-}3'
    with seq = ATGCCGTA
    → revcomp = TACGGCAT
Population geneticsm.ask(…)

Hardy-Weinberg test: n_AA = 298, n_Aa = 489, n_aa = 213

p = 0.5425
q = 0.4575
exp_AA = 294.30625
exp_Aa = 496.3875
exp_aa = 209.30625
chi2 = 0.2214895876
Show the steps
  1. Hardy-Weinberg chi-square test
    \chi^2 = \sum \frac{(O-E)^2}{E},\quad E = (Np^2,\ 2Npq,\ Nq^2)
    with n_AA = 298, n_Aa = 489, n_aa = 213
    → p = 0.5425, q = 0.4575, exp_AA = 294.30625, exp_Aa = 496.3875, exp_aa = 209.30625, chi2 = 0.2214895876, p_value = 0.6379072638, Ho = 0.489, He = 0.4963875, F = 0.01488252625
Alignmentm.ask(…)

Global alignment score: seq1 = GATTACA, seq2 = GCATGCU, match = 1, mismatch = -1, gap = -1

score = 0
Show the steps
  1. Global alignment score (Needleman-Wunsch, linear gaps)
    S_{i,j} = \max(S_{i-1,j-1}+s(x_i,y_j),\ S_{i-1,j}+g,\ S_{i,j-1}+g)
    with seq1 = GATTACA, seq2 = GCATGCU, match = 1, mismatch = -1, gap = -1
    → score = 0
Geneticsm.ask(…)

Cross phenotype ratio: parent1 = AaBb, parent2 = AaBb

p_all_dominant = 0.5625
p_all_recessive = 0.0625
n_genotypes = 9
n_phenotypes = 4
ratio = 9:3:3:1
Show the steps
  1. Phenotype ratio of a cross (complete dominance)
    (\tfrac34 D + \tfrac14 r)^n \Rightarrow 9:3:3:1 \text{ for two loci}
    with parent1 = AaBb, parent2 = AaBb
    → p_all_dominant = 0.5625, p_all_recessive = 0.0625, n_genotypes = 9, n_phenotypes = 4, ratio = 9:3:3:1
Enzyme kineticsm.solve(…)
m.solve("bio_michaelis_menten_fit", S="0.5, 1, 2, 5", v="2.2, 3.5, 5.1, 6.6")
Vmax = 8.500055206
Km = 1.400014367
Show the steps
  1. Michaelis-Menten nonlinear least-squares fit
    \min_{V_{\max},K_m} \sum_i \Big(v_i - \frac{V_{\max}S_i}{K_m+S_i}\Big)^2
    with S = [0.5, 1, 2, 5], v = [2.2, 3.5, 5.1, 6.6]
    → Vmax = 8.500055206, Km = 1.400014367
Ecologym.ask(…)

ACE richness estimator: counts = [1, 1, 2, 3, 5, 8, 20, 50], rare_threshold = 10

ace = 9.719298246
Show the steps
  1. ACE species richness estimator
    S_{ace} = S_{abund} + \frac{S_{rare}}{C_{ace}} + \frac{F_1}{C_{ace}}\gamma^2
    with counts = [1, 1, 2, 3, 5, 8, 20, 50], rare_threshold = 10
    → ace = 9.719298246
Microbial growthm.ask(…)

Chemostat steady state: mu_max = 1, Ks = 1, Y = 0.5, D = 0.5, S0 = 10

S = 1
X = 4.5
Show the steps
  1. Chemostat steady state (Monod kinetics)
    \bar S = \frac{K_sD}{\mu_{\max} - D},\quad \bar X = Y(S_0 - \bar S)
    with mu_max = 1, Ks = 1, Y = 0.5, D = 0.5, S0 = 10
    → S = 1, X = 4.5
Phylogeneticsm.ask(…)

Parsimony score: tree = ((A,B),(C,D));, states = A:AACG B:AATG C:GACT D:GGCT

score = 4
Show the steps
  1. Parsimony score of a tree (Fitch)
    c_v(a) = \sum_{w\in\mathrm{children}(v)} \min_b \big(c_w(b) + [a\ne b]\big)
    with tree = ((A,B),(C,D));, states = A:AACG B:AATG C:GACT D:GGCT
    → score = 4
Use it

From Python or the command line

Every snippet was run as shown; the output under it is what it printed.

import computational_biology_ai999x as m

a = m.ask("Reverse complement: seq = ATGCCGTA")
print(a.outcome)
print(a.values)
for step in a.steps:
    print(step["name"])
Output
SOLVED
{'revcomp': 'TACGGCAT'}
Reverse complement of a DNA sequence
Figures

Computed, not drawn by hand

Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.

Michaelis–Menten kinetics: measured rates and fitted curve

\min_{V_{\max},K_m} \sum_i \Big(v_i - \frac{V_{\max}S_i}{K_m+S_i}\Big)^2
Michaelis–Menten kinetics: measured rates and fitted curveMichaelis–Menten fit to 4 measured rates (S = [1, 2, 4, 8]): the package returns Vmax = 10 and Km = 1; the curve drawn is v = Vmax·S/(Km + S) with those two values (the double-reciprocal fit gives Vmax = 10, Km = 1, r² = 1). Marked: S = Km = 1, v = Vmax/2 = 5.0510152002.557.510Vmax = 10Km = 1fitted v = Vmax·S/(Km + S)measured rates[S] — substrate concentrationv — reaction rate
Michaelis–Menten fit to 4 measured rates (S = [1, 2, 4, 8]): the package returns Vmax = 10 and Km = 1; the curve drawn is v = Vmax·S/(Km + S) with those two values (the double-reciprocal fit gives Vmax = 10, Km = 1, r² = 1). Marked: S = Km = 1, v = Vmax/2 = 5.

Enzyme progress curve: substrate and product over time

K_m\ln\frac{S_0}{S} + (S_0 - S) = V_{\max}t
Enzyme progress curve: substrate and product over timeSubstrate and product over time for an enzyme reaction with S0 = 10, Vmax = 1 and Km = 2 (integrated Michaelis–Menten law), computed by the package at 101 times. Half the substrate is converted at t = 6.38629; marked: t = 6.38629, S = 5.0510152002.557.510half converted, t = 6.38629substrate Sproduct Pt — timeconcentration
Substrate and product over time for an enzyme reaction with S0 = 10, Vmax = 1 and Km = 2 (integrated Michaelis–Menten law), computed by the package at 101 times. Half the substrate is converted at t = 6.38629; marked: t = 6.38629, S = 5.

Chemostat steady states against dilution rate

\bar S = \frac{K_sD}{\mu_{\max} - D},\quad \bar X = Y(S_0 - \bar S)
Chemostat steady states against dilution rateChemostat operating diagram (Monod growth, μmax = 1, Ks = 1, Y = 0.5, feed S0 = 10): steady-state substrate and biomass computed by the package at 90 dilution rates up to washout; biomass productivity D·X peaks near D = 0.7 (2.68333). Marked: D = 0.5, X = 4.5, S = 1.00.20.40.60.802468X = 4.5substrate Sbiomass Xproductivity D·XD — dilution rate (1/time)steady-state concentration
Chemostat operating diagram (Monod growth, μmax = 1, Ks = 1, Y = 0.5, feed S0 = 10): steady-state substrate and biomass computed by the package at 90 dilution rates up to washout; biomass productivity D·X peaks near D = 0.7 (2.68333). Marked: D = 0.5, X = 4.5, S = 1.

Age-structured population growth (Leslie matrix)

\mathbf n_{t+1} = L\,\mathbf n_t,\quad L = \begin{pmatrix}F_1 & F_2 & \cdots\\ S_1 & 0 & \\ & \ddots & \end{pmatrix}
Age-structured population growth (Leslie matrix)Leslie-matrix projection of an age-structured population (fecundities F = [0, 1.5, 1], survival S = [0.5, 0.8], start n0 = [100, 50, 20]): each bar is the population the package returns at that step, split by age class. Growth settles to λ = 1.06152 per step (r = 0.0596993); at t = 12 the classes are [197.307, 92.9426, 69.9967]; marked: total = 360.247.05100100200300360.247age class 1age class 2age class 3t — time stepindividuals (stacked by age class)
Leslie-matrix projection of an age-structured population (fecundities F = [0, 1.5, 1], survival S = [0.5, 0.8], start n0 = [100, 50, 20]): each bar is the population the package returns at that step, split by age class. Growth settles to λ = 1.06152 per step (r = 0.0596993); at t = 12 the classes are [197.307, 92.9426, 69.9967]; marked: total = 360.247.

Hardy–Weinberg: observed against expected genotypes

\chi^2 = \sum \frac{(O-E)^2}{E},\quad E = (Np^2,\ 2Npq,\ Nq^2)
Hardy–Weinberg: observed against expected genotypesObserved genotype counts AA = 298, Aa = 489, aa = 213 beside the counts expected under Hardy–Weinberg equilibrium, computed by the package from the allele frequencies p = 0.5425, q = 0.4575: 294.306, 496.387, 209.306. χ² = 0.22149, p-value 0.637907; observed heterozygosity 0.489 against expected 0.496387 (F = 0.0148825).0200400AAAaaaobservedexpected under Hardy–Weinberggenotypeindividuals
Observed genotype counts AA = 298, Aa = 489, aa = 213 beside the counts expected under Hardy–Weinberg equilibrium, computed by the package from the allele frequencies p = 0.5425, q = 0.4575: 294.306, 496.387, 209.306. χ² = 0.22149, p-value 0.637907; observed heterozygosity 0.489 against expected 0.496387 (F = 0.0148825).

Heterozygosity lost by drift: population size against time

H_t = H_0\left(1 - \frac{1}{2N}\right)^t
Heterozygosity retainedFraction of heterozygosity retained under random genetic drift, (1 − 1/(2N))^t, for population sizes N = 5, 10, 25, 50, 100, 250 (rows) after 10, 25, 50, 100, 200 generations (columns), each cell computed by the package and rounded to 3 decimals. N = 50 keeps 0.366 after 100 generations; N = 5 keeps 0 after 200.0.3490.0720.005000.5990.2770.0770.00600.8170.6030.3640.1330.0180.9040.7780.6050.3660.1340.9510.8820.7780.6060.3670.980.9510.9050.8190.67retained · rows N = 5 → 250 · columns t = 10 → 200 generations
Fraction of heterozygosity retained under random genetic drift, (1 − 1/(2N))^t, for population sizes N = 5, 10, 25, 50, 100, 250 (rows) after 10, 25, 50, 100, 200 generations (columns), each cell computed by the package and rounded to 3 decimals. N = 50 keeps 0.366 after 100 generations; N = 5 keeps 0 after 200.
Formulas

The mathematics inside

12 of its 83 formulas; every one is in the capability browser below.

Reverse complement of a DNA sequence
5'\text{-}x_1\dots x_n\text{-}3' \mapsto 5'\text{-}\bar x_n\dots \bar x_1\text{-}3'
Hardy-Weinberg chi-square test
\chi^2 = \sum \frac{(O-E)^2}{E},\quad E = (Np^2,\ 2Npq,\ Nq^2)
Global alignment score (Needleman-Wunsch, linear gaps)
S_{i,j} = \max(S_{i-1,j-1}+s(x_i,y_j),\ S_{i-1,j}+g,\ S_{i,j-1}+g)
Phenotype ratio of a cross (complete dominance)
(\tfrac34 D + \tfrac14 r)^n \Rightarrow 9:3:3:1 \text{ for two loci}
Michaelis-Menten nonlinear least-squares fit
\min_{V_{\max},K_m} \sum_i \Big(v_i - \frac{V_{\max}S_i}{K_m+S_i}\Big)^2
ACE species richness estimator
S_{ace} = S_{abund} + \frac{S_{rare}}{C_{ace}} + \frac{F_1}{C_{ace}}\gamma^2
Chemostat steady state (Monod kinetics)
\bar S = \frac{K_sD}{\mu_{\max} - D},\quad \bar X = Y(S_0 - \bar S)
Parsimony score of a tree (Fitch)
c_v(a) = \sum_{w\in\mathrm{children}(v)} \min_b \big(c_w(b) + [a\ne b]\big)
Berger-Parker and McIntosh indices
d = \frac{n_{\max}}{N},\quad D = \frac{N - U}{N - \sqrt N}
Competitive inhibition global fit
v = \frac{V_{\max}S}{K_m\left(1 + \frac{[I]}{K_i}\right) + S}
Inbreeding coefficient from a pedigree
F_X = \sum_{\text{paths}} \left(\tfrac12\right)^{n_1+n_2+1}(1 + F_A)
Capabilities

Every capability, with an example

Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.

83 capabilities

Alignment 7

Global alignment score (Needleman-Wunsch, linear gaps)bio_global_alignment_score

The optimal global (Needleman-Wunsch) alignment score of two sequences with stated match, mismatch and linear gap scores.

S_{i,j} = \max(S_{i-1,j-1}+s(x_i,y_j),\ S_{i-1,j}+g,\ S_{i,j-1}+g)

Inputs

  • seq1 first sequence text
  • seq2 second sequence text
  • match score of a match
  • mismatch score of a mismatch
  • gap score of each gap position (<= 0)

Returns

  • score optimal global alignment score

Applies when

  • gap <= 0
  • end gaps scored like internal gaps

Example

m.ask("Global alignment score: seq1 = GATTACA, seq2 = GCATGCU, match = 1, mismatch = -1, gap = -1")
→ score = 0
Global alignment score with affine gaps (Gotoh)bio_global_alignment_affine

The optimal global alignment score with affine gaps: a gap of length L scores open + (L-1)*extend.

g(L) = o + (L-1)\,e

Inputs

  • seq1 first sequence text
  • seq2 second sequence text
  • match score of a match
  • mismatch score of a mismatch
  • open score of the first position of a gap (<= 0)
  • extend score of each further gap position (<= 0)

Returns

  • score optimal global alignment score

Applies when

  • open, extend <= 0
  • a gap of length L scores open + (L-1) extend
  • end gaps scored

Example

m.ask("Global alignment score with affine gaps: seq1 = ACGTTTACG, seq2 = ACGACG, match = 2, mismatch = -1, open = -5, extend = -1")
→ score = 5
Global protein alignment score (BLOSUM62, affine gaps)bio_protein_global_blosum62

The optimal global alignment score of two proteins with BLOSUM62 and affine gaps.

S = \max_{\text{alignments}} \sum B_{62}(x,y) + \sum_{\text{gaps}} [o + (L-1)e]

Inputs

  • seq1 first protein sequence text
  • seq2 second protein sequence text
  • open score of the first position of a gap (<= 0)
  • extend score of each further gap position (<= 0)

Returns

  • score optimal global alignment score

Applies when

  • standard amino acids
  • open, extend <= 0

Example

m.ask("Global protein alignment score: seq1 = HEAGAWGHEE, seq2 = PAWHEAE, open = -10, extend = -1")
→ score = 3
Local alignment score (Smith-Waterman, linear gaps)bio_local_alignment_score

The optimal local (Smith-Waterman) alignment score of two sequences with stated match, mismatch and linear gap scores.

S_{i,j} = \max(0,\ S_{i-1,j-1}+s(x_i,y_j),\ S_{i-1,j}+g,\ S_{i,j-1}+g)

Inputs

  • seq1 first sequence text
  • seq2 second sequence text
  • match score of a match
  • mismatch score of a mismatch
  • gap score of each gap position (<= 0)

Returns

  • score optimal local alignment score (>= 0)

Applies when

  • match > 0
  • gap <= 0

Example

m.ask("Local alignment score: seq1 = TGTTACGG, seq2 = GGTTGACTA, match = 3, mismatch = -3, gap = -2")
→ score = 13
Local alignment score with affine gapsbio_local_alignment_affine

The optimal local alignment score with affine gaps (a gap of length L scores open + (L-1)*extend).

g(L) = o + (L-1)\,e,\quad S \ge 0

Inputs

  • seq1 first sequence text
  • seq2 second sequence text
  • match score of a match
  • mismatch score of a mismatch
  • open score of the first position of a gap (<= 0)
  • extend score of each further gap position (<= 0)

Returns

  • score optimal local alignment score (>= 0)

Applies when

  • match > 0
  • open, extend <= 0

Example

m.ask("Local alignment score with affine gaps: seq1 = TTACGTACGTTT, seq2 = GGACGTTACGTGG, match = 2, mismatch = -1, open = -3, extend = -1")
→ score = 13
Local protein alignment score (BLOSUM62, affine gaps)bio_protein_local_blosum62

The optimal local (Smith-Waterman) alignment score of two proteins with BLOSUM62 and affine gaps.

S = \max\Big(0, \max_{\text{local alignments}} \textstyle\sum B_{62} + \sum [o + (L-1)e]\Big)

Inputs

  • seq1 first protein sequence text
  • seq2 second protein sequence text
  • open score of the first position of a gap (<= 0)
  • extend score of each further gap position (<= 0)

Returns

  • score optimal local alignment score (>= 0)

Applies when

  • standard amino acids
  • open, extend <= 0

Example

m.ask("Local protein alignment score: seq1 = HEAGAWGHEE, seq2 = PAWHEAE, open = -8, extend = -8")
→ score = 20
Semi-global (end-gap-free) alignment scorebio_semiglobal_alignment_score

The optimal alignment score when gaps at either end of either sequence are free (fitting a read inside a longer sequence, overlaps), with linear internal gaps.

S = \max\big(\max_j S_{n,j},\ \max_i S_{i,m}\big),\ S_{i,0}=S_{0,j}=0

Inputs

  • seq1 first sequence text
  • seq2 second sequence text
  • match score of a match
  • mismatch score of a mismatch
  • gap score of each internal gap position (<= 0)

Returns

  • score optimal semi-global alignment score

Applies when

  • gap <= 0
  • end gaps unscored

Example

m.ask("Semi-global alignment score: seq1 = TTTTACGTACGGGG, seq2 = ACGTAC, match = 1, mismatch = -1, gap = -1")
→ score = 6

Ecology 14

ACE species richness estimatorbio_ace

The abundance-based coverage estimator (ACE) of species richness, with a stated rare-species threshold (10 is the usual value).

S_{ace} = S_{abund} + \frac{S_{rare}}{C_{ace}} + \frac{F_1}{C_{ace}}\gamma^2

Inputs

  • counts number of individuals of each species vector
  • rare_threshold largest count of a rare species (usually 10) integer

Returns

  • ace estimated species richness

Applies when

  • whole counts
  • not every rare species a singleton

Example

m.ask("ACE richness estimator: counts = [1, 1, 2, 3, 5, 8, 20, 50], rare_threshold = 10")
→ ace = 9.7193
Berger-Parker and McIntosh indicesbio_dominance_indices

The Berger-Parker dominance (share of the most abundant species) and McIntosh's index of a sample.

d = \frac{n_{\max}}{N},\quad D = \frac{N - U}{N - \sqrt N}

Inputs

  • counts number of individuals of each species vector

Returns

  • berger_parker Berger-Parker dominance n_max/N
  • mcintosh McIntosh index (N - U)/(N - sqrt N), U = sqrt(sum n_i^2)

Applies when

  • whole counts
  • N >= 2

Example

m.ask("Berger-Parker and McIntosh indices: counts = [50, 30, 20]")
→ berger_parker = 0.5, mcintosh = 0.426176
Beta diversity between two samplesbio_beta_diversity

The Bray-Curtis dissimilarity (abundances) and the Jaccard and Sorensen dissimilarities (presence and absence) between two community samples.

BC = \frac{\sum|x_i - y_i|}{\sum (x_i + y_i)},\quad J = 1 - \frac{|A\cap B|}{|A\cup B|}

Inputs

  • x abundances of each species in the first sample vector
  • y abundances of the same species in the second sample vector

Returns

  • bray_curtis Bray-Curtis dissimilarity
  • jaccard Jaccard dissimilarity (1 - shared/union)
  • sorensen Sorensen dissimilarity (1 - 2 shared/(S_x + S_y))

Applies when

  • the same species order in both samples
  • each sample non-empty

Example

m.ask("Beta diversity: x = [6, 7, 4, 0], y = [10, 0, 6, 3]")
→ bray_curtis = 0.444444, jaccard = 0.5, sorensen = 0.333333
Brillouin diversity indexbio_brillouin_diversity

Brillouin's diversity index of a fully censused collection (natural logarithm).

H_B = \frac{\ln N! - \sum_i \ln n_i!}{N}

Inputs

  • counts number of individuals of each species vector

Returns

  • H_B Brillouin index (nats per individual)

Applies when

  • whole counts
  • N <= 20000

Example

m.ask("Brillouin diversity: counts = [5, 3, 2]")
→ H_B = 0.783201
Chao1 species richness estimatorbio_chao1

The Chao1 estimate of total species richness from abundance counts (bias-corrected or classic form), with the observed richness and the numbers of singletons and doubletons.

\hat S = S_{obs} + \frac{F_1(F_1-1)}{2(F_2+1)}

Inputs

  • counts number of individuals of each species vector
  • form bias_corrected or classic Chao1 choice

Returns

  • chao1 estimated species richness
  • s_obs observed number of species
  • singletons species seen once (F1)
  • doubletons species seen twice (F2)

Applies when

  • whole counts
  • the classic form needs F1 > 0 and F2 > 0, otherwise the bias-corrected form is used (as scikit-bio does)

Example

m.ask("Chao1: counts = [1, 1, 1, 2, 2, 5, 10], form = classic")
→ chao1 = 9.25, s_obs = 7, singletons = 3, doubletons = 2
Faith's phylogenetic diversitybio_faith_pd

Faith's phylogenetic diversity of a set of observed taxa: the total branch length of the rooted tree connecting them to the root.

PD = \sum_{b \in T(\text{taxa}) \cup R} \ell_b

Inputs

  • tree rooted tree in Newick format with branch lengths text
  • taxa observed taxa (leaf names separated by spaces) text

Returns

  • pd Faith's PD (sum of branch lengths)

Applies when

  • every branch has a length
  • taxa are leaves of the tree
  • rooted convention (path to the root included)

Example

m.ask("Faith's phylogenetic diversity: tree = ((A:1,B:2):3,(C:4,D:5):6);, taxa = A B")
→ pd = 6
Good's coverage of a samplebio_goods_coverage

Good's coverage estimator: the estimated fraction of the community's individuals belonging to species already seen in the sample.

C = 1 - \frac{F_1}{N}

Inputs

  • counts number of individuals of each species vector

Returns

  • coverage Good's coverage 1 - F1/N

Applies when

  • whole counts

Example

m.ask("Good's coverage: counts = [1, 1, 2, 6]")
→ coverage = 0.8
Margalef and Menhinick richness indicesbio_richness_indices

Margalef's richness index (S - 1)/ln N and Menhinick's richness index S/sqrt(N) of a sample.

D_{Mg} = \frac{S-1}{\ln N},\quad D_{Mn} = \frac{S}{\sqrt N}

Inputs

  • counts number of individuals of each species vector

Returns

  • margalef Margalef's index (S - 1)/ln N
  • menhinick Menhinick's index S/sqrt(N)

Applies when

  • whole counts
  • N >= 2

Example

m.ask("Richness indices: counts = [10, 20, 30, 40]")
→ margalef = 0.651442, menhinick = 0.4
Mark-recapture population estimate (Petersen MLE)bio_petersen_estimate

The maximum-likelihood population size from one mark-recapture experiment: M animals marked, C caught later, R of them marked (hypergeometric likelihood).

\hat N = \left\lfloor \frac{MC}{R} \right\rfloor

Inputs

  • M number marked and released integer
  • C number caught in the second sample integer
  • R number of marked animals recaptured integer

Returns

  • N_mle maximum-likelihood population size (largest maximiser)

Applies when

  • closed population
  • R >= 1, R <= min(M, C)
  • when MC/R is whole, N = MC/R and MC/R - 1 tie; the larger is given

Example

m.ask("Petersen estimate: M = 100, C = 80, R = 12")
→ N_mle = 666
Rarefied species richnessbio_rarefaction

The expected number of species in a random subsample of n individuals drawn without replacement (Hurlbert-Sanders rarefaction).

E[S_n] = \sum_i \left[1 - \binom{N-N_i}{n}\Big/\binom{N}{n}\right]

Inputs

  • counts number of individuals of each species vector
  • n subsample size (individuals) integer

Returns

  • expected_species expected number of species in the subsample

Applies when

  • whole counts
  • 1 <= n <= N

Example

m.ask("Rarefaction: counts = [2, 1, 1], n = 2")
→ expected_species = 1.83333
Schumacher-Eschmeyer multiple-census estimatebio_schumacher_eschmeyer

The Schumacher-Eschmeyer estimate of a closed population's size from repeated mark-recapture samples.

\hat N = \frac{\sum_t C_tM_t^2}{\sum_t R_tM_t}

Inputs

  • C number caught on each occasion vector
  • R number of those already marked vector
  • M number of marked animals at large before each occasion vector

Returns

  • N estimated population size

Applies when

  • closed population
  • whole counts, R <= C
  • at least one recapture of a marked animal

Example

m.ask("Schumacher-Eschmeyer estimate: C = [10, 10, 10], R = [0, 2, 3], M = [0, 10, 18]")
→ N = 57.2973
Shannon diversity indexbio_shannon_diversity

The Shannon diversity index H' of a community in the stated logarithm base, Pielou's evenness J' and the effective number of species exp(H').

H' = -\sum_i p_i \log_b p_i,\quad J' = \frac{H'}{\log_b S}

Inputs

  • counts number of individuals of each species vector
  • base logarithm base: e (nats), 2 (bits) or 10 choice

Returns

  • H Shannon index H' in the stated base
  • evenness Pielou's evenness J' = H'/ln S
  • effective_number effective number of species exp(H') (Hill number of order 1)

Applies when

  • whole non-negative counts
  • zero counts are not species of the sample

Example

m.ask("Shannon diversity: counts = [10, 10, 10, 10], base = e")
→ H = 1.38629, evenness = 1, effective_number = 4
Simpson diversity indicesbio_simpson_diversity

Simpson's dominance D, Simpson's diversity 1 - D and the inverse Simpson index 1/D, with the stated estimator (infinite population: sum p^2; finite sample: sum n(n-1)/(N(N-1))).

D = \sum_i p_i^2 \quad\text{or}\quad D = \frac{\sum n_i(n_i-1)}{N(N-1)}

Inputs

  • counts number of individuals of each species vector
  • estimator infinite (sum p^2) or finite-sample correction choice

Returns

  • D Simpson's dominance D
  • simpson Simpson's diversity 1 - D
  • inverse inverse Simpson 1/D

Applies when

  • whole non-negative counts
  • estimator stated

Example

m.ask("Simpson diversity: counts = [10, 10, 10, 10], estimator = infinite")
→ D = 0.25, simpson = 0.75, inverse = 4
Species-area relationship fitbio_species_area

The constants c and z of the Arrhenius species-area relationship S = c A^z fitted by least squares on log S against log A.

\ln S = \ln c + z\ln A

Inputs

  • A areas (any one unit) vector
  • S species counts vector

Returns

  • c constant c (species in a unit area)
  • z exponent z
  • r2 r^2 of the log-log fit

Applies when

  • positive areas and counts
  • c refers to the area unit used

Example

m.ask("Species-area relationship: A = [1, 10, 100, 1000], S = [10, 20, 40, 80]")
→ c = 10, z = 0.30103, r2 = 1

Enzyme kinetics 9

Competitive inhibition global fitbio_competitive_inhibition_fit

Vmax, Km and the inhibition constant Ki of a competitive inhibitor fitted globally to rates measured at several substrate and inhibitor concentrations (nonlinear least squares, unweighted).

v = \frac{V_{\max}S}{K_m\left(1 + \frac{[I]}{K_i}\right) + S}

Inputs

  • S substrate concentrations (one per measurement) vector
  • I inhibitor concentrations (one per measurement, 0 for none) vector
  • v measured rates vector

Returns

  • Vmax maximum rate
  • Km Michaelis constant (unit of S)
  • Ki inhibition constant (unit of I)

Applies when

  • rates without inhibitor at 3 or more S
  • rates with inhibitor
  • convergence

Example

m.ask("Competitive inhibition fit: S = [1, 2, 4, 8, 1, 2, 4, 8], I = [0, 0, 0, 0, 2, 2, 2, 2], v = [5, 6.66666666667, 8, 8.88888888889, 2.5, 4, 5.71428571429, 7.27272727273]")
→ Vmax = 10, Km = 1, Ki = 1
Eadie-Hofstee fit of Michaelis-Menten databio_eadie_hofstee

Vmax and Km from a least-squares line through the Eadie-Hofstee plot of v against v/S.

v = V_{\max} - K_m\frac{v}{S}

Inputs

  • S substrate concentrations (any one unit) vector
  • v initial rates (any one unit) vector

Returns

  • Vmax maximum rate (unit of v)
  • Km Michaelis constant (unit of S)
  • r2 coefficient of determination of the linear fit

Applies when

  • positive S and v
  • negative slope, positive intercept

Example

m.ask("Eadie-Hofstee fit: S = [1, 2, 4, 8], v = [5, 6.6666666667, 8, 8.8888888889]")
→ Vmax = 10, Km = 1, r2 = 1
Hanes-Woolf fit of Michaelis-Menten databio_hanes_woolf

Vmax and Km from a least-squares line through the Hanes-Woolf plot of S/v against S.

\frac Sv = \frac{1}{V_{\max}}S + \frac{K_m}{V_{\max}}

Inputs

  • S substrate concentrations (any one unit) vector
  • v initial rates (any one unit) vector

Returns

  • Vmax maximum rate (unit of v)
  • Km Michaelis constant (unit of S)
  • r2 coefficient of determination of the linear fit

Applies when

  • positive S and v
  • positive slope and intercept

Example

m.ask("Hanes-Woolf fit: S = [1, 2, 4, 8], v = [5, 6.6666666667, 8, 8.8888888889]")
→ Vmax = 10, Km = 1, r2 = 1
Hill coefficient from a Hill plotbio_hill_plot

The Hill coefficient n and half-saturation constant K from a least-squares line through the Hill plot of log10(Y/(1-Y)) against log10 S (Y = fractional saturation).

\log\frac{Y}{1-Y} = n\log S - n\log K

Inputs

  • S ligand or substrate concentrations vector
  • Y fractional saturations (0 < Y < 1) vector

Returns

  • n Hill coefficient
  • K half-saturation concentration (unit of S)
  • r2 coefficient of determination of the line

Applies when

  • 0 < Y < 1
  • positive S
  • rising Hill plot

Example

m.ask("Hill plot: S = [1, 2, 4, 8], Y = [0.0588235294118, 0.2, 0.5, 0.8]")
→ n = 2, K = 4, r2 = 1
Hill equation nonlinear least-squares fitbio_hill_fit

Vmax, the half-saturation constant K and the Hill coefficient n fitted to rate or binding data by nonlinear least squares (unweighted).

v = \frac{V_{\max}S^n}{K^n + S^n}

Inputs

  • S concentrations (any one unit) vector
  • v rates or responses (any one unit) vector

Returns

  • Vmax maximum rate
  • K half-saturation concentration (unit of S)
  • n Hill coefficient

Applies when

  • at least 4 distinct positive concentrations
  • positive responses
  • convergence

Example

m.ask("Hill fit: S = [1, 2, 4, 8, 16], v = [0.588235294118, 2, 5, 8, 9.41176470588]")
→ Vmax = 10, K = 4, n = 2
Lineweaver-Burk fit of Michaelis-Menten databio_lineweaver_burk

Vmax and Km from a least-squares line through the double-reciprocal (Lineweaver-Burk) plot of 1/v against 1/S.

\frac1v = \frac{K_m}{V_{\max}}\frac1S + \frac1{V_{\max}}

Inputs

  • S substrate concentrations (any one unit) vector
  • v initial rates (any one unit) vector

Returns

  • Vmax maximum rate (unit of v)
  • Km Michaelis constant (unit of S)
  • r2 coefficient of determination of the linear fit

Applies when

  • positive S and v
  • positive slope and intercept

Example

m.ask("Lineweaver-Burk fit: S = [1, 2, 4, 8], v = [5, 6.6666666667, 8, 8.8888888889]")
→ Vmax = 10, Km = 1, r2 = 1
Michaelis-Menten nonlinear least-squares fitbio_michaelis_menten_fit

Vmax and Km of the Michaelis-Menten equation fitted to rate data by nonlinear least squares (unweighted).

\min_{V_{\max},K_m} \sum_i \Big(v_i - \frac{V_{\max}S_i}{K_m+S_i}\Big)^2

Inputs

  • S substrate concentrations (any one unit) vector
  • v initial rates (any one unit) vector

Returns

  • Vmax maximum rate (unit of v)
  • Km Michaelis constant (unit of S)

Applies when

  • at least 3 distinct positive S
  • positive v
  • an interior least-squares optimum

Example

m.ask("Michaelis-Menten fit: S = [1, 2, 4, 8], v = [5, 6.6666666667, 8, 8.8888888889]")
→ Vmax = 10, Km = 1
Substrate remaining in a Michaelis-Menten reactionbio_michaelis_menten_progress

The substrate and product concentrations after a time t of an irreversible Michaelis-Menten reaction (integrated rate law; constant enzyme, no product inhibition).

K_m\ln\frac{S_0}{S} + (S_0 - S) = V_{\max}t

Inputs

  • S0 initial substrate concentration
  • Vmax maximum rate (concentration per time)
  • Km Michaelis constant (concentration)
  • t elapsed time (time unit of Vmax)

Returns

  • S substrate concentration at t
  • P product concentration at t

Applies when

  • positive S0, Vmax, Km
  • t >= 0
  • consistent units

Example

m.ask("Michaelis-Menten progress curve: S0 = 10, Vmax = 1, Km = 2, t = 5")
→ S = 6.01624, P = 3.98376
Time to reach a conversion in a Michaelis-Menten reactionbio_michaelis_menten_time

The time an irreversible Michaelis-Menten reaction needs to convert a stated fraction of its substrate.

t = \frac{K_m\ln\frac{1}{1-X} + S_0X}{V_{\max}}

Inputs

  • S0 initial substrate concentration
  • Vmax maximum rate (concentration per time)
  • Km Michaelis constant (concentration)
  • X fraction of substrate converted (0 to 1, or a percentage)

Returns

  • t time (time unit of Vmax)

Applies when

  • 0 < X < 1
  • positive S0, Vmax, Km

Example

m.ask("Michaelis-Menten time to conversion: S0 = 10, Vmax = 1, Km = 2, X = 0.5")
→ t = 6.38629

Genetics 5

Inbreeding coefficient from a pedigreebio_pedigree_inbreeding

Wright's inbreeding coefficient F of an individual from its pedigree (founders unrelated and not inbred).

F_X = \sum_{\text{paths}} \left(\tfrac12\right)^{n_1+n_2+1}(1 + F_A)

Inputs

  • pedigree parent-child pairs, e.g. [P-S, Q-S, P-D, Q-D, S-X, D-X] edges
  • individual name of the individual text

Returns

  • F inbreeding coefficient

Applies when

  • every non-founder has exactly two parents listed
  • no cycles
  • founders unrelated, F = 0

Example

m.ask("Pedigree inbreeding coefficient: pedigree = [P-S, Q-S, P-D, Q-D, S-X, D-X], individual = X")
→ F = 0.25
Map distance from a recombination fractionbio_map_distance

The genetic map distance (cM) corresponding to a recombination fraction, by the Haldane or Kosambi map function.

d_H = -\tfrac12\ln(1-2r),\quad d_K = \tfrac14\ln\frac{1+2r}{1-2r}

Inputs

  • r recombination fraction (0 to 0.5)
  • map map function: haldane (no interference) or kosambi choice

Returns

  • d_cM map distance in centimorgans

Applies when

  • 0 <= r < 0.5
  • map function stated

Example

m.ask("Map distance: r = 0.2, map = haldane")
→ d_cM = 25.5413
Phenotype ratio of a cross (complete dominance)bio_cross_phenotype_ratio

The offspring phenotype ratio of a cross with complete dominance, the probabilities of the all-dominant and all-recessive phenotypes and the numbers of genotypes and phenotypes.

(\tfrac34 D + \tfrac14 r)^n \Rightarrow 9:3:3:1 \text{ for two loci}

Inputs

  • parent1 genotype of the first parent, letter pairs (e.g. AaBb) text
  • parent2 genotype of the second parent text

Returns

  • p_all_dominant probability of showing every dominant trait
  • p_all_recessive probability of showing every recessive trait
  • n_genotypes number of distinct offspring genotypes
  • n_phenotypes number of distinct offspring phenotypes
  • ratio phenotype ratio, largest class first (e.g. 9:3:3:1)

Applies when

  • complete dominance at every locus
  • independent assortment

Example

m.ask("Cross phenotype ratio: parent1 = AaBb, parent2 = AaBb")
→ p_all_dominant = 0.5625, p_all_recessive = 0.0625, n_genotypes = 9, n_phenotypes = 4, ratio = 9:3:3:1
Probability of an offspring genotype in a crossbio_cross_genotype_probability

The probability that an offspring of two parents has a stated genotype (monohybrid, dihybrid or more loci; independent assortment).

P = \prod_{\ell} P_\ell(g_\ell)

Inputs

  • parent1 genotype of the first parent, letter pairs (e.g. AaBb) text
  • parent2 genotype of the second parent text
  • offspring offspring genotype asked about text

Returns

  • probability probability of the offspring genotype
  • fraction the same as a fraction

Applies when

  • the same loci in the same order
  • independent assortment
  • at most 6 loci

Example

m.ask("Cross genotype probability: parent1 = Aa, parent2 = Aa, offspring = Aa")
→ probability = 0.5, fraction = 1/2
Recombination fraction from a map distancebio_recombination_fraction

The recombination fraction between two loci a stated map distance apart, by the Haldane or Kosambi map function.

r_H = \tfrac12(1 - e^{-2d}),\quad r_K = \tfrac12\tanh 2d

Inputs

  • d_cM map distance in centimorgans
  • map map function: haldane (no interference) or kosambi choice

Returns

  • r recombination fraction

Applies when

  • d >= 0
  • map function stated

Example

m.ask("Recombination fraction: d_cM = 50, map = haldane")
→ r = 0.31606

Microbial growth 1

Chemostat steady state (Monod kinetics)bio_chemostat_steady_state

The steady-state substrate and biomass concentrations of a chemostat with Monod growth kinetics.

\bar S = \frac{K_sD}{\mu_{\max} - D},\quad \bar X = Y(S_0 - \bar S)

Inputs

  • mu_max maximum specific growth rate (1/time)
  • Ks half-saturation constant (concentration)
  • Y biomass yield (biomass per substrate)
  • D dilution rate (1/time, same unit as mu_max)
  • S0 feed substrate concentration

Returns

  • S steady-state substrate concentration
  • X steady-state biomass concentration

Applies when

  • D < mu_max
  • no washout (S < S0)
  • consistent units

Example

m.ask("Chemostat steady state: mu_max = 1, Ks = 1, Y = 0.5, D = 0.5, S0 = 10")
→ S = 1, X = 4.5

Phylogenetics 7

Jukes-Cantor distancebio_jukes_cantor_distance

The Jukes-Cantor (JC69) evolutionary distance between two aligned DNA sequences: the expected number of substitutions per site, corrected for multiple hits.

d = -\tfrac34 \ln\!\left(1 - \tfrac43 p\right)

Inputs

  • seq1 first aligned DNA sequence text
  • seq2 second aligned DNA sequence text

Returns

  • p proportion of differing sites
  • d Jukes-Cantor distance (substitutions per site)

Applies when

  • equal lengths, no gaps
  • p < 0.75

Example

m.ask("Jukes-Cantor distance: seq1 = AAAAAAAAAA, seq2 = AAAAAAAACC")
→ p = 0.2, d = 0.232616
Kimura two-parameter distancebio_kimura_distance

The Kimura two-parameter (K80) distance between two aligned DNA sequences, separating transitions (A<->G, C<->T) from transversions.

d = -\tfrac12\ln(1-2P-Q) - \tfrac14\ln(1-2Q)

Inputs

  • seq1 first aligned DNA sequence text
  • seq2 second aligned DNA sequence text

Returns

  • d K80 distance (substitutions per site)

Applies when

  • equal lengths, no gaps
  • 1 - 2P - Q > 0 and 1 - 2Q > 0

Example

m.ask("Kimura distance: seq1 = AAAAAAAAAA, seq2 = AAAAAAAGGC")
→ d = 0.402359
Neighbour-joining branch lengthsbio_neighbor_joining

The total tree length and the terminal branch lengths of the neighbour-joining tree of a distance matrix.

Q_{ij} = (r-2)d_{ij} - R_i - R_j,\quad \ell_i = \tfrac12 d_{ij} + \frac{R_i - R_j}{2(r-2)}

Inputs

  • D symmetric distance matrix, zero diagonal (at least 3 taxa) matrix

Returns

  • total_length sum of all branch lengths
  • branch terminal branch length of each taxon, in input order

Applies when

  • at least 3 taxa
  • no ties in the joining criterion
  • negative branch lengths kept as computed

Example

m.ask("Neighbour joining: D = [[0, 5, 9, 9, 8], [5, 0, 10, 10, 9], [9, 10, 0, 8, 7], [9, 10, 8, 0, 3], [8, 9, 7, 3, 0]]")
→ total_length = 17, branch = [2.0, 3.0, 4.0, 2.0, 1.0]
Number of possible phylogenetic treesbio_tree_count

The number of distinct labelled bifurcating trees for n taxa, rooted or unrooted.

N_{\text{rooted}} = (2n-3)!!,\quad N_{\text{unrooted}} = (2n-5)!!

Inputs

  • n number of taxa integer
  • rooted rooted or unrooted trees choice

Returns

  • count number of distinct bifurcating trees

Applies when

  • n >= 2 (rooted) or n >= 3 (unrooted)
  • n <= 100

Example

m.ask("Number of trees: n = 5, rooted = unrooted")
→ count = 15
Parsimony score of a tree (Fitch)bio_fitch_parsimony

The minimum number of character changes (small parsimony score) needed on a given rooted bifurcating tree to explain aligned sequences at its leaves.

c_v(a) = \sum_{w\in\mathrm{children}(v)} \min_b \big(c_w(b) + [a\ne b]\big)

Inputs

  • tree rooted bifurcating tree in Newick format text
  • states aligned sequence of each leaf, written name:SEQUENCE separated by spaces text

Returns

  • score parsimony score (number of changes)

Applies when

  • strictly bifurcating rooted tree
  • one aligned sequence per leaf
  • unit cost per change

Example

m.ask("Parsimony score: tree = ((A,B),(C,D));, states = A:AACG B:AATG C:GACT D:GGCT")
→ score = 4
Robinson-Foulds distance between treesbio_robinson_foulds

The Robinson-Foulds (symmetric-difference) distance between two trees on the same taxa, comparing their bipartitions (trees treated as unrooted), and the distance as a proportion.

\mathrm{RF} = |S_1 \setminus S_2| + |S_2 \setminus S_1|

Inputs

  • tree1 first tree in Newick format text
  • tree2 second tree in Newick format text

Returns

  • rf number of bipartitions found in only one tree
  • rf_normalized RF divided by the total number of non-trivial bipartitions of both trees

Applies when

  • the same taxa
  • at least 4 taxa
  • trees compared unrooted; branch lengths ignored

Example

m.ask("Robinson-Foulds distance: tree1 = ((A,B),(C,D),(E,F));, tree2 = ((A,C),(B,D),(E,F));")
→ rf = 4, rf_normalized = 0.666667
UPGMA tree heightsbio_upgma

The node heights of the UPGMA (average-linkage) tree of a distance matrix: the root height and every merge height (half the distance between the merged clusters).

d_{(ij),k} = \frac{n_i d_{ik} + n_j d_{jk}}{n_i + n_j},\quad h = d_{ij}/2

Inputs

  • D symmetric distance matrix, zero diagonal matrix

Returns

  • root_height height of the root
  • heights all node heights, ascending

Applies when

  • symmetric, zero diagonal, positive distances
  • no ties in a merge step

Example

m.ask("UPGMA: D = [[0, 2, 4, 6], [2, 0, 4, 6], [4, 4, 0, 6], [6, 6, 6, 0]]")
→ root_height = 3, heights = [1.0, 2.0, 3.0]

Population biology 2

Leslie matrix growth rate and stable age distributionbio_leslie_growth_rate

The asymptotic growth rate (dominant eigenvalue lambda and r = ln lambda), the net reproductive rate R0 and the stable age distribution of a Leslie model.

\sum_{i} F_i\,l_i\,\lambda^{-i} = 1,\quad R_0 = \sum_i F_i l_i

Inputs

  • F fecundity of each age class vector
  • S survival from each age class to the next (one fewer than F) vector

Returns

  • lambda1 dominant eigenvalue (growth factor per step)
  • r intrinsic rate ln(lambda)
  • R0 net reproductive rate (expected offspring per newborn)
  • stable stable age distribution (fractions summing to 1)

Applies when

  • 0 < S_i <= 1
  • F_i >= 0, at least one positive

Example

m.ask("Leslie growth rate: F = [0, 2], S = [0.5]")
→ lambda1 = 1, r = 0, R0 = 1, stable = [0.666666666667, 0.333333333333]
Leslie matrix population projectionbio_leslie_projection

The age-class numbers and total population after t time steps of an age-structured (Leslie) model.

\mathbf n_{t+1} = L\,\mathbf n_t,\quad L = \begin{pmatrix}F_1 & F_2 & \cdots\\ S_1 & 0 & \\ & \ddots & \end{pmatrix}

Inputs

  • F fecundity of each age class vector
  • S survival from each age class to the next (one fewer than F) vector
  • n0 initial number in each age class vector
  • t number of time steps integer

Returns

  • n_t number in each age class after t steps
  • total total population after t steps

Applies when

  • 0 < S_i <= 1
  • F_i >= 0, at least one positive
  • t <= 500

Example

m.ask("Leslie projection: F = [0, 1.5, 1], S = [0.5, 0.8], n0 = [100, 50, 20], t = 1")
→ n_t = [95.0, 50.0, 40.0], total = 185

Population genetics 16

Allele frequency under haploid (genic) selectionbio_haploid_selection

The frequency of allele A after t generations of haploid selection (relative fitness 1 + s against 1).

p' = \frac{p(1+s)}{1+sp}

Inputs

  • p0 initial frequency of A
  • s selection coefficient (fitness of A = 1 + s)
  • t number of generations integer

Returns

  • p_t frequency of A after t generations

Applies when

  • 0 < p0 < 1
  • s > -1
  • discrete generations

Example

m.ask("Haploid selection: p0 = 0.5, s = 1, t = 1")
→ p_t = 0.666667
Decline of a recessive lethal allelebio_recessive_lethal

The frequency of a recessive lethal allele after t generations of selection (aa never reproduce).

q' = \frac{q}{1+q}

Inputs

  • q0 initial frequency of the lethal allele
  • t number of generations integer

Returns

  • q_t frequency after t generations

Applies when

  • 0 < q0 <= 1
  • random mating, aa fitness 0

Example

m.ask("Recessive lethal allele frequency: q0 = 0.5, t = 1")
→ q_t = 0.333333
Effective population size with unequal sex ratiobio_ne_sex_ratio

The effective population size of a population with N_m breeding males and N_f breeding females.

N_e = \frac{4N_mN_f}{N_m+N_f}

Inputs

  • N_m number of breeding males integer
  • N_f number of breeding females integer

Returns

  • Ne effective population size
  • Ne_over_N Ne divided by the census N_m + N_f

Applies when

  • random mating within the breeding population
  • Wright-Fisher reproduction

Example

m.ask("Effective population size with unequal sex ratio: N_m = 10, N_f = 90")
→ Ne = 36, Ne_over_N = 0.36
Effective size of a fluctuating populationbio_ne_fluctuating_size

The effective population size over generations of changing size (harmonic mean) and the fraction of heterozygosity retained over those generations.

\frac{1}{N_e} = \frac{1}{t}\sum_{i=1}^t \frac{1}{N_i},\quad \frac{H_t}{H_0} = \prod_i \Big(1-\frac{1}{2N_i}\Big)

Inputs

  • sizes numbers of diploid individuals in successive generations vector

Returns

  • Ne effective size (harmonic mean of the sizes)
  • retained heterozygosity retained, product of (1 - 1/(2N_i))

Applies when

  • whole positive sizes
  • Wright-Fisher reproduction each generation

Example

m.ask("Effective size of a fluctuating population: sizes = [1000, 10, 1000]")
→ Ne = 29.4118, retained = 0.94905
Equilibrium under heterozygote advantagebio_heterozygote_advantage

The stable equilibrium frequency of allele A when the heterozygote is fittest (overdominance).

\hat p = \frac{w_{Aa} - w_{aa}}{2w_{Aa} - w_{AA} - w_{aa}} = \frac{t}{s+t}

Inputs

  • w_AA relative fitness of AA
  • w_Aa relative fitness of Aa
  • w_aa relative fitness of aa

Returns

  • p_eq equilibrium frequency of A

Applies when

  • w_Aa > w_AA and w_Aa > w_aa
  • fitnesses positive

Example

m.ask("Heterozygote advantage equilibrium: w_AA = 0.8, w_Aa = 1, w_aa = 0.6")
→ p_eq = 0.666667
Expected coalescence timesbio_coalescent_times

The expected time to the most recent common ancestor and the expected total branch length of the genealogy of n gene copies from a diploid population of effective size Ne (in generations).

E[T_{MRCA}] = 4N_e\left(1 - \frac1n\right),\quad E[L] = 4N_e\sum_{i=1}^{n-1}\frac1i

Inputs

  • n number of sampled gene copies integer
  • Ne diploid effective population size

Returns

  • t_mrca expected TMRCA in generations
  • total_length expected total branch length in generations

Applies when

  • neutral Kingman coalescent
  • diploid: a pair coalesces at rate 1/(2Ne) per generation

Example

m.ask("Coalescent times: n = 2, Ne = 1000")
→ t_mrca = 2000, total_length = 4000
Fixation index FST from subpopulation allele frequenciesbio_fst

Mean within-subpopulation heterozygosity HS, total heterozygosity HT and FST = (HT - HS)/HT for a biallelic locus in equally weighted subpopulations.

F_{ST} = \frac{H_T - H_S}{H_T}

Inputs

  • p frequency of one allele in each subpopulation vector

Returns

  • HS mean expected heterozygosity within subpopulations
  • HT expected heterozygosity of the pooled population
  • FST fixation index (HT - HS)/HT

Applies when

  • equal subpopulation weights
  • biallelic locus
  • 0 < mean p < 1

Example

m.ask("FST: p = [0.2, 0.8]")
→ HS = 0.32, HT = 0.5, FST = 0.36
Fixation probability in the Moran processbio_moran_fixation

The probability that a mutant with relative fitness r, starting from i copies in a Moran population of size N, eventually takes over the population.

\rho_i = \frac{1 - r^{-i}}{1 - r^{-N}}

Inputs

  • N population size integer
  • i initial number of mutants integer
  • r relative fitness of the mutant

Returns

  • rho fixation probability

Applies when

  • 0 < i < N
  • r > 0

Example

m.ask("Moran fixation probability: N = 10, i = 1, r = 1")
→ rho = 0.1
Hardy-Weinberg chi-square testbio_hardy_weinberg_test

Allele frequencies, Hardy-Weinberg expected genotype counts, the chi-square test of equilibrium (1 degree of freedom), observed and expected heterozygosity and the inbreeding coefficient F.

\chi^2 = \sum \frac{(O-E)^2}{E},\quad E = (Np^2,\ 2Npq,\ Nq^2)

Inputs

  • n_AA number of AA individuals integer
  • n_Aa number of Aa individuals integer
  • n_aa number of aa individuals integer

Returns

  • p frequency of allele A
  • q frequency of allele a
  • exp_AA expected AA count (N p^2)
  • exp_Aa expected Aa count (2 N p q)
  • exp_aa expected aa count (N q^2)
  • chi2 chi-square statistic
  • p_value p-value (chi-square, 1 degree of freedom)
  • Ho observed heterozygosity
  • He expected heterozygosity 2pq
  • F inbreeding coefficient 1 - Ho/He

Applies when

  • both alleles present
  • biallelic locus
  • no continuity correction

Example

m.ask("Hardy-Weinberg test: n_AA = 298, n_Aa = 489, n_aa = 213")
→ p = 0.5425, q = 0.4575, exp_AA = 294.306, exp_Aa = 496.387, exp_aa = 209.306, chi2 = 0.22149, p_value = 0.637907, Ho = 0.489, He = 0.496387, F = 0.0148825
Hardy-Weinberg exact testbio_hardy_weinberg_exact_test

The exact (Wigginton) test of Hardy-Weinberg equilibrium for a biallelic locus: the two-sided p-value and the probability of the observed number of heterozygotes given the allele counts.

P(n_{AB}\mid n_A) = \frac{N!}{n_{AA}!\,n_{AB}!\,n_{BB}!}\,\frac{2^{n_{AB}}\,n_A!\,n_B!}{(2N)!}

Inputs

  • n_AA number of AA individuals integer
  • n_Aa number of Aa individuals integer
  • n_aa number of aa individuals integer

Returns

  • p_value exact two-sided p-value (sum of probabilities not above the observed one)
  • p_observed probability of the observed heterozygote count

Applies when

  • both alleles present
  • N <= 1000

Example

m.ask("Hardy-Weinberg exact test: n_AA = 2, n_Aa = 0, n_aa = 2")
→ p_value = 0.0857143, p_observed = 0.0857143
Linkage disequilibrium D, D' and r^2bio_linkage_disequilibrium

The linkage disequilibrium between two biallelic loci from haplotype counts: D, Lewontin's D' and r^2.

D = p_{AB} - p_Ap_B,\quad r^2 = \frac{D^2}{p_Aq_Ap_Bq_B},\quad D' = \frac{D}{D_{\max}}

Inputs

  • n_AB number of AB haplotypes integer
  • n_Ab number of Ab haplotypes integer
  • n_aB number of aB haplotypes integer
  • n_ab number of ab haplotypes integer

Returns

  • D disequilibrium D = pAB - pA pB
  • D_prime Lewontin's D' = D / Dmax (signed)
  • r2 squared correlation r^2

Applies when

  • both loci polymorphic
  • phased haplotype counts

Example

m.ask("Linkage disequilibrium: n_AB = 40, n_Ab = 10, n_aB = 10, n_ab = 40")
→ D = 0.15, D_prime = 0.6, r2 = 0.36
Loss of heterozygosity by genetic driftbio_drift_heterozygosity

The expected heterozygosity after t generations of genetic drift in a Wright-Fisher population of N diploids, starting from i copies of an allele.

H_t = H_0\left(1 - \frac{1}{2N}\right)^t

Inputs

  • N number of diploid individuals integer
  • i initial copies of allele A (of 2N) integer
  • t number of generations integer

Returns

  • H0 initial heterozygosity 2pq
  • H_t expected heterozygosity after t generations
  • retained fraction of heterozygosity retained, (1 - 1/(2N))^t

Applies when

  • 0 < i < 2N
  • constant N, random mating, no mutation or selection

Example

m.ask("Drift heterozygosity: N = 10, i = 10, t = 1")
→ H0 = 0.5, H_t = 0.475, retained = 0.95
Mutation-selection balancebio_mutation_selection_balance

The equilibrium frequency of a deleterious allele maintained by recurrent mutation against selection (fitness 1, 1 - hs, 1 - s), from the exact recursion.

\hat q \approx \sqrt{\mu/s}\ (h=0),\quad \hat q \approx \frac{\mu}{hs}\ (h>0)

Inputs

  • mu mutation rate A -> a per generation
  • s selection coefficient against aa
  • h dominance coefficient (0 recessive, 0.5 additive)

Returns

  • q_eq equilibrium frequency of the deleterious allele

Applies when

  • 0 < mu <= 0.01
  • 0.01 <= s <= 1
  • 0 <= h <= 1
  • selection then mutation, no back mutation

Example

m.ask("Mutation-selection balance: mu = 0.0001, s = 1, h = 0")
→ q_eq = 0.01
Nucleotide diversitybio_nucleotide_diversity

The average number of pairwise differences k and the nucleotide diversity pi (per site) of a set of aligned DNA sequences.

\pi = \frac{1}{L}\binom{n}{2}^{-1}\sum_{i<j} d_{ij}

Inputs

  • seqs aligned DNA sequences separated by spaces text

Returns

  • k mean number of pairwise differences
  • pi nucleotide diversity per site

Applies when

  • at least 2 aligned DNA sequences of equal length, no gaps

Example

m.ask("Nucleotide diversity: seqs = AAAA AAAT AATT")
→ k = 1.33333, pi = 0.333333
Tajima's Dbio_tajima_d

Tajima's D neutrality statistic of aligned DNA sequences (the scaled difference between pi and Watterson's theta).

D = \frac{\hat\theta_\pi - \hat\theta_W}{\sqrt{e_1S + e_2S(S-1)}}

Inputs

  • seqs aligned DNA sequences separated by spaces (at least 4) text

Returns

  • D Tajima's D
  • k mean number of pairwise differences

Applies when

  • at least 4 aligned DNA sequences
  • at least one segregating site

Example

m.ask("Tajima's D: seqs = AAAAAA AAAAAT AAAATT AAATTT")
→ D = 0.167656, k = 1.66667
Watterson's estimator of thetabio_watterson_theta

The number of segregating sites S and Watterson's estimator of the population mutation rate theta, per sequence and per site.

\hat\theta_W = \frac{S}{a_n},\quad a_n = \sum_{i=1}^{n-1}\frac1i

Inputs

  • seqs aligned DNA sequences separated by spaces text

Returns

  • S number of segregating sites
  • theta Watterson's theta per sequence (S / a_n)
  • theta_site Watterson's theta per site

Applies when

  • at least 2 aligned DNA sequences of equal length, no gaps

Example

m.ask("Watterson theta: seqs = AAAA AAAT AATT")
→ S = 2, theta = 1.33333, theta_site = 0.333333

Sequences 21

Amino-acid composition of a proteinbio_amino_acid_composition

The percentage of each of the 20 standard amino acids in a protein, its most common residue (alphabetically first among ties) and its length.

\%a = 100\,\frac{n_a}{n}

Inputs

  • seq protein sequence text

Returns

  • percent percentage of each amino acid (one-letter code -> %)
  • most_common most common amino acid (alphabetically first among ties)
  • length number of residues

Applies when

  • standard amino acids only

Example

m.ask("Amino acid composition: seq = MAAAK")
→ percent = {'A': 60.0, 'C': 0.0, 'D': 0.0, 'E': 0.0, 'F': 0.0, 'G': 0.0, 'H': 0.0, 'I': 0.0, 'K': 20.0, 'L': 0.0, 'M': 20.0, 'N': 0.0, 'P': 0.0, 'Q': 0.0, 'R': 0.0, 'S': 0.0, 'T': 0.0, 'V': 0.0, 'W': 0.0, 'Y': 0.0}, most_common = A, length = 5
Aromaticity of a proteinbio_aromaticity

The aromaticity (relative frequency of Phe + Trp + Tyr, Lobry 1994) of a protein and its number of aromatic residues.

\mathrm{Ar} = \frac{n_F + n_W + n_Y}{n}

Inputs

  • seq protein sequence text

Returns

  • aromaticity fraction of F, W and Y residues
  • aromatic_count number of F, W and Y residues

Applies when

  • standard amino acids only

Example

m.ask("Aromaticity: seq = MFWYAK")
→ aromaticity = 0.5, aromatic_count = 3
Edit (Levenshtein) distance between sequencesbio_edit_distance

The minimum number of substitutions, insertions and deletions turning one sequence into the other (unit costs; an unaligned comparison, unlike the p-distance).

D_{i,j} = \min(D_{i-1,j}+1,\ D_{i,j-1}+1,\ D_{i-1,j-1}+[x_i\ne y_j])

Inputs

  • seq1 first sequence text
  • seq2 second sequence text

Returns

  • distance edit distance (unit costs)

Applies when

  • letters only

Example

m.ask("Edit distance: seq1 = KITTEN, seq2 = SITTING")
→ distance = 3
GC content of a nucleic acidbio_gc_content

The fraction and number of G and C bases in a DNA or RNA sequence.

\mathrm{GC} = \frac{n_G + n_C}{n}

Inputs

  • seq DNA or RNA sequence text

Returns

  • gc_fraction fraction of G + C
  • gc_count number of G and C bases

Applies when

  • unambiguous DNA or RNA letters

Example

m.ask("GC content: seq = ATGCGCGA")
→ gc_fraction = 0.625, gc_count = 5
Grand average of hydropathy (GRAVY)bio_gravy

The Kyte-Doolittle grand average of hydropathy of a protein (positive = hydrophobic).

\mathrm{GRAVY} = \frac{1}{n}\sum_i h(a_i)

Inputs

  • seq protein sequence text

Returns

  • gravy GRAVY score

Applies when

  • standard amino acids only

Example

m.ask("GRAVY: seq = MKTLLIL")
→ gravy = 1.88571
Isoelectric point of a proteinbio_isoelectric_point

The isoelectric point (pH of zero net charge) of a protein, with its net charge at pH 7 (Bjellqvist pK set).

Z(\mathrm{pI}) = 0

Inputs

  • seq protein sequence text

Returns

  • pI isoelectric point
  • charge_at_7 net charge at pH 7

Applies when

  • standard amino acids only

Example

m.ask("Isoelectric point: seq = INGAR")
→ pI = 9.75002, charge_at_7 = 0.760092
k-mer counts of a sequencebio_kmer_counts

Overlapping k-mer counts: the number of k-mers, of distinct k-mers, the highest count and the most frequent k-mer (alphabetically first among ties).

N_k = n - k + 1

Inputs

  • seq DNA or RNA sequence text
  • k k-mer length integer

Returns

  • total number of overlapping k-mers (n - k + 1)
  • distinct number of distinct k-mers
  • max_count count of the most frequent k-mer
  • most_frequent most frequent k-mer (alphabetically first among ties)

Applies when

  • 1 <= k <= sequence length

Example

m.ask("k-mer counts: seq = ATATAT, k = 2")
→ total = 5, distinct = 2, max_count = 3, most_frequent = AT
Longest open reading framebio_longest_orf

The longest open reading frame (ATG to the first in-frame stop, stop included) over all six frames of a DNA sequence, its protein length and the number of ORFs.

\ell = 3(j - i + 1)\ \text{for ATG at codon } i,\ \text{first stop at codon } j

Inputs

  • seq DNA sequence 5'->3' text

Returns

  • length_nt length of the longest ORF in nucleotides, stop codon included
  • protein_length amino acids encoded by the longest ORF (stop excluded)
  • orf_count number of ORFs (one per stop codon reached from an upstream in-frame ATG)

Applies when

  • DNA letters only
  • standard genetic code, start ATG, stops TAA TAG TGA

Example

m.ask("Longest ORF: seq = CCATGAAATTTGGGTAACC")
→ length_nt = 15, protein_length = 4, orf_count = 1
Melting temperature by nearest-neighbour thermodynamicsbio_tm_nearest_neighbor

The melting temperature of a DNA duplex (perfect complement) from nearest-neighbour thermodynamics (Allawi-SantaLucia 1997) with the SantaLucia 1998 sodium correction.

T_m = \frac{1000\,\Delta H}{\Delta S + 0.368(N-1)\ln[\mathrm{Na^+}] + R\ln k} - 273.15

Inputs

  • seq DNA sequence 5'->3' text
  • Na sodium concentration in mM
  • dnac1 concentration of the more concentrated strand in nM
  • dnac2 concentration of the less concentrated strand in nM

Returns

  • tm melting temperature in degC

Applies when

  • unambiguous DNA, length >= 2
  • Na > 0
  • dnac1 > dnac2/2

Example

m.ask("Nearest-neighbour melting temperature: seq = CGTTCCAAAGATGTGGGCATGAGCTTAC, Na = 50, dnac1 = 25, dnac2 = 25")
→ tm = 60.3209
Melting temperature by the Wallace rulebio_tm_wallace

The approximate melting temperature of a short DNA primer (14-20 nt) by the Wallace rule.

T_m = 2(n_A+n_T) + 4(n_G+n_C)\ ^\circ\mathrm{C}

Inputs

  • seq DNA primer sequence text

Returns

  • tm melting temperature in degC

Applies when

  • unambiguous DNA letters

Example

m.ask("Wallace melting temperature: seq = ACGTTGCAATGCCGTA")
→ tm = 48
Molecular mass of a proteinbio_protein_mass

The average molecular mass of a protein from its amino-acid sequence.

M = \sum_i m(a_i) - (n-1)\,m_{\mathrm{H_2O}}

Inputs

  • seq protein sequence (20 standard one-letter codes) text

Returns

  • mass molecular mass in g/mol (Da)

Applies when

  • standard amino acids only

Example

m.ask("Protein mass: seq = MAEGEITTFTALTEKFNLPPGNYKKPKLLYCSNGGHFLRILPDGTVDGTRDRSDQHIQLQLSAESVGEVYIKSTETGQYLAMDTSGLLYGSQTPSEECLFLERLEENHYNTYTSKKHAEKNWFVGLKKNGSCKRGPRTHYGQKAILFLPLPV")
→ mass = 17103.2
Molecular mass of DNA or RNAbio_nucleic_acid_mass

The average molecular mass of a single- or double-stranded linear DNA or RNA with a 5' phosphate.

M = \sum_i m(x_i) - (n-1)\,m_{\mathrm{H_2O}}

Inputs

  • seq DNA or RNA sequence text
  • molecule molecule type choice
  • strands single- or double-stranded choice

Returns

  • mass molecular mass in g/mol (Da)

Applies when

  • the sequence letters match the stated molecule

Example

m.ask("Nucleic acid mass: seq = AGC, molecule = DNA, strands = single")
→ mass = 949.61
Net charge of a protein at a pHbio_protein_net_charge

The net charge of a protein at a stated pH from its ionisable groups (Bjellqvist pK set).

Z = \sum_{\text{basic}} \frac{n_i}{1+10^{\,pH-pK_i}} - \sum_{\text{acidic}} \frac{n_j}{1+10^{\,pK_j-pH}}

Inputs

  • seq protein sequence text
  • pH pH of the solution (0 to 14)

Returns

  • charge net charge (elementary charges)

Applies when

  • standard amino acids only
  • 0 <= pH <= 14

Example

m.ask("Protein net charge: seq = INGAR, pH = 7")
→ charge = 0.760092
p-distance (Hamming) between aligned sequencesbio_hamming_distance

Mismatches, p-distance and identity of two aligned sequences of equal length (no indels): the proportion of sites that differ.

p = \frac{1}{n}\sum_i [x_i \ne y_i]

Inputs

  • seq1 first aligned sequence text
  • seq2 second aligned sequence (same length) text

Returns

  • mismatches number of differing sites
  • p_distance proportion of differing sites
  • identity proportion of identical sites

Applies when

  • equal lengths (aligned, no gaps)

Example

m.ask("p-distance: seq1 = GAGCCTACTAACGGGAT, seq2 = CATCGTAATGACGGCCT")
→ mismatches = 7, p_distance = 0.411765, identity = 0.588235
Protein extinction coefficient at 280 nmbio_protein_extinction

The molar extinction coefficient at 280 nm (cysteines reduced, and all cysteines as cystines) and the absorbance of a 1 g/L solution.

\varepsilon_{280} = 5500\,n_W + 1490\,n_Y + 125\,n_{\text{cystine}}

Inputs

  • seq protein sequence text

Returns

  • eps_reduced extinction coefficient, cysteines reduced (M^-1 cm^-1)
  • eps_cystines extinction coefficient, cysteines paired as cystines (M^-1 cm^-1)
  • abs_reduced absorbance of 1 g/L, 1 cm, cysteines reduced
  • abs_cystines absorbance of 1 g/L, 1 cm, cystines

Applies when

  • standard amino acids only

Example

m.ask("Protein extinction coefficient: seq = MAEGEITTFTALTEKFNLPPGNYKKPKLLYCSNGGHFLRILPDGTVDGTRDRSDQHIQLQLSAESVGEVYIKSTETGQYLAMDTSGLLYGSQTPSEECLFLERLEENHYNTYTSKKHAEKNWFVGLKKNGSCKRGPRTHYGQKAILFLPLPV")
→ eps_reduced = 17420, eps_cystines = 17545, abs_reduced = 1.01853, abs_cystines = 1.02583
Protein instability indexbio_instability_index

The Guruprasad instability index of a protein from its dipeptides (above 40 suggests an unstable protein in vivo).

II = \frac{10}{L}\sum_{i=1}^{L-1} \mathrm{DIWV}(a_i, a_{i+1})

Inputs

  • seq protein sequence (at least 2 residues) text

Returns

  • index instability index

Applies when

  • standard amino acids, length >= 2

Example

m.ask("Instability index: seq = MAEGEITTFTALTEKFNLPPGNYKKPKLLYCSNGGHFLRILPDGTVDGTRDRSDQHIQLQLSAESVGEVYIKSTETGQYLAMDTSGLLYGSQTPSEECLFLERLEENHYNTYTSKKHAEKNWFVGLKKNGSCKRGPRTHYGQKAILFLPLPV")
→ index = 41.9803
Restriction sites and fragmentsbio_restriction_sites

Where a restriction enzyme cuts a linear DNA sequence: the number of sites, the cut positions and the fragment lengths.

\text{cut at } i + c \text{ for each site start } i

Inputs

  • seq linear DNA sequence 5'->3' text
  • enzyme restriction enzyme (name) choice

Returns

  • n_sites number of cuts
  • positions cut positions (1-based first base after each cut, top strand)
  • fragments fragment lengths in bp, 5'->3' order

Applies when

  • linear DNA
  • a listed enzyme

Example

m.ask("Restriction sites: seq = AAGAATTCTTGAATTCGGATCC, enzyme = EcoRI")
→ n_sites = 2, positions = [4, 12], fragments = [3, 8, 11]
Reverse complement of a DNA sequencebio_reverse_complement

The reverse complement of a DNA strand (the partner strand read 5'->3').

5'\text{-}x_1\dots x_n\text{-}3' \mapsto 5'\text{-}\bar x_n\dots \bar x_1\text{-}3'

Inputs

  • seq DNA sequence 5'->3' (A, C, G, T) text

Returns

  • revcomp reverse complement 5'->3'

Applies when

  • DNA letters A, C, G, T only

Example

m.ask("Reverse complement: seq = ATGCCGTA")
→ revcomp = TACGGCAT
Secondary-structure propensity fractionsbio_secondary_structure_fraction

The fractions of residues that tend to be in helices (E M A L K), turns (N P G S D) and sheets (V I Y F W L T), as ProtParam defines them (L counts for helix and sheet).

f_{\text{helix}} = \frac{n_E+n_M+n_A+n_L+n_K}{n}

Inputs

  • seq protein sequence text

Returns

  • helix fraction of helix-favouring residues
  • turn fraction of turn-favouring residues
  • sheet fraction of sheet-favouring residues

Applies when

  • standard amino acids only

Example

m.ask("Secondary structure fraction: seq = EMALKNPGSD")
→ helix = 0.5, turn = 0.5, sheet = 0.1
Transcription of DNA into mRNAbio_transcription

The mRNA transcribed from a DNA strand given 5'->3', stated as the coding (sense) or template (antisense) strand.

\text{mRNA} = \text{coding strand with } T\to U = \overline{\text{template}}^{\,R}

Inputs

  • seq DNA strand 5'->3' (A, C, G, T) text
  • strand which strand is given: coding (sense) or template (antisense) choice

Returns

  • mrna mRNA 5'->3'

Applies when

  • DNA letters only
  • the strand is stated

Example

m.ask("Transcription: seq = ATGGCTTAA, strand = coding")
→ mrna = AUGGCUUAA
Translation with the standard genetic codebio_translation

The protein encoded by a DNA or mRNA sequence read in frame 1 with the standard genetic code; stop codons shown as '*' or the protein truncated at the first stop.

\text{codon } x_{3i+1}x_{3i+2}x_{3i+3} \mapsto \text{amino acid}_i

Inputs

  • seq DNA or mRNA sequence 5'->3', length a multiple of 3 text
  • stops show stop codons as '*' or truncate at the first stop choice

Returns

  • protein amino-acid sequence (one-letter codes)
  • length number of residues shown

Applies when

  • length a multiple of 3
  • DNA or RNA letters, not a mixture

Example

m.ask("Translation: seq = ATGGCCATTGTAATGGGCCGCTGA, stops = show")
→ protein = MAIVMGR*, length = 8

Systems biology 1

Flux balance analysis (optimal objective)bio_flux_balance_analysis

The maximum of a linear objective (e.g. a biomass or product flux) over all steady-state flux distributions of a metabolic network within flux bounds: flux balance analysis.

\max_v\ c^\top v \ \text{ s.t. } Sv = 0,\ \ l \le v \le u

Inputs

  • S stoichiometric matrix (metabolites x reactions) matrix
  • lb lower bound of each reaction flux vector
  • ub upper bound of each reaction flux vector
  • c objective coefficient of each reaction vector

Returns

  • objective optimal objective value

Applies when

  • steady state S v = 0
  • finite bounds lb <= ub
  • a feasible flux distribution exists

Example

m.ask("Flux balance analysis: S = [[1, -1, 0, 0], [0, 1, -1, -1]], lb = [0, 0, 0, 0], ub = [10, 8, 100, 3], c = [0, 0, 1, 0]")
→ objective = 8
Questions

Frequently asked

What does computational-biology-ai999x do?

Computational Biology answers questions in computational biology: DNA and protein sequences, alignment, molecular weights, genetics and population genetics, phylogenetics, enzyme kinetics, metabolic and population models, and ecology. Each answer gives the value with its unit, the steps and the formula in LaTeX.

How do I install computational-biology-ai999x?

With pip: pip install computational-biology-ai999x. The same files are on Hugging Face (hf download AI999X/computational-biology-ai999x --local-dir computational-biology-ai999x) and GitHub.

Does it run offline?

Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.

How many capabilities does computational-biology-ai999x have?

83 capabilities in 10 topics, including Sequences, Population genetics, Ecology, Enzyme kinetics, Alignment.

Which field and tasks does it cover?

Field: Life Sciences. Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction.

What does an answer look like?

Asked "Reverse complement: seq = ATGCCGTA", it answers: revcomp = TACGGCAT.

What happens when a question cannot be answered?

It says so and names what is missing or out of range, instead of guessing a number.

More from AI999X

Explore every model.