From 505c4bb231da4721603230a5a861140cb925b3d4 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Fri, 9 Aug 2024 21:16:40 +0200 Subject: [PATCH] Update openmmdlsetup.py Adjusted with the moval of the script generation --- openmmdl/openmmdl_setup/openmmdlsetup.py | 155 +++-------------------- 1 file changed, 16 insertions(+), 139 deletions(-) diff --git a/openmmdl/openmmdl_setup/openmmdlsetup.py b/openmmdl/openmmdl_setup/openmmdlsetup.py index f30a0097..e060b714 100644 --- a/openmmdl/openmmdl_setup/openmmdlsetup.py +++ b/openmmdl/openmmdl_setup/openmmdlsetup.py @@ -32,7 +32,7 @@ import webbrowser import zipfile -from openmmdl.openmmdl_setup.setup_options import SimulationOptionsConfigurator +from openmmdl.openmmdl_setup.setup_options import SetupOptionsConfigurator from openmmdl.openmmdl_setup.configfile_creator import ConfigCreator @@ -260,35 +260,10 @@ def downloadAmberBashScript(): def configureDefaultAmberOptions(): """Select default options based on the file format and force field.""" - # Ligand - session["nmLig"] = "" - session["spLig"] = "" - session["lig_ff"] = "gaff2" - session["charge_value"] = "0" - session["charge_method"] = "bcc" - - # Receptor - session["prot_ff"] = "ff19SB" - session["dna_ff"] = "OL15" - session["rna_ff"] = "OL3" - session["carbo_ff"] = "GLYCAM_06j" - - # AddWaterMembrane - session["addType"] = "addWater" - session["boxType"] = "cube" - session["dist"] = "10" - - session["lipid_tp"] = "POPC" - session["other_lipid_tp_input"] = "POPC:TOPC" - session["lipid_ratio"] = "1:1" - session["lipid_ff"] = "lipid21" - session["dist2Border"] = "15" - session["padDist"] = "17" - - session["water_ff"] = "opc" - session["pos_ion"] = "Na+" - session["neg_ion"] = "Cl-" - session["ionConc"] = "0.15" + + simulation_configurator = SetupOptionsConfigurator(session) + + simulation_configurator.configureDefaultAmberOptions() def createAmberBashScript(): @@ -1031,123 +1006,25 @@ def configureDefaultOptions(): """Select default options based on the file format and force field.""" # Initialize the configurator with the session - simulation_configurator = SimulationOptionsConfigurator(session) + simulation_configurator = SetupOptionsConfigurator(session) simulation_configurator.configure_default_options() def createScript(): script = [] + config_creator = ConfigCreator(session, uploadedFiles) - # If we are creating this script for internal use to run a simulation directly, add extra code at the top - # to set the working directory and redirect stdout to the pipe. - # Header - - script.append( - "# This script was generated by OpenMMDL Setup on %s.\n" - % datetime.date.today() - ) - script.append( - """ - ,-----. .-------. .-''-. ,---. .--.,---. ,---.,---. ,---. ______ .---. - .' .-, '. \ _(`)_ \ .'_ _ \ | \ | || \ / || \ / || _ `''. | ,_| - / ,-.| \ _ \ | (_ o._)| / ( ` ) '| , \ | || , \/ , || , \/ , || _ | ) _ \,-./ ) - ; \ '_ / | :| (_,_) /. (_ o _) || |\_ \| || |\_ /| || |\_ /| ||( ''_' ) |\ '_ '`) - | _`,/ \ _/ || '-.-' | (_,_)___|| _( )_\ || _( )_/ | || _( )_/ | || . (_) `. | > (_) ) - : ( '\_/ \ ;| | ' \ .---.| (_ o _) || (_ o _) | || (_ o _) | ||(_ ._) '( . .-' - \ `"/ \ ) / | | \ `-' /| (_,_)\ || (_,_) | || (_,_) | || (_.\.' / `-'`-'|___ - '. \_/``".' / ) \ / | | | || | | || | | || .' | \ - '-----' `---' `'-..-' '--' '--''--' '--''--' '--''-----'` `--------` -""" - ) - - script.append( - """ - __ __ ___ __ ___ ___ - / ` / \ |\ | |__ | / _` |__ | | |__ - \__, \__/ | \| | | \__> | | |___ |___ -""" - ) # Input files - script.append("\n# Input Files") - fileType = session["fileType"] - if fileType == "pdb": - script.append("""############# Ligand and Protein Data ###################""") - script.append( - """######## Add the Ligand SDF File and Protein PDB File in the Folder with the Script ######### \n""" - ) - pdbType = session["pdbType"] - if pdbType == "pdb": - script.append('input_file_type = "pdb"') - script.append('protein = "%s"' % uploadedFiles["file"][0][1]) - if session["sdfFile"] != "": - script.append("ligand = '%s'" % session["sdfFile"]) - script.append('ligand_name = "UNK"') - script.append("minimization = %s" % session["ligandMinimization"]) - script.append("smallMoleculeForceField = '%s'" % session["smallMoleculeForceField"]) - script.append("sanitization = %s" % session["ligandSanitization"]) - water = session["waterModel"] - elif fileType == "amber": - script.append( - """####### Add the Amber Files in the Folder with this Script ####### \n""" - ) - # amber_files related variables - if session["has_files"] == "yes": - script.append('input_file_type = "amber"') - script.append("prmtop_file = '%s'" % uploadedFiles["prmtopFile"][0][1]) - script.append('inpcrd_file = "%s"' % uploadedFiles["inpcrdFile"][0][1]) - - # ligand related variables - if session["nmLig"] == True: - nmLigName = session["nmLigName"] # e.g. 'UNL' - else: - nmLigName = None - - if session["spLig"] == True: # success - spLigName = session["spLigName"] # e.g. 'HEME' - else: - spLigName = None - - elif session["has_files"] == "no": - script.append("prmtop_file = 'system.%s.prmtop'" % session["water_ff"]) - script.append("inpcrd_file = 'system.%s.inpcrd' " % session["water_ff"]) - - # ligand related variables - if session["nmLig"] == True: - nmLigFileName = uploadedFiles["nmLigFile"][0][1] # e.g. '8QY.pdb' - nmLigName = extractLigName( - nmLigFileName - ) # e.g '8QY' or 'UNL' # resname in topology - else: - nmLigFileName = None - nmLigName = None - - if session["spLig"] == True: # success - spLigFileName = uploadedFiles["spLigFile"][0][1] - spLigName = extractLigName(spLigFileName) - else: - spLigFileName = None - spLigName = None - - ## Feed prmtop_file and inpcrd_file to OpenMM Reader - script.append("prmtop = AmberPrmtopFile(prmtop_file)") - script.append("inpcrd = AmberInpcrdFile(inpcrd_file)") - - config_creator = ConfigCreator(session) - config_creator.add_forcefield_and_water_model_configuration(script) - - if fileType == "pdb": - script.append( - """\n############# Forcefield, Water and Membrane Model Selection ###################\n""" - ) - script.append("forcefield = '%s'" % session["forcefield"]) - if water != "None": - script.append("water = '%s'" % water) - else: - script.append("water = %s" % water) + + config_creator.add_openmmdl_ascii_art_logo(script) + + config_creator.add_ascii_config_art(script) - ################################## IF CLEANING WAS PERFORMED ############################################## - ########################################################################################################### - ########################################################################################################### + config_creator.add_pdb_input_files_configuration(script) + + config_creator.add_amber_file_configuration(script) + + config_creator.add_forcefield_and_water_model_configuration(script) config_creator.add_solvent_configuration(script)