Exemplo n.º 1
0
    def launch(self):
        """Launches the execution of the GROMACS solvate module.
        """
        out_log, err_log = fu.get_logs(path=self.path, mutation=self.mutation, step=self.step)
        self.output_top_path = fu.add_step_mutation_path_to_name(self.output_top_path, self.step, self.mutation)

        # Unzip topology to topology_out
        fu.unzip_top(zip_file=self.input_top_zip_path, top_file=self.output_top_path)

        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [gmx, 'solvate',
               '-cp', self.input_solute_gro_path,
               '-cs', self.input_solvent_gro_path,
               '-o',  self.output_gro_path,
               '-p',  self.output_top_path]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        returncode = command.launch()

        with open(self.output_top_path) as topology_file:
            out_log.info('Last 5 lines of new top file: ')
            lines = topology_file.readlines()
            for index in [-i for i in range(5,0,-1)]:
                out_log.info(lines[index])


        # zip new_topology
        fu.zip_top(self.output_top_path, self.output_top_zip_path, remove_files=True)
        return returncode
Exemplo n.º 2
0
    def launch(self):
        """Launches the execution of the GROMACS rms module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        gmx = 'gmx' if self.gmx_path is 'None' else self.gmx_path

        cmd = [
            gmx, 'rms', '-xvg', 'none', '-s', self.input_gro_path, '-f',
            self.input_trr_path, '-o', self.output_xvg_path
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
            cmd.append('<<<')
            cmd.append('\"' + "$'0\n0\n'" + '\"')
        else:
            cmd.insert(0, '|')
            cmd.insert(0, '\"' + '0 0' + '\"')
            cmd.insert(0, 'echo')
        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        command.launch()
        xvg = self.output_xvg_path if os.path.isfile(
            self.output_xvg_path) else ntpath.basename(self.output_xvg_path)
        self.mutation = '' if self.mutation is None else self.mutation
        return {self.mutation: np.loadtxt(xvg)}
Exemplo n.º 3
0
 def launch(self):
     # using cmd_wrapper
     out_log, err_log = fu.get_logs(path=self.properties['path'],
                                    step=self.properties['step'])
     cmd = ["python ", self.script, self.res_lib, self.pdb_in, self.pdb_out]
     command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
     command.launch()
Exemplo n.º 4
0
    def launch(self):
        """Launches the execution of the GROMACS editconf module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, 'make_ndx', '-f', self.input_structure_path, '-o',
            self.output_ndx_path
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')

        if self.mpirun:
            cmd.append('<<<')
            cmd.append('\"' + self.selection + '\"')
        else:
            cmd.insert(0, '|')
            cmd.insert(0, '\"' + self.selection + '\"')
            cmd.insert(0, 'echo')

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 5
0
    def launch(self):
        """Launches the execution of the GROMACS rms module.
        """
        out_log, err_log = fu.get_logs(path=self.path, mutation=self.mutation, step=self.step)
        gmx = 'gmx' if self.gmx_path is 'None' else self.gmx_path

        cmd = [gmx, 'cluster',
               '-s', self.input_gro_path,
               '-f', self.input_xtc_path,
               '-cl', self.output_pdb_path,
               '-cutoff', str(self.cutoff)]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
            cmd.append('<<<')
            cmd.append('\"'+"$'0\n0\n'"+'\"')
        else:
            cmd.insert(0, '|')
            cmd.insert(0, '\"'+'1 1'+'\"')
            cmd.insert(0, 'echo')
        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 6
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
Exemplo n.º 7
0
    def launch(self):
        """Launches the execution of the GNUPLOT binary.
        """
        out_log, err_log = fu.get_logs(path=self.path, mutation=self.mutation, step=self.step)
        self.output_plotscript_path = fu.add_step_mutation_path_to_name(self.output_plotscript_path, self.step, self.mutation)
        # Create the input script for gnuplot
        xvg_file_list = []
        with open(self.output_plotscript_path, 'w') as ps:
            ps.write('set term '+self.term+'\n')
            ps.write('set output "' + self.output_png_path + '"'+'\n')
            ps.write('plot')
            for k, v in self.input_xvg_path_dict.iteritems():
                if isinstance(v, basestring) and os.path.isfile(v):
                    ps.write(' "' + v + '" u 1:3 w lp t "' + k + '",')
                else:
                    xvg_file = fu.add_step_mutation_path_to_name(k + '.xvg', self.step, self.mutation)
                    np.savetxt(xvg_file, v, fmt='%4.7f')
                    out_log.info('Creating file: '+os.path.abspath(xvg_file))
                    xvg_file_list.append(os.path.abspath(xvg_file))
                    ps.write(' "' + xvg_file + '" u 0:2 w lp t "' + k + '", ')


        gplot = 'gnuplot' if self.gnuplot_path is None else self.gnuplot_path
        cmd = [gplot, self.output_plotscript_path]

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        returncode = command.launch()
        return returncode
    def launch(self):
        """Launches the execution of the MGLTools prepare_receptor module."""
        out_log, err_log = fu.get_logs(path=self.path)

        cmd = [self.executor_path, self.script_path,
               '-r', self.input_receptor_pdb_path,
               '-o', self.output_receptor_pdbqt_path]

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 9
0
    def launch(self):
        """Launches the execution of the GROMACS genion module.
        """
        if self.global_log is not None:
            if self.concentration:
                self.global_log.info(19 * ' ' + 'To reach up ' +
                                     str(self.concentration) +
                                     ' mol/litre concentration')

        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        self.output_top_path = fu.add_step_mutation_path_to_name(
            self.output_top_path, self.step, self.mutation)

        # Unzip topology to topology_out
        fu.unzip_top(zip_file=self.input_top_zip_path,
                     top_file=self.output_top_path)
        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, 'genion', '-s', self.input_tpr_path, '-o',
            self.output_gro_path, '-p', self.output_top_path
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        if self.neutral:
            cmd.append('-neutral')
        if self.concentration:
            cmd.append('-conc')
            cmd.append(str(self.concentration))

        if self.seed is not None:
            cmd.append('-seed')
            cmd.append(str(self.seed))

        if self.mpirun:
            cmd.append('<<<')
            cmd.append('\"' + self.replaced_group + '\"')
        else:
            cmd.insert(0, '|')
            cmd.insert(0, '\"' + self.replaced_group + '\"')
            cmd.insert(0, 'echo')
        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        returncode = command.launch()

        # zip new_topology
        fu.zip_top(self.output_top_path,
                   self.output_top_zip_path,
                   remove_files=True)
        return returncode
Exemplo n.º 10
0
    def launch(self):
        """Launches the execution of the sdf2pdb module."""
        out_log, err_log = fu.get_logs(path=self.path, mutation=self.mutation, step=self.step)
        pdb_list = []
        for mol_index, mol in enumerate(pybel.readfile("sdf", self.input_sdf_path)):
            if mol_index >= self.max_pdbs and self.max_pdbs !=0 : break
            fname=str(mol.title)+'.pdb'
            mol.write("pdb", fname, overwrite=True)
            pdb_list.append(os.path.abspath(fname))

        return pdb_list
Exemplo n.º 11
0
    def launch(self):
        """Launches the execution of the SCWRL binary.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mut,
                                       step=self.step)
        if self.mutation is not None:
            # Read structure with Biopython
            parser = PDBParser(PERMISSIVE=1)
            st = parser.get_structure(
                's', self.input_pdb_path)  # s random id never used

            # Remove the side chain of the AA to be mutated
            if self.mutation['chain'] != '*':
                chains = [self.mutation['chain']]
            else:
                chains = [chain.id for chain in st[0]]

            resnum = int(self.mutation['resnum'])

            for chain in chains:
                residue = st[0][chain][(' ', resnum, ' ')]
                backbone_atoms = ['N', 'CA', 'C', 'O', 'CB']
                not_backbone_atoms = []

                # The following formula does not work. Biopython bug?
                # for atom in residue:
                #     if atom.id not in backbone_atoms:
                #         residue.detach_child(atom.id)

                for atom in residue:
                    if atom.id not in backbone_atoms:
                        not_backbone_atoms.append(atom)
                for atom in not_backbone_atoms:
                    residue.detach_child(atom.id)

                # Change residue name
                residue.resname = self.mutation['mt'].upper()

            # Write resultant structure
            w = PDBIO()
            w.set_structure(st)
            prepared_file_path = self.mut + self.step + 'prepared.pdb'
            w.save(prepared_file_path)
        else:
            prepared_file_path = self.input_pdb_path

        scrwl = 'Scwrl4' if self.scwrl4_path is None else self.scwrl4_path
        cmd = [scrwl, '-i', prepared_file_path, '-o', self.output_pdb_path]

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 12
0
 def launch(self, deleteTmpDir=True):
     # using cmd_wrapper
     self.out_log, self.err_log = fu.get_logs(path=self.properties['path'],
                                              step=self.properties['step'])
     command = cmd_wrapper.CmdWrapper(self.run.setup(), self.out_log,
                                      self.err_log)
     command.launch()
     # using original CMIP execute
     # self.result = self.run.execute
     self.result = Result(self.run.tmpdir, self.run.files)
     if deleteTmpDir:
         self.run.rmTmpDir()
     return self.result
Exemplo n.º 13
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 LAUNCH_______')
    out_log.info('')

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

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

    #Create setupfiles dir and copy files
    mdfiles_path = os.path.join(workflow_path,'mdfiles')
    fu.create_dir(mdfiles_path)
    shutil.copy(paths['step2_mdeq']['input_tpr_path'], os.path.join(mdfiles_path, 'md.tpr'))
    shutil.copy(paths['step2_mdeq']['output_cpt_path'], os.path.join(mdfiles_path, 'md.cpt'))
    shutil.copy(paths['step2_mdeq']['output_gro_path'], os.path.join(mdfiles_path, 'md.gro'))
    shutil.copy('_step2_mdeq_mdeq.xtc', os.path.join(mdfiles_path, 'md.xtc'))

    removed_list = fu.remove_temp_files(['#', '.top', '.plotscript', '.edr', '.xtc', '.itp', '.top', '.log', '.pdb', '.cpt', '.mdp', '.trr'])
    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('')
Exemplo n.º 14
0
    def launch(self):
        """Launches the execution of the GROMACS mdrun module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, 'mdrun', '-s', self.input_tpr_path, '-c', self.output_gro_path
        ]

        if self.output_trr_path is not None:
            cmd.append('-o')
            cmd.append(self.output_trr_path)
        if self.output_xtc_path is not None:
            cmd.append('-x')
            cmd.append(self.output_xtc_path)
        if self.output_edr_path is not None:
            cmd.append('-e')
            cmd.append(self.output_edr_path)
        if self.output_cpt_path is not None:
            cmd.append('-cpo')
            cmd.append(self.output_cpt_path)
        if self.output_log_path is not None:
            cmd.append('-g')
            cmd.append(self.output_log_path)

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        #Number of threads to run (0 is guess)
        if not self.num_threads is None:
            cmd.append('-nt')
            cmd.append(str(self.num_threads))
        if not self.ntmpi is None:
            cmd.append('-ntmpi')
            cmd.append(str(self.ntmpi))
        if not self.ntomp is None:
            cmd.append('-ntomp')
            cmd.append(str(self.ntomp))
        if not self.gpu_id is None:
            cmd.append('-gpu_id')
            cmd.append(str(self.gpu_id))

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 15
0
    def launch(self):
        """Launches the execution of the AutoDock Vina docking"""
        out_log, err_log = fu.get_logs(path=self.path, step=self.step)

        vina = 'vina' if self.vina_path is None else self.vina_path
        x0, y0, z0, sidex, sidey, sidez = AutoDockVina._calculate_box(
            self.box_path)
        cmd = [
            vina, '--ligand', self.ligand_pdbqt_path, '--receptor',
            self.receptor_pdbqt_path, '--center_x=' + x0, '--center_y=' + y0,
            '--center_z=' + z0, '--size_x=' + sidex, '--size_y=' + sidey,
            '--size_z=' + sidez, '--out', self.output_path, '--log',
            self.log_file
        ]

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 16
0
    def test_launch(self):
        out_log, _ = fu.get_logs(path=self.properties['path'], console=True)
        self.properties['global_log'] = out_log
        output_tpr_path = opj(self.properties['path'],
                              self.properties['output_tpr_path'])
        returncode = Grompp(
            input_gro_path=opj(self.data_dir,
                               self.properties['input_gro_path']),
            input_top_zip_path=opj(self.data_dir,
                                   self.properties['input_top_zip_path']),
            input_cpt_path=opj(self.data_dir,
                               self.properties['input_cpt_path']),
            output_tpr_path=output_tpr_path,
            properties=self.properties).launch()

        assert fx.exe_success(returncode)
        assert fx.not_empty(output_tpr_path)
Exemplo n.º 17
0
    def launch(self):
        """Launches the execution of the GROMACS grompp module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        mdp_file_path = self.create_mdp(
        ) if self.input_mdp_path is None else self.input_mdp_path
        if self.global_log is not None:
            md = self.mdp.get('type', 'minimization')
            if md != 'index' and md != 'free':
                self.global_log.info(22 * ' ' + 'Will run a ' + md +
                                     ' md of ' + str(self.nsteps) + ' steps')
            elif md == 'index':
                self.global_log.info(
                    22 * ' ' +
                    'Will create a TPR to be used as structure file')
            else:
                self.global_log.info(
                    22 * ' ' + 'Will run a ' + md + ' md of ' +
                    fu.human_readable_time(int(self.nsteps) * float(self.dt)))

        # Unzip topology in de directory of the output_tpr_path and get the
        # topology path
        topology_path = fu.unzip_top(self.input_top_zip_path)
        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, 'grompp', '-f', mdp_file_path, '-c', self.input_gro_path,
            '-p', topology_path, '-o', self.output_tpr_path
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        if self.input_cpt_path is not None:
            cmd.append('-t')
            cmd.append(self.input_cpt_path)
        if self.output_mdp_path is not None:
            cmd.append('-po')
            cmd.append(self.output_mdp_path)

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 18
0
    def launch(self):
        """Launches the execution of the GROMACS pdb2gmx module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        self.output_top_path = fu.add_step_mutation_path_to_name(
            self.output_top_path, self.step, self.mutation)

        gmx = "gmx" if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, "pdb2gmx", "-f", self.input_structure_pdb_path, "-o",
            self.output_gro_path, "-p", self.output_top_path, "-water",
            self.water_type, "-ff", self.force_field
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        if self.output_itp_path is not None:
            self.output_itp_path = self.output_itp_path if self.step is None else self.step + '_' + self.output_itp_path
            self.output_itp_path = self.output_itp_path if self.mutation is None else self.mutation + '_' + self.output_itp_path
            cmd.append("-i")
            cmd.append(self.output_itp_path)
        if self.ignh:
            cmd.append("-ignh")

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        returncode = command.launch()

        #Remove comment (first line) from gro file
        with open(self.output_gro_path, 'r') as fin:
            data = fin.read().splitlines(True)
            data[0] = 'Created with pdb2gmx building block\n'
        with open(self.output_gro_path, 'w') as fout:
            fout.writelines(data)

        # zip topology
        fu.zip_top(self.output_top_path,
                   self.output_top_zip_path,
                   remove_files=True)

        return returncode
Exemplo n.º 19
0
    def launch(self):
        """Launches the execution of the GROMACS editconf module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        gmx = 'gmx' if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, 'editconf', '-f', self.input_gro_path, '-o',
            self.output_gro_path, '-d',
            str(self.distance_to_molecule), '-bt', self.box_type
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')
        if self.center_molecule:
            cmd.append('-c')

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 20
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')
Exemplo n.º 21
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()
    props = conf.get_prop_dic(global_log=out_log)

    out_log.info('')
    out_log.info('_______TEST CMIP TITRATION WORKFLOW_______')
    out_log.info('')

    stepid = 'step1_mmbpdb'
    out_log.info(stepid)
    props['step'] = stepid

    # For testing only
    fu.create_dir(props[stepid]['path'])

    copyfile(paths['step1_mmbpdb']['input_test_pdb_path'],
             paths['step1_mmbpdb']['output_pdb_path'])
    out_log.info('Test input file copy from: ' +
                 paths['step1_mmbpdb']['input_test_pdb_path'] + ' to: ' +
                 paths['step1_mmbpdb']['output_pdb_path'])

    stepid = 'step2_preppdbCMIP'
    out_log.info(stepid)
    props['step'] = stepid
    fu.create_dir(props[stepid]['path'])
    out_log.info('Step 2 prep pdb CMIP create dir: ' + props[stepid]['path'])
    PPW.prepPDBWrapper(paths[stepid], props[stepid]).launch()

    # stepid = 'step3_CMIPTitration'
    # out_log.info(stepid)
    # props['step'] = stepid
    #
    # fu.create_dir(props[stepid]['path'])
    #
    # cw = CW.CMIPWrapper(paths[stepid],props[stepid])
    # #Delaying removal of temporary dir until output is processed
    # cw.launch(False)
    # out_log.debug ("Temp directory: "+ cw.run.tmpdir)
    # out_log.info(stepid + " CMIP Output")
    #
    # if cw.result.errstr:
    #     out_log.error(cw.result.errstr)
    #     sys.exit(1)
    # else:
    #     out_log.info(cw.result.output)
    # out_log.info('')
    #
    # outpdbFn = cw.result.getFileName('outpdb')+".pdb"
    # out_log.info('Building output pdb file at')
    # out_log.info(paths[stepid]['output_pdb_path'])
    #
    # out_log.info('Base File: '+ paths[stepid]['input_pdb_path'])
    # out_log.info('Titration File: '+ outpdbFn)
    #
    # outFh = open(paths[stepid]['output_pdb_path'],"w")
    # baseFh = open(paths[stepid]['input_pdb_path'],"r")
    # addFh = open(outpdbFn,"r")
    #
    # outFh.write(baseFh.read())
    # baseFh.close()
    # for line in addFh:
    #     if re.match('^ATOM',line):
    #         outFh.write(line)
    # outFh.close()
    # addFh.close()
    #
    # out_log.info('')
    #
    # cw.run.rmTmpDir()
    #
    elapsed_time = time.time() - start_time
    out_log.info('')
    out_log.info('')
    out_log.info('Execution successful: ')
    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('')
Exemplo n.º 22
0
    def launch(self):
        """Launches the execution of the GROMACS pdb2gmx module.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        self.output_top_path = fu.add_step_mutation_path_to_name(
            self.output_top_path, self.step, self.mutation)
        self.output_itp_path = fu.add_step_mutation_path_to_name(
            self.output_itp_path, self.step, self.mutation)

        gmx = "gmx" if self.gmx_path is None else self.gmx_path
        cmd = [
            gmx, "genrestr", "-f", self.input_structure_path, "-n",
            self.input_ndx_path, "-o", self.output_itp_path, "-fc",
            self.force_constants
        ]

        if self.mpirun_np is not None:
            cmd.insert(0, str(self.mpirun_np))
            cmd.insert(0, '-np')
        if self.mpirun:
            cmd.insert(0, 'mpirun')

        if self.mpirun:
            cmd.append('<<<')
            cmd.append('\"' + self.restricted_group + '\"')
        else:
            cmd.insert(0, '|')
            cmd.insert(0, '\"' + self.restricted_group + '\"')
            cmd.insert(0, 'echo')

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        returncode = command.launch()

        fu.unzip_top(zip_file=self.input_top_zip_path,
                     top_file=self.output_top_path)
        out_log.info('Unzip: ' + self.input_top_zip_path + ' to: ' +
                     self.output_top_path)
        with open(self.output_top_path, 'r') as fin:
            for line in fin:
                if line.startswith('#ifdef POSRES'):
                    itp_name = re.findall('"([^"]*)"', fin.next())[0]
                    out_log.debug('itp_name: ' + itp_name)
                    break

        # with open(self.output_top_path, 'r') as fin:
        #     data = fin.read().splitlines(True)
        #     index = data.index('#ifdef POSRES\n')
        #     data[index+2] = 'system\n'
        #     data.insert(index, '\n')
        #     data.insert(index, '#endif\n')
        #     data.insert(index, '#include "'+self.output_itp_path+'"\n')
        #     data.insert(index, '#ifdef CUSTOM_POSRES\n')
        #     data.insert(index, '; Include Position restraint file\n')
        #     # data.insert(index, '#include "'+self.output_itp_path+'"\n')
        #     # data.insert(index, '; Include genrestr generated itp\n')
        # with open(self.output_top_path, 'w') as fout:
        #     fout.writelines(data)

        with open(self.output_itp_path, 'r') as fin:
            data = fin.read().splitlines(True)
            # data.insert(0, '\n')
            # data.insert(0, 'system    3\n')
            # data.insert(0, ';Name    nrexcl\n')
            # data.insert(0, '[ system ]\n')
        with open(itp_name, 'w') as fout:
            fout.writelines(data)
        os.remove(self.output_itp_path)

        # zip topology
        fu.zip_top(self.output_top_path,
                   self.output_top_zip_path,
                   remove_files=False)
        out_log.info('Zip: ' + self.output_top_path + ' to: ' +
                     self.output_top_zip_path)

        return returncode
Exemplo n.º 23
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('')
Exemplo n.º 24
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('')
Exemplo n.º 25
0
    def launch(self):
        """Launches the execution of the SCWRL binary.
        """

        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        if self.mutation is not None:
            # Read structure with Biopython
            parser = PDBParser(PERMISSIVE=1, QUIET=True)
            st = parser.get_structure(
                's', self.input_pdb_path)  # s random id never used

            if self.mut_dict['chain'] != 'ALL':
                chains = [self.mut_dict['chain']]
            else:
                chains = [chain.id for chain in st[0]]

            resnum = int(self.mut_dict['resnum'])

            sequence = ''
            for chain in chains:
                residue = st[0][chain][(' ', resnum, ' ')]
                backbone_atoms = ['N', 'CA', 'C', 'O', 'CB']
                not_backbone_atoms = []

                # The following formula does not work. Biopython bug?
                # for atom in residue:
                #     if atom.id not in backbone_atoms:
                #         residue.detach_child(atom.id)

                for atom in residue:
                    if atom.id not in backbone_atoms:
                        not_backbone_atoms.append(atom)
                for atom in not_backbone_atoms:
                    residue.detach_child(atom.id)

                # Change residue name
                residue.resname = self.mut_dict['mt'].upper()

                # Creating a sequence file where the lower case residues will
                # remain untouched and the upper case residues will be modified
                aa1c = {
                    'ALA': 'A',
                    'CYS': 'C',
                    'CYX': 'C',
                    'ASP': 'D',
                    'ASH': 'D',
                    'GLU': 'E',
                    'GLH': 'E',
                    'PHE': 'F',
                    'GLY': 'G',
                    'HIS': 'H',
                    'HID': 'H',
                    'HIE': 'H',
                    'HIP': 'H',
                    'ILE': 'I',
                    'LYS': 'K',
                    'LYP': 'K',
                    'LEU': 'L',
                    'MET': 'M',
                    'MSE': 'M',
                    'ASN': 'N',
                    'PRO': 'P',
                    'HYP': 'P',
                    'GLN': 'Q',
                    'ARG': 'R',
                    'SER': 'S',
                    'THR': 'T',
                    'VAL': 'V',
                    'TRP': 'W',
                    'TYR': 'Y'
                }
                for res in st[0][chain].get_residues():
                    if res.resname not in aa1c:
                        st[0][chain].detach_child(res.id)
                    elif (res.id == (' ', resnum, ' ')):
                        sequence += aa1c[res.resname].upper()
                    else:
                        sequence += aa1c[res.resname].lower()

            # Write resultant sequence
            sequence_file_path = fu.add_step_mutation_path_to_name(
                "sequence.seq", self.step, self.mutation)
            with open(sequence_file_path, 'w') as sqfile:
                sqfile.write(sequence + "\n")

            # Write resultant structure
            w = PDBIO()
            w.set_structure(st)
            prepared_file_path = fu.add_step_mutation_path_to_name(
                "prepared.pdb", self.step, self.mutation)
            w.save(prepared_file_path)

        else:
            prepared_file_path = self.input_pdb_path

        scrwl = 'Scwrl4' if self.scwrl4_path is None else self.scwrl4_path
        cmd = [
            scrwl, '-i', prepared_file_path, '-o', self.output_pdb_path, '-h',
            '-t'
        ]
        if self.mutation:
            cmd.append('-s')
            cmd.append(sequence_file_path)

        command = cmd_wrapper.CmdWrapper(cmd, out_log, err_log)
        return command.launch()
Exemplo n.º 26
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('')
Exemplo n.º 27
0
    def launch(self):
        """Launch the topology generation.
        """
        out_log, err_log = fu.get_logs(path=self.path,
                                       mutation=self.mutation,
                                       step=self.step)
        self.output_top_path = fu.add_step_mutation_path_to_name(
            self.output_top_path, self.step, self.mutation)

        fu.unzip_top(zip_file=self.input_top_zip_path,
                     top_file=self.output_top_path)
        out_log.info('Unzip: ' + self.input_top_zip_path + ' to: ' +
                     self.output_top_path)

        # Create index list of index file :)
        index_dic = {}
        lines = open(self.input_ndx_path, 'r').read().splitlines()
        for index, line in enumerate(lines):
            if line.startswith('['):
                index_dic[line] = index,
                if index > 0:
                    index_dic[label] = index_dic[label][0], index
                label = line
        index_dic[label] = index_dic[label][0], index
        out_log.info('Index_dic: ' + str(index_dic))

        self.ref_rest_chain_triplet_list = [
            tuple(elem.strip(' ()').replace(' ', '').split(','))
            for elem in self.ref_rest_chain_triplet_list.split('),')
        ]
        for reference_group, restrain_group, chain in self.ref_rest_chain_triplet_list:
            out_log.info('Reference group: ' + reference_group)
            out_log.info('Restrain group: ' + restrain_group)
            out_log.info('Chain: ' + chain)
            self.output_itp_path = fu.add_step_mutation_path_to_name(
                restrain_group + '.itp', self.step, self.mutation)

            # Mapping atoms from absolute enumeration to Chain relative enumeration
            out_log.info('reference_group_index: start_closed:' +
                         str(index_dic['[ ' + reference_group + ' ]'][0] + 1) +
                         ' stop_open: ' +
                         str(index_dic['[ ' + reference_group + ' ]'][1]))
            reference_group_list = [
                int(elem)
                for line in lines[index_dic['[ ' + reference_group + ' ]'][0] +
                                  1:index_dic['[ ' + reference_group +
                                              ' ]'][1]]
                for elem in line.split()
            ]
            out_log.info('restrain_group_index: start_closed:' +
                         str(index_dic['[ ' + restrain_group + ' ]'][0] + 1) +
                         ' stop_open: ' +
                         str(index_dic['[ ' + restrain_group + ' ]'][1]))
            restrain_group_list = [
                int(elem)
                for line in lines[index_dic['[ ' + restrain_group + ' ]'][0] +
                                  1:index_dic['[ ' + restrain_group + ' ]'][1]]
                for elem in line.split()
            ]
            selected_list = [
                reference_group_list.index(atom) + 1
                for atom in restrain_group_list
            ]

            # Creating new ITP with restrictions
            with open(self.output_itp_path, 'w') as f:
                out_log.info('Creating: ' + str(f) +
                             ' and adding the selected atoms force constants')
                f.write('[ position_restraints ]\n')
                f.write('; atom  type      fx      fy      fz\n')
                for atom in selected_list:
                    f.write(
                        str(atom) + '     1  ' + self.force_constants + '\n')

            # Including new ITP in the corresponding ITP-chain file
            for file_name in os.listdir('.'):
                if not file_name.startswith(
                        "posre") and not file_name.endswith("_pr.itp"):
                    if fnmatch.fnmatch(file_name, "*_chain_" + chain + ".itp"):
                        with open(file_name, 'a') as f:
                            out_log.info(
                                'Opening: ' + str(f) +
                                ' and adding the ifdef include statement')
                            f.write('\n')
                            f.write('; Include Position restraint file\n')
                            f.write('#ifdef CUSTOM_POSRES\n')
                            f.write('#include "' + self.output_itp_path +
                                    '"\n')
                            f.write('#endif\n')

        # zip topology
        fu.zip_top(self.output_top_path,
                   self.output_top_zip_path,
                   remove_files=True)
        out_log.info('Zip: ' + self.output_top_path + ' to: ' +
                     self.output_top_zip_path)

        return 0
Exemplo n.º 28
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('')

    out_log.info('step1:  mmbpdb ------ Get PDB')
    structure = conf.properties[system].get('initial_structure_pdb_path', None)
    out_log.info(22 * ' ' + 'Selected PDB structure: ' + structure)

    out_log.info('step2 and 3:  scw --- Check and Repair PDB')
    fu.create_dir(prop['step3_scw']['path'])
    paths['step3_scw']['input_pdb_path'] = structure
    out_log.debug('\nPaths:\n' + str(paths['step3_scw']) + '\nProperties:\n' +
                  str(prop['step3_scw']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step4_p2g']) + '\nProperties:\n' +
                  str(prop['step4_p2g']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step5_ec']) + '\nProperties:\n' +
                  str(prop['step5_ec']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step6_sol']) + '\nProperties:\n' +
                  str(prop['step6_sol']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step7_gppions']) +
                  '\nProperties:\n' + str(prop['step7_gppions']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step8_gio']) + '\nProperties:\n' +
                  str(prop['step8_gio']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step9_gppndx']) +
                  '\nProperties:\n' + str(prop['step9_gppndx']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step10_make_ndx']) +
                  '\nProperties:\n' + str(prop['step10_make_ndx']) + '\n')
    make_ndx.MakeNdx(properties=prop['step10_make_ndx'],
                     **paths['step10_make_ndx']).launch()

    out_log.info('Step11: genrest - Create restrain topology')
    fu.create_dir(prop['step11_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step11_genrestr']) +
                  '\nProperties:\n' + str(prop['step11_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step11_genrestr'],
                      **paths['step11_genrestr']).launch()

    out_log.info('step15: gppmin ------ Preprocessing: minimization')
    fu.create_dir(prop['step15_gppmin']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step15_gppmin']) +
                  '\nProperties:\n' + str(prop['step15_gppmin']) + '\n')
    grompp.Grompp(properties=prop['step15_gppmin'],
                  **paths['step15_gppmin']).launch()

    out_log.info('step16: mdmin ------- Running: minimization')
    fu.create_dir(prop['step16_mdmin']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step16_mdmin']) +
                  '\nProperties:\n' + str(prop['step16_mdmin']) + '\n')
    mdrun.Mdrun(properties=prop['step16_mdmin'],
                **paths['step16_mdmin']).launch()

    out_log.info('Step17: genrestr - Create restrain topology')
    fu.create_dir(prop['step17_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step17_genrestr']) +
                  '\nProperties:\n' + str(prop['step17_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step17_genrestr'],
                      **paths['step17_genrestr']).launch()

    out_log.info('step18: gppsa ------- Preprocessing: simulated annealing')
    fu.create_dir(prop['step18_gppsa']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step18_gppsa']) +
                  '\nProperties:\n' + str(prop['step18_gppsa']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step19_mdsa']) +
                  '\nProperties:\n' + str(prop['step19_mdsa']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step20_gppnvt_1000']) +
                  '\nProperties:\n' + str(prop['step20_gppnvt_1000']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step21_mdnvt_1000']) +
                  '\nProperties:\n' + str(prop['step21_mdnvt_1000']) + '\n')
    mdrun.Mdrun(properties=prop['step21_mdnvt_1000'],
                **paths['step21_mdnvt_1000']).launch()

    out_log.info('Step22: genrestr - Create restrain topology')
    fu.create_dir(prop['step22_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step22_genrestr']) +
                  '\nProperties:\n' + str(prop['step22_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step22_genrestr'],
                      **paths['step22_genrestr']).launch()

    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('\nPaths:\n' + str(paths['step23_gppnvt_800']) +
                  '\nProperties:\n' + str(prop['step23_gppnvt_800']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step24_mdnvt_800']) +
                  '\nProperties:\n' + str(prop['step24_mdnvt_800']) + '\n')
    mdrun.Mdrun(properties=prop['step24_mdnvt_800'],
                **paths['step24_mdnvt_800']).launch()

    out_log.info('Step25: genrestr - Create restrain topology')
    fu.create_dir(prop['step25_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step25_genrestr']) +
                  '\nProperties:\n' + str(prop['step25_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step25_genrestr'],
                      **paths['step25_genrestr']).launch()

    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('\nPaths:\n' + str(paths['step26_gppnpt_500']) +
                  '\nProperties:\n' + str(prop['step26_gppnpt_500']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step27_mdnpt_500']) +
                  '\nProperties:\n' + str(prop['step27_mdnpt_500']) + '\n')
    mdrun.Mdrun(properties=prop['step27_mdnpt_500'],
                **paths['step27_mdnpt_500']).launch()

    out_log.info('Step28: genrestr - Create restrain topology')
    fu.create_dir(prop['step28_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step28_genrestr']) +
                  '\nProperties:\n' + str(prop['step28_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step28_genrestr'],
                      **paths['step28_genrestr']).launch()

    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('\nPaths:\n' + str(paths['step29_gppnpt_300']) +
                  '\nProperties:\n' + str(prop['step29_gppnpt_300']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step30_mdnpt_300']) +
                  '\nProperties:\n' + str(prop['step30_mdnpt_300']) + '\n')
    mdrun.Mdrun(properties=prop['step30_mdnpt_300'],
                **paths['step30_mdnpt_300']).launch()

    out_log.info('Step31: genrestr - Create restrain topology')
    fu.create_dir(prop['step31_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step31_genrestr']) +
                  '\nProperties:\n' + str(prop['step31_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step31_genrestr'],
                      **paths['step31_genrestr']).launch()

    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('\nPaths:\n' + str(paths['step32_gppnpt_200']) +
                  '\nProperties:\n' + str(prop['step32_gppnpt_200']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step33_mdnpt_200']) +
                  '\nProperties:\n' + str(prop['step33_mdnpt_200']) + '\n')
    mdrun.Mdrun(properties=prop['step33_mdnpt_200'],
                **paths['step33_mdnpt_200']).launch()

    out_log.info('Step34: genrestr - Create restrain topology')
    fu.create_dir(prop['step34_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step34_genrestr']) +
                  '\nProperties:\n' + str(prop['step34_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step34_genrestr'],
                      **paths['step34_genrestr']).launch()

    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('\nPaths:\n' + str(paths['step35_gppnpt_100']) +
                  '\nProperties:\n' + str(prop['step35_gppnpt_100']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step36_mdnpt_100']) +
                  '\nProperties:\n' + str(prop['step36_mdnpt_100']) + '\n')
    mdrun.Mdrun(properties=prop['step36_mdnpt_100'],
                **paths['step36_mdnpt_100']).launch()

    out_log.info('Step37: genrestr - Create restrain topology')
    fu.create_dir(prop['step37_genrestr']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step37_genrestr']) +
                  '\nProperties:\n' + str(prop['step37_genrestr']) + '\n')
    genrestr.Genrestr(properties=prop['step37_genrestr'],
                      **paths['step37_genrestr']).launch()

    out_log.info(
        'step38: gppnpt ------ Preprocessing: npt constant number of molecules, pressure and temp'
    )
    fu.create_dir(prop['step38_gppnpt']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step38_gppnpt']) +
                  '\nProperties:\n' + str(prop['step38_gppnpt']) + '\n')
    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'])
    out_log.debug('\nPaths:\n' + str(paths['step39_mdnpt']) +
                  '\nProperties:\n' + str(prop['step39_mdnpt']) + '\n')
    mdrun.Mdrun(properties=prop['step39_mdnpt'],
                **paths['step39_mdnpt']).launch()

    out_log.info(
        'step40: gppmd ------- Preprocessing: Free Molecular dynamics')
    fu.create_dir(prop['step40_gppmd']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step40_gppmd']) +
                  '\nProperties:\n' + str(prop['step40_gppmd']) + '\n')
    grompp.Grompp(properties=prop['step40_gppmd'],
                  **paths['step40_gppmd']).launch()

    out_log.info('step41: md ---------- Running: Free Molecular dynamics')
    fu.create_dir(prop['step41_md']['path'])
    out_log.debug('\nPaths:\n' + str(paths['step41_md']) + '\nProperties:\n' +
                  str(prop['step41_md']) + '\n')
    mdrun.Mdrun(properties=prop['step41_md'], **paths['step41_md']).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('')
Exemplo n.º 29
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('')
Exemplo n.º 30
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('')