In my previous bioinformatics challenge, I asked you to mutate a DNA sequence. This time, I'd like you to evaluate how likely a mutation, or a series of mutations, is.
The two types of substitutions are transitions and transversions, and due to the chemical structure of DNA bases, transitions are more likely to occur than transversions. A transition is when a base is turned into one of the same size (purine -> purine or pyrimidine -> pyrimidine), and a transversion involves two bases of different sizes (purine <-> pyrimidine). Following Kimura's model, postulated in 1980, we can define a
as the probability of a transition occurring for each unit of time, and b
as the probability of a transversion occurring.
See diagram below. A and G are purines, C and T are pyrimidines.
Although the exact values of a
and b
change from organism to organism (and even between different areas in an organism's genome), we can set a=0.25
and b=0.1
for this challenge.
Given two DNA strings of same length as input, I would like you to calculate how likely it would be for string B to be a mutated version of string A. This is code golf, so fewest bytes wins!
Test cases:
Input String A | Input string B | Output probability
tgcctatc | tgcctata | 0.1
aggttcctt | gggttcctt | 0.25
aactgg | aaccgg | 0.25
atgccct | atcgcct | 0.01
tatcactaag | tgtcaatgag | 0.00625
ctcctgggca | cttttgcgca | 0.00625
ctgtgtgct | cagagagca | 0.0001
atcgctttca | ttggctttca | 0.01
attcac | taagcg | 0.000001
attttcattg | attttttacg | 0.000625
Specifications:
- The input DNA strings can be as strings of characters, binary or numerical.
- We will assume that all of the mutations are independent events.
- The output can be in plain notation (0.00015) or scientific (\$1.5\times10^{-4}\$).
If you have any questions or require more specifications, send them my way in the comments!
P
isn't a base, otherwise we could calculate the chance ofPPCG
mutating toCGCC
... \$\endgroup\$tatcactaag | tgtcaatgag | 0.0625
should be corrected totatcactaag | tgtcaatgag | 0.00625
and the sixth case should also be 0.00625 and the nineth should be0.000001
I think since it's 6b
s and noa
s. \$\endgroup\$1/40
? \$\endgroup\$