-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomics.html
415 lines (375 loc) · 16.2 KB
/
omics.html
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Omics Tools</title>
<!-- Link to your shared CSS -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Header -->
<header class="header">
<h1>Omics Tools</h1>
<nav class="navbar">
<ul>
<li><a href="index.html">Home</a></li>
</ul>
</nav>
</header>
<main>
<!-- 1) DNA Section (unchanged) -->
<section id="dna-section" class="calc-section active">
<h2>DNA Tools</h2>
<p>
Input a DNA sequence (using A, T, G, C). We’ll calculate:
<ul>
<li><strong>Length</strong> of the sequence</li>
<li><strong>GC content</strong></li>
<li><strong>Reverse complement</strong></li>
<li><strong>Transcription</strong> (DNA → RNA)</li>
<li><strong>Translation</strong> (DNA → protein)</li>
<li><strong>Base counts</strong> (our extra idea)</li>
</ul>
</p>
<form class="calc-form">
<div class="form-group">
<label for="dnaInput">DNA Sequence</label>
<textarea id="dnaInput" placeholder="e.g., ATGCGT..." rows="3"></textarea>
</div>
<!-- Buttons: Calculate + Clear -->
<button type="button" id="dnaCalcBtn" class="primary-btn">Calculate DNA Info</button>
<button type="button" id="dnaClearBtn" class="primary-btn" style="background-color:#999;">
Clear
</button>
</form>
<div id="dnaResult" class="result-box"></div>
</section>
<!-- 2) RNA Section (unchanged) -->
<section id="rna-section" class="calc-section active">
<h2>RNA Tools</h2>
<p>
Input an RNA sequence (using A, U, G, C). We’ll compute:
<ul>
<li><strong>Length</strong> of the sequence</li>
<li><strong>GC content</strong></li>
<li><strong>Reverse complement</strong> (RNA-based; complement pairs A–U, G–C)</li>
<li><strong>Reverse transcription</strong> (RNA → DNA)</li>
<li><strong>Translation</strong> (RNA → protein)</li>
<li><strong>Check for start codon</strong> (AUG), etc.</li>
</ul>
</p>
<form class="calc-form">
<div class="form-group">
<label for="rnaInput">RNA Sequence</label>
<textarea id="rnaInput" placeholder="e.g., AUGCGU..." rows="3"></textarea>
</div>
<!-- Buttons: Calculate + Clear -->
<button type="button" id="rnaCalcBtn" class="primary-btn">Calculate RNA Info</button>
<button type="button" id="rnaClearBtn" class="primary-btn" style="background-color:#999;">
Clear
</button>
</form>
<div id="rnaResult" class="result-box"></div>
</section>
<!-- 3) Protein Section: One-letter input only, always output both one- and three-letter -->
<section id="protein-section" class="calc-section active">
<h2>Protein Tools</h2>
<p>
Input a protein sequence in <strong>one-letter</strong> code only
(<em>A, R, N, D, C, E, Q, G, H, I, L, K, M, F, P, S, T, W, Y, V</em>).
We’ll compute:
<ul>
<li><strong>Length</strong> (number of amino acids)</li>
<li><strong>Composition</strong> (# of each AA)</li>
<li><strong>Reverse translation</strong> (protein → naive RNA codons)</li>
<li>Show the final sequence in <strong>both</strong> 1-letter and 3-letter forms</li>
</ul>
</p>
<form class="calc-form">
<div class="form-group">
<label for="protInput">Protein Sequence (One-letter only)</label>
<textarea id="protInput" placeholder="e.g., AGPN" rows="3"></textarea>
</div>
<!-- Buttons: Calculate + Clear -->
<button type="button" id="protCalcBtn" class="primary-btn">Calculate Protein Info</button>
<button type="button" id="protClearBtn" class="primary-btn" style="background-color:#999;">
Clear
</button>
</form>
<div id="protResult" class="result-box"></div>
</section>
</main>
<!-- Embedded JS -->
<script>
/*********************************************
* CODON & PROTEIN TABLES
*********************************************/
const CODON_TABLE = {
"UUU": { "one_letter": "F", "three_letter": "Phe" },
"UUC": { "one_letter": "F", "three_letter": "Phe" },
"UUA": { "one_letter": "L", "three_letter": "Leu" },
"UUG": { "one_letter": "L", "three_letter": "Leu" },
"UCU": { "one_letter": "S", "three_letter": "Ser" },
"UCC": { "one_letter": "S", "three_letter": "Ser" },
"UCA": { "one_letter": "S", "three_letter": "Ser" },
"UCG": { "one_letter": "S", "three_letter": "Ser" },
"UAU": { "one_letter": "Y", "three_letter": "Tyr" },
"UAC": { "one_letter": "Y", "three_letter": "Tyr" },
"UAA": { "one_letter": "*", "three_letter": "Stop" },
"UAG": { "one_letter": "*", "three_letter": "Stop" },
"UGU": { "one_letter": "C", "three_letter": "Cys" },
"UGC": { "one_letter": "C", "three_letter": "Cys" },
"UGA": { "one_letter": "*", "three_letter": "Stop" },
"UGG": { "one_letter": "W", "three_letter": "Trp" },
"CUU": { "one_letter": "L", "three_letter": "Leu" },
"CUC": { "one_letter": "L", "three_letter": "Leu" },
"CUA": { "one_letter": "L", "three_letter": "Leu" },
"CUG": { "one_letter": "L", "three_letter": "Leu" },
"CCU": { "one_letter": "P", "three_letter": "Pro" },
"CCC": { "one_letter": "P", "three_letter": "Pro" },
"CCA": { "one_letter": "P", "three_letter": "Pro" },
"CCG": { "one_letter": "P", "three_letter": "Pro" },
"CAU": { "one_letter": "H", "three_letter": "His" },
"CAC": { "one_letter": "H", "three_letter": "His" },
"CAA": { "one_letter": "Q", "three_letter": "Gln" },
"CAG": { "one_letter": "Q", "three_letter": "Gln" },
"CGU": { "one_letter": "R", "three_letter": "Arg" },
"CGC": { "one_letter": "R", "three_letter": "Arg" },
"CGA": { "one_letter": "R", "three_letter": "Arg" },
"CGG": { "one_letter": "R", "three_letter": "Arg" },
"AUU": { "one_letter": "I", "three_letter": "Ile" },
"AUC": { "one_letter": "I", "three_letter": "Ile" },
"AUA": { "one_letter": "I", "three_letter": "Ile" },
"AUG": { "one_letter": "M", "three_letter": "Met" },
"ACU": { "one_letter": "T", "three_letter": "Thr" },
"ACC": { "one_letter": "T", "three_letter": "Thr" },
"ACA": { "one_letter": "T", "three_letter": "Thr" },
"ACG": { "one_letter": "T", "three_letter": "Thr" },
"AAU": { "one_letter": "N", "three_letter": "Asn" },
"AAC": { "one_letter": "N", "three_letter": "Asn" },
"AAA": { "one_letter": "K", "three_letter": "Lys" },
"AAG": { "one_letter": "K", "three_letter": "Lys" },
"AGU": { "one_letter": "S", "three_letter": "Ser" },
"AGC": { "one_letter": "S", "three_letter": "Ser" },
"AGA": { "one_letter": "R", "three_letter": "Arg" },
"AGG": { "one_letter": "R", "three_letter": "Arg" },
"GUU": { "one_letter": "V", "three_letter": "Val" },
"GUC": { "one_letter": "V", "three_letter": "Val" },
"GUA": { "one_letter": "V", "three_letter": "Val" },
"GUG": { "one_letter": "V", "three_letter": "Val" },
"GCU": { "one_letter": "A", "three_letter": "Ala" },
"GCC": { "one_letter": "A", "three_letter": "Ala" },
"GCA": { "one_letter": "A", "three_letter": "Ala" },
"GCG": { "one_letter": "A", "three_letter": "Ala" },
"GAU": { "one_letter": "D", "three_letter": "Asp" },
"GAC": { "one_letter": "D", "three_letter": "Asp" },
"GAA": { "one_letter": "E", "three_letter": "Glu" },
"GAG": { "one_letter": "E", "three_letter": "Glu" },
"GGU": { "one_letter": "G", "three_letter": "Gly" },
"GGC": { "one_letter": "G", "three_letter": "Gly" },
"GGA": { "one_letter": "G", "three_letter": "Gly" },
"GGG": { "one_letter": "G", "three_letter": "Gly" }
};
const PROTEIN_TABLE = {
"A": { "three_letter": "Ala", "full_name": "Alanine" },
"R": { "three_letter": "Arg", "full_name": "Arginine" },
"N": { "three_letter": "Asn", "full_name": "Asparagine" },
"D": { "three_letter": "Asp", "full_name": "Aspartic acid" },
"C": { "three_letter": "Cys", "full_name": "Cysteine" },
"E": { "three_letter": "Glu", "full_name": "Glutamic acid" },
"Q": { "three_letter": "Gln", "full_name": "Glutamine" },
"G": { "three_letter": "Gly", "full_name": "Glycine" },
"H": { "three_letter": "His", "full_name": "Histidine" },
"I": { "three_letter": "Ile", "full_name": "Isoleucine" },
"L": { "three_letter": "Leu", "full_name": "Leucine" },
"K": { "three_letter": "Lys", "full_name": "Lysine" },
"M": { "three_letter": "Met", "full_name": "Methionine" },
"F": { "three_letter": "Phe", "full_name": "Phenylalanine" },
"P": { "three_letter": "Pro", "full_name": "Proline" },
"S": { "three_letter": "Ser", "full_name": "Serine" },
"T": { "three_letter": "Thr", "full_name": "Threonine" },
"W": { "three_letter": "Trp", "full_name": "Tryptophan" },
"Y": { "three_letter": "Tyr", "full_name": "Tyrosine" },
"V": { "three_letter": "Val", "full_name": "Valine" }
};
/*********************************************
* DNA TOOLS
*********************************************/
const dnaCalcBtn = document.getElementById('dnaCalcBtn');
const dnaClearBtn = document.getElementById('dnaClearBtn');
const dnaInput = document.getElementById('dnaInput');
const dnaResult = document.getElementById('dnaResult');
dnaCalcBtn.addEventListener('click', () => {
let seq = dnaInput.value.trim().toUpperCase();
if (!seq) {
dnaResult.textContent = 'Please enter a DNA sequence.';
return;
}
if (!/^[ACGT]+$/.test(seq)) {
dnaResult.textContent = 'Invalid characters found. Use only A, C, G, T.';
return;
}
const length = seq.length;
let gCount = 0, cCount = 0;
for (const base of seq) {
if (base === 'G') gCount++;
if (base === 'C') cCount++;
}
const gcContent = ((gCount + cCount) / length) * 100;
const complements = { A: 'T', T: 'A', C: 'G', G: 'C' };
let revCompArr = [];
for (let i = seq.length - 1; i >= 0; i--) {
revCompArr.push(complements[seq[i]]);
}
const revComp = revCompArr.join('');
// Transcription
const rnaSeq = seq.replace(/T/g, 'U');
// Translation
let proteinOne = '';
for (let i = 0; i < rnaSeq.length; i += 3) {
const codon = rnaSeq.substring(i, i+3);
if (codon.length < 3) break;
proteinOne += CODON_TABLE[codon] ? CODON_TABLE[codon].one_letter : 'X';
}
const aCount = (seq.match(/A/g) || []).length;
const tCount = (seq.match(/T/g) || []).length;
dnaResult.innerHTML = `
<p><strong>Length:</strong> ${length} bases</p>
<p><strong>GC Content:</strong> ${gcContent.toFixed(2)}%</p>
<p><strong>Reverse Complement:</strong> ${revComp}</p>
<p><strong>Transcribed RNA:</strong> ${rnaSeq}</p>
<p><strong>Translated Protein (1-letter):</strong> ${proteinOne}</p>
<p><strong>Base Counts:</strong> A=${aCount}, T=${tCount}, G=${gCount}, C=${cCount}</p>
`;
});
dnaClearBtn.addEventListener('click', () => {
dnaInput.value = '';
dnaResult.innerHTML = '';
});
/*********************************************
* RNA TOOLS
*********************************************/
const rnaCalcBtn = document.getElementById('rnaCalcBtn');
const rnaClearBtn = document.getElementById('rnaClearBtn');
const rnaInput = document.getElementById('rnaInput');
const rnaResult = document.getElementById('rnaResult');
rnaCalcBtn.addEventListener('click', () => {
let seq = rnaInput.value.trim().toUpperCase();
if (!seq) {
rnaResult.textContent = 'Please enter an RNA sequence.';
return;
}
if (!/^[ACGU]+$/.test(seq)) {
rnaResult.textContent = 'Invalid characters found. Use only A, C, G, U.';
return;
}
const length = seq.length;
let gCount = 0, cCount = 0;
for (const base of seq) {
if (base === 'G') gCount++;
if (base === 'C') cCount++;
}
const gcContent = ((gCount + cCount) / length) * 100;
const complements = { A: 'U', U: 'A', C: 'G', G: 'C' };
let revCompArr = [];
for (let i = seq.length - 1; i >= 0; i--) {
revCompArr.push(complements[seq[i]]);
}
const revComp = revCompArr.join('');
// Reverse transcription (RNA->DNA)
const dnaSeq = seq.replace(/U/g, 'T');
// Translation
let proteinOne = '';
for (let i = 0; i < seq.length; i += 3) {
const codon = seq.substring(i, i+3);
if (codon.length < 3) break;
proteinOne += CODON_TABLE[codon] ? CODON_TABLE[codon].one_letter : 'X';
}
const hasStart = seq.includes('AUG');
rnaResult.innerHTML = `
<p><strong>Length:</strong> ${length} bases</p>
<p><strong>GC Content:</strong> ${gcContent.toFixed(2)}%</p>
<p><strong>Reverse Complement (RNA-based):</strong> ${revComp}</p>
<p><strong>Reverse Transcription (DNA seq):</strong> ${dnaSeq}</p>
<p><strong>Translated Protein (1-letter):</strong> ${proteinOne}</p>
<p><strong>Start Codon Found?</strong> ${hasStart ? 'Yes (AUG)' : 'No'}</p>
`;
});
rnaClearBtn.addEventListener('click', () => {
rnaInput.value = '';
rnaResult.innerHTML = '';
});
/*********************************************
* PROTEIN TOOLS: One-letter input only
* Always display both 1-letter & 3-letter
*********************************************/
const protCalcBtn = document.getElementById('protCalcBtn');
const protClearBtn = document.getElementById('protClearBtn');
const protInput = document.getElementById('protInput');
const protResult = document.getElementById('protResult');
protCalcBtn.addEventListener('click', () => {
let seq = protInput.value.trim().toUpperCase();
if (!seq) {
protResult.textContent = 'Please enter a protein sequence (one-letter).';
return;
}
// remove dashes
seq = seq.replace(/-/g, '');
// validate: only A,R,N,D,C,E,Q,G,H,I,L,K,M,F,P,S,T,W,Y,V
if (!/^[ARNDCEQGHILKMFPSTWYV]+$/.test(seq)) {
protResult.textContent = 'Invalid characters found. Use only valid single-letter codes (A,R,N,D,C,E,Q,G,H,I,L,K,M,F,P,S,T,W,Y,V).';
return;
}
// Convert to array
const aminoArr = seq.split('');
// 1) length
const length = aminoArr.length;
// 2) composition
let compMap = {};
for (const aa of aminoArr) {
compMap[aa] = (compMap[aa] || 0) + 1;
}
let compStr = Object.keys(compMap).sort().map(k => `${k}:${compMap[k]}`).join(', ');
// 3) Reverse translation => naive RNA
let letterToCodon = {};
for (const codon in CODON_TABLE) {
const one = CODON_TABLE[codon].one_letter;
if (!letterToCodon[one]) {
letterToCodon[one] = codon;
}
}
let naiveRNA = '';
for (const aa of aminoArr) {
if (letterToCodon[aa]) {
naiveRNA += letterToCodon[aa];
} else {
naiveRNA += 'NNN';
}
}
// 4) Build both 1-letter and 3-letter output
const oneLetter = aminoArr.join('');
let threeLetterArr = aminoArr.map(one => {
if (PROTEIN_TABLE[one]) {
return PROTEIN_TABLE[one].three_letter;
} else {
return 'Xxx';
}
});
const threeLetter = threeLetterArr.join('-');
// final result
protResult.innerHTML = `
<p><strong>Length:</strong> ${length}</p>
<p><strong>Composition:</strong> ${compStr}</p>
<p><strong>Naive Reverse Translation (RNA):</strong> ${naiveRNA}</p>
<p><strong>One-letter Output:</strong> ${oneLetter}</p>
<p><strong>Three-letter Output:</strong> ${threeLetter}</p>
`;
});
protClearBtn.addEventListener('click', () => {
protInput.value = '';
protResult.innerHTML = '';
});
</script>
</body>
</html>