summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-08-01 16:22:54 -0500
committersanine-a <sanine.not@pm.me>2023-08-01 16:22:54 -0500
commit1dec9525213de7b8c23bf3393b2b76a46e27f6c7 (patch)
treee9216f5390ad80fcd193159503437d9775a415de
parent0fef1e7c013b139229f9814acf030ae25c6fee01 (diff)
remove src/protein/
-rw-r--r--src/protein/protein.js10
-rw-r--r--src/protein/protein.test.js29
2 files changed, 0 insertions, 39 deletions
diff --git a/src/protein/protein.js b/src/protein/protein.js
deleted file mode 100644
index 0223203..0000000
--- a/src/protein/protein.js
+++ /dev/null
@@ -1,10 +0,0 @@
-const xnor = (a, b) => a === b ? 1 : 0;
-
-export function compare(pa, pb) {
- if (pa.length !== pb.length) {
- throw new Error(`attempted to compare proteins with different lengths: ${pa.length} vs ${pb.length}`);
- }
- return (1/pa.length) * pa
- .map((_, i) => xnor(pa[i], pb[i]))
- .reduce((acc, val) => acc + val, 0)
-}
diff --git a/src/protein/protein.test.js b/src/protein/protein.test.js
deleted file mode 100644
index 61c4896..0000000
--- a/src/protein/protein.test.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-
-import { compare } from './protein';
-
-test('compare size-1 proteins', () => {
- expect(compare([0], [0])).toBe(1);
- expect(compare([0], [1])).toBe(0);
- expect(compare([1], [0])).toBe(0);
- expect(compare([1], [1])).toBe(1);
-});
-
-
-test('compare larger proteins', () => {
- expect(compare([0,0], [0,0])).toBe(1);
- expect(compare([1,1], [1,1])).toBe(1);
- expect(compare([0,1], [1,1])).toBeCloseTo(0.5);
- expect(compare([0,1,0], [1,1,1])).toBeCloseTo(1/3);
- expect(compare([0,1,0,1], [1,1,1,1])).toBeCloseTo(0.5);
- expect(compare([0,1,0,1], [0,1,1,1])).toBeCloseTo(0.75);
- expect(compare([0,1,0,1], [0,1,1,0])).toBeCloseTo(0.5);
- expect(compare([0,1,0,0], [0,1,1,0])).toBeCloseTo(0.75);
- expect(compare([0,1,1,0], [0,1,1,0])).toBeCloseTo(1);
-});
-
-
-test('comparisons between differently-sized proteins throw', () => {
- expect(() => compare([0], [0, 0])).toThrow();
- expect(() => compare([0, 0], [0])).toThrow();
-});