Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hoist out plasmid cache and remove unused canvases
- Loading branch information
Showing
2 changed files
with
101 additions
and
81 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/req/renderer/containers/circularGenome/cachedPlasmid.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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Plasmid } from '../../../ngplasmid/lib/plasmid'; | ||
import { CircularFigure, buildBaseFigureTemplate, assembleCompilableTemplates, assembleCompilableCoverageTrack } from '../../circularFigure/circularFigure'; | ||
import {Node, loadFromString } from '../../../ngplasmid/lib/html'; | ||
|
||
export interface CachedPlasmid | ||
{ | ||
uuid : string; | ||
plasmid : Plasmid | ||
} | ||
|
||
let plasmidCache = new Array<CachedPlasmid>(); | ||
|
||
export async function loadPlasmid(target : string,figure : CircularFigure) : Promise<CachedPlasmid| undefined> | ||
{ | ||
let scope = {genome : figure}; | ||
if(target == figure.uuid) | ||
{ | ||
console.log("Loading base figure"); | ||
console.log(figure.name); | ||
|
||
let plasmid : Plasmid = new Plasmid(); | ||
plasmid.$scope = scope; | ||
|
||
let nodes : Array<Node> = await loadFromString( | ||
assembleCompilableTemplates(figure, | ||
buildBaseFigureTemplate(figure) | ||
) | ||
); | ||
|
||
for(let i = 0; i != nodes.length; ++i) | ||
{ | ||
if(nodes[i].name == "div") | ||
{ | ||
for(let k = 0; k != nodes[i].children.length; ++k) | ||
{ | ||
if(nodes[i].children[k].name == "plasmid") | ||
{ | ||
plasmid.fromNode(nodes[i].children[k]); | ||
return { | ||
uuid : figure.uuid, | ||
plasmid : plasmid | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
else | ||
{ | ||
let coverageTrack = figure.renderedCoverageTracks.find((x) => x.uuid == target); | ||
if(coverageTrack) | ||
{ | ||
let plasmid : Plasmid = new Plasmid(); | ||
plasmid.$scope = scope; | ||
|
||
let nodes : Array<Node> = await loadFromString(assembleCompilableCoverageTrack(figure,coverageTrack)); | ||
|
||
for(let i = 0; i != nodes.length; ++i) | ||
{ | ||
if(nodes[i].name == "div") | ||
{ | ||
for(let k = 0; k != nodes[i].children.length; ++k) | ||
{ | ||
if(nodes[i].children[k].name == "plasmid") | ||
{ | ||
plasmid.fromNode(nodes[i].children[k]); | ||
plasmidCache = [ | ||
...plasmidCache, | ||
{ | ||
uuid : target, | ||
plasmid : plasmid | ||
} | ||
]; | ||
|
||
return {uuid:target,plasmid:plasmid}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return undefined; | ||
} |
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