Probability
12 problems from Rosalind — Bioinformatics Stronghold. Press Run on any block to execute it in your browser.
IPRB — Mendel's First Law
solved Problem statement
Mendel's first law as a probability question. The whole content is that two alleles segregate independently, which is what makes the offspring distribution a product rather than something requiring simulation.
IEV — Calculating Expected Offspring
solved Problem statement
Expectation is linear whether or not the events are independent, so the answer is a weighted sum with no interaction between genotypes to model. That property is why expected values are reached for far more often than full distributions.
LIA — Independent Alleles
solved Problem statement
Mendel's second law. Alleles at different loci assort independently, so the two-locus probability factors — which is what makes this a binomial calculation rather than a simulation.
SEXL — Sex-Linked Inheritance
solved Problem statement
Males carry one X, so a recessive allele on it is expressed with no second copy to mask it. The proportion of affected males is therefore the allele frequency itself, which is why X-linked recessive conditions appear far more often in males than females.
AFRQ — Counting Disease Carriers
solved Problem statement
Hardy-Weinberg run backwards: the disease frequency gives the allele frequency, and the carrier frequency 2pq follows. For a rare recessive allele carriers vastly outnumber sufferers, which is the counterintuitive result the arithmetic exists to make obvious.
PROB — Introduction to Random Strings
solved Problem statement
Computed in logarithms because the raw probability of any particular long string underflows to zero — the same reason the HMM problems decode in log space rather than multiplying probabilities directly.
EVAL — Expected Number of Restriction Sites
solved Problem statement
The expected number of times a motif appears in a random sequence, which is what makes an observed count interesting or unremarkable. Without a baseline, finding a site says nothing at all.
EBIN — Wright-Fisher's Expected Behavior
solved Problem statement
Expected allele counts under Wright-Fisher, where expectation is linear and so the answer is a sum of binomial means. WFMD gives the distribution this summarises.
INDC — Independent Segregation of Chromosomes
solved Problem statement
Rosalind allows 0.001 absolute error and its printed sample rounds some entries differently, so the assertion pins the exact endpoints — log10(1023/1024) and log10(1/1024) — and that the tail never increases, rather than a rounding-dependent array.
WFMD — The Wright-Fisher Model of Genetic Drift
solved Problem statement
Genetic drift: allele frequencies move at random in a finite population, and an allele can be lost or fixed with no selection involved at all. It is the null model everything claiming selection has to be tested against.
RSTR — Matching Random Motifs
solved Problem statement
Derived rather than recalled: the motif has four weak and four strong bases, so p = 0.2^4 x 0.3^4 = 1.296e-05 and 1-(1-p)^90 = 0.00117. The assertion pins p as well as the answer.
FOUN — The Founder Effect and Genetic Drift
solved Problem statement
The first generation was derived by hand — from one copy, (7/8)^8 = 0.343609 so log10 = -0.463936 — and the assertion pins that plus the requirement that loss never becomes less likely over time.