rosalind

Rosalind - Inferring mRNA from Protein

rosalind

Problem: Please find the problem here. Solution: To figure out how many RNA is possible, we simply multiply all possibilities. Note that we also make sure the protein ends with a stop codon. Code:

Rosalind - Independent Alleles

rosalind

Problem: Please find the problem here. Analysis: The code is deceptively simple. Let’s not read the code and understand the problem first. Because A and B are independent, we can consider them separately. Tom’s offspring has the following distribution: AA - 0.25 Aa - 0.5 aa - 0.25 To consider the next generation, let’s generalize and consider the next generation of an arbitrary distribution. Let’s say the current distribution is

Rosalind - Calculating Expected Offspring

rosalind

Problem: Please find the problem here. Solution: The probability for AA-AA to produce an offspring with a dominant phenotype offspring is 1. The probability for AA-Aa to produce an offspring with a dominant phenotype offspring is 1. The probability for AA-aa to produce an offspring with a dominant phenotype offspring is 1. The probability for Aa-Aa to produce an offspring with a dominant phenotype offspring is 0.75. The probability for Aa-aa to produce an offspring with a dominant phenotype offspring is 0.

Rosalind - Overlap Graphs

rosalind

Problem: Please find the problem here. Solution: To construct the graph, we go through every pair, excluding self-loops, and output an edge when the suffix matches the prefix. Care is taken to make sure the string actually has at least 3 characters. Code:

Rosalind - Finding a Shared Motif

rosalind

Problem: Please find the problem here. Solution: This is a complicated solution. I spent almost a week on it. It is based on a suffix tree. Suffix tree itself is a complicated beast. I described it earlier in this series of posts, please check it out if you have no idea what is a suffix tree. In the sequel, I assumed the suffix tree is built on a string built on the DNAs concatenated and separated by unique characters.

Rosalind - Mortal Fibonacci Rabbits

rosalind

Problem: Please find the problem here. Solution: The matrix solution I used in my previous solution is still applicable, but it is cumbersome to implement. It is time to actually use dynamic programming. Conceptually, it is easy. We know rabbits can have life from \( 0 \) to \( m - 1 \) month, so we keep an array to see how many pairs of rabbits are there at that age.

Rosalind - Consensus and Profile

rosalind

Problem: Please find the problem here. Solution: Because we need to output the whole matrix, we just simply have to compute it. Code:

Rosalind - Finding a Motif in DNA

rosalind

Problem: Please find the problem here. Solution: This feels like cheating. The problem is obviously asking for implementing a substring search, and I am using the Python builtin. I have implemented Boyer Moore in C#, so I don’t feel bad. In fact, I validated my implementation using the Rosalind test cases, and it passed there as well. Code:

Rosalind - Translating RNA into Protein

rosalind

Problem: Please find the problem here. Solution: To perform the translation, we used a lookup table. Code:

Rosalind - Mendel's First Law

rosalind

Problem: Please find the problem here. Solution: When two heterozygous organisms mate, the offspring have \( \frac{1}{4} \) chance to be homozygous recessive. When a heterozygous organism and a homozygous organism mate, the offspring have \( \frac{1}{2} \) chance to be homozygous recessive. When two homozygous recessive organisms mate, their offspring must be homozygous recessive. There are no other ways to produce a homozygous recessive offspring. The probability of getting a homozygous recessive is therefore: