Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure in completing #161

Open
parkc23 opened this issue Apr 16, 2022 · 4 comments
Open

failure in completing #161

parkc23 opened this issue Apr 16, 2022 · 4 comments

Comments

@parkc23
Copy link

parkc23 commented Apr 16, 2022

Hi,
Recently I tried a file of a few thousands of molecules, and found that ODDT keeps getting stuck and idle halfway through. I would appreciate it if you could look into the problem.
Thanks.

@mwojcikowski
Copy link
Contributor

Hi @parkc23,
Could you please provide the code and file to reproduce the issue?

@parkc23
Copy link
Author

parkc23 commented Apr 27, 2022 via email

@echonemanja
Copy link

echonemanja commented Aug 25, 2022

The same thing is happening with autodock_vina. It just stuck at some molecules (py process fills up whole memory after vina process ends), usually larger ones. Example is bellow. Tested on windows and ubuntu. Example from shorturl.at/eNRX0 works fine.
Any thoughts?

Code:
mol = Chem.AddHs(Chem.MolFromSmiles('CC(=O)O[C@H]1C[C@@H](OC(C)=O)C(C)(C)[C@@H]2C[C@@H](OC(C)=O)[C@]3(C)[C@H](CC[C@@]4(C)[C@H](c5ccoc5)OC(=O)[C@H]5O[C@]543)[C@@]12C'))
AllChem.EmbedMolecule(mol)
odmol = oddt.toolkits.rdk.Molecule(mol)
obmol = oddt.toolkits.ob.Molecule(odmol)
vs.center
res = vs.dock(ligands=[obmol])

@echonemanja
Copy link

echonemanja commented Aug 31, 2022

The same thing is happening with autodock_vina. It just stuck at some molecules (py process fills up whole memory after vina process ends), usually larger ones. Example is bellow. Tested on windows and ubuntu. Example from shorturl.at/eNRX0 works fine. Any thoughts?

Code: mol = Chem.AddHs(Chem.MolFromSmiles('CC(=O)O[C@H]1C[C@@H](OC(C)=O)C(C)(C)[C@@H]2C[C@@H](OC(C)=O)[C@]3(C)[C@H](CC[C@@]4(C)[C@H](c5ccoc5)OC(=O)[C@H]5O[C@]543)[C@@]12C')) AllChem.EmbedMolecule(mol) odmol = oddt.toolkits.rdk.Molecule(mol) obmol = oddt.toolkits.ob.Molecule(odmol) vs.center res = vs.dock(ligands=[obmol])

Just to follow up on the issue I reported in previous comment. Basically, what prevented python process to finish was part of the code of "dock" function of AutodockVina.py which renumbers the atoms order and calculates the RMSD on that messed up atoms. When I deleted (commented out) the parts of the code referring to the renumbering and rmsd calculations, everything worked just fine. Modified AutodockVina.py dock function is attached below. Probably something went wrong with open babel version (i have tested versions 3.0.0 and above). I hope this will help others to solve the issue on failure in completing.

def dock(self, ligands, protein=None):
        """Automated docking procedure.

        Parameters
        ----------
        ligands: iterable of oddt.toolkit.Molecule objects
            Ligands to dock

        protein: oddt.toolkit.Molecule object or None
            Protein object to be used. If None, then the default one
            is used, else the protein is new default.

        Returns
        -------
        ligands : array of oddt.toolkit.Molecule objects
            Array of ligands (scores are stored in mol.data method)
        """
        if protein:
            self.set_protein(protein)
        if not self.protein_file:
            raise IOError("No receptor.")
        if is_molecule(ligands):
            ligands = [ligands]
        ligand_dir = mkdtemp(dir=self.tmp_dir, prefix='ligands_')
        output_array = []
        for n, ligand in enumerate(ligands):
            check_molecule(ligand, force_coords=True)
            ligand_file = write_vina_pdbqt(ligand, ligand_dir, name_id=n)
            ligand_outfile = ligand_file[:-6] + '_out.pdbqt'
            try:
                scores = parse_vina_docking_output(
                    subprocess.check_output([self.executable, '--receptor',
                                             self.protein_file,
                                             '--ligand', ligand_file,
                                             '--out', ligand_outfile] +
                                            self.params +
                                            ['--cpu', str(self.n_cpu)],
                                            stderr=subprocess.STDOUT))
            except subprocess.CalledProcessError as e:
                sys.stderr.write(e.output.decode('ascii'))
                if self.skip_bad_mols:
                    continue  # TODO: print some warning message
                else:
                    raise Exception('Autodock Vina failed. Command: "%s"' %
                                    ' '.join(e.cmd))

            # docked conformations may have wrong connectivity - use source ligand
            if is_openbabel_molecule(ligand):
                if oddt.toolkits.ob.__version__ >= '2.4.0':
                    # find the order of PDBQT atoms assigned by OpenBabel
                    with open(ligand_file) as f:
                        write_order = [int(line[7:12].strip())
                                       for line in f
                                       if line[:4] == 'ATOM']
                    new_order = sorted(range(len(write_order)),
                                       key=write_order.__getitem__)
                    new_order = [i + 1 for i in new_order]  # OBMol has 1 based idx

                    assert len(new_order) == len(ligand.atoms)
                else:
                    # Openbabel 2.3.2 does not support perserving atom order.
                    # We read back the PDBQT ligand to get "correct" bonding.
                    ligand = next(oddt.toolkit.readfile('pdbqt', ligand_file))
                    if 'REMARK' in ligand.data:
                        del ligand.data['REMARK']

            docked_ligands = oddt.toolkit.readfile('pdbqt', ligand_outfile)
            for docked_ligand, score in zip(docked_ligands, scores):
                # Renumber atoms to match the input ligand
#                if (is_openbabel_molecule(docked_ligand) and
#                        oddt.toolkits.ob.__version__ >= '2.4.0'):
#                    docked_ligand.OBMol.RenumberAtoms(new_order)
                # HACK: copy docked coordinates onto source ligand
                # We assume that the order of atoms match between ligands
                clone = docked_ligand.clone
                clone.clone_coords(docked_ligand)
                clone.data.update(score)

                # Calculate RMSD to the input pose
#                try:
#                    clone.data['vina_rmsd_input'] = rmsd(ligand, clone)
#                    clone.data['vina_rmsd_input_min'] = rmsd(ligand, clone,
#                                                             method='min_symmetry')
#                except Exception:
#                    pass
                output_array.append(clone)
        rmtree(ligand_dir)
        return output_array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants