Skip to content

Commit

Permalink
cleaned up more unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPoppleton committed May 16, 2024
1 parent e2cd1a8 commit 17c7646
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 65 deletions.
43 changes: 12 additions & 31 deletions dist/file_handling/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion dist/ox_serve/live_relax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 14 additions & 32 deletions ts/file_handling/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion ts/ox_serve/live_relax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 17c7646

Please sign in to comment.