-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmRNA_translator_aminoacid.java
280 lines (277 loc) · 7.3 KB
/
mRNA_translator_aminoacid.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
Author: Jonathan Lee
CSCI Professor: Gita Faroughi
Biology Professor: Cody Watters Section 1, Dr. Priscilla Issac Section 2 Sacramento State University
Class: CSCI13 Grader
Date: Nov 7 2022
Program: Bioinfomatics translate an mRNA transcript into a sequence of amino acids.
*/
import java.util.*;
public class mRNA_translator_aminoacid
{
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
System.out.print("Enter DNA sequence:");
String mRNA = transcribe(console.next());
//System.out.println(mRNA.length()); //test point only valid counts are A,C,G,T
while(mRNA.length()%3 != 0)//data validation must take triplets only and will count only DNA A C G or T
{
System.out.print("Please enter only tripletts and use correct entries for DNA A, C, G, or T:");
mRNA = transcribe(console.next()); //test new entry until %3 = 0
}
System.out.println("Transcribed: "+ mRNA);
System.out.println("Amino Acids: "+AminoAcids(mRNA));
}
/* This private method will transcribe a sequence of dna. A=U G=C if T=A RNA does not contain T.*/
private static String transcribe(String DNA)
{
DNA = DNA.toUpperCase();
String mRNA = "";
for(int i = 0; i<DNA.length(); i++)
{
char check = DNA.charAt(i);
switch(check)
{
case ('A'):
{
mRNA += 'U';
continue;
}
case ('T'):
{
mRNA += 'A';
continue;
}
case ('G'):
{
mRNA += 'C';
continue;
}
case ('C'):
{
mRNA += 'G';
continue;
}
default:
{
continue;
}
}
}
return mRNA;
}
/* This method will determine the amino acid sequence that would be produced from the sequence after transcription.
Per Professor Cody Watters if stop UAA, UAG, or UGA is seen the Amino Acid sequence is completed the rest is ignored see return area.
Start must also be AUG before code starts*/
private static String AminoAcids(String mRNA)
{
String AminoAcids = "";
boolean flag = false;//used with start AUG MET
for(int i = 0; i<mRNA.length(); i+=3)
{
String check = mRNA.substring(i, i+3);
switch(check)
{
case ("UUU"): case ("UUC"):
{
if(flag)
{
AminoAcids += "Phe-";
}
continue;
}
case ("UCU"): case ("UCC"):
case ("UCA"): case ("UCG"):
{
if(flag)
{
AminoAcids += "Ser-";
}
continue;
}
case ("UAU"): case ("UAC"):
{
if(flag)
{
AminoAcids += "Tyr-";
}
continue;
}
case ("UAA"): case ("UAG"): //stop case
case ("UGA"):
{
if(flag)
{
AminoAcids += "STOP ";
}
return AminoAcids;
}
case ("UGU"): case ("UGC"):
{
if(flag)
{
AminoAcids += "Cys-";
}
continue;
}
case ("UGG"):
{
if(flag)
{
AminoAcids += "Trp-";
}
continue;
}
case ("CUU"): case ("CUC"):
case ("CUA"): case ("CUG"):
case ("UUA"): case ("UUG"):
{
if(flag)
{
AminoAcids += "Leu-";
}
continue;
}
case ("CCU"): case ("CCC"):
case ("CCA"): case ("CCG"):
{
if(flag)
{
AminoAcids += "Pro-";
}
continue;
}
case ("CAU"): case ("CAC"):
{
if(flag)
{
AminoAcids += "His-";
}
continue;
}
case ("CAA"): case ("CAG"):
{
if(flag)
{
AminoAcids += "Gin-";
}
continue;
}
case ("CGU"): case ("CGC"):
case ("CGA"): case ("CGG"):
{
if(flag)
{
AminoAcids += "Arg-";
}
continue;
}
case ("AUU"): case ("AUC"):
case ("AUA"):
{
if(flag)
{
AminoAcids += "Ile-";
}
continue;
}
case ("AUG")://start case will turn flag on for to find sequence until stop is found
{
AminoAcids += "START Met-";
flag = true;
continue;
}
case ("ACU"): case ("ACC"):
case ("ACA"): case ("ACG"):
{
if(flag)
{
AminoAcids += "Thr-";
}
continue;
}
case ("AAU"): case ("AAC"):
{
if(flag)
{
AminoAcids += "Asn-";
}
continue;
}
case ("AAA"): case ("AAG"):
{
if(flag)
{
AminoAcids += "Lys-";
}
continue;
}
case ("AGU"): case ("AGC"):
{
if(flag)
{
AminoAcids += "Ser-";
}
continue;
}
case ("AGA"): case ("AGG"):
{
if(flag)
{
AminoAcids += "Arg-";
}
continue;
}
case ("GUU"): case ("GUC"):
case ("GUA"): case ("GUG"):
{
if(flag)
{
AminoAcids += "Val-";
}
continue;
}
case ("GCU"): case ("GCC"):
case ("GCA"): case ("GCG"):
{
if(flag)
{
AminoAcids += "Ala-";
}
continue;
}
case ("GAU"): case ("GAC"):
{
if(flag)
{
AminoAcids += "Asp-";
}
continue;
}
case ("GAA"): case ("GAG"):
{
if(flag)
{
AminoAcids += "Glu-";
}
continue;
}
case ("GGU"): case ("GGC"):
case ("GGA"): case ("GGG"):
{
if(flag)
{
AminoAcids += "Gly-";
}
continue;
}
default:
{
continue;
}
}
}
return AminoAcids;
}
}