You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Queuefirst_dna = newQueue(1000); // first queue for dna
9
+
Queuecomp_dna = newQueue(1000); // second queue for complement dna
10
+
Queueamino = newQueue(1000); // third queue for triple dna code
11
+
QueueaminoAcids_name = newQueue(1000); // fourth queue for the amino acids
12
+
13
+
for (inti = 0; i < 21; i++) {
14
+
charsymbol; // for the base
15
+
intnumber = rnd.nextInt(4); // generate base randomly for first dna
16
+
if(number == 0) {
17
+
symbol ='A';
18
+
first_dna.enqueue(symbol);
19
+
}
20
+
elseif(number == 1) {
21
+
symbol ='T';
22
+
first_dna.enqueue(symbol);
23
+
}
24
+
elseif(number == 2) {
25
+
symbol ='G';
26
+
first_dna.enqueue(symbol);
27
+
}
28
+
elseif(number == 3) {
29
+
symbol ='C';
30
+
first_dna.enqueue(symbol);
31
+
}
32
+
}
33
+
Queuesaved_dna1 = newQueue(1000);
34
+
System.out.println("-First DNA-"); // print first dna
35
+
for (inti = 0; i <21; i++) {
36
+
System.out.print(first_dna.peek() + " ");
37
+
first_dna.enqueue(first_dna.dequeue());
38
+
}
39
+
System.out.println();
40
+
// construct a new queue which contains the complement of the DNA sequence --- complement dna
41
+
for(inti =0; i < 21; i++) {
42
+
charnew_symbol; // complement base
43
+
charsymbol; // base
44
+
symbol = (char) first_dna.peek();
45
+
if(symbol == 'A') { // A-T
46
+
new_symbol = 'T';
47
+
comp_dna.enqueue(new_symbol);
48
+
first_dna.enqueue(first_dna.dequeue());
49
+
}
50
+
elseif(symbol == 'T') { // T-A
51
+
new_symbol = 'A';
52
+
comp_dna.enqueue(new_symbol);
53
+
first_dna.enqueue(first_dna.dequeue());
54
+
}
55
+
elseif(symbol == 'G') { // G-C
56
+
new_symbol = 'C';
57
+
comp_dna.enqueue(new_symbol);
58
+
first_dna.enqueue(first_dna.dequeue());
59
+
}
60
+
elseif(symbol == 'C') { // C-G
61
+
new_symbol = 'G';
62
+
comp_dna.enqueue(new_symbol);
63
+
first_dna.enqueue(first_dna.dequeue());
64
+
}
65
+
}
66
+
System.out.println("\n-Complement of first DNA-"); // print the complement dna
67
+
for (inti = 0; i < 21; i++) {
68
+
System.out.print(comp_dna.peek() + " ");
69
+
first_dna.enqueue(comp_dna.dequeue());
70
+
}
71
+
72
+
for(inti =0; i<21;i++) { // This is necessary because it will used in crossover part
73
+
saved_dna1.enqueue(first_dna.dequeue());
74
+
}
75
+
Queuesaved_dna2 = newQueue(1000); // this is necessary too. It will used in amino acids part
76
+
77
+
for(inti =0; i < 21; i++) { // this is the most important part. Without it, amino acids printed wrong. There was a problem in here, when I fix it with adding this code.
78
+
charnew_symbol;
79
+
charsymbol;
80
+
symbol = (char) first_dna.peek();
81
+
if(symbol == 'A') { // A-T
82
+
new_symbol = 'T';
83
+
saved_dna2.enqueue(new_symbol);
84
+
first_dna.enqueue(first_dna.dequeue());
85
+
}
86
+
elseif(symbol == 'T') { // T-A
87
+
new_symbol = 'A';
88
+
saved_dna2.enqueue(new_symbol);
89
+
first_dna.enqueue(first_dna.dequeue());
90
+
}
91
+
elseif(symbol == 'G') { // G-C
92
+
new_symbol = 'C';
93
+
saved_dna2.enqueue(new_symbol);
94
+
first_dna.enqueue(first_dna.dequeue());
95
+
}
96
+
elseif(symbol == 'C') { // C-G
97
+
new_symbol = 'G';
98
+
saved_dna2.enqueue(new_symbol);
99
+
first_dna.enqueue(first_dna.dequeue());
100
+
}
101
+
}
102
+
System.out.println();
103
+
// for the second part ( amino acids )
104
+
for (inti = 0; i < 7; i++) {
105
+
Stringamino_acid ="";
106
+
for (intj = 0; j < 3; j++) {
107
+
amino_acid += saved_dna2.dequeue(); // I stored the dna codes 3-3
108
+
}
109
+
amino.enqueue(amino_acid);
110
+
}
111
+
System.out.println("\n**Each 3 letters of DNA code for one amino acid**");
112
+
113
+
for (inti = 0; i < 7; i++) {
114
+
System.out.print(amino.peek() + " ");
115
+
amino.enqueue(amino.dequeue());
116
+
}
117
+
System.out.println();
118
+
for (inti = 0; i < 7; i++) { // A DNA sequence codes for a sequence of amino acids that make up a protein. Each 3 letters of DNA code for one amino acid
119
+
Stringpiece = (String) amino.dequeue();
120
+
// starts with A
121
+
if (piece.startsWith("AA")) {
122
+
if (piece.endsWith("A") || piece.endsWith("G")) aminoAcids_name.enqueue("Lys");
0 commit comments