-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
60 lines (55 loc) · 1.79 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const assert = require("assert");
const { getSequenceFileForType } = require("./helperFns");
const it = (desc, fn) => {
try {
fn();
console.info("\x1b[32m%s\x1b[0m", `\u2714 ${desc}`);
} catch (error) {
console.info("\n");
console.info("\x1b[31m%s\x1b[0m", `\u2718 ${desc}`);
console.error(error);
}
};
it(`can generate genbanks`, () => {
const gbs = getSequenceFileForType({
type: "gb",
toFile: false,
});
assert.strictEqual(gbs.length, 10);
assert.strictEqual(gbs[0].includes("LOCUS pTG_001"), true);
assert.strictEqual(gbs[0].includes("//\n"), true);
assert.strictEqual(gbs[0].length > 1000, true);
assert.strictEqual(gbs[9].includes("LOCUS pTG_0010"), true);
});
it(`can generate genbanks passing defined lengths`, () => {
const gbs = getSequenceFileForType({
type: "gb",
toFile: false,
lengths: "40,41",
});
assert.strictEqual(gbs.length, 10);
assert.strictEqual(gbs[0].includes("LOCUS pTG_001"), true);
assert.strictEqual(gbs[0].includes("//\n"), true);
assert.strictEqual(getLength(gbs[0]), 40);
assert.strictEqual(getLength(gbs[1]), 41);
assert.strictEqual(getLength(gbs[2]), 40);
assert.strictEqual(getLength(gbs[3]), 41);
assert.strictEqual(gbs[9].includes("LOCUS pTG_0010"), true);
});
it(`can generate fasta`, () => {
const gbs = getSequenceFileForType({
type: "fasta",
toFile: false,
});
assert.strictEqual(gbs.length, 10);
assert.strictEqual(gbs[0].includes("LOCUS pTG_001"), true);
assert.strictEqual(gbs[0].includes("//\n"), true);
assert.strictEqual(gbs[0].length > 1000, true);
assert.strictEqual(gbs[9].includes("LOCUS pTG_0010"), true);
});
function getLength(a) {
return a
.match(` 1 .*\n`)[0]
.replace(" 1 ", "")
.replace("\n", "").length;
}