def dock(self, engine, protein, *args, **kwargs): """Docking procedure. Parameters ---------- engine: string Which docking engine to use. Note ---- Additional parameters are passed directly to the engine. """ if engine.lower() == 'autodock_vina': from oddt.docking import autodock_vina engine = autodock_vina(protein, *args, **kwargs) else: raise ValueError('Docking engine %s was not implemented in ODDT' % engine) if self.n_cpu != 1: _parallel_helper_partial = partial(_parallel_helper, engine, 'dock') docking_results = (Pool(self.n_cpu if self.n_cpu > 0 else None) .imap(_parallel_helper_partial, ({'ligands': lig, 'single': True} for lig in self._pipe))) else: docking_results = (engine.dock(lig, single=True) for lig in self._pipe) self._pipe = chain.from_iterable(docking_results)
def dock(self, engine, protein, *args, **kwargs): """Docking procedure. Parameters ---------- engine: string Which docking engine to use. Returns ------- None Note ---- Additional parameters are passed directly to the engine. Following docking engines are supported: 1. Audodock Vina (``engine="autodock_vina"``), see `oddt.docking.autodock_vina`. """ if engine.lower() == 'autodock_vina': from oddt.docking import autodock_vina engine = autodock_vina(protein, *args, **kwargs) else: raise ValueError('Docking engine %s was not implemented in ODDT' % engine) self._pipe.append(partial(method_caller, engine, 'dock'))
def dock(self, engine, protein, *args, **kwargs): """Docking procedure. Parameters ---------- engine: string Which docking engine to use. Note ---- Additional parameters are passed directly to the engine. """ if engine.lower() == 'autodock_vina': from oddt.docking import autodock_vina engine = autodock_vina(protein, *args, **kwargs) else: raise ValueError('Docking engine %s was not implemented in ODDT' % engine) def _iter_conf(results): """ Generator to go through docking results, and put them to pipe """ for confs in results: for conf in confs: yield conf if self.n_cpu != 1: _parallel_helper_partial = partial(_parallel_helper, engine, 'dock') docking_results = self._pool.imap(_parallel_helper_partial, ({'ligands':lig, 'single': True} for lig in self._pipe)) else: docking_results = (engine.dock(lig, single=True) for lig in self._pipe) self._pipe = _iter_conf(docking_results)
def __init__(self, protein=None, vina_scores=None): self.protein = protein self.vina = autodock_vina(protein) self.vina_scores = vina_scores or [ 'vina_affinity', 'vina_gauss1', 'vina_gauss2', 'vina_repulsion', 'vina_hydrophobic', 'vina_hydrogen' ] self.titles = self.vina_scores
def score(self, function, protein = None, *args, **kwargs): """Scoring procedure. Parameters ---------- function: string Which scoring function to use. protein: oddt.toolkit.Molecule Default protein to use as reference Note ---- Additional parameters are passed directly to the scoring function. """ if type(protein) is str: extension = protein.split('.')[-1] protein = six.next(toolkit.readfile(extension, protein)) protein.protein = True # trigger cache protein.atom_dict if type(function) is str: if function.lower().startswith('rfscore'): from oddt.scoring.functions.RFScore import rfscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) elif bit.startswith('v'): new_kwargs['version'] = int(bit.replace('v', '')) sf = rfscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower().startswith('nnscore'): from oddt.scoring.functions.NNScore import nnscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) sf = nnscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower() == 'autodock_vina': from oddt.docking import autodock_vina sf = autodock_vina(protein, *args, **kwargs) sf.set_protein(protein) else: raise ValueError('Scoring Function %s was not implemented in ODDT' % function) else: if hasattr(function, 'set_protein') and hasattr(function, 'predict_ligands') and hasattr(function, 'predict_ligand'): sf = function sf.set_protein(protein) else: raise ValueError('Supplied object "%s" is not an ODDT scoring funtion' % function.__name__) if self.n_cpu != 1: _parallel_helper_partial = partial(_parallel_helper, sf, 'predict_ligand') self._pipe = Pool(self.n_cpu if self.n_cpu > 0 else None).imap(_parallel_helper_partial, ({'ligand': lig} for lig in self._pipe), chunksize=100) else: self._pipe = sf.predict_ligands(self._pipe)
def score(self, function, protein = None, *args, **kwargs): """Scoring procedure. Parameters ---------- function: string Which scoring function to use. protein: oddt.toolkit.Molecule Default protein to use as reference Note ---- Additional parameters are passed directly to the scoring function. """ if type(protein) is str: extension = protein.split('.')[-1] protein = toolkit.readfile(extension, protein).next() protein.protein = True # trigger cache protein.atom_dict if type(function) is str: if function.lower().startswith('rfscore'): from oddt.scoring.functions.RFScore import rfscore tmp = function.lower().split('_') v = int(tmp[-1][1:]) if len(tmp) > 1 else 1 sf = rfscore.load(version=v) sf.set_protein(protein) elif function.lower() == 'nnscore': from oddt.scoring.functions.NNScore import nnscore sf = nnscore.load() sf.set_protein(protein) elif function.lower() == 'autodock_vina': from oddt.docking import autodock_vina sf = autodock_vina(protein, *args, **kwargs) sf.set_protein(protein) else: raise ValueError('Scoring Function %s was not implemented in ODDT' % function) else: if hasattr(function, 'set_protein') and hasattr(function, 'predict_ligands') and hasattr(function, 'predict_ligand'): sf = function sf.set_protein(protein) else: raise ValueError('Supplied object "%s" is not an ODDT scoring funtion' % function.__name__) if self.n_cpu != 1: _parallel_helper_partial = partial(_parallel_helper, sf, 'predict_ligand') self._pipe = self._pool.imap(_parallel_helper_partial, ({'ligand': lig} for lig in self._pipe), chunksize=100) else: self._pipe = sf.predict_ligands(self._pipe)
def __init__( self, protein=None, vina_scores=[ "vina_affinity", "vina_gauss1", "vina_gauss2", "vina_repulsion", "vina_hydrophobic", "vina_hydrogen", ], ): self.protein = protein self.vina = autodock_vina(protein) self.vina_scores = vina_scores
def __init__(self, protein = None): """ Descriptor build from binana script (as used in NNScore 2.0 Parameters ---------- protein: oddt.toolkit.Molecule object (default=None) Protein object to be used while generating descriptors. """ self.protein = protein self.vina = autodock_vina(protein) # Close contacts descriptor generators cc_4_types = (('A', 'A'), ('A', 'C'), ('A', 'CL'), ('A', 'F'), ('A', 'FE'), ('A', 'HD'), ('A', 'MG'), ('A', 'MN'), ('A', 'N'), ('A', 'NA'), ('A', 'OA'), ('A', 'SA'), ('A', 'ZN'), ('BR', 'C'), ('BR', 'HD'), ('BR', 'OA'), ('C', 'C'), ('C', 'CL'), ('C', 'F'), ('C', 'HD'), ('C', 'MG'), ('C', 'MN'), ('C', 'N'), ('C', 'NA'), ('C', 'OA'), ('C', 'SA'), ('C', 'ZN'), ('CL', 'FE'), ('CL', 'HD'), ('CL', 'MG'), ('CL', 'N'), ('CL', 'OA'), ('CL', 'ZN'), ('F', 'HD'), ('F', 'N'), ('F', 'OA'), ('F', 'SA'), ('FE', 'HD'), ('FE', 'N'), ('FE', 'OA'), ('HD', 'HD'), ('HD', 'I'), ('HD', 'MG'), ('HD', 'MN'), ('HD', 'N'), ('HD', 'NA'), ('HD', 'OA'), ('HD', 'P'), ('HD', 'S'), ('HD', 'SA'), ('HD', 'ZN'), ('MG', 'NA'), ('MG', 'OA'), ('MN', 'N'), ('MN', 'OA'), ('N', 'N'), ('N', 'NA'), ('N', 'OA'), ('N', 'SA'), ('N', 'ZN'), ('NA', 'OA'), ('NA', 'SA'), ('NA', 'ZN'), ('OA', 'OA'), ('OA', 'SA'), ('OA', 'ZN'), ('S', 'ZN'), ('SA', 'ZN'), ('A', 'BR'), ('A', 'I'), ('A', 'P'), ('A', 'S'), ('BR', 'N'), ('BR', 'SA'), ('C', 'FE'), ('C', 'I'), ('C', 'P'), ('C', 'S'), ('CL', 'MN'), ('CL', 'NA'), ('CL', 'P'), ('CL', 'S'), ('CL', 'SA'), ('CU', 'HD'), ('CU', 'N'), ('FE', 'NA'), ('FE', 'SA'), ('I', 'N'), ('I', 'OA'), ('MG', 'N'), ('MG', 'P'), ('MG', 'S'), ('MG', 'SA'), ('MN', 'NA'), ('MN', 'P'), ('MN', 'S'), ('MN', 'SA'), ('N', 'P'), ('N', 'S'), ('NA', 'P'), ('NA', 'S'), ('OA', 'P'), ('OA', 'S'), ('P', 'S'), ('P', 'SA'), ('P', 'ZN'), ('S', 'SA'), ('SA', 'SA'), ('A', 'CU'), ('C', 'CD') ) cc_4_rec_types, cc_4_lig_types = zip(*cc_4_types) self.cc_4 = cc_4_nn = close_contacts(protein, cutoff=4, protein_types=cc_4_rec_types, ligand_types=cc_4_lig_types, mode='atom_types_ad4', aligned_pairs=True) cc_25_types = [('A', 'A'), ('A', 'C'), ('A', 'CL'), ('A', 'F'), ('A', 'FE'), ('A', 'HD'), ('A', 'MG'), ('A', 'MN'), ('A', 'N'), ('A', 'NA'), ('A', 'OA'), ('A', 'SA'), ('A', 'ZN'), ('BR', 'C'), ('BR', 'HD'), ('BR', 'OA'), ('C', 'C'), ('C', 'CL'), ('C', 'F'), ('C', 'HD'), ('C', 'MG'), ('C', 'MN'), ('C', 'N'), ('C', 'NA'), ('C', 'OA'), ('C', 'SA'), ('C', 'ZN'), ('CD', 'OA'), ('CL', 'FE'), ('CL', 'HD'), ('CL', 'MG'), ('CL', 'N'), ('CL', 'OA'), ('CL', 'ZN'), ('F', 'HD'), ('F', 'N'), ('F', 'OA'), ('F', 'SA'), ('F', 'ZN'), ('FE', 'HD'), ('FE', 'N'), ('FE', 'OA'), ('HD', 'HD'), ('HD', 'I'), ('HD', 'MG'), ('HD', 'MN'), ('HD', 'N'), ('HD', 'NA'), ('HD', 'OA'), ('HD', 'P'), ('HD', 'S'), ('HD', 'SA'), ('HD', 'ZN'), ('MG', 'NA'), ('MG', 'OA'), ('MN', 'N'), ('MN', 'OA'), ('N', 'N'), ('N', 'NA'), ('N', 'OA'), ('N', 'SA'), ('N', 'ZN'), ('NA', 'OA'), ('NA', 'SA'), ('NA', 'ZN'), ('OA', 'OA'), ('OA', 'SA'), ('OA', 'ZN'), ('S', 'ZN'), ('SA', 'ZN')] cc_25_rec_types, cc_25_lig_types = zip(*cc_25_types) self.cc_25 = close_contacts(protein, cutoff=2.5, protein_types=cc_25_rec_types, ligand_types=cc_25_lig_types, mode='atom_types_ad4', aligned_pairs=True)
def dock(self, engine, protein, *args, **kwargs): """Docking procedure. Parameters ---------- engine: string Which docking engine to use. Notes ----- Additional parameters are passed directly to the engine. Following docking engines are supported: 1. Audodock Vina (```engine="autodock_vina"```), see :class:`oddt.docking.autodock_vina`. """ if engine.lower() == 'autodock_vina': from oddt.docking import autodock_vina engine = autodock_vina(protein, *args, **kwargs) else: raise ValueError('Docking engine %s was not implemented in ODDT' % engine) self._pipe.append(partial(method_caller, engine, 'dock'))
def dock(self, engine, protein, *args, **kwargs): """Docking procedure. Parameters ---------- engine: string Which docking engine to use. Note ---- Additional parameters are passed directly to the engine. """ if engine.lower() == 'autodock_vina': from oddt.docking import autodock_vina engine = autodock_vina(protein, *args, **kwargs) else: raise ValueError('Docking engine %s was not implemented in ODDT' % engine) def _iter_conf(results): """ Generator to go through docking results, and put them to pipe """ for confs in results: for conf in confs: yield conf if self.n_cpu != 1: _parallel_helper_partial = partial(_parallel_helper, engine, 'dock') docking_results = self._pool.imap(_parallel_helper_partial, ({ 'ligands': lig, 'single': True } for lig in self._pipe)) else: docking_results = (engine.dock(lig, single=True) for lig in self._pipe) self._pipe = _iter_conf(docking_results)
def score(self, function, protein=None, *args, **kwargs): """Scoring procedure compatible with any scoring function implemented in ODDT and other pickled SFs which are subclasses of `oddt.scoring.scorer`. Parameters ---------- function: string Which scoring function to use. protein: oddt.toolkit.Molecule Default protein to use as reference Note ---- Additional parameters are passed directly to the scoring function. """ if isinstance(protein, six.string_types): extension = protein.split('.')[-1] protein = next(oddt.toolkit.readfile(extension, protein)) protein.protein = True elif protein is None: raise ValueError('Protein needs to be set for structure based ' 'scoring') # trigger cache protein.atom_dict if isinstance(function, six.string_types): if isfile(function): sf = scorer.load(function) sf.set_protein(protein) elif function.lower().startswith('rfscore'): from oddt.scoring.functions.RFScore import rfscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) elif bit.startswith('v'): new_kwargs['version'] = int(bit.replace('v', '')) sf = rfscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower().startswith('nnscore'): from oddt.scoring.functions.NNScore import nnscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) sf = nnscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower() == 'autodock_vina': from oddt.docking import autodock_vina sf = autodock_vina(protein, *args, **kwargs) sf.set_protein(protein) else: raise ValueError('Scoring Function %s was not implemented in ' 'ODDT' % function) else: if isinstance(function, scorer): sf = function sf.set_protein(protein) else: raise ValueError('Supplied object "%s" is not an ODDT scoring ' 'funtion' % function.__name__) self._pipe.append(partial(method_caller, sf, 'predict_ligands'))
def score(self, function, protein=None, *args, **kwargs): """Scoring procedure compatible with any scoring function implemented in ODDT and other pickled SFs which are subclasses of `oddt.scoring.scorer`. Parameters ---------- function: string Which scoring function to use. protein: oddt.toolkit.Molecule Default protein to use as reference Notes ----- Additional parameters are passed directly to the scoring function. """ if isinstance(protein, six.string_types): extension = protein.split('.')[-1] protein = next(oddt.toolkit.readfile(extension, protein)) protein.protein = True elif protein is None: raise ValueError('Protein needs to be set for structure based ' 'scoring') # trigger cache protein.atom_dict if isinstance(function, six.string_types): if isfile(function): sf = scorer.load(function) sf.set_protein(protein) elif function.lower().startswith('rfscore'): from oddt.scoring.functions.RFScore import rfscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) elif bit.startswith('v'): new_kwargs['version'] = int(bit.replace('v', '')) sf = rfscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower().startswith('nnscore'): from oddt.scoring.functions.NNScore import nnscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) sf = nnscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower().startswith('plec'): from oddt.scoring.functions.PLECscore import PLECscore new_kwargs = {} for bit in function.lower().split('_'): if bit.startswith('pdbbind'): new_kwargs['pdbbind_version'] = int(bit.replace('pdbbind', '')) elif bit.startswith('plec'): new_kwargs['version'] = bit.replace('plec', '') elif bit.startswith('p'): new_kwargs['depth_protein'] = int(bit.replace('p', '')) elif bit.startswith('l'): new_kwargs['depth_ligand'] = int(bit.replace('l', '')) elif bit.startswith('s'): new_kwargs['size'] = int(bit.replace('s', '')) sf = PLECscore.load(**new_kwargs) sf.set_protein(protein) elif function.lower() == 'autodock_vina': from oddt.docking import autodock_vina sf = autodock_vina(protein, *args, **kwargs) sf.set_protein(protein) else: raise ValueError('Scoring Function %s was not implemented in ' 'ODDT' % function) else: if isinstance(function, scorer): sf = function sf.set_protein(protein) else: raise ValueError('Supplied object "%s" is not an ODDT scoring ' 'funtion' % function.__name__) self._pipe.append(partial(method_caller, sf, 'predict_ligands'))
def __init__(self, protein = None, vina_scores = ['vina_affinity', 'vina_gauss1', 'vina_gauss2', 'vina_repulsion', 'vina_hydrophobic', 'vina_hydrogen']): self.protein = protein self.vina = autodock_vina(protein) self.vina_scores = vina_scores
def __init__(self, protein=None): """ Descriptor build from binana script (as used in NNScore 2.0 Parameters ---------- protein: oddt.toolkit.Molecule object (default=None) Protein object to be used while generating descriptors. """ self.protein = protein self.vina = autodock_vina(protein) # Close contacts descriptor generators cc_4_types = (('A', 'A'), ('A', 'C'), ('A', 'CL'), ('A', 'F'), ('A', 'FE'), ('A', 'HD'), ('A', 'MG'), ('A', 'MN'), ('A', 'N'), ('A', 'NA'), ('A', 'OA'), ('A', 'SA'), ('A', 'ZN'), ('BR', 'C'), ('BR', 'HD'), ('BR', 'OA'), ('C', 'C'), ('C', 'CL'), ('C', 'F'), ('C', 'HD'), ('C', 'MG'), ('C', 'MN'), ('C', 'N'), ('C', 'NA'), ('C', 'OA'), ('C', 'SA'), ('C', 'ZN'), ('CL', 'FE'), ('CL', 'HD'), ('CL', 'MG'), ('CL', 'N'), ('CL', 'OA'), ('CL', 'ZN'), ('F', 'HD'), ('F', 'N'), ('F', 'OA'), ('F', 'SA'), ('FE', 'HD'), ('FE', 'N'), ('FE', 'OA'), ('HD', 'HD'), ('HD', 'I'), ('HD', 'MG'), ('HD', 'MN'), ('HD', 'N'), ('HD', 'NA'), ('HD', 'OA'), ('HD', 'P'), ('HD', 'S'), ('HD', 'SA'), ('HD', 'ZN'), ('MG', 'NA'), ('MG', 'OA'), ('MN', 'N'), ('MN', 'OA'), ('N', 'N'), ('N', 'NA'), ('N', 'OA'), ('N', 'SA'), ('N', 'ZN'), ('NA', 'OA'), ('NA', 'SA'), ('NA', 'ZN'), ('OA', 'OA'), ('OA', 'SA'), ('OA', 'ZN'), ('S', 'ZN'), ('SA', 'ZN'), ('A', 'BR'), ('A', 'I'), ('A', 'P'), ('A', 'S'), ('BR', 'N'), ('BR', 'SA'), ('C', 'FE'), ('C', 'I'), ('C', 'P'), ('C', 'S'), ('CL', 'MN'), ('CL', 'NA'), ('CL', 'P'), ('CL', 'S'), ('CL', 'SA'), ('CU', 'HD'), ('CU', 'N'), ('FE', 'NA'), ('FE', 'SA'), ('I', 'N'), ('I', 'OA'), ('MG', 'N'), ('MG', 'P'), ('MG', 'S'), ('MG', 'SA'), ('MN', 'NA'), ('MN', 'P'), ('MN', 'S'), ('MN', 'SA'), ('N', 'P'), ('N', 'S'), ('NA', 'P'), ('NA', 'S'), ('OA', 'P'), ('OA', 'S'), ('P', 'S'), ('P', 'SA'), ('P', 'ZN'), ('S', 'SA'), ('SA', 'SA'), ('A', 'CU'), ('C', 'CD')) cc_4_rec_types, cc_4_lig_types = zip(*cc_4_types) self.cc_4 = cc_4_nn = close_contacts(protein, cutoff=4, protein_types=cc_4_rec_types, ligand_types=cc_4_lig_types, mode='atom_types_ad4', aligned_pairs=True) cc_25_types = [('A', 'A'), ('A', 'C'), ('A', 'CL'), ('A', 'F'), ('A', 'FE'), ('A', 'HD'), ('A', 'MG'), ('A', 'MN'), ('A', 'N'), ('A', 'NA'), ('A', 'OA'), ('A', 'SA'), ('A', 'ZN'), ('BR', 'C'), ('BR', 'HD'), ('BR', 'OA'), ('C', 'C'), ('C', 'CL'), ('C', 'F'), ('C', 'HD'), ('C', 'MG'), ('C', 'MN'), ('C', 'N'), ('C', 'NA'), ('C', 'OA'), ('C', 'SA'), ('C', 'ZN'), ('CD', 'OA'), ('CL', 'FE'), ('CL', 'HD'), ('CL', 'MG'), ('CL', 'N'), ('CL', 'OA'), ('CL', 'ZN'), ('F', 'HD'), ('F', 'N'), ('F', 'OA'), ('F', 'SA'), ('F', 'ZN'), ('FE', 'HD'), ('FE', 'N'), ('FE', 'OA'), ('HD', 'HD'), ('HD', 'I'), ('HD', 'MG'), ('HD', 'MN'), ('HD', 'N'), ('HD', 'NA'), ('HD', 'OA'), ('HD', 'P'), ('HD', 'S'), ('HD', 'SA'), ('HD', 'ZN'), ('MG', 'NA'), ('MG', 'OA'), ('MN', 'N'), ('MN', 'OA'), ('N', 'N'), ('N', 'NA'), ('N', 'OA'), ('N', 'SA'), ('N', 'ZN'), ('NA', 'OA'), ('NA', 'SA'), ('NA', 'ZN'), ('OA', 'OA'), ('OA', 'SA'), ('OA', 'ZN'), ('S', 'ZN'), ('SA', 'ZN')] cc_25_rec_types, cc_25_lig_types = zip(*cc_25_types) self.cc_25 = close_contacts(protein, cutoff=2.5, protein_types=cc_25_rec_types, ligand_types=cc_25_lig_types, mode='atom_types_ad4', aligned_pairs=True)