-
Notifications
You must be signed in to change notification settings - Fork 0
/
DNA.c
338 lines (296 loc) · 12.1 KB
/
DNA.c
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*****************************************************************/
/* */
/* Casio DNA to RNA converter */
/* */
/* File name : DNATORNA.c */
/* */
/* Copyright (c) 2023 Felix Wittwer */
/* */
/*****************************************************************/
#include "fxlib.h"
#include <stdio.h>
void RenderStrand(int x, int y, int marker, int ends, char symbols[], int line){
//int x ; int y are for the position
//int marker specifies in which direction and how long the markers get rendered
//int ends defines how the ends of the stands should be labeled
//chat symbols[] is a list of the rendered characters
int iteration = 0;
int xaddition;
unsigned char buffer[12];
if(line==1){
Bdisp_DrawLineVRAM(x,y,x+102,y);
// function just for this specific program shortend because of storage
if(ends==3 && marker<0){
PrintMini(x-7,y-4,(unsigned char*)"3'", MINI_OVER);
PrintMini(x+104,y-4,(unsigned char*)"5'", MINI_OVER);
}else if(ends==5 && marker>0){
PrintMini(x-7,y,(unsigned char*)"5'", MINI_OVER);
PrintMini(x+104,y,(unsigned char*)"3'", MINI_OVER);
}
}
while(iteration<15){
xaddition = (iteration)*5+(7*((iteration)/3))+2;
if(line==1){
Bdisp_DrawLineVRAM(x+xaddition,y,x+xaddition,y+marker);
}
sprintf(buffer, "%c", symbols[iteration]);
if(marker>0){
PrintMini(x+xaddition-1,y+3, buffer, MINI_OVER);
}else if(marker<0){
PrintMini(x+xaddition-1,y-7, buffer, MINI_OVER);
}
iteration = iteration + 1;
}
}
void RendertRNA(int x, int y){
Bdisp_DrawLineVRAM(x-5,y,x-5,y+1);
Bdisp_DrawLineVRAM(x,y,x,y+2);
Bdisp_DrawLineVRAM(x+5,y,x+5,y+1);
Bdisp_DrawLineVRAM(x-5,y+1,x+5,y+1);
}
RenderPointer(int x, int y, int pointer){
int xaddition;
xaddition = (pointer)*5+(7*((pointer)/3))+2;
Bdisp_DrawLineVRAM(x+xaddition-2,y-1,x+xaddition-2,y-7);
}
RenderResult(int x, int y, int pos1, int pos2, int pos3, char symbols[]){
if(symbols[pos1]=='A'){
if(symbols[pos2]=='U'){
if(symbols[pos3]=='G'){
PrintMini(x,y, (unsigned char*)"Met", MINI_OVER);
}else if(symbols[pos3]=='U'||symbols[pos3]=='C'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Ile ", MINI_OVER);
}
}else if(symbols[pos2]=='C'){
PrintMini(x,y, (unsigned char*)"Thr ", MINI_OVER);
}else if(symbols[pos2]=='A'){
if(symbols[pos3]=='G'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Lys ", MINI_OVER);
}else if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Asn ", MINI_OVER);
}
}else if(symbols[pos2]=='G'){
if(symbols[pos3]=='G'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Arg ", MINI_OVER);
}else if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Ser ", MINI_OVER);
}
}
}else if(symbols[pos1]=='G'){
if(symbols[pos2]=='U'){
PrintMini(x,y, (unsigned char*)"Val ", MINI_OVER);
}else if(symbols[pos2]=='C'){
PrintMini(x,y, (unsigned char*)"Ala ", MINI_OVER);
}else if(symbols[pos2]=='A'){
if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Asp ", MINI_OVER);
}else if(symbols[pos3]=='G'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Glu ", MINI_OVER);
}
}else if(symbols[pos2]=='G'){
PrintMini(x,y, (unsigned char*)"Gly ", MINI_OVER);
}
}else if(symbols[pos1]=='U'){
if(symbols[pos2]=='U'){
if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Phe ", MINI_OVER);
}else if(symbols[pos3]=='G'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Leu ", MINI_OVER);
}
}else if(symbols[pos2]=='C'){
PrintMini(x,y, (unsigned char*)"Ser ", MINI_OVER);
}else if(symbols[pos2]=='A'){
if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Tyr ", MINI_OVER);
}else if(symbols[pos3]=='A'||symbols[pos3]=='G'){
PrintMini(x,y, (unsigned char*)"Stop", MINI_OVER);
}
}else if(symbols[pos2]=='G'){
if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"Cys ", MINI_OVER);
}else if(symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Stop", MINI_OVER);
}else if(symbols[pos3]=='G'){
PrintMini(x,y, (unsigned char*)"Trp ", MINI_OVER);
}
}
}else if(symbols[pos1]=='C'){
if(symbols[pos2]=='U'){
PrintMini(x,y, (unsigned char*)"Leu ", MINI_OVER);
}else if(symbols[pos2]=='C'){
PrintMini(x,y, (unsigned char*)"Pro ", MINI_OVER);
}else if(symbols[pos2]=='A'){
if(symbols[pos3]=='U'||symbols[pos3]=='C'){
PrintMini(x,y, (unsigned char*)"His ", MINI_OVER);
}else if(symbols[pos3]=='G'||symbols[pos3]=='A'){
PrintMini(x,y, (unsigned char*)"Gln ", MINI_OVER);
}
}else if(symbols[pos2]=='G'){
PrintMini(x,y, (unsigned char*)"Arg ", MINI_OVER);
}
}else if(symbols[pos1]==' '||symbols[pos2]==' '||symbols[pos3]==' '){
PrintMini(x,y, (unsigned char*)" ", MINI_OVER);
}
}
//****************************************************************************
// AddIn_main (Sample program main function)
//
// param : isAppli : 1 = This application is launched by MAIN MENU.
// : 0 = This application is launched by a strip in eACT application.
//
// OptionNum : Strip number (0~3)
// (This parameter is only used when isAppli parameter is 0.)
//
// retval : 1 = No error / 0 = Error
//
//****************************************************************************
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned int key;
int iteration = 0;
int pointer = 1;
int pointery = 1;
char dnaone [15] = "ATGACTGTGCTGTAT";
char dnatwo [15] = "";
char mrna [15] = "";
char trna [15] = "";
Bdisp_AllClr_DDVRAM();
PrintMini(10,10,(unsigned char*)"Performance Edition",MINI_OVER);
PrintMini(10,20,(unsigned char*)"V 1.00.00",MINI_OVER);
PrintMini(10,30,(unsigned char*)"(c) 2023 Felix Wittwer",MINI_OVER);
PrintMini(10,57,(unsigned char*)"Press any key to continue >>>",MINI_OVER);
while(1){
GetKey(&key);
Bdisp_AllClr_DDVRAM();
//handle input
if(key==KEY_CHAR_1){
if(pointery==1||pointery==3){
dnaone[pointer-1] = 'T';
}else if(pointery==2||pointery==4){
dnaone[pointer-1] = 'A';
}
}else if(key==KEY_CHAR_4){
if(pointery==1||pointery==3){
dnaone[pointer-1] = 'A';
}else if(pointery==2||pointery==4){
dnaone[pointer-1] = 'T';
}
}else if(key==KEY_CHAR_3){
if(pointery==1||pointery==3){
dnaone[pointer-1] = 'C';
}else if(pointery==2||pointery==4){
dnaone[pointer-1] = 'G';
}
}else if(key==KEY_CHAR_6){
if(pointery==1||pointery==3){
dnaone[pointer-1] = 'G';
}else if(pointery==2||pointery==4){
dnaone[pointer-1] = 'C';
}
}else if(key==KEY_CTRL_DEL){
dnaone[pointer-2] = ' ';
pointer=pointer-1;
}
while(iteration<15){
if(dnaone[iteration]=='T'){
dnatwo[iteration]='A';
}else if(dnaone[iteration]=='A'){
dnatwo[iteration]='T';
}else if(dnaone[iteration]=='G'){
dnatwo[iteration]='C';
}else if(dnaone[iteration]=='C'){
dnatwo[iteration]='G';
}else if(dnaone[iteration]==' '){
dnatwo[iteration]=' ';
}
//copy dnaone to mrna
if(dnaone[iteration] != 'T'){
mrna[iteration] = dnaone[iteration];
}else if(dnaone[iteration]=='T'){
mrna[iteration] = 'U';
}
if(dnatwo[iteration] != 'T'){
trna[iteration] = dnatwo[iteration];
}else if(dnatwo[iteration]=='T'){
trna[iteration] = 'U';
}
iteration = iteration + 1;
}
iteration = 0;
//if strand changed pointer + 1
if(key==KEY_CHAR_1||key==KEY_CHAR_3||key==KEY_CHAR_4||key==KEY_CHAR_6){
pointer = pointer + 1;
}
//move pointer with arrowkeys
if(key==KEY_CTRL_RIGHT){
pointer = pointer + 1;
}else if(key==KEY_CTRL_LEFT){
pointer = pointer - 1;
}else if(key==KEY_CTRL_UP){
pointery = pointery - 1;
}else if(key==KEY_CTRL_DOWN){
pointery = pointery + 1;
}
//dont move pointer out of range
if(pointer < 1){
pointer = 15;
}else if(pointer > 15){
pointer = 1;
}else if(pointery < 1){
pointery = 4;
}else if(pointery > 4){
pointery = 1;
}
//display strands
RenderStrand(12,2,1,5, dnaone,1);
RenderStrand(12,20,-1,3, dnatwo,1);
RenderStrand(12,22,1,5, mrna,1);
RenderStrand(12,29,1,5, trna,0);
if(pointery==1){
RenderPointer(12, 11, pointer-1);
}else if(pointery==2){
RenderPointer(12,19, pointer-1);
}else if(pointery==3){
RenderPointer(12,31, pointer-1);
}else if(pointery==4){
RenderPointer(12,38, pointer-1);
}
//displa tRNA
RendertRNA(19,38);
RendertRNA(41,38);
RendertRNA(63,38);
RendertRNA(85,38);
RendertRNA(107,38);
RenderResult(13,43,0,1,2,mrna);
RenderResult(35,43,3,4,5,mrna);
RenderResult(57,43,6,7,8,mrna);
RenderResult(79,43,9,10,11,mrna);
RenderResult(101,43,12,13,14,mrna);
}
return 1;
}
//****************************************************************************
//************** ****************
//************** Notice! ****************
//************** ****************
//************** Please do not change the following source. ****************
//************** ****************
//****************************************************************************
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
//****************************************************************************
// InitializeSystem
//
// param : isAppli : 1 = Application / 0 = eActivity
// OptionNum : Option Number (only eActivity)
//
// retval : 1 = No error / 0 = Error
//
//****************************************************************************
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section