def test_mdrun_docker(self): returncode = Mdrun(properties=self.properties, **self.paths).launch() assert fx.not_empty(self.paths['output_trr_path']) assert gmx_rms(self.paths['output_trr_path'], self.paths['ref_output_trr_path'], self.paths['input_tpr_path'], self.properties.get('gmx_path', 'gmx')) assert fx.not_empty(self.paths['output_gro_path']) assert fx.not_empty(self.paths['output_edr_path']) assert fx.not_empty(self.paths['output_log_path']) assert fx.exe_success(returncode)
def _mdrun(input_tpr_path, output_trr_path, output_gro_path, output_edr_path, output_log_path, input_cpt_path, output_xtc_path, output_cpt_path, output_dhdl_path, properties, **kwargs): task_config.config_multinode(properties) try: Mdrun(input_tpr_path=input_tpr_path, output_trr_path=output_trr_path, output_gro_path=output_gro_path, output_edr_path=output_edr_path, output_log_path=output_log_path, input_cpt_path=input_cpt_path, output_xtc_path=output_xtc_path, output_cpt_path=output_cpt_path, output_dhdl_path=output_dhdl_path, properties=properties, **kwargs).launch() except Exception as e: traceback.print_exc() raise e finally: sys.stdout.flush() sys.stderr.flush()
# ## Execute system equilibration # Execute the energy minimization using the MDrun module and the input the portable binary run file (.tpr) as the main input. # The main output of this BB will be updated structure file (.gro) and the [Gromacs trajectory file](http://manual.gromacs.org/documentation/2019/reference-manual/file-formats.html#trr) (.trr). # Mdrun: Running minimization from biobb_md.gromacs.mdrun import Mdrun # Create prop dict and inputs/outputs output_min_trr_path = base_path + '/min.trr' output_min_gro_path = base_path + '/min.gro' output_min_edr_path = base_path + '/min.edr' output_min_log_path = base_path + '/min.log' #Create and launch bb Mdrun(input_tpr_path=output_gppmin_tpr_path, output_trr_path=output_min_trr_path, output_gro_path=output_min_gro_path, output_edr_path=output_min_edr_path, output_log_path=output_min_log_path).launch() # ## Preprocess system temperature equilibration # Equilibrate the solvent and ions restraining the protein heavy atoms # Create the [portable binary run file (.tpr)](http://manual.gromacs.org/documentation/2019/reference-manual/file-formats.html#tpr) for system equilibration, using the Grompp module. The main default parameters for this execution are: # - Define = -DPOSRES # - integrator = md # - dt = 0.002 # - nsteps = 5000 # - pcoupl = no # - gen_vel = yes # - gen_temp = 300 # - gen_seed = -1 #
def main(config, system=None): start_time = time.time() conf = settings.ConfReader(config, system) global_log, _ = fu.get_logs(path=conf.get_working_dir_path(), light_format=True) global_prop = conf.get_prop_dic(global_log=global_log) global_paths = conf.get_paths_dic() dhdl_paths_listA = [] dhdl_paths_listB = [] for ensemble, mutation in conf.properties['mutations'].items(): ensemble_prop = conf.get_prop_dic(prefix=ensemble, global_log=global_log) ensemble_paths = conf.get_paths_dic(prefix=ensemble) #Create and launch bb global_log.info( ensemble + " Step 0: gmx trjconv: Extract snapshots from equilibrium trajectories" ) ensemble_paths['step0_trjconv']['input_traj_path'] = conf.properties[ 'input_trajs'][ensemble]['input_traj_path'] ensemble_paths['step0_trjconv']['input_top_path'] = conf.properties[ 'input_trajs'][ensemble]['input_tpr_path'] GMXTrjConvStrEns(**ensemble_paths["step0_trjconv"], properties=ensemble_prop["step0_trjconv"]).launch() with zipfile.ZipFile( ensemble_paths["step0_trjconv"]["output_str_ens_path"], 'r') as zip_f: zip_f.extractall() state_pdb_list = zip_f.namelist() for pdb_path in state_pdb_list: pdb_name = os.path.splitext(pdb_path)[0] prop = conf.get_prop_dic(prefix=os.path.join(ensemble, pdb_name), global_log=global_log) paths = conf.get_paths_dic(prefix=os.path.join(ensemble, pdb_name)) #Create and launch bb global_log.info("Step 1: pmx mutate: Generate Hybrid Structure") paths['step1_pmx_mutate']['input_structure_path'] = pdb_path prop['step1_pmx_mutate']['mutation_list'] = mutation Mutate(**paths["step1_pmx_mutate"], properties=prop["step1_pmx_mutate"]).launch() # Step 2: gmx pdb2gmx: Generate Topology # From pmx tutorial: # gmx pdb2gmx -f mut.pdb -ff amber99sb-star-ildn-mut -water tip3p -o pdb2gmx.pdb global_log.info("Step 2: gmx pdb2gmx: Generate Topology") Pdb2gmx(**paths["step2_gmx_pdb2gmx"], properties=prop["step2_gmx_pdb2gmx"]).launch() # Step 3: pmx gentop: Generate Hybrid Topology # From pmx tutorial: # python generate_hybrid_topology.py -itp topol_Protein.itp -o topol_Protein.itp -ff amber99sb-star-ildn-mut global_log.info("Step 3: pmx gentop: Generate Hybrid Topology") Gentop(**paths["step3_pmx_gentop"], properties=prop["step3_pmx_gentop"]).launch() # Step 4: gmx make_ndx: Generate Gromacs Index File to select atoms to freeze # From pmx tutorial: # echo -e "a D*\n0 & ! 19\nname 20 FREEZE\nq\n" | gmx make_ndx -f frame0/pdb2gmx.pdb -o index.ndx global_log.info( "Step 4: gmx make_ndx: Generate Gromacs Index file to select atoms to freeze" ) MakeNdx(**paths["step4_gmx_makendx"], properties=prop["step4_gmx_makendx"]).launch() if ensemble == 'stateA': # In stateA, with lamdda=0, we don't need the energy minimization step, so simply get the output # from the step2 (pdb2gmx) as output from the step6 (energy minimization) # From pmx tutorial: # There are no dummies in this state at lambda=0, therefore simply convert mut.pdb to emout.gro paths['step7_gmx_grompp']['input_gro_path'] = paths[ 'step2_gmx_pdb2gmx']['output_gro_path'] elif ensemble == 'stateB': # Step 5: gmx grompp: Creating portable binary run file for energy minimization # From pmx tutorial: # gmx grompp -c pdb2gmx.pdb -p topol.top -f ../../mdp/em_FREEZE.mdp -o em.tpr -n ../index.ndx global_log.info( "Step 5: gmx grompp: Creating portable binary run file for energy minimization" ) Grompp(**paths["step5_gmx_grompp"], properties=prop["step5_gmx_grompp"]).launch() # Step 6: gmx mdrun: Running energy minimization # From pmx tutorial: # gmx mdrun -s em.tpr -c emout.gro -v global_log.info( ensemble + " Step 6: gmx mdrun: Running energy minimization") Mdrun(**paths["step6_gmx_mdrun"], properties=prop["step6_gmx_mdrun"]).launch() # Step 7: gmx grompp: Creating portable binary run file for system equilibration # From pmx tutorial: # gmx grompp -c emout.gro -p topol.top -f ../../mdp/eq_20ps.mdp -o eq_20ps.tpr -maxwarn 1 global_log.info( ensemble + " Step 7: gmx grompp: Creating portable binary run file for system equilibration" ) Grompp(**paths["step7_gmx_grompp"], properties=prop["step7_gmx_grompp"]).launch() # Step 8: gmx mdrun: Running system equilibration # From pmx tutorial: # gmx mdrun -s eq_20ps.tpr -c eqout.gro -v global_log.info(ensemble + " Step 8: gmx mdrun: Running system equilibration") Mdrun(**paths["step8_gmx_mdrun"], properties=prop["step8_gmx_mdrun"]).launch() # Step 9: gmx grompp: Creating portable binary run file for thermodynamic integration (ti) # From pmx tutorial: # gmx grompp -c eqout.gro -p topol.top -f ../../mdp/ti.mdp -o ti.tpr -maxwarn 1 global_log.info( ensemble + " Step 9: Creating portable binary run file for thermodynamic integration (ti)" ) Grompp(**paths["step9_gmx_grompp"], properties=prop["step9_gmx_grompp"]).launch() # Step 10: gmx mdrun: Running thermodynamic integration # From pmx tutorial: # gmx mdrun -s ti.tpr -c eqout.gro -v global_log.info( ensemble + " Step 10: gmx mdrun: Running thermodynamic integration") Mdrun(**paths["step10_gmx_mdrun"], properties=prop["step10_gmx_mdrun"]).launch() if ensemble == "stateA": dhdl_paths_listA.append( paths["step10_gmx_mdrun"]["output_dhdl_path"]) elif ensemble == "stateB": dhdl_paths_listB.append( paths["step10_gmx_mdrun"]["output_dhdl_path"]) #Creating zip file containing all the dhdl files dhdlA_path = 'dhdlA.zip' dhdlB_path = 'dhdlB.zip' fu.zip_list(dhdlA_path, dhdl_paths_listA) fu.zip_list(dhdlB_path, dhdl_paths_listB) # Step 11: pmx analyse: Calculate free energies from fast growth thermodynamic integration simulations # From pmx tutorial: # python analyze_dhdl.py -fA ../stateA/frame*/dhdl*.xvg -fB ../stateB/frame*/dhdl*.xvg --nbins 25 -t 293 --reverseB global_log.info( ensemble + " Step 11: pmx analyse: Calculate free energies from fast growth thermodynamic integration simulations" ) global_paths["step11_pmx_analyse"]["input_A_xvg_zip_path"] = dhdlA_path global_paths["step11_pmx_analyse"]["input_B_xvg_zip_path"] = dhdlB_path Analyse(**global_paths["step11_pmx_analyse"], properties=global_prop["step11_pmx_analyse"]).launch() elapsed_time = time.time() - start_time global_log.info('') global_log.info('') global_log.info('Execution successful: ') global_log.info(' Workflow_path: %s' % conf.get_working_dir_path()) global_log.info(' Config File: %s' % config) if system: global_log.info(' System: %s' % system) global_log.info('') global_log.info('Elapsed time: %.1f minutes' % (elapsed_time / 60)) global_log.info('')
def main(config, system=None): start_time = time.time() conf = settings.ConfReader(config, system) global_log, _ = fu.get_logs(path=conf.get_working_dir_path(), light_format=True) global_prop = conf.get_prop_dic(global_log=global_log) global_paths = conf.get_paths_dic() initial_structure = conf.properties.get('initial_structure') if initial_structure: global_paths["step2_fixsidechain"]['input_pdb_path'] = initial_structure else: global_log.info("step1_mmbpdb: Dowload the initial Structure") Pdb(**global_paths["step1_mmbpdb"], properties=global_prop["step1_mmbpdb"]).launch() global_log.info("step2_fixsidechain: Modeling the missing heavy atoms in the structure side chains") FixSideChain(**global_paths["step2_fixsidechain"], properties=global_prop["step2_fixsidechain"]).launch() for mutation_number, mutation in enumerate(conf.properties['mutations']): global_log.info('') global_log.info("Mutation: %s %d/%d" % (mutation, mutation_number+1, len(conf.properties['mutations']))) global_log.info('') prop = conf.get_prop_dic(prefix=mutation, global_log=global_log) paths = conf.get_paths_dic(prefix=mutation) global_log.info("step3_mutate Modeling mutation") prop['step3_mutate']['mutation_list'] = mutation paths['step3_mutate']['input_pdb_path'] = global_paths['step2_fixsidechain']['output_pdb_path'] Mutate(**paths["step3_mutate"], properties=prop["step3_mutate"]).launch() global_log.info("step4_pdb2gmx: Generate the topology") Pdb2gmx(**paths["step4_pdb2gmx"], properties=prop["step4_pdb2gmx"]).launch() global_log.info("step5_editconf: Create the solvent box") Editconf(**paths["step5_editconf"], properties=prop["step5_editconf"]).launch() global_log.info("step6_solvate: Fill the solvent box with water molecules") Solvate(**paths["step6_solvate"], properties=prop["step6_solvate"]).launch() global_log.info("step7_grompp_genion: Preprocess ion generation") Grompp(**paths["step7_grompp_genion"], properties=prop["step7_grompp_genion"]).launch() global_log.info("step8_genion: Ion generation") Genion(**paths["step8_genion"], properties=prop["step8_genion"]).launch() global_log.info("step9_grompp_min: Preprocess energy minimization") Grompp(**paths["step9_grompp_min"], properties=prop["step9_grompp_min"]).launch() global_log.info("step10_mdrun_min: Execute energy minimization") Mdrun(**paths["step10_mdrun_min"], properties=prop["step10_mdrun_min"]).launch() global_log.info("step11_grompp_nvt: Preprocess system temperature equilibration") Grompp(**paths["step11_grompp_nvt"], properties=prop["step11_grompp_nvt"]).launch() global_log.info("step12_mdrun_nvt: Execute system temperature equilibration") Mdrun(**paths["step12_mdrun_nvt"], properties=prop["step12_mdrun_nvt"]).launch() global_log.info("step13_grompp_npt: Preprocess system pressure equilibration") Grompp(**paths["step13_grompp_npt"], properties=prop["step13_grompp_npt"]).launch() global_log.info("step14_mdrun_npt: Execute system pressure equilibration") Mdrun(**paths["step14_mdrun_npt"], properties=prop["step14_mdrun_npt"]).launch() global_log.info("step15_grompp_md: Preprocess free dynamics") Grompp(**paths["step15_grompp_md"], properties=prop["step15_grompp_md"]).launch() global_log.info("step16_mdrun_md: Execute free molecular dynamics simulation") Mdrun(**paths["step16_mdrun_md"], properties=prop["step16_mdrun_md"]).launch() elapsed_time = time.time() - start_time global_log.info('') global_log.info('') global_log.info('Execution sucessful: ') global_log.info(' Workflow_path: %s' % conf.get_working_dir_path()) global_log.info(' Config File: %s' % config) if system: global_log.info(' System: %s' % system) global_log.info('') global_log.info('Elapsed time: %.1f minutes' % (elapsed_time/60)) global_log.info('')