-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CRISPR functionality and fix DNA ID retrieval in ElitismUtil… (
#358) * Refactor CRISPR functionality and fix DNA ID retrieval in ElitismUtils.ts * Refactor CRISPR functionality and adjust neuron and synapse connections in CRISPR.ts * Refactor CRISPR functionality and remove tags from synapses in Append.ts * Refactor CRISPR imports to use the latest version of the std library --------- Co-authored-by: Nigel Leck <[email protected]>
- Loading branch information
Showing
96 changed files
with
2,016 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { | |
red, | ||
white, | ||
yellow, | ||
} from "https://deno.land/std@0.223.0/fmt/colors.ts"; | ||
} from "https://deno.land/std@0.224.0/fmt/colors.ts"; | ||
import { addTag, getTag } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Creature } from "../Creature.ts"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { blue, bold, cyan } from "https://deno.land/std@0.223.0/fmt/colors.ts"; | ||
import { blue, bold, cyan } from "https://deno.land/std@0.224.0/fmt/colors.ts"; | ||
import { addTag, getTag } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Creature } from "../Creature.ts"; | ||
import { CreatureUtil } from "./CreatureUtils.ts"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { assert } from "https://deno.land/std@0.223.0/assert/mod.ts"; | ||
import { assert } from "https://deno.land/std@0.224.0/assert/mod.ts"; | ||
import { addTag, getTag } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Creature } from "../../Creature.ts"; | ||
import { TrainOptions } from "../../config/TrainOptions.ts"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts"; | ||
import { Creature } from "../../src/Creature.ts"; | ||
import { CRISPR } from "../../src/reconstruct/CRISPR.ts"; | ||
import { CreatureInternal } from "../../src/architecture/CreatureInterfaces.ts"; | ||
|
||
((globalThis as unknown) as { DEBUG: boolean }).DEBUG = true; | ||
|
||
Deno.test("CRISPR/Append", async () => { | ||
const networkTXT = Deno.readTextFileSync("test/data/CRISPR/network.json"); | ||
const network = Creature.fromJSON(JSON.parse(networkTXT)); | ||
network.validate(); | ||
|
||
const crispr = new CRISPR(network); | ||
const dnaTXT = Deno.readTextFileSync("test/data/CRISPR/DNA-RANGE.json"); | ||
|
||
const networkIF = await crispr.cleaveDNA(JSON.parse(dnaTXT)); | ||
(networkIF as Creature).validate(); | ||
const expectedJSON = JSON.parse( | ||
Deno.readTextFileSync("test/data/CRISPR/expected-range.json"), | ||
); | ||
|
||
const expectedTXT = JSON.stringify( | ||
clean(Creature.fromJSON(expectedJSON).internalJSON()), | ||
null, | ||
2, | ||
); | ||
Deno.writeTextFileSync("test/data/CRISPR/.expected-range.txt", expectedTXT); | ||
|
||
const actualJSON = clean((networkIF as Creature).internalJSON()); | ||
|
||
const actualTXT = JSON.stringify( | ||
actualJSON, | ||
null, | ||
2, | ||
); | ||
|
||
Deno.writeTextFileSync( | ||
"test/data/CRISPR/.actual-range.json", | ||
JSON.stringify((networkIF as Creature).exportJSON(), null, 2), | ||
); | ||
Deno.writeTextFileSync("test/data/CRISPR/.actual-range.txt", actualTXT); | ||
assertEquals(actualTXT, expectedTXT, "should have converted"); | ||
}); | ||
|
||
function clean(creature: CreatureInternal): { uuid: string | undefined } { | ||
const cleanCreature = JSON.parse(JSON.stringify(creature)); | ||
delete cleanCreature.tags; | ||
delete cleanCreature.uuid; | ||
cleanCreature.neurons.forEach((neuron: { uuid: string | undefined }) => { | ||
delete neuron.uuid; | ||
}); | ||
|
||
cleanCreature.synapses.forEach((synapse: { tags: string | undefined }) => { | ||
delete synapse.tags; | ||
}); | ||
return cleanCreature; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { | ||
assert, | ||
assertEquals, | ||
} from "https://deno.land/std@0.223.0/assert/mod.ts"; | ||
} from "https://deno.land/std@0.224.0/assert/mod.ts"; | ||
import { getTag } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Creature } from "../../src/Creature.ts"; | ||
import { CreatureInternal } from "../../src/architecture/CreatureInterfaces.ts"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { | ||
assert, | ||
assertAlmostEquals, | ||
} from "https://deno.land/std@0.223.0/assert/mod.ts"; | ||
} from "https://deno.land/std@0.224.0/assert/mod.ts"; | ||
import { getTag } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { Creature } from "../../src/Creature.ts"; | ||
import { CRISPR } from "../../src/reconstruct/CRISPR.ts"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.