Bifalgorithm post · Computer science one · Exercises
How can programs analyze DNA n-gram frequencies and subsequence occurrences?
How can programs analyze DNA n-gram frequencies and subsequence occurrences? (Computer science one · Exercises) — "Exercise 9.11. A DNA sequence is a sequence…
Ideas in this flowchart
- Exercises on processing DNA sequences
- Exercise 9.11: Compute n-gram frequencies in a DNA sequence
- A DNA sequence uses the nucleobases A, C, G, and T.
- An n-gram is a DNA subsequence of length n.
- There are 4^n possible n-grams.
- The program reads a DNA sequence from a plaintext file and computes the relative frequency of each n-gram.
- For a sequence of length L, the total number of n-grams is L − (n − 1).
- For n = 2, all 16 length-two combinations are counted in the example sequence.
- The example reports the relative frequencies of all 2-grams, including AA, AC, AG, and the other combinations.
- Exercise 9.12: Count occurrences of a specified subsequence.
- The program reads a DNA sequence from a text file, receives a subsequence s, and counts how many times s appears.
- In the examples, GTA appears twice, while CC appears three times in CCCC.
- Exercise 9.13: Translate a DNA sequence into a protein.
- First, DNA is translated into RNA by replacing each thymine nucleotide T with uracil U.
- Then, the RNA sequence is processed three bases at a time, with each trigram translated into an amino acid using known encoding rules.