-
Notifications
You must be signed in to change notification settings - Fork 0
/
5ComputingGCContent.js
36 lines (27 loc) · 989 Bytes
/
5ComputingGCContent.js
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
/*****************************************************************
*
* Finding Highest GC rate among 10 DNA samples of same lengths
*
* @author iambarack
*
*****************************************************************/
import { rf, wf } from './modules.js'
var dna = rf('./datasets/rosalind_gc.txt').toString()
dna=dna.replace(/>Rosalind_/g,':').replace(/[\r\n]/g, "").split(':').filter(e=>e!="")
console.log(dna);
//dna=dna.split('')
let gcmap = new Map()
for (let o = 0; o < dna.length; o++) {
const el = dna[o].split("");
let gc = 0;
for (let i = 0; i < el.length; i++) {
if(el[i] == 'G' || el[i] == 'C') gc++;
}
gcmap.set("Rosalind_"+dna[o].substring(0,4), 100*(gc/(dna[o].length-4)))
}
gcmap = [...gcmap.entries()].sort((a, b) => b[1] - a[1]);
console.log(gcmap);
console.log("===RESULT===");
console.log("Rosalind_"+gcmap[0][0]+'\n'+gcmap[0][1]);
console.log("====END====");
wf('out/5.txt', JSON.stringify(gcmap))