Skip to content

Commit

Permalink
Update setup_options.py
Browse files Browse the repository at this point in the history
Added additional sessions
  • Loading branch information
talagayev authored Aug 12, 2024
1 parent 75c6da1 commit 7150804
Showing 1 changed file with 84 additions and 7 deletions.
91 changes: 84 additions & 7 deletions openmmdl/openmmdl_setup/setup_options.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

from flask import session, request

class SetupOptionsConfigurator:
def __init__(self, session):
self.session = session

def configure_default_options(self):
"""Select default options based on the file format and force field."""
"""
Sets default simulation options based on session data.
Updates parameters for ensemble type, platform, cutoff, tolerances,
simulation length, and output files.
"""
implicitWater = False
self.session["restart_checkpoint"] = False
self.session["mdtraj_output"] = "mdtraj_pdb_dcd"
Expand Down Expand Up @@ -33,7 +38,7 @@ def configure_default_options(self):
self.session["hmr"] = True
self.session["hmrMass"] = "1.5"
self.session["dt"] = "0.002"
self.session["sim_length"] = "30"
self.session["sim_length"] = "50"
self.session["equilibration"] = "equilibration"
self.session["temperature"] = "300"
self.session["friction"] = "1.0"
Expand Down Expand Up @@ -68,7 +73,11 @@ def configure_default_options(self):
self.session["md_postprocessing"] = "True"

def configureDefaultAmberOptions(self):
"""Select default options based on the file format and force field."""
"""
Sets default options for ligand, receptor, and solvation in Amber.
Configures force fields, ion types, water model, and lipid properties.
"""
# Ligand
self.session["nmLig"] = ""
self.session["spLig"] = ""
Expand Down Expand Up @@ -98,13 +107,30 @@ def configureDefaultAmberOptions(self):
self.session["pos_ion"] = "Na+"
self.session["neg_ion"] = "Cl-"
self.session["ionConc"] = "0.15"


class RequestSessionManager:
def __init__(self, form):
self.form = form

def setAmberOptions_update_session(self):
def setAmberOptions_rcp_session(self):
"""
Sets receptor-related Amber options from form data.
"""
session["rcpType"] = self.form.get("rcpType", "")
session["prot_ff"] = self.form.get("prot_ff", "")
session["other_prot_ff_input"] = self.form.get("other_prot_ff_input", "")
session["dna_ff"] = self.form.get("dna_ff", "")
session["other_dna_ff_input"] = self.form.get("other_dna_ff_input", "")
session["rna_ff"] = self.form.get("rna_ff", "")
session["other_rna_ff_input"] = self.form.get("other_rna_ff_input", "")
session["carbo_ff"] = self.form.get("carbo_ff", "")
session["other_carbo_ff_input"] = self.form.get("other_carbo_ff_input", "")

def setAmberOptions_water_membrane_session(self):
"""
Sets water and membrane-related Amber options from form data.
"""
session["addType"] = self.form.get("addType", "")
session["boxType"] = self.form.get("boxType", "")
session["dist"] = self.form.get("dist", "")
Expand All @@ -118,3 +144,54 @@ def setAmberOptions_update_session(self):
session["pos_ion"] = self.form.get("pos_ion", "")
session["neg_ion"] = self.form.get("neg_ion", "")
session["ionConc"] = self.form.get("ionConc", "")

def addhydrogens_add_water_or_membrane_session(self):
"""
Configures water or membrane settings based on form data.
"""
if "addWater" in self.form:
session["solvent"] = True
session["add_membrane"] = False
padding, boxSize, boxShape = None, None, None

if self.form["boxType"] == "geometry":
session["water_padding"] = True
session["water_padding_distance"] = float(self.form["geomPadding"])
session["water_boxShape"] = self.form["geometryDropdown"]
else:
session["water_padding"] = False
session["box_x"] = float(self.form["boxx"])
session["box_y"] = float(self.form["boxy"])
session["box_z"] = float(self.form["boxz"])
boxSize = (
float(self.form["boxx"]),
float(self.form["boxy"]),
float(self.form["boxz"]),
)
session["water_ionicstrength"] = float(self.form["ionicstrength"])
session["water_positive"] = self.form["positiveion"] + "+"
session["water_negative"] = self.form["negativeion"] + "-"

elif "addMembrane" in self.form:
session["solvent"] = True
session["add_membrane"] = True
session["lipidType"] = self.form["lipidType"]
session["membrane_padding"] = float(self.form["membranePadding"])
session["membrane_ionicstrength"] = float(self.form["ionicstrength"])
session["membrane_positive"] = self.form["positiveion"] + "+"
session["membrane_negative"] = self.form["negativeion"] + "-"

def simulationoptions_add_general_settings(self):
"""
Adds general simulation settings from form data to the session.
"""
for key in self.form:
session[key] = self.form[key]
session["ligand"] = "ligand" in self.form
session["writeDCD"] = "writeDCD" in self.form
session["writeData"] = "writeData" in self.form
session["writeCheckpoint"] = "writeCheckpoint" in self.form
session["dataFields"] = self.form.getlist("dataFields")
session["hmr"] = "hmr" in self.form
session["writeSimulationXml"] = "writeSimulationXml" in self.form
session["writeFinalState"] = "writeFinalState" in self.form

0 comments on commit 7150804

Please sign in to comment.