示例#1
0
    def run_ligprep(self, smiles: list):
        """
        Call ligprep to prepare molecules.
        :param smiles: List of SMILES strings
        """
        ligprep_commands = []
        # Write out smiles to sdf files and prepare ligprep commands
        for smi, name in zip(smiles, self.file_names):
            smi_in = os.path.join(self.directory, f'{name}.smi')
            sdf_out = os.path.join(self.directory, f'{name}_ligprep.sdf')

            with open(smi_in, 'w') as f:
                f.write(smi)

            command = " ".join(
                (self.ligprep_env, f"-ismi {smi_in}", f"-osd {sdf_out}",
                 "-ph 7.0", "-pht 1.0", "-bff 16", "-s 8", "-epik", "-WAIT",
                 "-NOJOBID"))
            ligprep_commands.append(command)

        # Initialize subprocess
        logger.debug('LigPrep called')
        p = timedSubprocess(timeout=self.timeout).run

        # Run commands either using Dask or sequentially
        if self.cluster is not None:
            futures = self.client.map(p, ligprep_commands)
            _ = self.client.gather(futures)
        else:
            _ = [p(command) for command in ligprep_commands]
        logger.debug('LigPrep finished')
        return self
示例#2
0
    def dock_ligands(self, ligand_paths):
        smina_commands = []
        log_paths = []
        for l in ligand_paths:
            out_file = os.path.join(
                self.directory,
                os.path.basename(l).replace("_gypsum.sdf", "_docked.sdf"))
            out_log = os.path.join(
                self.directory,
                os.path.basename(l).replace("_gypsum.sdf", "_log.txt"))
            log_paths.append(out_log)
            cmd = f"smina -r {self.receptor} -l {l} --autobox_ligand {self.ref} -o {out_file} " \
                  f"--cpu {self.cpus} --exhaustiveness 8 --energy_range 3 --min_rmsd_filter 1 --quiet " \
                  f"--log {out_log}"
            smina_commands.append(cmd)

        # Initialize subprocess
        logger.debug('Smina called')
        p = timedSubprocess(timeout=self.timeout).run

        if self.cluster is not None:
            futures = self.client.map(p, smina_commands)
            _ = self.client.gather(futures)
        else:
            _ = [p(command) for command in smina_commands]
        logger.debug('Smina finished')
        return log_paths
示例#3
0
    def run_glide(self):
        """
        Write GLIDE new input files and submit each to Glide
        """
        glide_commands = []
        for name in self.file_names:
            for variant in self.variants[name]:
                # Set some file paths
                glide_in = self.glide_options.copy()
                # Change glide_in file
                glide_in = self.modify_glide_in(
                    glide_in, 'LIGANDFILE',
                    os.path.join(self.directory,
                                 f'{name}-{variant}_ligprep.sdf'))
                glide_in = self.modify_glide_in(glide_in, 'OUTPUTDIR',
                                                os.path.join(self.directory))

                # Write new input file (.in)
                with open(os.path.join(self.directory, f'{name}-{variant}.in'),
                          'wt') as f:
                    [f.write(line) for line in glide_in]

                # Prepare command line command
                command = self.glide_env + ' -WAIT -NOJOBID -NOLOCAL ' + \
                          os.path.join(self.directory, f'{name}-{variant}.in')
                glide_commands.append(command)

        # Initialize subprocess
        logger.debug('Glide called')
        p = timedSubprocess(timeout=self.timeout).run

        if self.cluster is not None:
            futures = self.client.map(p, glide_commands)
            _ = self.client.gather(futures)
        else:
            _ = [p(command) for command in glide_commands]
        logger.debug('Glide finished')
        return self