From 17c7646a64e5e91e713b3494f576798ba1c2b28b Mon Sep 17 00:00:00 2001 From: Erik Poppleton Date: Thu, 16 May 2024 11:18:04 +0200 Subject: [PATCH] cleaned up more unnecessary code --- dist/file_handling/io.js | 43 ++++++++++------------------------ dist/ox_serve/live_relax.js | 1 - ts/file_handling/io.ts | 46 +++++++++++-------------------------- ts/ox_serve/live_relax.ts | 1 - 4 files changed, 26 insertions(+), 65 deletions(-) diff --git a/dist/file_handling/io.js b/dist/file_handling/io.js index 97f14d2a..33c47773 100644 --- a/dist/file_handling/io.js +++ b/dist/file_handling/io.js @@ -150,7 +150,6 @@ class TrajectoryReader { indexTrajectory() { var worker = new Worker('./dist/file_handling/read_worker.js'); worker.postMessage(this.datFile); - this.firstConf; worker.onmessage = (e) => { let [indices, last, state] = e.data; this.lookupReader.position_lookup = indices; @@ -255,38 +254,20 @@ class TrajectoryReader { // discard the header lines = lines.slice(3); let currentNucleotide, l; - if (this.firstConf) { - this.firstConf = false; - //for each line in the current configuration, read the line and calculate positions - for (let i = 0; i < numNuc; i++) { - if (lines[i] == "" || lines[i].slice(0, 1) == 't') { - notify("WARNING: provided configuration is shorter than topology. Assuming you know what you're doing.", 'warning'); - break; - } - ; - // get the nucleotide associated with the line - currentNucleotide = elements.get(i + system.globalStartId); - // consume a new line from the file - l = lines[i].split(/\s+/); - currentNucleotide.calcPositionsFromConfLine(l); + //for each line in the current configuration, read the line and calculate positions + for (let i = 0; i < numNuc; i++) { + if (lines[i] == "" || lines[i].slice(0, 1) == 't') { + notify("WARNING: provided configuration is shorter than topology. Assuming you know what you're doing.", 'warning'); + break; } - system.callAllUpdates(); - } - else { //Update an existing system - let topDirection = !view.getInputBool("topFormat"); - systems.forEach(system => { - system.strands.forEach((strand) => { - strand.forEach(e => { - let line = lines.shift().split(' '); - e.calcPositionsFromConfLine(line); - }, topDirection); - }); - system.callUpdates(['instanceOffset', 'instanceRotation', 'instanceScale']); - }); - tmpSystems.forEach(system => { - system.callUpdates(['instanceOffset', 'instanceRotation', 'instanceScale']); - }); + ; + // get the nucleotide associated with the line + currentNucleotide = elements.get(i + system.globalStartId); + // consume a new line from the file + l = lines[i].split(/\s+/); + currentNucleotide.calcPositionsFromConfLine(l); } + system.callAllUpdates(); centerAndPBC(system.getMonomers(), newBox); if (forceHandler) forceHandler.redraw(); diff --git a/dist/ox_serve/live_relax.js b/dist/ox_serve/live_relax.js index cbd6e535..67b2b12e 100644 --- a/dist/ox_serve/live_relax.js +++ b/dist/ox_serve/live_relax.js @@ -65,7 +65,6 @@ class OXServeSocket extends WebSocket { super(url); // make a fake reader to recieve the trajectory let oxServeTrajReader = new TrajectoryReader(new File([], 'oxServe.dat'), systems[systems.length - 1]); - oxServeTrajReader.firstConf = false; oxServeTrajReader.system = systems[systems.length - 1]; this.onmessage = (response) => { if (!this.abort) { //ignore all incomming messages when we stop the simulation diff --git a/ts/file_handling/io.ts b/ts/file_handling/io.ts index 3145a5b5..e8dd097f 100644 --- a/ts/file_handling/io.ts +++ b/ts/file_handling/io.ts @@ -180,7 +180,6 @@ class TrajectoryReader { indexTrajectory(){ var worker = new Worker('./dist/file_handling/read_worker.js'); worker.postMessage(this.datFile); - this.firstConf worker.onmessage = (e: MessageEvent) => { let [indices, last, state] = e.data; this.lookupReader.position_lookup=indices; @@ -305,39 +304,22 @@ class TrajectoryReader { let currentNucleotide: BasicElement, l: string[]; - - if (this.firstConf){ - this.firstConf = false; - //for each line in the current configuration, read the line and calculate positions - for (let i = 0; i < numNuc; i++) { - if (lines[i] == "" || lines[i].slice(0, 1) == 't') { - notify("WARNING: provided configuration is shorter than topology. Assuming you know what you're doing.", 'warning') - break - }; - // get the nucleotide associated with the line - currentNucleotide = elements.get(i+system.globalStartId); - // consume a new line from the file - l = lines[i].split(/\s+/); - currentNucleotide.calcPositionsFromConfLine(l); - } - system.callAllUpdates(); - } - else{ //Update an existing system - let topDirection = !view.getInputBool("topFormat") - systems.forEach(system =>{ - system.strands.forEach((strand: Strand) => { - strand.forEach(e => { - let line = lines.shift().split(' '); - e.calcPositionsFromConfLine(line); - }, topDirection); - }); - system.callUpdates(['instanceOffset','instanceRotation', 'instanceScale']); - }); - tmpSystems.forEach(system => { - system.callUpdates(['instanceOffset','instanceRotation', 'instanceScale']); - }); + //for each line in the current configuration, read the line and calculate positions + for (let i = 0; i < numNuc; i++) { + if (lines[i] == "" || lines[i].slice(0, 1) == 't') { + notify("WARNING: provided configuration is shorter than topology. Assuming you know what you're doing.", 'warning') + break + }; + // get the nucleotide associated with the line + currentNucleotide = elements.get(i+system.globalStartId); + // consume a new line from the file + l = lines[i].split(/\s+/); + currentNucleotide.calcPositionsFromConfLine(l); } + + system.callAllUpdates(); + centerAndPBC(system.getMonomers(), newBox); if (forceHandler) forceHandler.redraw(); // Signal that config has been loaded diff --git a/ts/ox_serve/live_relax.ts b/ts/ox_serve/live_relax.ts index ce9779a8..77350ca7 100644 --- a/ts/ox_serve/live_relax.ts +++ b/ts/ox_serve/live_relax.ts @@ -88,7 +88,6 @@ class OXServeSocket extends WebSocket{ // make a fake reader to recieve the trajectory let oxServeTrajReader = new TrajectoryReader(new File([], 'oxServe.dat'), systems[systems.length-1]) - oxServeTrajReader.firstConf = false; oxServeTrajReader.system = systems[systems.length-1] this.onmessage = (response) => {