5 kyu

N-Hybrid Inheritance

Description:

'The Punnett square is a square diagram that is used to predict the genotypes of a particular cross or breeding experiment. It is named after Reginald C. Punnett, who devised the approach in 1905. The diagram is used by biologists to determine the probability of an offspring having a particular genotype. The Punnett square is a tabular summary of possible combinations of maternal alleles with paternal alleles.' - Wikipedia

When mating a mother (Bb) and a father (Bb), the offspring genotype is predicted by finding every possible combination of alleles from the parents. As shown in the diagram below the four possible outcomes are BB, Bb, Bb and bb. This is known as Monohybrid Inheritance as only a single gene (or letter) is being utilised

┌─┬──┬──┐
│ │B │b │
├─┼──┼──┤
│B│BB│Bb│
├─┼──┼──┤
│b│Bb│bb│
└─┴──┴──┘

A capital letter implies that the allele for the gene is dominant and a non capital letter implies that the allele for the gene is recessive. If the B allele is lets say brown eyes and the b allele is lets say blue eyes. If the alleles of a person are BB, they will have brown eyes. Similarly if the alleles of a person are bb, they will have blue eyes. However if the alleles of a person are Bb they have brown eyes as the dominant B or brown allele will 'dominate' over the recessive b or blue allele.

Furthermore this type of inheritance can be extended for multiple genes. If there are two different genes, this is known as dihybrid inheritance. For example for a mother with the alleles RrAa and a father with the alleles RrAa, their offspring will have 16 possible genotypes, shown in the Punnett square below.

┌──┬────┬────┬────┬────┐
│  │RA  │Ra  │rA  │ra  │
├──┼────┼────┼────┼────┤
│RA│RRAA│RRAa│RrAA│RrAa│
├──┼────┼────┼────┼────┤
│Ra│RRAa│RRaa│RrAa│Rraa│
├──┼────┼────┼────┼────┤
│rA│RrAA│RrAa│rrAA│rrAa│
├──┼────┼────┼────┼────┤
│ra│RrAa│Rraa│rrAa│rraa│
└──┴────┴────┴────┴────┘

Your task if to find the probability of an offspring expressing certain alleles depending upon the genetic makeup of both parents rounded to 18 decimal points. The input will consist of the the Father's alleles, the Mothers alleles and the string of expressed alleles of the offspring.

For example if the Father's alleles are Bb and the Mother's alleles are Bb and the offspring's potential allele expression is b, the probability is 0.25 or 1/4 as 1 out of the 4 squares above express the allele b.

Furthermore if the Father's alleles are RrAa and the Mother's alleles are RrAa and the offspring potential allele expression is RA, the probability is 0.5625 or 9/16 as 9 out of the 16 squares above express the alleles RA.

Note that the input string of the mother and the father will always have the same length and that the offspring input string will always be half that. The maximum amount of pairs of alleles in this Kata is 5.

Probability

More By Author:

Check out these other kata created by ColderThanSeptember

Stats:

CreatedMay 31, 2022
PublishedJun 7, 2022
Warriors Trained394
Total Skips185
Total Code Submissions202
Total Times Completed46
Python Completions46
Total Stars7
% of votes with a positive feedback rating94% of 18
Total "Very Satisfied" Votes17
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes1
Total Rank Assessments13
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • ColderThanSeptember Avatar
  • dfhwze Avatar
Ad