def test_grompp(self):
     returncode = Grompp(properties=self.properties, **self.paths).launch()
     assert fx.not_empty(self.paths['output_tpr_path'])
     assert gmx_check(self.paths['output_tpr_path'],
                      self.paths['ref_output_tpr_path'],
                      gmx=self.properties.get('gmx_path', 'gmx'))
     assert fx.exe_success(returncode)
Пример #2
0
def _grompp(input_gro_path, input_top_zip_path, output_tpr_path,
            input_cpt_path, input_ndx_path, input_mdp_path, properties,
            **kwargs):

    task_config.pop_pmi(os.environ)

    try:
        Grompp(input_gro_path=input_gro_path,
               input_top_zip_path=input_top_zip_path,
               output_tpr_path=output_tpr_path,
               input_cpt_path=input_cpt_path,
               input_ndx_path=input_ndx_path,
               input_mdp_path=input_mdp_path,
               properties=properties,
               **kwargs).launch()
    except Exception as e:
        traceback.print_exc()
        raise e
    finally:
        sys.stdout.flush()
        sys.stderr.flush()
Пример #3
0
# Create the [portable binary run file (.tpr)](http://manual.gromacs.org/documentation/2019/reference-manual/file-formats.html#tpr) for ion generation, using the Grompp module. The main default parameters for this execution are:
# -  integrator  = steep         ; Algorithm (steep = steepest descent minimization)
# -  emtol       = 1000.0        ; Stop minimization when the maximum force < 1000.0 kJ/mol/nm
# -  emstep      = 0.01          ; Minimization step size
# -  nsteps      = 50000         ; Maximum number of (minimization) steps to perform
#
# The main output of this BB will be the portable binary run file (.tpr).

# Grompp: Creating portable binary run file for ion generation
from biobb_md.gromacs.grompp import Grompp
# Create prop dict and inputs/outputs
prop = {'mdp': {'type': 'minimization', 'nsteps': '5000'}}
output_gppion_tpr_path = base_path + '/gppion.tpr'
#Create and launch bb
Grompp(input_gro_path=output_solvate_gro_path,
       input_top_zip_path=output_solvate_top_zip_path,
       output_tpr_path=output_gppion_tpr_path,
       properties=prop).launch()

# ## Ion generation
# Replace solvent molecules to neutralice the system and then reach a 0.05 mol/litre concentration by default. Using the Genion module.
# The main output of this BB will be an updated post-procesed Gromacs structure file (.gro) and a zip file containing the updated topology file (.top) and the restriction files (.itp).

# Genion: Adding ions to reach a 0.05 nm concentration
from biobb_md.gromacs.genion import Genion
# Create prop dict and inputs/outputs
prop = {'neutral': True, 'concentration': 0.05}
output_genion_gro_path = base_path + '/genion.gro'
output_genion_top_zip_path = base_path + '/genion_top.zip'
#Create and launch bb
Genion(input_tpr_path=output_gppion_tpr_path,
       output_gro_path=output_genion_gro_path,
Пример #4
0
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('')
Пример #5
0
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('')