Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPoppleton committed Nov 4, 2024
2 parents 661d9a4 + ea0e3b8 commit 912d0d6
Show file tree
Hide file tree
Showing 21 changed files with 739 additions and 100 deletions.
2 changes: 1 addition & 1 deletion dist/UI/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ class fluxGraph {
// this.chart.toBase64Image();
//}
},
responsiveAnimationDuration: 0,
responsiveAnimationDuration: 0, // animation duration after a resize
responsive: true,
title: {
display: true,
Expand Down
33 changes: 33 additions & 0 deletions dist/api/plugin_api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// let's define a storage structure for the plugin API
// it will sit in local storage and load the code for the individual plugins named as key
// and the code as value packed away in a JSON object hidden at the key "plugins" in local storage
// this is the object that will be stored in local storage
// it will contain the code for the individual plugins
// the key will be the name of the plugin, the value will be the code
let plugins = {};
// this function will load the plugins from local storage
// it will be called at the beginning of the program
function loadPlugins() {
let pluginsString = localStorage.getItem("plugins");
if (pluginsString) {
plugins = JSON.parse(pluginsString);
}
// if there are no plugins in local storage, we will create an empty object
else {
plugins = {}; //"test": plugin_code};
}
//iterate over all the plugins and load them
for (let plugin in plugins) {
eval(plugins[plugin]);
}
}
// this function will save the plugins to local storage (it will be called any time we add a new plugin)
function savePlugins() {
localStorage.setItem("plugins", JSON.stringify(plugins));
}
function addPlugin(name, plugin_code) {
plugins[name] = plugin_code;
eval(plugin_code);
savePlugins();
}
loadPlugins();
47 changes: 36 additions & 11 deletions dist/file_handling/aux_readers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,47 @@ const handleCSV = (file) => {
render();
});
};
//parse a trap file
function readTrap(trapFile) {
trapFile.text().then(text => {
function readForce(forceFile) {
forceFile.text().then(text => {
//{ can be replaced with \n to make sure no parameter is lost
while (text.indexOf("{") >= 0)
text = text.replace("{", "\n");
// traps can be split by } because everything between {} is one trap
let traps = text.split("}");
// forces can be split by } because everything between {} is one force
let forces = text.split("}");
let trap_objs = [];
traps.forEach((trap) => {
let lines = trap.split('\n');
forces.forEach((force) => {
let lines = force.split('\n');
//empty lines and empty traps need not be processed as well as comments
lines = lines.filter((line) => line !== "" && !line.startsWith("#"));
if (lines.length == 0)
return;
let trap_obj = {};
lines.forEach((line) => {
// remove comments
let com_pos = line.indexOf("#");
if (com_pos >= 0)
line = line.slice(0, com_pos).trim();
//another chance an empty line can be encountered. Remove whitespace
// another chance an empty line can be encountered. Remove whitespace
if (line.trim().length == 0)
return;
//split into option name and value
// split into option name and value
let options = line.split("=");
let lft = options[0].trim();
let rght = options[1].trim();
trap_obj[lft] = Number.isNaN(parseFloat(rght)) ? rght : parseFloat(rght);
// Check if the string represents a list of floats (numbers separated by commas)
if (rght.includes(',')) {
// Split the string by commas and convert each part to a float
let floatList = rght.split(',').map(Number);
trap_obj[lft] = floatList;
}
else if (/^-?\d+(\.\d+)?$/.test(rght)) {
// Check if the entire string is a valid number
trap_obj[lft] = parseFloat(rght);
}
else {
// Otherwise, treat it as a string
trap_obj[lft] = rght;
}
});
if (Object.keys(trap_obj).length > 0)
trap_objs.push(trap_obj);
Expand All @@ -146,8 +159,20 @@ function readTrap(trapFile) {
skewTrap.update();
forces.push(skewTrap);
break;
case "repulsion_plane":
let repPlane = new RepulsionPlane();
repPlane.setFromParsedJson(f);
repPlane.update();
forces.push(repPlane);
break;
case "attraction_plane":
let attrPlane = new AttractionPlane();
attrPlane.setFromParsedJson(f);
attrPlane.update();
forces.push(attrPlane);
break;
default:
notify(`External force ${f["type"]} type not supported yet, feel free to implement in aux_readers.ts and force.ts`);
notify(`External force -${f["type"]}- type not supported yet, feel free to implement in aux_readers.ts and force.ts`);
break;
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/file_handling/file_handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function handleFiles(files) {
auxFiles.push(new File2reader(files[i], 'json', readJson));
}
else if (ext === "txt" && (fileName.includes("trap") || fileName.includes("force"))) {
auxFiles.push(new File2reader(files[i], 'force', readTrap));
auxFiles.push(new File2reader(files[i], 'force', readForce));
}
else if (ext === "txt" && (fileName.includes("_m"))) {
auxFiles.push(new File2reader(files[i], 'mass', readMassFile));
Expand Down
10 changes: 5 additions & 5 deletions dist/file_handling/order_parameter_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ let loadHyperSelector = () => {
// mode:"dataset", // it is possible to remove the line view from the plot
// intersect:true // on hover, but i find it to distracting
},
responsiveAnimationDuration: 0,
responsiveAnimationDuration: 0, // animation duration after a resize
scales: {
xAxes: [{ display: true, scaleLabel: { display: true, labelString: 'Time' }, gridLines: { drawOnChartArea: false } }],
yAxes: [{ display: true, gridLines: { drawOnChartArea: false } }],
},
spanGaps: true,
spanGaps: true, // handle null in the chart data
annotation: {
events: ["click"],
annotations: [
Expand Down Expand Up @@ -143,7 +143,7 @@ let handleParameterDrop = (files) => {
else {
console.log("adding new axis");
myChart.options.scales.yAxes.push({
type: 'linear',
type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
display: true,
position: 'left',
id: `y-axis-id${axis_counter}`,
Expand All @@ -159,7 +159,7 @@ let handleParameterDrop = (files) => {
labels: labels,
datasets: [
{
label: parameter_name,
label: parameter_name, //files[0].name.split(".")[0],
data: data,
fill: false,
borderColor: chartColorMap.get(),
Expand All @@ -170,7 +170,7 @@ let handleParameterDrop = (files) => {
}
else {
myChart.data.datasets.push({
label: parameter_name,
label: parameter_name, //files[i].name.split(".")[0],
data: data,
fill: false,
borderColor: chartColorMap.get(),
Expand Down
14 changes: 7 additions & 7 deletions dist/file_handling/output_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ function getNewIds(useNew = false) {
});
// these subtypes are not implemented in the CG-oxDNA model, just used for a 'relative' subtype that oxDNA will take as input
let gsSubtypes = {
subtypelist: [],
masses: [],
radii: [],
subtypelist: [], // per particle subtype assignment
masses: [], //
radii: [], //
subtype: -1
};
// Next, generic sphere objects
Expand Down Expand Up @@ -477,9 +477,9 @@ function makeUNFOutput(name) {
let naStrandsSchema = {
"id": strand.id,
"name": strand.label,
"isScaffold": strand.getLength() > 1000 ? true : false,
"naType": strand.end5.isDNA() ? "DNA" : "RNA",
"color": strand.end5.color ? '#'.concat(strand.end5.color.getHexString()) : '',
"isScaffold": strand.getLength() > 1000 ? true : false, //entirely arbitrary, but generally right.
"naType": strand.end5.isDNA() ? "DNA" : "RNA", // Nucleotide type is actually pretty poorly defined in oxView, so this is the best I can do
"color": strand.end5.color ? '#'.concat(strand.end5.color.getHexString()) : '', // OxView defines colors on a per-nucleotide level while UNF defines it at the strand level.
"fivePrimeId": strand.end5.id,
"threePrimeId": strand.end3.id,
"pdbFileId": 0,
Expand All @@ -504,7 +504,7 @@ function makeUNFOutput(name) {
let aaChainSchema = {
"id": strand.id,
"chainName": strand.label,
"color": strand.end5.color ? '#'.concat(strand.end5.color.getHexString()) : '',
"color": strand.end5.color ? '#'.concat(strand.end5.color.getHexString()) : '', // OxView defines colors on a per-nucleotide level while UNF defines it at the strand level.
"pdbFileId": 0,
"nTerm": strand.end5.id,
"cTerm": strand.end3.id,
Expand Down
44 changes: 22 additions & 22 deletions dist/file_handling/pdb_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,48 @@ this.onmessage = function (e) {
postMessage(ret, undefined);
};
var backboneColors = [
new THREE.Color(0xfdd291),
new THREE.Color(0xffb322),
new THREE.Color(0x437092),
new THREE.Color(0xfdd291), //light yellow
new THREE.Color(0xffb322), //goldenrod
new THREE.Color(0x437092), //dark blue
new THREE.Color(0x6ea4cc), //light blue
];
var nucleosideColors = [
new THREE.Color(0x4747B8),
new THREE.Color(0xFFFF33),
new THREE.Color(0x4747B8), //A or K; Royal Blue
new THREE.Color(0xFFFF33), //G or C; Medium Yellow
//C or A
new THREE.Color(0x8CFF8C),
new THREE.Color(0x8CFF8C), //Medium green
//T/U or T
new THREE.Color(0xFF3333),
new THREE.Color(0xFF3333), //Red
//E
new THREE.Color(0x660000),
new THREE.Color(0x660000), //Dark Brown
//S
new THREE.Color(0xFF7042),
new THREE.Color(0xFF7042), //Medium Orange
//D
new THREE.Color(0xA00042),
new THREE.Color(0xA00042), //Dark Rose
//N
new THREE.Color(0xFF7C70),
new THREE.Color(0xFF7C70), //Light Salmon
//Q
new THREE.Color(0xFF4C4C),
new THREE.Color(0xFF4C4C), //Dark Salmon
//H
new THREE.Color(0x7070FF),
new THREE.Color(0x7070FF), //Medium Blue
//G
new THREE.Color(0xEBEBEB),
new THREE.Color(0xEBEBEB), // light GREY
//P
new THREE.Color(0x525252),
new THREE.Color(0x525252), //Dark Grey
//R
new THREE.Color(0x00007C),
new THREE.Color(0x00007C), //Dark Blue
//V
new THREE.Color(0x5E005E),
new THREE.Color(0x5E005E), //Dark Purple
//I
new THREE.Color(0x004C00),
new THREE.Color(0x004C00), //Dark Green
//L
new THREE.Color(0x455E45),
new THREE.Color(0x455E45), //Olive Green
//M
new THREE.Color(0xB8A042),
new THREE.Color(0xB8A042), //Light Brown
//F
new THREE.Color(0x534C42),
new THREE.Color(0x534C42), //Olive Grey
//Y
new THREE.Color(0x8C704C),
new THREE.Color(0x8C704C), //Medium Brown
//W
new THREE.Color(0x4F4600), //Olive Brown
];
Expand Down
Loading

0 comments on commit 912d0d6

Please sign in to comment.