예제 #1
0
    def get_decoys_from_pdb(self):
        """
        Returns the pdb_code decoys
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        out_log.info(self.pdb_code + ' not in target list checking cluster')
        print 'hola'
        if self.pdb_code in self.targets:
            target = self.targets.get(self.pdb_code.lower())
        else:
            out_log.info(self.pdb_code +
                         ' not in target list checking cluster')
            print '2'
            pdb_set = pdb.MmbPdb().get_cluster_pdb_codes(self.pdb_code.lower())
            targets_set = set(self.targets.keys())
            targets_pdb_set = pdb_set.intersection(targets_set)
            target = self.targets.get(targets_pdb_set.pop()).lower()
            print target
            if not target:
                return None

        decoys_file_name = 'decoys_final.sdf.gz'
        url = self.url + '/targets/' + target.lower() + '/' + decoys_file_name
        print url
        req = requests.get(url, allow_redirects=True)
        with open(decoys_file_name, 'wb') as gz_file:
            gz_file.write(req.content)
        with gzip.open(decoys_file_name, 'rb') as gz_file:
            with open(self.output_sdf_path, 'wb') as sdf_file:
                sdf_file.write(gz_file.read())

        return self.output_sdf_path
예제 #2
0
파일: dude.py 프로젝트: athina1/pymdsetup
    def get_decoys_from_pdb(self, pdb_code, output_sdf_path):
        """
        Returns the pdb_code decoys
        """
        if pdb_code in self.targets:
            target = self.targets.get(pdb_code.lower())
        else:
            pdb_set = pdb.MmbPdb().get_cluster_pdb_codes(pdb_code.lower())
            targets_set = set(self.targets.keys())
            targets_pdb_set = pdb_set.intersection(targets_set)
            target = self.targets.get(targets_pdb_set.pop()).lower()
            if not target:
                return None

        decoys_file_name = 'decoys_final.sdf.gz'
        url = self.url + '/targets/' + target.lower() + '/' + decoys_file_name
        req = requests.get(url, allow_redirects=True)
        with open(decoys_file_name, 'wb') as gz_file:
            gz_file.write(req.content)
        with gzip.open(decoys_file_name, 'rb') as gz_file:
            with open(output_sdf_path, 'wb') as sdf_file:
                sdf_file.write(gz_file.read())

        return output_sdf_path
예제 #3
0
def main():
    from pycompss.api.api import compss_open
    start_time = time.time()
    yaml_path = sys.argv[1]
    system = sys.argv[2]
    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True)
    paths_glob = conf.get_paths_dic()
    prop_glob = conf.get_prop_dic()

    out_log.info('')
    out_log.info('_______GROMACS FULL WORKFLOW_______')
    out_log.info('')

    out_log.info('step1:  mmbpdb -- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info('     Selected PDB code: ' +
                     prop_glob['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop_glob['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop_glob['step1_mmbpdb']['pdb_code'],
                             paths_glob['step1_mmbpdb']['output_pdb_path'])
        structure = paths_glob['step1_mmbpdb']['output_pdb_path']

    out_log.info('step2:  mmbuniprot -- Get mutations')
    mutations = conf.properties.get('input_mapped_mutations_list', None)
    if mutations is None or len(mutations) < 7:
        mmbuniprot = uniprot.MmbVariants(prop_glob['step1_mmbpdb']['pdb_code'])
        mutations = mmbuniprot.get_pdb_variants()
        if mutations is None or len(mutations) == 0: return
    else:
        mutations = [
            m.strip() for m in conf.properties.get(
                'input_mapped_mutations_list').split(',')
        ]

    mutations_limit = min(
        len(mutations), int(prop_glob.get('mutations_limit', len(mutations))))
    out_log.info('')
    out_log.info('Number of mutations to be modelled: ' + str(mutations_limit))

    rms_list = []
    mutations_counter = 0
    for mut in mutations:
        if mutations_counter == mutations_limit: break
        mutations_counter += 1
        paths = conf.get_paths_dic(mut)
        prop = conf.get_prop_dic(mut)

        out_log.info('')
        out_log.info('-------------------------')
        out_log.info(
            str(mutations_counter) + '/' + str(mutations_limit) + ' ' + mut)
        out_log.info('-------------------------')
        out_log.info('')

        out_log.info('step3:  scw ------ Model mutation')
        fu.create_dir(prop['step3_scw']['path'])
        paths['step3_scw']['input_pdb_path'] = structure
        scwrl_pc(properties=prop['step3_scw'], **paths['step3_scw'])

        out_log.info('step4:  p2g ------ Create gromacs topology')
        fu.create_dir(prop['step4_p2g']['path'])
        pdb2gmx_pc(properties=prop['step4_p2g'], **paths['step4_p2g'])

        out_log.info('step5:  ec ------- Define box dimensions')
        fu.create_dir(prop['step5_ec']['path'])
        editconf_pc(properties=prop['step5_ec'], **paths['step5_ec'])

        out_log.info('step6:  sol ------ Fill the box with water molecules')
        fu.create_dir(prop['step6_sol']['path'])
        solvate_pc(properties=prop['step6_sol'], **paths['step6_sol'])

        out_log.info(
            'step7:  gppions -- Preprocessing: Adding monoatomic ions')
        fu.create_dir(prop['step7_gppions']['path'])
        grompp_pc(properties=prop['step7_gppions'], **paths['step7_gppions'])

        out_log.info('step8:  gio ------ Running: Adding monoatomic ions')
        fu.create_dir(prop['step8_gio']['path'])
        genion_pc(properties=prop['step8_gio'], **paths['step8_gio'])

        out_log.info('step9:  gppmin --- Preprocessing: Energy minimization')
        fu.create_dir(prop['step9_gppmin']['path'])
        grompp_pc(properties=prop['step9_gppmin'], **paths['step9_gppmin'])

        out_log.info('step10: mdmin ---- Running: Energy minimization')
        fu.create_dir(prop['step10_mdmin']['path'])
        mdrun_pc(properties=prop['step10_mdmin'], **paths['step10_mdmin'])

        out_log.info(
            'step11: gppnvt --- Preprocessing: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step11_gppnvt']['path'])
        grompp_pc(properties=prop['step11_gppnvt'], **paths['step11_gppnvt'])

        out_log.info(
            'step12: mdnvt ---- Running: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step12_mdnvt']['path'])
        mdrun_pc_cpt(properties=prop['step12_mdnvt'], **paths['step12_mdnvt'])

        out_log.info(
            'step13: gppnpt --- Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step13_gppnpt']['path'])
        grompp_pc_cpt(properties=prop['step13_gppnpt'],
                      **paths['step13_gppnpt'])

        out_log.info(
            'step14: mdnpt ---- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step14_mdnpt']['path'])
        mdrun_pc_cpt(properties=prop['step14_mdnpt'], **paths['step14_mdnpt'])

        out_log.info(
            'step15: gppeq ---- Preprocessing: 1ns Molecular dynamics Equilibration'
        )
        fu.create_dir(prop['step15_gppeq']['path'])
        grompp_pc_cpt(properties=prop['step15_gppeq'], **paths['step15_gppeq'])

        out_log.info(
            'step16: mdeq ----- Running: 1ns Molecular dynamics Equilibration')
        fu.create_dir(prop['step16_mdeq']['path'])
        mdrun_pc(properties=prop['step16_mdeq'], **paths['step16_mdeq'])

        out_log.info('step17: rmsd ----- Computing RMSD')
        fu.create_dir(prop['step17_rmsd']['path'])
        rms_list.append(
            rms_pc(properties=prop['step17_rmsd'], **paths['step17_rmsd']))

    xvg_dict = reduce(merge_dictionaries, rms_list)
    out_log.info('step18: gnuplot ----- Creating RMSD plot')
    fu.create_dir(prop_glob['step18_gnuplot']['path'])
    output_png_path = paths_glob['step18_gnuplot']['output_png_path']
    properties = prop_glob['step18_gnuplot']
    gnuplot_pc(xvg_dict, output_png_path, properties)
    png = compss_open(output_png_path)
    elapsed_time = time.time() - start_time

    with open(opj(workflow_path, 'time.txt'), 'a') as time_file:
        time_file.write('Elapsed time: ')
        time_file.write(str(elapsed_time))
        time_file.write('\n')
        time_file.write('Config File: ')
        time_file.write(sys.argv[1])
        time_file.write('\n')
        time_file.write('Sytem: ')
        time_file.write(sys.argv[2])
        time_file.write('\n')
        if len(sys.argv) >= 4:
            time_file.write('Nodes: ')
            time_file.write(sys.argv[3])
            time_file.write('\n')
예제 #4
0
def main():
    start_time = time.time()
    yaml_path = sys.argv[1]
    system = sys.argv[2]

    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True, level='DEBUG')
    paths = conf.get_paths_dic()
    prop = conf.get_prop_dic(global_log=out_log)

    out_log.info('')
    out_log.info('_______GROMACS FULL WORKFLOW_______')
    out_log.info('')
    out_log.info("Command Executed:")
    out_log.info(" ".join(sys.argv))
    out_log.info('Workflow_path: ' + workflow_path)
    out_log.info('Config File: ' + yaml_path)
    out_log.info('System: ' + system)
    out_log.info('')

    #Download initial structure
    out_log.info('step1:  mmbpdb -- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info('     Selected PDB code: ' +
                     prop['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop['step1_mmbpdb']['pdb_code'],
                             paths['step1_mmbpdb']['output_pdb_path'],
                             "filter=:" + prop['step1_mmbpdb']['pdb_chain'])
        structure = paths['step1_mmbpdb']['output_pdb_path']

    decoys_sdf_path = conf.properties[system].get('decoys_sdf_path', None)
    if not decoys_sdf_path:
        #Dowload decoys
        out_log.info('Downloading decoys from DUDe')
        fu.create_dir(prop['dude']['path'])
        out_log.debug('\nPaths:\n' + str(paths['dude']) + '\nProperties:\n' +
                      str(prop['dude']) + '\n')
        decoys_sdf_path = dude.Dude(properties=prop['dude'],
                                    **paths['dude']).get_decoys_from_pdb()
    #SDF to PDB list
    out_log.info('Converting sdf to pdb')
    fu.create_dir(prop['sdf2pdb']['path'])
    out_log.debug('\nPaths:\n' + str(paths['sdf2pdb']) + '\nProperties:\n' +
                  str(prop['sdf2pdb']) + '\n')
    decoys_pdb_list = sdf2pdb.SDF2PDB(input_sdf_path=decoys_sdf_path,
                                      properties=prop['sdf2pdb']).launch()

    #Get Actives
    actives_dir_path = conf.properties[system].get('actives_dir_path', None)
    actives_pdb_list = []
    if not actives_dir_path:
        pass
    for dirpath, _, filenames in os.walk(actives_dir_path):
        for f in filenames:
            actives_pdb_list.append(os.path.abspath(os.path.join(dirpath, f)))

    #Merge actives and decoys
    small_molecules_list = decoys_pdb_list + actives_pdb_list

    #Get bindingsite
    out_log.info('bindingsite')
    fu.create_dir(prop['bindingsite']['path'])
    out_log.debug('\nPaths:\n' + str(paths['bindingsite']) +
                  '\nProperties:\n' + str(prop['bindingsite']) + '\n')
    bindingsite.BindingSite(properties=prop['bindingsite'],
                            **paths['bindingsite']).launch()

    # Get Receptor pdb cluster
    receptors_pdb_path = conf.properties[system].get('receptors_pdb_path',
                                                     None)
    if not receptors_pdb_path:
        out_log.info('md_clustering workflow')
        fu.create_dir(prop['md_clustering']['path'])
        out_log.debug('\nPaths:\n' + str(paths['md_clustering']) +
                      '\nProperties:\n' + str(prop['md_clustering']) + '\n')
        receptors_pdb_path = md_cluster.MDCluster(
            yaml_path=prop['md_clustering']['yaml_path'],
            system=prop['md_clustering']['system'],
            workflow_path=paths['md_clustering']['workflow_path'],
            structure_pdb_path=structure).launch()

    # Get BindingSite BOX
    out_log.info('box')
    fu.create_dir(prop['box']['path'])
    out_log.debug('\nPaths:\n' + str(paths['box']) + '\nProperties:\n' +
                  str(prop['box']) + '\n')
    box.Box(properties=prop['box'],
            input_pdb_path=receptors_pdb_path,
            **paths['box']).launch()

    # Split receptor PDB into multiple PDBs
    parser = Bio.PDB.PDBParser()
    st = parser.get_structure('st', receptors_pdb_path)
    receptors_list = []
    for i in range(len(st)):
        structure_tmp = st.copy()
        for j in range(len(st)):
            if j != i:
                structure_tmp.detach_child(j)
        io = Bio.PDB.PDBIO()
        io.set_structure(structure_tmp)
        receptor_name = 'receptor_' + str(i) + '.pdb'
        io.save(receptor_name)
        receptors_list.append(receptor_name)

    max_receptors = conf.properties[system].get('max_receptors',
                                                len(receptors_list))
    max_ligands = conf.properties[system].get('max_ligands',
                                              len(small_molecules_list))
    for receptor_index, receptor_path in enumerate(receptors_list):
        if receptor_index >= max_receptors: break
        #Prepare receptor
        out_log.info('Prepare receptor')
        fu.create_dir(prop['prepare_receptor']['path'])
        out_log.debug('\nPaths:\n' + str(paths['prepare_receptor']) +
                      '\nProperties:\n' + str(prop['prepare_receptor']) + '\n')
        prepare_receptor.VinaPrepareReceptor(
            properties=prop['prepare_receptor'],
            input_receptor_pdb_path=receptor_path,
            **paths['prepare_receptor']).launch()

        for ligand_index, ligand_path in enumerate(small_molecules_list):
            if ligand_index >= max_ligands: break
            #Prepare Ligand
            out_log.info('Prepare ligand')
            fu.create_dir(prop['prepare_ligand']['path'])
            out_log.debug('\nPaths:\n' + str(paths['prepare_ligand']) +
                          '\nProperties:\n' + str(prop['prepare_ligand']) +
                          '\n')
            prepare_ligand.VinaPrepareLigand(
                properties=prop['prepare_ligand'],
                input_ligand_pdb_path=ligand_path,
                **paths['prepare_ligand']).launch()
            #Launch vina docking
            paths['vina']['output_path'] = os.path.join(
                prop['vina']['path'],
                os.path.splitext(os.path.basename(receptor_path))[0] + '_' +
                os.path.splitext(os.path.basename(ligand_path))[0] +
                '_docking.pdbqt')
            out_log.info('vina')
            fu.create_dir(prop['vina']['path'])
            out_log.debug('\nPaths:\n' + str(paths['vina']) +
                          '\nProperties:\n' + str(prop['vina']) + '\n')
            vina.AutoDockVina(properties=prop['vina'],
                              **paths['vina']).launch()
            #Docking to list

    #Get top 10 ligands

    elapsed_time = time.time() - start_time
    out_log.info('')
    out_log.info('')
    out_log.info('Execution sucessful: ')
    out_log.info('  Workflow_path: ' + workflow_path)
    out_log.info('  Config File: ' + yaml_path)
    out_log.info('  System: ' + system)
    out_log.info('')
    out_log.info('Elapsed time: ' + str(elapsed_time) + ' seconds')
    out_log.info('')
예제 #5
0
def main():
    from pycompss.api.api import compss_open, compss_barrier
    start_time = time.time()
    yaml_path = sys.argv[1]
    system = sys.argv[2]
    n_mutations = sys.argv[3]

    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True, level='DEBUG')
    paths_glob = conf.get_paths_dic()
    prop_glob = conf.get_prop_dic()

    out_log.info('')
    out_log.info('_______GROMACS FULL WORKFLOW_______')
    out_log.info('')

    out_log.info("Command Executed:")
    out_log.info(" ".join(sys.argv))
    out_log.info('Workflow_path: ' + workflow_path)
    out_log.info('Config File: ' + yaml_path)
    out_log.info('System: ' + system)
    out_log.info('Mutations limit: ' + n_mutations)
    if len(sys.argv) >= 5:
        out_log.info('Nodes: ' + sys.argv[4])

    out_log.info('')
    out_log.info('step1:  mmbpdb -- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info(22 * ' ' + 'Selected PDB code: ' +
                     prop_glob['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop_glob['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop_glob['step1_mmbpdb']['pdb_code'],
                             paths_glob['step1_mmbpdb']['output_pdb_path'])
        structure = paths_glob['step1_mmbpdb']['output_pdb_path']
    else:
        out_log.info(22 * ' ' + 'Selected PDB structure: ' + structure)

    out_log.info('step2:  mmbuniprot -- Get mutations')
    mutations = conf.properties.get('input_mapped_mutations_list', None)
    if mutations is None or len(mutations) < 7:
        mmbuniprot = uniprot.MmbVariants(prop_glob['step1_mmbpdb']['pdb_code'])
        mutations = mmbuniprot.get_pdb_variants()
        if mutations is None or len(mutations) == 0:
            return
        else:
            out_log.info(22 * ' ' + 'Number of obtained mutations: ' +
                         str(len(mutations)))
    else:
        mutations = [
            m.strip() for m in conf.properties.get(
                'input_mapped_mutations_list').split(',')
        ]
        out_log.info(22 * ' ' + 'Number of mutations in list: ' +
                     str(len(mutations)))

    mutations_limit = min(len(mutations), int(n_mutations))
    out_log.info('')
    out_log.info('Number of mutations to be modelled: ' + str(mutations_limit))

    rms_list = []
    mutations_counter = 0
    for mut in mutations:
        if mutations_counter == mutations_limit: break
        mutations_counter += 1
        mut = mut if not mut.startswith('*') else mut.replace('*', 'ALL')
        paths = conf.get_paths_dic(mut)
        prop = conf.get_prop_dic(mut)

        out_log.info('')
        out_log.info('-------------------------')
        out_log.info(
            str(mutations_counter) + '/' + str(mutations_limit) + ' ' + mut)
        out_log.info('-------------------------')
        out_log.info('')

        out_log.info('step3: scw ---------- Model mutation')
        fu.create_dir(prop['step3_scw']['path'])
        paths['step3_scw']['input_pdb_path'] = structure
        out_log.debug('Paths:')
        out_log.debug(str(paths['step3_scw']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step3_scw']) + '\n')
        scwrl_pc(properties=prop['step3_scw'], **paths['step3_scw'])

        out_log.info('step4: p2g ---------- Create gromacs topology')
        fu.create_dir(prop['step4_p2g']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step4_p2g']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step4_p2g']) + '\n')
        pdb2gmx_pc(properties=prop['step4_p2g'], **paths['step4_p2g'])

        out_log.info('step5: ec ----------- Define box dimensions')
        fu.create_dir(prop['step5_ec']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step5_ec']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step5_ec']) + '\n')
        editconf_pc(properties=prop['step5_ec'], **paths['step5_ec'])

        out_log.info('step6: sol ---------- Fill the box with water molecules')
        fu.create_dir(prop['step6_sol']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step6_sol']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step6_sol']) + '\n')
        solvate_pc(properties=prop['step6_sol'], **paths['step6_sol'])

        out_log.info(
            'step7: gppions ------ Preprocessing: Adding monoatomic ions')
        fu.create_dir(prop['step7_gppions']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step7_gppions']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step7_gppions']) + '\n')
        grompp_pc(properties=prop['step7_gppions'], **paths['step7_gppions'])

        out_log.info('step8: gio ---------- Running: Adding monoatomic ions')
        fu.create_dir(prop['step8_gio']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step8_gio']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step8_gio']) + '\n')
        genion_pc(properties=prop['step8_gio'], **paths['step8_gio'])

        out_log.info('Step9: gppndx ------- Preprocessing index creation')
        fu.create_dir(prop['step9_gppndx']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step9_gppndx']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step9_gppndx']) + '\n')
        grompp_pc(properties=prop['step9_gppndx'], **paths['step9_gppndx'])

        out_log.info('Step10: make_ndx ---- Create restrain index')
        fu.create_dir(prop['step10_make_ndx']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step10_make_ndx']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step10_make_ndx']) + '\n')
        make_ndx_pc(properties=prop['step10_make_ndx'],
                    **paths['step10_make_ndx'])

        out_log.info('Step11: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step11_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step11_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step11_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step11_ndx2resttop'],
                       **paths['step11_ndx2resttop'])

        out_log.info(
            'step12: gppresmin --- Preprocessing: Mutated residue minimization'
        )
        fu.create_dir(prop['step12_gppresmin']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step12_gppresmin']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step12_gppresmin']) + '\n')
        grompp_pc(properties=prop['step12_gppresmin'],
                  **paths['step12_gppresmin'])

        out_log.info(
            'step13: mdresmin ---- Running: Mutated residue minimization')
        fu.create_dir(prop['step13_mdresmin']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step13_mdresmin']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step13_mdresmin']) + '\n')
        mdrun_pc(properties=prop['step13_mdresmin'],
                 **paths['step13_mdresmin'])

        out_log.info('Step14: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step14_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step14_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step14_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step14_ndx2resttop'],
                       **paths['step14_ndx2resttop'])

        out_log.info('step15: gppmin ------ Preprocessing: minimization')
        fu.create_dir(prop['step15_gppmin']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step15_gppmin']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step15_gppmin']) + '\n')
        grompp_pc(properties=prop['step15_gppmin'], **paths['step15_gppmin'])

        out_log.info('step16: mdmin ------- Running: minimization')
        fu.create_dir(prop['step16_mdmin']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step16_mdmin']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step16_mdmin']) + '\n')
        mdrun_pc(properties=prop['step16_mdmin'], **paths['step16_mdmin'])

        out_log.info('Step17: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step17_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step17_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step17_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step17_ndx2resttop'],
                       **paths['step17_ndx2resttop'])

        out_log.info(
            'step18: gppsa ------- Preprocessing: simulated annealing')
        fu.create_dir(prop['step18_gppsa']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step18_gppsa']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step18_gppsa']) + '\n')
        grompp_pc(properties=prop['step18_gppsa'], **paths['step18_gppsa'])

        out_log.info('step19: mdsa -------- Running: simulated annealing')
        fu.create_dir(prop['step19_mdsa']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step19_mdsa']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step19_mdsa']) + '\n')
        mdrun_pc_cpt(properties=prop['step19_mdsa'], **paths['step19_mdsa'])

        out_log.info(
            'step20: gppnvt_1000 - Preprocessing: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step20_gppnvt_1000']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step20_gppnvt_1000']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step20_gppnvt_1000']) + '\n')
        grompp_pc_cpt(properties=prop['step20_gppnvt_1000'],
                      **paths['step20_gppnvt_1000'])

        out_log.info(
            'step21: mdnvt_1000 -- Running: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step21_mdnvt_1000']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step21_mdnvt_1000']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step21_mdnvt_1000']) + '\n')
        mdrun_pc_cpt(properties=prop['step21_mdnvt_1000'],
                     **paths['step21_mdnvt_1000'])

        out_log.info('Step22: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step22_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step22_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step22_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step22_ndx2resttop'],
                       **paths['step22_ndx2resttop'])

        out_log.info(
            'step23: gppnvt_800 -- Preprocessing: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step23_gppnvt_800']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step23_gppnvt_800']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step23_gppnvt_800']) + '\n')
        grompp_pc_cpt(properties=prop['step23_gppnvt_800'],
                      **paths['step23_gppnvt_800'])

        out_log.info(
            'step24: mdnvt_800 --- Running: nvt constant number of molecules, volume and temp'
        )
        fu.create_dir(prop['step24_mdnvt_800']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step24_mdnvt_800']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step24_mdnvt_800']) + '\n')
        mdrun_pc_cpt(properties=prop['step24_mdnvt_800'],
                     **paths['step24_mdnvt_800'])

        out_log.info('Step25: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step25_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step25_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step25_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step25_ndx2resttop'],
                       **paths['step25_ndx2resttop'])

        out_log.info(
            'step26: gppnpt_500 -- Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step26_gppnpt_500']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step26_gppnpt_500']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step26_gppnpt_500']) + '\n')
        grompp_pc_cpt(properties=prop['step26_gppnpt_500'],
                      **paths['step26_gppnpt_500'])

        out_log.info(
            'step27: mdnpt_500 --- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step27_mdnpt_500']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step27_mdnpt_500']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step27_mdnpt_500']) + '\n')
        mdrun_pc_cpt(properties=prop['step27_mdnpt_500'],
                     **paths['step27_mdnpt_500'])

        out_log.info('Step28: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step28_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step28_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step28_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step28_ndx2resttop'],
                       **paths['step28_ndx2resttop'])

        out_log.info(
            'step29: gppnpt_300 -- Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step29_gppnpt_300']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step29_gppnpt_300']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step29_gppnpt_300']) + '\n')
        grompp_pc_cpt(properties=prop['step29_gppnpt_300'],
                      **paths['step29_gppnpt_300'])

        out_log.info(
            'step30: mdnpt_300 --- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step30_mdnpt_300']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step30_mdnpt_300']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step30_mdnpt_300']) + '\n')
        mdrun_pc_cpt(properties=prop['step30_mdnpt_300'],
                     **paths['step30_mdnpt_300'])

        out_log.info('Step31: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step31_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step31_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step31_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step31_ndx2resttop'],
                       **paths['step31_ndx2resttop'])

        out_log.info(
            'step32: gppnpt_200 -- Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step32_gppnpt_200']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step32_gppnpt_200']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step32_gppnpt_200']) + '\n')
        grompp_pc_cpt(properties=prop['step32_gppnpt_200'],
                      **paths['step32_gppnpt_200'])

        out_log.info(
            'step33: mdnpt_200 --- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step33_mdnpt_200']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step33_mdnpt_200']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step33_mdnpt_200']) + '\n')
        mdrun_pc_cpt(properties=prop['step33_mdnpt_200'],
                     **paths['step33_mdnpt_200'])

        out_log.info('Step34: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step34_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step34_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step34_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step34_ndx2resttop'],
                       **paths['step34_ndx2resttop'])

        out_log.info(
            'step35: gppnpt_100 -- Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step35_gppnpt_100']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step35_gppnpt_100']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step35_gppnpt_100']) + '\n')
        grompp_pc_cpt(properties=prop['step35_gppnpt_100'],
                      **paths['step35_gppnpt_100'])

        out_log.info(
            'step36: mdnpt_100 --- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step36_mdnpt_100']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step36_mdnpt_100']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step36_mdnpt_100']) + '\n')
        mdrun_pc_cpt(properties=prop['step36_mdnpt_100'],
                     **paths['step36_mdnpt_100'])

        out_log.info('Step37: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step37_ndx2resttop']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step37_ndx2resttop']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step37_ndx2resttop']) + '\n')
        ndx2resttop_pc(properties=prop['step37_ndx2resttop'],
                       **paths['step37_ndx2resttop'])

        out_log.info(
            'step38: gppnpt ------ Preprocessing: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step38_gppnpt']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step38_gppnpt']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step38_gppnpt']) + '\n')
        grompp_pc_cpt(properties=prop['step38_gppnpt'],
                      **paths['step38_gppnpt'])

        out_log.info(
            'step39: mdnpt ------- Running: npt constant number of molecules, pressure and temp'
        )
        fu.create_dir(prop['step39_mdnpt']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step39_mdnpt']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step39_mdnpt']) + '\n')
        mdrun_pc_cpt(properties=prop['step39_mdnpt'], **paths['step39_mdnpt'])

        out_log.info(
            'step40: gppmd ------- Preprocessing: Free Molecular dynamics')
        fu.create_dir(prop['step40_gppmd']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step40_gppmd']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step40_gppmd']) + '\n')
        grompp_pc_cpt(properties=prop['step40_gppmd'], **paths['step40_gppmd'])

        out_log.info('step41: md ---------- Running: Free Molecular dynamics')
        fu.create_dir(prop['step41_md']['path'])
        out_log.debug('Paths:')
        out_log.debug(str(paths['step41_md']))
        out_log.debug('Properties:')
        out_log.debug(str(prop['step41_md']) + '\n')
        mdrun_pc_cpt(properties=prop['step41_md'], **paths['step41_md'])

        # out_log.info('step42: rmsd -------- Computing RMSD')
        # fu.create_dir(prop['step42_rmsd']['path'])
        # out_log.debug('Paths:')
        # out_log.debug(str(paths['step42_rmsd']))
        # out_log.debug('Properties:')
        # out_log.debug(str(prop['step42_rmsd'])+'\n')
        # rms_list.append(rms_pc(properties=prop['step42_rmsd'], **paths['step42_rmsd']))

    #     fu.remove_temp_files(['#', '.top', '.plotscript', '.edr', '.xtc', '.itp', '.top', '.log', '.pdb', '.cpt', '.mdp', '.xvg', '.seq'])
    #
    #     xvg_dict = reduce(merge_dictionaries, rms_list)
    #
    # out_log.info('')
    # out_log.info('step43: gnuplot ----- Creating RMSD plot')
    # fu.create_dir(prop_glob['step43_gnuplot']['path'])
    # output_png_path = paths_glob['step43_gnuplot']['output_png_path']
    # properties = prop_glob['step43_gnuplot']
    # gnuplot_pc(xvg_dict, output_png_path, properties)
    #
    # png = compss_open(output_png_path)
    compss_barrier()
    elapsed_time = time.time() - start_time

    out_log.info('')
    out_log.info('')
    out_log.info('Execution sucessful: ')
    out_log.info('  Workflow_path: ' + workflow_path)
    out_log.info('  Config File: ' + yaml_path)
    out_log.info('  System: ' + system)
    if len(sys.argv) >= 5:
        out_log.info('  Nodes: ' + sys.argv[4])
    out_log.info('')
    out_log.info('Elapsed time: ' + str(elapsed_time) + ' seconds')
    out_log.info('')
예제 #6
0
def main():
    start_time = time.time()
    yaml_path=sys.argv[1]
    system=sys.argv[2]
    n_mutations=sys.argv[3]

    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True)
    paths_glob = conf.get_paths_dic()
    prop_glob = conf.get_prop_dic()

    out_log.info('')
    out_log.info('_______GROMACS FULL WORKFLOW_______')
    out_log.info('')

    out_log.info("Command Executed:")
    out_log.info(" ".join(sys.argv))
    out_log.info('Workflow_path: '+workflow_path)
    out_log.info('Config File: '+yaml_path)
    out_log.info('System: '+system)
    out_log.info('Mutations limit: '+n_mutations)
    if len(sys.argv) >= 5:
        out_log.info('Nodes: '+sys.argv[4])

    out_log.info('')
    out_log.info( 'step1:  mmbpdb -- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info( '     Selected PDB code: ' + prop_glob['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop_glob['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop_glob['step1_mmbpdb']['pdb_code'], paths_glob['step1_mmbpdb']['output_pdb_path'])
        structure = paths_glob['step1_mmbpdb']['output_pdb_path']

    out_log.info( 'step2:  mmbuniprot -- Get mutations')
    mutations = conf.properties.get('input_mapped_mutations_list', None)
    if mutations is None or len(mutations) < 7:
        mmbuniprot = uniprot.MmbVariants(prop_glob['step1_mmbpdb']['pdb_code'])
        mutations = mmbuniprot.get_pdb_variants()
        if mutations is None or len(mutations) == 0: return
    else:
        mutations = [m.strip() for m in conf.properties.get('input_mapped_mutations_list').split(',')]

    mutations_limit = min(len(mutations), int(n_mutations))
    out_log.info('')
    out_log.info('Number of mutations to be modelled: ' + str(mutations_limit))

    rms_list = []
    mutations_counter = 0
    for mut in mutations:
        if mutations_counter == mutations_limit: break
        mutations_counter += 1
        paths = conf.get_paths_dic(mut)
        prop = conf.get_prop_dic(mut, global_log=out_log)

        out_log.info('')
        out_log.info('-------------------------')
        out_log.info(str(mutations_counter) + '/' + str(mutations_limit) + ' ' + mut)
        out_log.info('-------------------------')
        out_log.info('')

        out_log.info('step3:  scw ------ Model mutation')
        fu.create_dir(prop['step3_scw']['path'])
        paths['step3_scw']['input_pdb_path']=structure
        scwrl.Scwrl4(properties=prop['step3_scw'], **paths['step3_scw']).launch()

        out_log.info('step4:  p2g ------ Create gromacs topology')
        fu.create_dir(prop['step4_p2g']['path'])
        pdb2gmx.Pdb2gmx(properties=prop['step4_p2g'], **paths['step4_p2g']).launch()

        out_log.info('step5:  ec ------- Define box dimensions')
        fu.create_dir(prop['step5_ec']['path'])
        editconf.Editconf(properties=prop['step5_ec'], **paths['step5_ec']).launch()

        out_log.info('step6:  sol ------ Fill the box with water molecules')
        fu.create_dir(prop['step6_sol']['path'])
        solvate.Solvate(properties=prop['step6_sol'], **paths['step6_sol']).launch()

        out_log.info('step7:  gppions -- Preprocessing: Adding monoatomic ions')
        fu.create_dir(prop['step7_gppions']['path'])
        grompp.Grompp(properties=prop['step7_gppions'], **paths['step7_gppions']).launch()

        out_log.info('step8:  gio ------ Running: Adding monoatomic ions')
        fu.create_dir(prop['step8_gio']['path'])
        genion.Genion(properties=prop['step8_gio'], **paths['step8_gio']).launch()

        out_log.info('step9:  gppmin --- Preprocessing: Energy minimization')
        fu.create_dir(prop['step9_gppmin']['path'])
        grompp.Grompp(properties=prop['step9_gppmin'], **paths['step9_gppmin']).launch()

        out_log.info('step10: mdmin ---- Running: Energy minimization')
        fu.create_dir(prop['step10_mdmin']['path'])
        mdrun.Mdrun(properties=prop['step10_mdmin'], **paths['step10_mdmin']).launch()

        out_log.info('step11: gppnvt --- Preprocessing: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step11_gppnvt']['path'])
        grompp.Grompp(properties=prop['step11_gppnvt'], **paths['step11_gppnvt']).launch()

        out_log.info('step12: mdnvt ---- Running: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step12_mdnvt']['path'])
        mdrun.Mdrun(properties=prop['step12_mdnvt'], **paths['step12_mdnvt']).launch()

        out_log.info('step13: gppnpt --- Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step13_gppnpt']['path'])
        grompp.Grompp(properties=prop['step13_gppnpt'], **paths['step13_gppnpt']).launch()

        out_log.info('step14: mdnpt ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step14_mdnpt']['path'])
        mdrun.Mdrun(properties=prop['step14_mdnpt'], **paths['step14_mdnpt']).launch()

        out_log.info('step15: gppeq ---- Preprocessing: 1ns Molecular dynamics Equilibration')
        fu.create_dir(prop['step15_gppeq']['path'])
        grompp.Grompp(properties=prop['step15_gppeq'], **paths['step15_gppeq']).launch()

        out_log.info('step16: mdeq ----- Running: Free Molecular dynamics Equilibration')
        fu.create_dir(prop['step16_mdeq']['path'])
        mdrun.Mdrun(properties=prop['step16_mdeq'], **paths['step16_mdeq']).launch()

        out_log.info('step17: rmsd ----- Computing RMSD')
        fu.create_dir(prop['step17_rmsd']['path'])
        rms_list.append(rms.Rms(properties=prop['step17_rmsd'], **paths['step17_rmsd']).launch())
        removed_list = fu.remove_temp_files(['#', '.top', '.plotscript', '.edr', '.xtc', '.itp', '.top', '.log', '.pdb', '.cpt', '.mdp', '.xvg', '.grp', '.seq'])

    xvg_dict=reduce(lambda a, b: dict(a, **b), rms_list)
    out_log.info('step18: gnuplot ----- Creating RMSD plot')
    fu.create_dir(prop_glob['step18_gnuplot']['path'])
    gnuplot.Gnuplot(input_xvg_path_dict=xvg_dict, properties=prop_glob['step18_gnuplot'], **paths_glob['step18_gnuplot']).launch()
    elapsed_time = time.time() - start_time


    out_log.info('')
    out_log.info('')
    out_log.info('Execution sucessful: ')
    out_log.info('  Workflow_path: '+workflow_path)
    out_log.info('  Config File: '+yaml_path)
    out_log.info('  System: '+system)
    if len(sys.argv) >= 5:
        out_log.info('  Nodes: '+sys.argv[4])
    out_log.info('')
    out_log.info('Elapsed time: '+str(elapsed_time)+' seconds')
    out_log.info('')
예제 #7
0
def main():
    start_time = time.time()
    yaml_path=sys.argv[1]
    system=sys.argv[2]
    n_mutations=sys.argv[3]

    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True)
    paths_glob = conf.get_paths_dic()
    prop_glob = conf.get_prop_dic()

    out_log.info('')
    out_log.info('_______GROMACS FULL WORKFLOW_______')
    out_log.info('')

    out_log.info("Command Executed:")
    out_log.info(" ".join(sys.argv))
    out_log.info('Workflow_path: '+workflow_path)
    out_log.info('Config File: '+yaml_path)
    out_log.info('System: '+system)
    out_log.info('Mutations limit: '+n_mutations)
    if len(sys.argv) >= 5:
        out_log.info('Nodes: '+sys.argv[4])

    out_log.info('')
    out_log.info( 'step1:  mmbpdb -- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info( '     Selected PDB code: ' + prop_glob['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop_glob['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop_glob['step1_mmbpdb']['pdb_code'], paths_glob['step1_mmbpdb']['output_pdb_path'])
        structure = paths_glob['step1_mmbpdb']['output_pdb_path']

    out_log.info( 'step2:  mmbuniprot -- Get mutations')
    mutations = conf.properties.get('input_mapped_mutations_list', None)
    if mutations is None or len(mutations) < 7:
        mmbuniprot = uniprot.MmbVariants(prop_glob['step1_mmbpdb']['pdb_code'])
        mutations = mmbuniprot.get_pdb_variants()
        if mutations is None or len(mutations) == 0: return
    else:
        mutations = [m.strip() for m in conf.properties.get('input_mapped_mutations_list').split(',')]

    mutations_limit = min(len(mutations), int(n_mutations))
    out_log.info('')
    out_log.info('Number of mutations to be modelled: ' + str(mutations_limit))

    rms_list = []
    mutations_counter = 0
    for mut in mutations:
        if mutations_counter == mutations_limit: break
        mutations_counter += 1
        mut = mut if not mut.startswith('*') else mut.replace('*', 'ALL')
        paths = conf.get_paths_dic(mut)
        prop = conf.get_prop_dic(mut, global_log=out_log)

        out_log.info('')
        out_log.info('-------------------------')
        out_log.info(str(mutations_counter) + '/' + str(mutations_limit) + ' ' + mut)
        out_log.info('-------------------------')
        out_log.info('')

        out_log.info('step3:  scw --------- Model mutation')
        fu.create_dir(prop['step3_scw']['path'])
        paths['step3_scw']['input_pdb_path']=structure
        scwrl.Scwrl4(properties=prop['step3_scw'], **paths['step3_scw']).launch()

        out_log.info('step4:  p2g --------- Create gromacs topology')
        fu.create_dir(prop['step4_p2g']['path'])
        pdb2gmx.Pdb2gmx(properties=prop['step4_p2g'], **paths['step4_p2g']).launch()

        out_log.info('step5:  ec ---------- Define box dimensions')
        fu.create_dir(prop['step5_ec']['path'])
        editconf.Editconf(properties=prop['step5_ec'], **paths['step5_ec']).launch()

        out_log.info('step6:  sol --------- Fill the box with water molecules')
        fu.create_dir(prop['step6_sol']['path'])
        solvate.Solvate(properties=prop['step6_sol'], **paths['step6_sol']).launch()

        out_log.info('step7:  gppions ----- Preprocessing: Adding monoatomic ions')
        fu.create_dir(prop['step7_gppions']['path'])
        grompp.Grompp(properties=prop['step7_gppions'], **paths['step7_gppions']).launch()

        out_log.info('step8:  gio --------- Running: Adding monoatomic ions')
        fu.create_dir(prop['step8_gio']['path'])
        genion.Genion(properties=prop['step8_gio'], **paths['step8_gio']).launch()

        out_log.info('Step9: gppndx ------- Preprocessing index creation')
        fu.create_dir(prop['step9_gppndx']['path'])
        grompp.Grompp(properties=prop['step9_gppndx'], **paths['step9_gppndx']).launch()

        out_log.info('Step10: make_ndx ---- Create restrain index')
        fu.create_dir(prop['step10_make_ndx']['path'])
        make_ndx.MakeNdx(properties=prop['step10_make_ndx'], **paths['step10_make_ndx']).launch()

        out_log.info('Step11: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step11_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step11_ndx2resttop'], **paths['step11_ndx2resttop']).launch()

        out_log.info('step12: gppresmin  Preprocessing: Mutated residue minimization')
        fu.create_dir(prop['step12_gppresmin']['path'])
        grompp.Grompp(properties=prop['step12_gppresmin'], **paths['step12_gppresmin']).launch()

        out_log.info('step13: mdresmin ---- Running: Mutated residue minimization')
        fu.create_dir(prop['step13_mdresmin']['path'])
        mdrun.Mdrun(properties=prop['step13_mdresmin'], **paths['step13_mdresmin']).launch()

        out_log.info('Step14: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step14_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step14_ndx2resttop'], **paths['step14_ndx2resttop']).launch()

        out_log.info('step15: gppmin  Preprocessing: minimization')
        fu.create_dir(prop['step15_gppmin']['path'])
        grompp.Grompp(properties=prop['step15_gppmin'], **paths['step15_gppmin']).launch()

        out_log.info('step16: mdmin ---- Running: minimization')
        fu.create_dir(prop['step16_mdmin']['path'])
        mdrun.Mdrun(properties=prop['step16_mdmin'], **paths['step16_mdmin']).launch()

        out_log.info('Step17: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step17_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step17_ndx2resttop'], **paths['step17_ndx2resttop']).launch()

        out_log.info('step18: gppsa  Preprocessing: simulated annealing')
        fu.create_dir(prop['step18_gppsa']['path'])
        grompp.Grompp(properties=prop['step18_gppsa'], **paths['step18_gppsa']).launch()

        out_log.info('step19: mdsa ---- Running: simulated annealing')
        fu.create_dir(prop['step19_mdsa']['path'])
        mdrun.Mdrun(properties=prop['step19_mdsa'], **paths['step19_mdsa']).launch()

        out_log.info('step20: gppnvt_1000  Preprocessing: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step20_gppnvt_1000']['path'])
        grompp.Grompp(properties=prop['step20_gppnvt_1000'], **paths['step20_gppnvt_1000']).launch()

        out_log.info('step21: mdnvt_1000 ---- Running: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step21_mdnvt_1000']['path'])
        mdrun.Mdrun(properties=prop['step21_mdnvt_1000'], **paths['step21_mdnvt_1000']).launch()

        out_log.info('Step22: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step22_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step22_ndx2resttop'], **paths['step22_ndx2resttop']).launch()

        out_log.info('step23: gppnvt_800  Preprocessing: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step23_gppnvt_800']['path'])
        grompp.Grompp(properties=prop['step23_gppnvt_800'], **paths['step23_gppnvt_800']).launch()

        out_log.info('step24: mdnvt_800 ---- Running: nvt constant number of molecules, volume and temp')
        fu.create_dir(prop['step24_mdnvt_800']['path'])
        mdrun.Mdrun(properties=prop['step24_mdnvt_800'], **paths['step24_mdnvt_800']).launch()

        out_log.info('Step25: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step25_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step25_ndx2resttop'], **paths['step25_ndx2resttop']).launch()

        out_log.info('step26: gppnpt_500  Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step26_gppnpt_500']['path'])
        grompp.Grompp(properties=prop['step26_gppnpt_500'], **paths['step26_gppnpt_500']).launch()

        out_log.info('step27: mdnpt_500 ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step27_mdnpt_500']['path'])
        mdrun.Mdrun(properties=prop['step27_mdnpt_500'], **paths['step27_mdnpt_500']).launch()

        out_log.info('Step28: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step28_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step28_ndx2resttop'], **paths['step28_ndx2resttop']).launch()

        out_log.info('step29: gppnpt_300  Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step29_gppnpt_300']['path'])
        grompp.Grompp(properties=prop['step29_gppnpt_300'], **paths['step29_gppnpt_300']).launch()

        out_log.info('step30: mdnpt_300 ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step30_mdnpt_300']['path'])
        mdrun.Mdrun(properties=prop['step30_mdnpt_300'], **paths['step30_mdnpt_300']).launch()

        out_log.info('Step31: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step31_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step31_ndx2resttop'], **paths['step31_ndx2resttop']).launch()

        out_log.info('step32: gppnpt_200  Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step32_gppnpt_200']['path'])
        grompp.Grompp(properties=prop['step32_gppnpt_200'], **paths['step32_gppnpt_200']).launch()

        out_log.info('step33: mdnpt_200 ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step33_mdnpt_200']['path'])
        mdrun.Mdrun(properties=prop['step33_mdnpt_200'], **paths['step33_mdnpt_200']).launch()

        out_log.info('Step34: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step34_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step34_ndx2resttop'], **paths['step34_ndx2resttop']).launch()

        out_log.info('step35: gppnpt_100  Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step35_gppnpt_100']['path'])
        grompp.Grompp(properties=prop['step35_gppnpt_100'], **paths['step35_gppnpt_100']).launch()

        out_log.info('step36: mdnpt_100 ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step36_mdnpt_100']['path'])
        mdrun.Mdrun(properties=prop['step36_mdnpt_100'], **paths['step36_mdnpt_100']).launch()

        out_log.info('Step37: ndx2resttop - Create restrain topology')
        fu.create_dir(prop['step37_ndx2resttop']['path'])
        ndx2resttop.Ndx2resttop(properties=prop['step37_ndx2resttop'], **paths['step37_ndx2resttop']).launch()

        out_log.info('step38: gppnpt - Preprocessing: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step38_gppnpt']['path'])
        grompp.Grompp(properties=prop['step38_gppnpt'], **paths['step38_gppnpt']).launch()

        out_log.info('step39: mdnpt ---- Running: npt constant number of molecules, pressure and temp')
        fu.create_dir(prop['step39_mdnpt']['path'])
        mdrun.Mdrun(properties=prop['step39_mdnpt'], **paths['step39_mdnpt']).launch()

        fu.remove_temp_files(['#', '.top', '.plotscript', '.edr', '.xtc', '.itp', '.top', '.log', '.pdb', '.cpt', '.mdp', '.xvg', '.seq'])

    elapsed_time = time.time() - start_time
    out_log.info('')
    out_log.info('')
    out_log.info('Execution sucessful: ')
    out_log.info('  Workflow_path: '+workflow_path)
    out_log.info('  Config File: '+yaml_path)
    out_log.info('  System: '+system)
    if len(sys.argv) >= 5:
        out_log.info('  Nodes: '+sys.argv[4])
    out_log.info('')
    out_log.info('Elapsed time: '+str(elapsed_time)+' seconds')
    out_log.info('')
예제 #8
0
def main():
    start_time = time.time()
    yaml_path = sys.argv[1]
    system = sys.argv[2]
    conf = settings.YamlReader(yaml_path, system)
    workflow_path = conf.properties[system]['workflow_path']
    fu.create_dir(os.path.abspath(workflow_path))
    out_log, _ = fu.get_logs(path=workflow_path, console=True)
    paths = conf.get_paths_dic()
    prop = conf.get_prop_dic(global_log=out_log)

    out_log.info('')
    out_log.info('_______MD SETUP FULL WORKFLOW_______')
    out_log.info('')

    out_log.info('step1:  mmbpdb --- Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    if structure is None or not os.path.isfile(structure):
        out_log.info('                   Selected PDB code: ' +
                     prop['step1_mmbpdb']['pdb_code'])
        fu.create_dir(prop['step1_mmbpdb']['path'])
        pdb.MmbPdb().get_pdb(prop['step1_mmbpdb']['pdb_code'],
                             paths['step1_mmbpdb']['output_pdb_path'])
        structure = paths['step1_mmbpdb']['output_pdb_path']

    out_log.info('step2:  p2g ------ Create gromacs topology')
    fu.create_dir(prop['step2_p2g']['path'])
    pdb2gmx.Pdb2gmx(properties=prop['step2_p2g'],
                    **paths['step2_p2g']).launch()

    out_log.info('step3:  ec ------- Define box dimensions')
    fu.create_dir(prop['step3_ec']['path'])
    editconf.Editconf(properties=prop['step3_ec'],
                      **paths['step3_ec']).launch()

    out_log.info('step4:  sol ------ Fill the box with water molecules')
    fu.create_dir(prop['step4_sol']['path'])
    solvate.Solvate(properties=prop['step4_sol'],
                    **paths['step4_sol']).launch()

    out_log.info('step5:  gppions -- Preprocessing: Adding monoatomic ions')
    fu.create_dir(prop['step5_gppions']['path'])
    grompp.Grompp(properties=prop['step5_gppions'],
                  **paths['step5_gppions']).launch()

    out_log.info('step6:  gio ------ Running: Adding monoatomic ions')
    fu.create_dir(prop['step6_gio']['path'])
    genion.Genion(properties=prop['step6_gio'], **paths['step6_gio']).launch()

    out_log.info('step7:  gppmin --- Preprocessing: Energy minimization')
    fu.create_dir(prop['step7_gppmin']['path'])
    grompp.Grompp(properties=prop['step7_gppmin'],
                  **paths['step7_gppmin']).launch()

    out_log.info('step8:  mdmin ---- Running: Energy minimization')
    fu.create_dir(prop['step8_mdmin']['path'])
    mdrun.Mdrun(properties=prop['step8_mdmin'],
                **paths['step8_mdmin']).launch()

    out_log.info(
        'step9:  gppnvt --- Preprocessing: nvt constant number of molecules, volume and temp'
    )
    fu.create_dir(prop['step9_gppnvt']['path'])
    grompp.Grompp(properties=prop['step9_gppnvt'],
                  **paths['step9_gppnvt']).launch()

    out_log.info(
        'step10: mdnvt ---- Running: nvt constant number of molecules, volume and temp'
    )
    fu.create_dir(prop['step10_mdnvt']['path'])
    mdrun.Mdrun(properties=prop['step10_mdnvt'],
                **paths['step10_mdnvt']).launch()

    out_log.info(
        'step11: gppnpt --- Preprocessing: npt constant number of molecules, pressure and temp'
    )
    fu.create_dir(prop['step11_gppnpt']['path'])
    grompp.Grompp(properties=prop['step11_gppnpt'],
                  **paths['step11_gppnpt']).launch()

    out_log.info(
        'step12: mdnpt ---- Running: npt constant number of molecules, pressure and temp'
    )
    fu.create_dir(prop['step12_mdnpt']['path'])
    mdrun.Mdrun(properties=prop['step12_mdnpt'],
                **paths['step12_mdnpt']).launch()

    out_log.info(
        'step13: gppeq ---- Preprocessing: Molecular dynamics Equilibration')
    fu.create_dir(prop['step13_gppeq']['path'])
    grompp.Grompp(properties=prop['step13_gppeq'],
                  **paths['step13_gppeq']).launch()

    out_log.info(
        'step14: mdeq ----- Running: Molecular dynamics Equilibration')
    fu.create_dir(prop['step14_mdeq']['path'])
    mdrun.Mdrun(properties=prop['step14_mdeq'],
                **paths['step14_mdeq']).launch()

    #Create setupfiles dir and copy files
    setupfiles_path = os.path.join(workflow_path, 'setupfiles')
    fu.create_dir(setupfiles_path)
    shutil.copy(paths['step14_mdeq']['output_gro_path'],
                os.path.join(setupfiles_path, 'md_setup.gro'))
    shutil.copy(paths['step14_mdeq']['output_cpt_path'],
                os.path.join(setupfiles_path, 'md_setup.cpt'))
    shutil.copy(paths['step6_gio']['output_top_zip_path'],
                os.path.join(setupfiles_path, 'md_setup.zip'))

    removed_list = fu.remove_temp_files([
        '#', '.top', '.plotscript', '.edr', '.xtc', '.itp', '.top', '.log',
        '.pdb', '.cpt', '.mdp'
    ])
    out_log.info('')
    out_log.info('Removing unwanted files: ')
    for removed_file in removed_list:
        out_log.info('    X    ' + removed_file)

    elapsed_time = time.time() - start_time
    out_log.info('')
    out_log.info('')
    out_log.info('Execution sucessful: ')
    out_log.info('  Workflow_path: ' + workflow_path)
    out_log.info('  Config File: ' + yaml_path)
    out_log.info('  System: ' + system)
    if len(sys.argv) >= 4:
        out_log.info('  Nodes: ' + sys.argv[3])
    out_log.info('')
    out_log.info('Elapsed time: ' + str(elapsed_time) + ' seconds')
    out_log.info('')