Exemplo n.º 1
0
def process_output_fpocket_filter(search_list, tmp_folder, input_pockets_zip,
                                  output_filter_pockets_zip, remove_tmp,
                                  out_log):
    """ Creates the output_filter_pockets_zip """

    # decompress the input_pockets_zip file to tmp_folder
    cluster_list = fu.unzip_list(zip_file=input_pockets_zip,
                                 dest_dir=tmp_folder,
                                 out_log=out_log)

    # list all files of tmp_folder
    pockets_list = [str(i) for i in Path(tmp_folder).iterdir()]

    # select search_list items from pockets_list
    sel_pockets_list = [
        p for p in pockets_list for s in search_list if s + '_' in p
    ]

    fu.log('Creating %s output file' % output_filter_pockets_zip, out_log)

    # compress output to output_filter_pockets_zip
    fu.zip_list(zip_file=output_filter_pockets_zip,
                file_list=sel_pockets_list,
                out_log=out_log)

    if remove_tmp:
        # remove temporary folder
        fu.rm(tmp_folder)
        fu.log('Removed temporary folder: %s' % tmp_folder, out_log)
Exemplo n.º 2
0
    def launch(self) -> int:
        """Execute the :class:`PdbClusterZip <api.pdb_cluster_zip.PdbClusterZip>` api.pdb_cluster_zip.PdbClusterZip object."""
        
        # check input/output paths and parameters
        self.check_data_params(self.out_log, self.err_log)

        # Setup Biobb
        if self.check_restart(): return 0
        self.stage_files()

        check_mandatory_property(self.pdb_code, 'pdb_code', self.out_log, self.__class__.__name__)

        self.pdb_code = self.pdb_code.strip().lower()

        file_list = []
        #Downloading PDB_files
        pdb_code_list = get_cluster_pdb_codes(pdb_code=self.pdb_code, cluster=self.cluster, out_log=self.out_log, global_log=self.global_log)
        unique_dir = fu.create_unique_dir()
        for pdb_code in pdb_code_list:
            pdb_file = os.path.join(unique_dir, pdb_code+".pdb")
            pdb_string = download_pdb(pdb_code=pdb_code, api_id=self.api_id, out_log=self.out_log, global_log=self.global_log)
            write_pdb(pdb_string, pdb_file, self.filter, self.out_log, self.global_log)
            file_list.append(os.path.abspath(pdb_file))

        #Zipping files
        fu.log("Zipping the pdb files to: %s" % self.output_pdb_zip_path)
        fu.zip_list(self.output_pdb_zip_path, file_list, out_log=self.out_log)

        if self.remove_tmp:
            # remove temporary folder
            fu.rm(unique_dir)
            fu.log('Removed temporary folder: %s' % unique_dir, self.out_log)

        return 0
Exemplo n.º 3
0
def process_output_trjconv_str_ens(tmp_folder, remove_tmp, output_file,
                                   glob_pattern, out_log):
    """ Compresses, moves and removes temporal files generated by the wrapper """
    # list all files in temporary folder
    tmp_fl = list(Path(tmp_folder).glob(glob_pattern))
    files_list = []
    for file_name in tmp_fl:
        files_list.append(file_name)

    # adding files from temporary folder to zip
    fu.zip_list(output_file, files_list, out_log)

    if remove_tmp:
        # remove temporary folder
        fu.rm(tmp_folder)
        fu.log('Removed temporary folder: %s' % tmp_folder, out_log)
Exemplo n.º 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_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)
        ensemble_paths = conf.get_paths_dic(prefix=ensemble)

        # step0_image
        global_log.info(
            ensemble +
            " Step 0: gmx image: Imaging trajectories to remove PBC issues")
        ensemble_paths['step0_image']['input_traj_path'] = conf.properties[
            'input_trajs'][ensemble]['input_traj_path']
        ensemble_paths['step0_image']['input_top_path'] = conf.properties[
            'input_trajs'][ensemble]['input_tpr_path']
        gmx_image_pc(**ensemble_paths["step0_image"],
                     properties=ensemble_prop["step0_image"])

        # step1_trjconv
        global_log.info(
            ensemble +
            " Step 1: gmx trjconv: Extract snapshots from equilibrium trajectories"
        )
        ensemble_paths['step1_trjconv_' +
                       ensemble]['input_top_path'] = conf.properties[
                           'input_trajs'][ensemble]['input_tpr_path']
        gmx_trjconv_str_ens_pc(**ensemble_paths['step1_trjconv_' + ensemble],
                               properties=ensemble_prop['step1_trjconv_' +
                                                        ensemble])

    for ensemble, mutation in conf.properties['mutations'].items():
        ensemble_prop = conf.get_prop_dic(prefix=ensemble)
        ensemble_paths = conf.get_paths_dic(prefix=ensemble)
        compss_wait_on_file(ensemble_paths['step1_trjconv_' +
                                           ensemble]["output_str_ens_path"])

        with zipfile.ZipFile(
                ensemble_paths['step1_trjconv_' +
                               ensemble]["output_str_ens_path"]) as zip_f:
            unique_dir = os.path.abspath(
                fu.create_unique_dir(
                    prefix=ensemble_prop['step1_trjconv_' +
                                         ensemble]['working_dir_path'] + '/' +
                    ensemble + '/'))
            zip_f.extractall(unique_dir)
            state_pdb_list = [
                os.path.join(unique_dir, name) for name in zip_f.namelist()
            ]

        for pdb_path in state_pdb_list:
            pdb_name = os.path.splitext(os.path.basename(pdb_path))[0]
            prop = conf.get_prop_dic(prefix=os.path.join(ensemble, pdb_name))
            paths = conf.get_paths_dic(prefix=os.path.join(ensemble, pdb_name))

            # Fixing terminal residues
            newpdb = pdb_path + ".term.gro"
            #fix_gro("/gpfs/scratch/bsc19/bsc19611/RATG13-RBD/fixGro.sh", pdb_path, newpdb)
            fix_term(pdb_path, newpdb)

            # Fixing terminal residues
            #newpdb2 = pdb_path + ".term.gro"
            #cmd2 = "sed 's/600ASN /600NASN/g' " + pdb_path + "| sed 's/    1SER   /    1NSER  /g' | sed 's/597ASP /597CASP/g' | sed 's/793PRO /793CPRO/g' > " + newpdb2
            #subprocess.call(cmd2, shell=True)

            paths['step1_pmx_mutate']['input_structure_path'] = newpdb

            # step1_pmx_mutate
            global_log.info(ensemble + " " + pdb_name +
                            " Step 1: pmx mutate: Generate Hybrid Structure")
            prop['step1_pmx_mutate']['mutation_list'] = mutation
            mutate_pc(**paths["step1_pmx_mutate"],
                      properties=prop["step1_pmx_mutate"])

            # step1.1_check_dummies
            global_log.info(ensemble + " " + pdb_name +
                            " Step 1.1 Check for dummy atoms")
            extract_atoms_pc(**paths['step1.1_check_dummies'],
                             properties=prop['step1.1_check_dummies'])
            #compss_wait_on_file(paths['step1.1_check_dummies']['output_structure_path'])
            #try:
            #    dummy = bool(os.path.getsize(paths['step1.1_check_dummies']['output_structure_path']))
            #except:
            #    global_log.info("Error ocurred while checking the file containing dummy atoms")
            #    global_log.info(sys.exc_info()[0])

            # step1.2_remove_ligand
            #global_log.info(ensemble + " " + pdb_name + " Step 1.2 Remove ligand")
            #remove_ligand_pc(**paths['step1.2_remove_ligand'], properties=prop['step1.2_remove_ligand'])

            # step2_gmx_pdb2gmx
            global_log.info(ensemble + " " + pdb_name +
                            " Step 2: gmx pdb2gmx: Generate Topology")
            pdb2gmx_pc(**paths["step2_gmx_pdb2gmx"],
                       properties=prop["step2_gmx_pdb2gmx"])

            # step2.1_sort_gro
            #global_log.info(ensemble + " " + pdb_name + " Step 2.1 Sort gro residues")
            #sort_gro_residues_pc(**paths['step2.1_sort_gro'], properties=prop['step2.1_sort_gro'])

            # step2.2_lig_gmx_appendLigand
            #global_log.info(ensemble + " " + pdb_name +" Step 2.2_lig: gmx appendLigand: Append a ligand to a GROMACS topology")
            #append_ligand_pc(**paths["step2.2_lig_gmx_appendLigand"], properties=prop["step2.2_lig_gmx_appendLigand"])

            # step3_pmx_gentop
            global_log.info(ensemble + " " + pdb_name +
                            " Step 3: pmx gentop: Generate Hybrid Topology")
            gentop_pc(**paths["step3_pmx_gentop"],
                      properties=prop["step3_pmx_gentop"])

            # step4_gmx_makendx, step5_gmx_grompp, step6_gmx_mdrun
            #global_log.info(ensemble + " " + pdb_name +" Check structure and Step 4-6 (Dummies): gmx make_ndx: Generate Gromacs Index file to select atoms to freeze, gmx grompp: Creating portable binary run file for energy minimization, gmx mdrun: Running energy minimization")
            #check_structure_and_run_ndx_pc(ensemble, **paths["step4_gmx_makendx"], properties_makendx=prop["step4_gmx_makendx"], **paths["step5_gmx_grompp"], properties_grompp=prop["step5_gmx_grompp"], **paths["step6_gmx_mdrun"], properties_mdrun=prop["step6_gmx_mdrun"])

            # step4_gmx_makendx, step5_gmx_grompp, step6_gmx_mdrun
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 4-6 (Check structure and ndx): gmx make_ndx: Generate Gromacs Index file to select atoms to freeze, gmx grompp: Creating portable binary run file for energy minimization, gmx mdrun: Running energy minimization"
            )
            fu.create_dir(prop["step4_gmx_makendx"]['working_dir_path'] + "/" +
                          ensemble + "/" + pdb_name + "/step4_gmx_makendx")
            fu.create_dir(prop["step5_gmx_grompp"]['working_dir_path'] + "/" +
                          ensemble + "/" + pdb_name + "/step5_gmx_grompp")
            fu.create_dir(prop["step6_gmx_mdrun"]['working_dir_path'] + "/" +
                          ensemble + "/" + pdb_name + "/step6_gmx_mdrun")
            check_structure_and_run_ndx_pc(
                ensemble,
                output_structure_path=paths['step1.1_check_dummies']
                ['output_structure_path'],
                **paths["step4_gmx_makendx"],
                properties_makendx=prop["step4_gmx_makendx"],
                **paths["step5_gmx_grompp"],
                properties_grompp=prop["step5_gmx_grompp"],
                **paths["step6_gmx_mdrun"],
                properties_mdrun=prop["step6_gmx_mdrun"])

            # step7_gmx_grompp
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 7: gmx grompp: Creating portable binary run file for system equilibration"
            )
            grompp_pc(**paths["step7_gmx_grompp"],
                      properties=prop["step7_gmx_grompp"])

            # step8_gmx_mdrun
            global_log.info(ensemble + " " + pdb_name +
                            " Step 8: gmx mdrun: Running system equilibration")
            mdrun_pc(**paths["step8_gmx_mdrun"],
                     properties=prop["step8_gmx_mdrun"])

            # step9_gmx_grompp
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 9: Creating portable binary run file for thermodynamic integration (ti)"
            )
            grompp_pc(**paths["step9_gmx_grompp"],
                      properties=prop["step9_gmx_grompp"])

            # step10_gmx_mdrun
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 10: gmx mdrun: Running thermodynamic integration")
            mdrun_dhdl_pc(**paths["step10_gmx_mdrun"],
                          properties=prop["step10_gmx_mdrun"])

            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 = os.path.join(
        global_prop["step11_pmx_analyse"]['working_dir_path'], 'dhdlA.zip')
    dhdlB_path = os.path.join(
        global_prop["step11_pmx_analyse"]['working_dir_path'], 'dhdlB.zip')
    for dhdl_file in dhdl_paths_listA:
        compss_wait_on_file(dhdl_file)
    for dhdl_file in dhdl_paths_listB:
        compss_wait_on_file(dhdl_file)
    fu.zip_list(dhdlA_path, dhdl_paths_listA)
    fu.zip_list(dhdlB_path, dhdl_paths_listB)

    # step11_pmx_analyse
    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_pc(**global_paths["step11_pmx_analyse"],
               properties=global_prop["step11_pmx_analyse"])

    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('')
Exemplo n.º 5
0
def process_output_fpocket(tmp_folder, output_pockets_zip, output_summary,
                           sort_by, remove_tmp, out_log, classname):
    """ Creates the output_pockets_zip and generates the  output_summary """

    path = str(PurePath(tmp_folder).joinpath('input_out'))

    if not Path(path).is_dir():
        if remove_tmp:
            # remove temporary folder
            fu.rm(tmp_folder)
            fu.log('Removing temporary folder: %s' % tmp_folder, out_log)

        fu.log(
            classname +
            ': Error executing fpocket, please check your properties', out_log)
        raise SystemExit(
            classname +
            ': Error executing fpocket, please check your properties')

    # summary
    # read input_info.txt file
    info = PurePath(path).joinpath('input_info.txt')
    with open(info, 'r') as info_text:
        lines = info_text.readlines()
        lines = [x for x in lines if x != '\n']

    data = {}

    # parse input_info.txt file to python object
    pocket = ''
    for line in lines:
        if not line.startswith('\t'):
            # first level: pocket
            num = re.findall('\d+', line)[0]
            pocket = 'pocket' + num
            data[pocket] = {}
        else:
            # second level: pocket properties
            groups = re.findall('(.*)(?:\ *\:\ *)(.*)', line)[0]
            key = groups[0].lower().strip()
            key = re.sub(r'\-|\.', '', key)
            key = re.sub(r'\s+', '_', key)
            value = float(groups[1]) if '.' in groups[1] else int(groups[1])
            data[pocket][key] = value

    # get number of pockets
    fu.log('%d pockets found' % (len(data)), out_log)

    # sort data by sort_by property
    fu.log('Sorting output data by %s' % (sort_by), out_log)
    data = dict(
        sorted(data.items(),
               key=lambda item: float(item[1][sort_by]),
               reverse=True))

    # compress pockets
    pockets = PurePath(path).joinpath('pockets')
    files_list = [str(i) for i in Path(pockets).iterdir()]
    fu.zip_list(zip_file=output_pockets_zip,
                file_list=files_list,
                out_log=out_log)

    # save summary
    fu.log('Saving summary to %s file' % (output_summary), out_log)
    with open(output_summary, 'w') as outfile:
        json.dump(data, outfile, indent=4)

    if remove_tmp:
        # remove temporary folder
        fu.rm(tmp_folder)
        fu.log('Removed temporary folder: %s' % tmp_folder, out_log)
Exemplo n.º 6
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('')
Exemplo n.º 7
0
def main(config, imaged_traj_available):
    start_time = time.time()
    conf = settings.ConfReader(config)
    global_log, _ = fu.get_logs(path=conf.get_working_dir_path(),
                                light_format=True)
    global_prop = conf.get_prop_dic()
    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)
        ensemble_paths = conf.get_paths_dic(prefix=ensemble)

        if not imaged_traj_available:
            # step0_image There isn't an imaged trajectory
            global_log.info(
                ensemble +
                " Step 0: gmx image: Imaging trajectories to remove PBC issues"
            )
            ensemble_paths['step0_image']['input_top_path'] = conf.properties[
                'input_trajs'][ensemble]['input_tpr_path']
            ensemble_paths['step0_image']['input_traj_path'] = conf.properties[
                'input_trajs'][ensemble]['input_traj_path']
            gmx_image_pc(**ensemble_paths["step0_image"],
                         properties=ensemble_prop["step0_image"])

        else:
            # An imaged trajectory is available
            ensemble_paths['step1_trjconv_' +
                           ensemble]['input_traj_path'] = conf.properties[
                               'input_trajs'][ensemble]['input_traj_path']

        # step1_trjconv
        global_log.info(
            ensemble +
            " Step 1: gmx trjconv: Extract snapshots from equilibrium trajectories"
        )
        ensemble_paths['step1_trjconv_' +
                       ensemble]['input_top_path'] = conf.properties[
                           'input_trajs'][ensemble]['input_tpr_path']
        gmx_trjconv_str_ens_pc(**ensemble_paths['step1_trjconv_' + ensemble],
                               properties=ensemble_prop['step1_trjconv_' +
                                                        ensemble])

    for ensemble, mutation in conf.properties['mutations'].items():
        ensemble_prop = conf.get_prop_dic(prefix=ensemble)
        ensemble_paths = conf.get_paths_dic(prefix=ensemble)
        compss_wait_on_file(ensemble_paths['step1_trjconv_' +
                                           ensemble]["output_str_ens_path"])

        with zipfile.ZipFile(
                ensemble_paths['step1_trjconv_' +
                               ensemble]["output_str_ens_path"]) as zip_f:
            unique_dir = os.path.abspath(
                fu.create_unique_dir(
                    prefix=ensemble_prop['step1_trjconv_' +
                                         ensemble]['working_dir_path'] + '/' +
                    ensemble + '/'))
            zip_f.extractall(unique_dir)
            state_pdb_list = [
                os.path.join(unique_dir, name) for name in zip_f.namelist()
            ]

        for pdb_path in state_pdb_list:
            pdb_name = os.path.splitext(os.path.basename(pdb_path))[0]
            prop = conf.get_prop_dic(prefix=os.path.join(ensemble, pdb_name))
            paths = conf.get_paths_dic(prefix=os.path.join(ensemble, pdb_name))

            # step2_pmx_mutate
            global_log.info(ensemble + " " + pdb_name +
                            " Step 2: pmx mutate: Generate Hybrid Structure")
            paths['step2_pmx_mutate']['input_structure_path'] = pdb_path
            prop['step2_pmx_mutate']['mutation_list'] = mutation
            mutate_pc(**paths["step2_pmx_mutate"],
                      properties=prop["step2_pmx_mutate"])

            # step3_check_dummies
            global_log.info(ensemble + " " + pdb_name +
                            " Step 3 Check for dummy atoms")
            extract_atoms_pc(**paths['step3_check_dummies'],
                             properties=prop['step3_check_dummies'])
            compss_wait_on_file(
                paths['step3_check_dummies']['output_structure_path'])
            try:
                dummy = bool(
                    os.path.getsize(
                        paths['step3_check_dummies']['output_structure_path']))
            except:
                global_log.info(
                    "Error ocurred while checking the file containing dummy atoms"
                )
                global_log.info(sys.exc_info()[0])

            # step4_gmx_pdb2gmx
            global_log.info(ensemble + " " + pdb_name +
                            " Step 4: gmx pdb2gmx: Generate Topology")
            pdb2gmx_pc(**paths["step4_gmx_pdb2gmx"],
                       properties=prop["step4_gmx_pdb2gmx"])

            # step5_pmx_gentop
            global_log.info(ensemble + " " + pdb_name +
                            " Step 5: pmx gentop: Generate Hybrid Topology")
            gentop_pc(**paths["step5_pmx_gentop"],
                      properties=prop["step5_pmx_gentop"])

            if not dummy:
                paths['step9_gmx_grompp']['input_gro_path'] = paths[
                    'step4_gmx_pdb2gmx']['output_gro_path']
            else:
                # step6_gmx_makendx
                global_log.info(
                    ensemble + " " + pdb_name +
                    " Step 6: (Dummies): gmx make_ndx: Generate Gromacs Index file to select atoms to freeze"
                )
                make_ndx_pc(**paths["step6_gmx_makendx"],
                            properties=prop["step6_gmx_makendx"])

                # step7_gmx_grompp
                global_log.info(
                    ensemble + " " + pdb_name +
                    " Step 7: (Dummies): gmx grompp: Creating portable binary run file for energy minimization"
                )
                grompp_ndx_pc(**paths["step7_gmx_grompp"],
                              properties=prop["step7_gmx_grompp"])

                # step8_gmx_mdrun
                global_log.info(
                    ensemble + " " + pdb_name +
                    " Step 8: (Dummies): gmx mdrun: Running energy minimization"
                )
                mdrun_pc(**paths["step8_gmx_mdrun"],
                         properties=prop["step8_gmx_mdrun"])

            # step9_gmx_grompp
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 9: gmx grompp: Creating portable binary run file for system equilibration"
            )
            grompp_pc(**paths["step9_gmx_grompp"],
                      properties=prop["step9_gmx_grompp"])

            # step10_gmx_mdrun
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 10: gmx mdrun: Running system equilibration")
            mdrun_pc(**paths["step10_gmx_mdrun"],
                     properties=prop["step10_gmx_mdrun"])

            # step11_gmx_grompp
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 11: Creating portable binary run file for thermodynamic integration (ti)"
            )
            grompp_pc(**paths["step11_gmx_grompp"],
                      properties=prop["step11_gmx_grompp"])

            # step12_gmx_mdrun
            global_log.info(
                ensemble + " " + pdb_name +
                " Step 12: gmx mdrun: Running thermodynamic integration")
            mdrun_dhdl_pc(**paths["step12_gmx_mdrun"],
                          properties=prop["step12_gmx_mdrun"])

            if ensemble == "stateA":
                dhdl_paths_listA.append(
                    paths["step12_gmx_mdrun"]["output_dhdl_path"])
            elif ensemble == "stateB":
                dhdl_paths_listB.append(
                    paths["step12_gmx_mdrun"]["output_dhdl_path"])

    # Creating zip file containing all the dhdl files
    dhdlA_path = os.path.join(
        global_prop["step13_pmx_analyse"]['working_dir_path'], 'dhdlA.zip')
    dhdlB_path = os.path.join(
        global_prop["step13_pmx_analyse"]['working_dir_path'], 'dhdlB.zip')
    for dhdl_file in dhdl_paths_listA:
        compss_wait_on_file(dhdl_file)
    for dhdl_file in dhdl_paths_listB:
        compss_wait_on_file(dhdl_file)
    fu.zip_list(dhdlA_path, dhdl_paths_listA)
    fu.zip_list(dhdlB_path, dhdl_paths_listB)

    # step13_pmx_analyse
    global_log.info(
        ensemble +
        " Step 13: pmx analyse: Calculate free energies from fast growth thermodynamic integration simulations"
    )
    global_paths["step13_pmx_analyse"]["input_a_xvg_zip_path"] = dhdlA_path
    global_paths["step13_pmx_analyse"]["input_b_xvg_zip_path"] = dhdlB_path
    analyse_pc(**global_paths["step13_pmx_analyse"],
               properties=global_prop["step13_pmx_analyse"])

    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)
    global_log.info('')
    global_log.info('Elapsed time: %.1f minutes' % (elapsed_time / 60))
    global_log.info('')