diff --git a/openmmdl/openmmdl_setup/openmmdlsetup.py b/openmmdl/openmmdl_setup/openmmdlsetup.py index 75b9f107..59af3b4d 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 SetupOptionsConfigurator +from openmmdl.openmmdl_setup.setup_options import SetupOptionsConfigurator, RequestSessionManager from openmmdl.openmmdl_setup.configfile_creator import ConfigCreator from openmmdl.openmmdl_setup.amberscript_creator import AmberScriptGenerator @@ -235,19 +235,8 @@ def setAmberOptions(): saveUploadedFiles() ######## Add Water/Membrane ######## - session["addType"] = request.form.get("addType", "") - session["boxType"] = request.form.get("boxType", "") - session["dist"] = request.form.get("dist", "") - session["lipid_tp"] = request.form.get("lipid_tp", "") - session["other_lipid_tp_input"] = request.form.get("other_lipid_tp_input", "") - session["lipid_ratio"] = request.form.get("lipid_ratio", "") - session["lipid_ff"] = request.form.get("lipid_ff", "") - session["dist2Border"] = request.form.get("dist2Border", "") - session["padDist"] = request.form.get("padDist", "") - session["water_ff"] = request.form.get("water_ff", "") - session["pos_ion"] = request.form.get("pos_ion", "") - session["neg_ion"] = request.form.get("neg_ion", "") - session["ionConc"] = request.form.get("ionConc", "") + form = request.form + session_manager = RequestSessionManager(form) return createAmberBashScript() @@ -269,31 +258,9 @@ def configureDefaultAmberOptions(): def createAmberBashScript(): a_script = [] - a_script.append( - "# This script was generated by OpenMMDL-Setup on %s.\n" % datetime.date.today() - ) - a_script.append( - """ - # ,-----. .-------. .-''-. ,---. .--.,---. ,---.,---. ,---. ______ .---. - # .' .-, '. \ _(`)_ \ .'_ _ \ | \ | || \ / || \ / || _ `''. | ,_| - # / ,-.| \ _ \ | (_ o._)| / ( ` ) '| , \ | || , \/ , || , \/ , || _ | ) _ \,-./ ) - # ; \ '_ / | :| (_,_) /. (_ o _) || |\_ \| || |\_ /| || |\_ /| ||( ''_' ) |\ '_ '`) - # | _`,/ \ _/ || '-.-' | (_,_)___|| _( )_\ || _( )_/ | || _( )_/ | || . (_) `. | > (_) ) - # : ( '\_/ \ ;| | ' \ .---.| (_ o _) || (_ o _) | || (_ o _) | ||(_ ._) '( . .-' - # \ `"/ \ ) / | | \ `-' /| (_,_)\ || (_,_) | || (_,_) | || (_.\.' / `-'`-'|___ - # '. \_/``".' / ) \ / | | | || | | || | | || .' | \ - # '-----' `---' `'-..-' '--' '--''--' '--''--' '--''-----'` `--------` - - - """ - ) - boxType = session.get("boxType") - - a_script.append("#!/bin/bash\n") amber_script = AmberScriptGenerator(session, uploadedFiles) - - + amber_script.add_openmmdl_amber_logo(a_script) # Receptor amber_script.add_receptor_type(a_script) @@ -307,132 +274,23 @@ def createAmberBashScript(): # Combine all components to be modelled. amber_script.add_combine_components_commands(a_script) - # Add Water/Membrane - a_script.append( - "################################ Add Water/Membrane ##############################" - ) ## Box setting amber_script.add_solvation_commands(a_script) amber_script.add_membrane_commands(a_script) - addType = session["addType"] ## Water Setting amber_script.add_water_ff_commands(a_script) - water_ff = session["water_ff"] ## Ion Setting - pos_ion = session["pos_ion"] - if pos_ion != "other_pos_ion": - a_script.append("pos_ion=%s" % session["pos_ion"]) - elif pos_ion == "other_pos_ion": - a_script.append( - "pos_ion=%s # In development!" % session["other_pos_ion_input"] - ) - - neg_ion = session["neg_ion"] - if neg_ion != "other_neg_ion": - a_script.append("neg_ion=%s" % session["neg_ion"]) - elif neg_ion == "other_neg_ion": - a_script.append( - "neg_ion=%s # In development!" % session["other_neg_ion_input"] - ) - - if addType == "addWater": - a_script.append( - "numIon=0 # `numIon` is the flag for `addions` in tleap. When set to 0, the system will be neutralized" - ) - a_script.append("\n") - elif addType == "addMembrane": - a_script.append("ionConc=%s" % session["ionConc"]) - a_script.append("\n") + amber_script.add_ion_commands(a_script) ## Build the membrane - if addType == "addMembrane": - a_script.append("## Build the membrane") - if session["nmLig"] == False and session["spLig"] == False: - a_script.append( - "packmol-memgen --pdb ${rcp_nm}_cnt_rmv.pdb --lipids ${lipid_tp} --ratio ${lipid_ratio} --preoriented --dist ${dist2Border} --dist_wat ${padDist} --salt --salt_c ${pos_ion} --saltcon ${ionConc} --nottrim --overwrite --notprotonate\n" - ) - a_script.append( - "## Clean the complex pdb by `pdb4amber` for further `tleap` process" - ) - a_script.append( - "pdb4amber -i bilayer_${rcp_nm}_cnt_rmv.pdb -o clean_bilayer_${rcp_nm}.pdb" - ) - ## remove 'CONECT' line in the pdb file - a_script.append( - "grep -v '^CONECT' clean_bilayer_${rcp_nm}.pdb > clean_bilayer_${rcp_nm}_cnt_rmv.pdb" - ) - a_script.append("\n") - if session["nmLig"] or session["spLig"]: - a_script.append( - "packmol-memgen --pdb comp.pdb --lipids ${lipid_tp} --ratio ${lipid_ratio} --preoriented --dist ${dist2Border} --dist_wat ${padDist} --salt --salt_c ${pos_ion} --saltcon ${ionConc} --nottrim --overwrite --notprotonate\n" - ) - a_script.append( - "## Clean the complex pdb by `pdb4amber` for further `tleap` process" - ) - a_script.append("pdb4amber -i bilayer_comp.pdb -o clean_bilayer_comp.pdb") - ## remove 'CONECT' line in the pdb file - a_script.append( - "grep -v '^CONECT' clean_bilayer_comp.pdb > clean_bilayer_comp_cnt_rmv.pdb" - ) - a_script.append("\n") + amber_script.add_membrane_building_commands(a_script) # Generate the prmtop and frcmod file for the complex. - a_script.append( - "##################### Generate Prmtop and Frcmod File for the Complex ###################### " - ) - a_script.append("cat > tleap.in < tleap.out") + amber_script.generate_tleap_commands(a_script) + return "\n".join(a_script) @@ -760,20 +618,15 @@ def createScript(): config_creator.add_forcefield_and_water_model_configuration(script) - - config_creator.add_solvent_configuration(script) - + config_creator.add_solvent_configuration(script) # System configuration config_creator.add_system_configuration(script) # Integration options - config_creator.add_integration_configuration(script) # Simulation options - - config_creator.add_simulation_time_and_steps_configuration(script) config_creator.add_equilibration_configuration(script) @@ -782,17 +635,12 @@ def createScript(): config_creator.add_checkpoint_configuration(script) - config_creator.add_xml_serialization_configuration(script) config_creator.add_postprocessing_configuration(script) config_creator.add_openmmdl_analysis_configuration(script) - - - - return "\n".join(script)