lineage/gene/dominance

Expression rules for dominant-recessive inheritance.

Each function in this module returns a gene.Expression — a closure that accepts the list of alleles carried by an individual and resolves them to a phenotype string, or None if the allele combination is not recognised.

Values

pub fn simple(
  dominant: #(String, String),
  recessive: #(String, String),
) -> fn(List(String)) -> option.Option(String)

Returns an expression rule for a gene with one dominant and one recessive allele.

The dominant phenotype is expressed whenever the dominant allele is present, regardless of what the other allele is. The recessive phenotype is only expressed when the dominant allele is absent and the recessive allele is present. If neither allele is found in the list, the expression returns None.

Both arguments are tuples of #(allele, phenotype_label).

Examples

let expr = simple(#("R", "round"), #("r", "wrinkled"))
expr(["R", "R"])
// -> option.Some("round")
expr(["R", "r"])
// -> option.Some("round")
expr(["r", "r"])
// -> option.Some("wrinkled")
expr(["x", "y"])
// -> option.None
Search Document