Friday 5 November 2021

Inferring mRna from Protein (Rosalind | English)

            

rosalind


Hi everyone, how are you? This time, I want to discuss about a problem, which is bioinformatics problem, that exist in rosalind.info's web. The title is "Inferring mRna from Protein". For the reference, you can first check out the problem that will be discussed (here). 

DNA -> RNA -> Protein.

Overview

In this problem we will given a string representing a protein strain, lets call it s. Our task is to counting the number of all possible RNA strain that can be formed with s

As we know, the protein strain is string-form strain formed from the RNA strain. 

For understanding how to transform RNA strain into protein strain we need to look first at the RNA codon table. RNA codon table is a table that can be used as a dictionary for translating between the RNA strain and the protein strain. 

So, to solving this problem, the idea is, counting the number of RNA strain that can be used as a candidate by multiplying the translated RNA potential, letter by letter. For example; 'A' protein has 4 RNA potential strains, and 'D' has 2; for finding the number of "AD" RNA strain candidate we can multiply 4 by 2. Don't forget to counting stop codon protein (has 3 potential RNA) at the end of the strain. 

The Code 

This is the code for solving this problem (with java language): 

01    static void solve() {
02 int[] pts = new int[26];
03 pts['V' - 'A']++;
04 pts['V' - 'A']++;
05 pts['V' - 'A']++;
06 pts['V' - 'A']++;
07 pts['A' - 'A']++;
08 pts['A' - 'A']++;
09 pts['A' - 'A']++;
10 pts['A' - 'A']++;
11 pts['D' - 'A']++;
12 pts['D' - 'A']++;
13 pts['E' - 'A']++;
14 pts['E' - 'A']++;
15 pts['G' - 'A']++;
16 pts['G' - 'A']++;
17 pts['G' - 'A']++;
18 pts['G' - 'A']++;
19 pts['F' - 'A']++;                 
20 pts['F' - 'A']++;                 
21 pts['L' - 'A']++;                 
22 pts['L' - 'A']++;                 
23 pts['S' - 'A']++;                 
24 pts['S' - 'A']++;                 
25 pts['S' - 'A']++;                 
26 pts['S' - 'A']++;                 
27 pts['Y' - 'A']++;                 
28 pts['Y' - 'A']++;                 
29 pts['C' - 'A']++;                 
30 pts['C' - 'A']++;                 
31 pts['W' - 'A']++;                  
32 pts['L' - 'A']++;
33 pts['L' - 'A']++;
34 pts['L' - 'A']++;
35 pts['L' - 'A']++;
36 pts['P' - 'A']++;
37 pts['P' - 'A']++;
38 pts['P' - 'A']++;
39 pts['P' - 'A']++;
40 pts['H' - 'A']++;
41 pts['H' - 'A']++;
42 pts['Q' - 'A']++;
43 pts['Q' - 'A']++;
44 pts['R' - 'A']++;
45 pts['R' - 'A']++;
46 pts['R' - 'A']++;
47 pts['R' - 'A']++;
48 pts['I' - 'A']++;
49 pts['I' - 'A']++;
50 pts['I' - 'A']++;
51 pts['M' - 'A']++;
52 pts['T' - 'A']++;
53 pts['T' - 'A']++;
54 pts['T' - 'A']++;
55 pts['T' - 'A']++;
56 pts['N' - 'A']++;
57 pts['N' - 'A']++;
58 pts['K' - 'A']++;
59 pts['K' - 'A']++;
60 pts['S' - 'A']++;
61 pts['S' - 'A']++;
62 pts['R' - 'A']++;
63 pts['R' - 'A']++;
64 String s = ns();
65 long res = 1L;
66 for (char chs : s.toCharArray()) {
67 res *= pts[chs - 'A'];
68 res %= 1000000L;
69 }
70 res *= 3; 
71            res %= 1000000L;
72 out.println(res);
73   }  

First, we can converse the codon table into array-form codon table to find the number of the potential RNA that can be formed for each protein (line 2-63). Then we can find the total RNA potential strain by multiplying them letter by letter, and don't forget to adding stop codon protein in the end. The answer will be served as modular arithmetic 1.000.000-form, so we can "mod" it by 1.000.000 before submitting it. 

Input and Output

In the code above, I used ns() function for entering the string-form data (line 64). That function is an extend from one of the system inputs which are available in java, called BufferedReader. 

And for the output I used out.println() function (line 72). That function is a modification from System.out.println() function which is very familiar in java. You can see the additional code for that modification (input and output) in my complete code at github.

That's it. If you want to ask something, you can write it in the comment section below. I hope this article is useful and see you in the next article!


Reference :
Source of Image 1 :https://www.facebook.com/ProjectRosalind/
Source of Image 2 :https://www.abbexa.com/mRNA-cancer-treatment

No comments:

Post a Comment