Python rdkit.Chem.AssignStereochemistry() Examples
The following are 9
code examples of rdkit.Chem.AssignStereochemistry().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rdkit.Chem
, or try the search function
.
Example #1
Source File: standardize.py From MolVS with MIT License | 6 votes |
def standardize(self, mol): """Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :py:func:`~rdkit.Chem.rdmolops.RemoveHs`, RDKit :py:func:`~rdkit.Chem.rdmolops.SanitizeMol`, :class:`~molvs.metal.MetalDisconnector`, :class:`~molvs.normalize.Normalizer`, :class:`~molvs.charge.Reionizer`, RDKit :py:func:`~rdkit.Chem.rdmolops.AssignStereochemistry`. :param mol: The molecule to standardize. :type mol: rdkit.Chem.rdchem.Mol :returns: The standardized molecule. :rtype: rdkit.Chem.rdchem.Mol """ mol = copy.deepcopy(mol) Chem.SanitizeMol(mol) mol = Chem.RemoveHs(mol) mol = self.disconnect_metals(mol) mol = self.normalize(mol) mol = self.reionize(mol) Chem.AssignStereochemistry(mol, force=True, cleanIt=True) # TODO: Check this removes symmetric stereocenters return mol
Example #2
Source File: initialization.py From ASKCOS with Mozilla Public License 2.0 | 6 votes |
def initialize_rxn_from_smarts(reaction_smarts): # Initialize reaction rxn = AllChem.ReactionFromSmarts(reaction_smarts) rxn.Initialize() if rxn.Validate()[1] != 0: raise ValueError('validation failed') if PLEVEL >= 2: print('Validated rxn without errors') unmapped = 700 for rct in rxn.GetReactants(): rct.UpdatePropertyCache() Chem.AssignStereochemistry(rct) # Fill in atom map numbers for a in rct.GetAtoms(): if not a.HasProp('molAtomMapNumber'): a.SetIntProp('molAtomMapNumber', unmapped) unmapped += 1 if PLEVEL >= 2: print('Added {} map nums to unmapped reactants'.format(unmapped-700)) if unmapped > 800: raise ValueError('Why do you have so many unmapped atoms in the template reactants?') return rxn
Example #3
Source File: PyPretreatMolutil.py From PyBioMed with BSD 3-Clause "New" or "Revised" License | 6 votes |
def standardize(self, mol): """Return a standardized version the given molecule. The standardization process consists of the following stages: RDKit :rdkit:`RemoveHs <Chem.rdmolops-module.html#RemoveHs>`, RDKit :rdkit:`SanitizeMol <Chem.rdmolops-module.html#SanitizeMol>`, :class:`~molvs.metal.MetalDisconnector`, :class:`~molvs.normalize.Normalizer`, :class:`~molvs.charge.Reionizer`, RDKit :rdkit:`AssignStereochemistry <Chem.rdmolops-module.html#AssignStereochemistry>`. :param mol: The molecule to standardize. :type mol: :rdkit:`Mol <Chem.rdchem.Mol-class.html>` :returns: The standardized molecule. :rtype: :rdkit:`Mol <Chem.rdchem.Mol-class.html>` """ mol = copy.deepcopy(mol) Chem.RemoveHs(mol) Chem.SanitizeMol(mol) mol = self.disconnect_metals(mol) mol = self.normalize(mol) mol = self.reionize(mol) Chem.AssignStereochemistry(mol, force=True, cleanIt=True) # TODO: Check this removes symmetric stereocenters return mol
Example #4
Source File: initialization.py From GLN with MIT License | 5 votes |
def initialize_rxn_from_smarts(reaction_smarts): # Initialize reaction rxn = AllChem.ReactionFromSmarts(reaction_smarts) rxn.Initialize() if rxn.Validate()[1] != 0: raise ValueError('validation failed') if PLEVEL >= 2: print('Validated rxn without errors') # Figure out if there are unnecessary atom map numbers (that are not balanced) # e.g., leaving groups for retrosynthetic templates. This is because additional # atom map numbers in the input SMARTS template may conflict with the atom map # numbers of the molecules themselves prd_maps = [a.GetAtomMapNum() for prd in rxn.GetProducts() for a in prd.GetAtoms() if a.GetAtomMapNum()] unmapped = 700 for rct in rxn.GetReactants(): rct.UpdatePropertyCache() Chem.AssignStereochemistry(rct) # Fill in atom map numbers for a in rct.GetAtoms(): if not a.GetAtomMapNum() or a.GetAtomMapNum() not in prd_maps: a.SetAtomMapNum(unmapped) unmapped += 1 if PLEVEL >= 2: print('Added {} map nums to unmapped reactants'.format(unmapped-700)) if unmapped > 800: raise ValueError('Why do you have so many unmapped atoms in the template reactants?') return rxn
Example #5
Source File: initialization.py From GLN with MIT License | 5 votes |
def initialize_reactants_from_smiles(reactant_smiles): # Initialize reactants reactants = Chem.MolFromSmiles(reactant_smiles) Chem.AssignStereochemistry(reactants, flagPossibleStereoCenters=True) reactants.UpdatePropertyCache() # To have the product atoms match reactant atoms, we # need to populate the map number field, since this field # gets copied over during the reaction via reactant_atom_idx. [a.SetAtomMapNum(i+1) for (i, a) in enumerate(reactants.GetAtoms())] if PLEVEL >= 2: print('Initialized reactants, assigned map numbers, stereochem, flagpossiblestereocenters') return reactants
Example #6
Source File: initialization.py From ASKCOS with Mozilla Public License 2.0 | 5 votes |
def initialize_reactants_from_smiles(reactant_smiles): # Initialize reactants reactants = Chem.MolFromSmiles(reactant_smiles) Chem.AssignStereochemistry(reactants, flagPossibleStereoCenters=True) reactants.UpdatePropertyCache() # To have the product atoms match reactant atoms, we # need to populate the Isotope field, since this field # gets copied over during the reaction. [a.SetIsotope(i+1) for (i, a) in enumerate(reactants.GetAtoms())] if PLEVEL >= 2: print('Initialized reactants, assigned isotopes, stereochem, flagpossiblestereocenters') return reactants
Example #7
Source File: xyz2mol.py From xyz2mol with MIT License | 5 votes |
def chiral_stereo_check(mol): """ Find and embed chiral information into the model based on the coordinates args: mol - rdkit molecule, with embeded conformer """ Chem.SanitizeMol(mol) Chem.DetectBondStereochemistry(mol, -1) Chem.AssignStereochemistry(mol, flagPossibleStereoCenters=True, force=True) Chem.AssignAtomChiralTagsFromStructure(mol, -1) return
Example #8
Source File: xyz2mol.py From BCAI_kaggle_CHAMPS with MIT License | 5 votes |
def chiral_stereo_check(mol): Chem.SanitizeMol(mol) Chem.DetectBondStereochemistry(mol,-1) Chem.AssignStereochemistry(mol, flagPossibleStereoCenters=True, force=True) Chem.AssignAtomChiralTagsFromStructure(mol,-1) return mol
Example #9
Source File: dataset.py From 3DGCN with MIT License | 4 votes |
def get_atom_features(self, mol): AllChem.ComputeGasteigerCharges(mol) Chem.AssignStereochemistry(mol) hydrogen_donor_match = sum(mol.GetSubstructMatches(self.hydrogen_donor), ()) hydrogen_acceptor_match = sum(mol.GetSubstructMatches(self.hydrogen_acceptor), ()) acidic_match = sum(mol.GetSubstructMatches(self.acidic), ()) basic_match = sum(mol.GetSubstructMatches(self.basic), ()) ring = mol.GetRingInfo() m = [] for atom_idx in range(mol.GetNumAtoms()): atom = mol.GetAtomWithIdx(atom_idx) o = [] o += one_hot(atom.GetSymbol(), ['C', 'O', 'N', 'S', 'Cl', 'F', 'Br', 'P', 'I', 'Si', 'B', 'Na', 'Sn', 'Se', 'other']) if self.use_atom_symbol else [] o += one_hot(atom.GetDegree(), [0, 1, 2, 3, 4, 5, 6]) if self.use_degree else [] o += one_hot(atom.GetHybridization(), [Chem.rdchem.HybridizationType.SP, Chem.rdchem.HybridizationType.SP2, Chem.rdchem.HybridizationType.SP3, Chem.rdchem.HybridizationType.SP3D, Chem.rdchem.HybridizationType.SP3D2]) if self.use_hybridization else [] o += one_hot(atom.GetImplicitValence(), [0, 1, 2, 3, 4, 5, 6]) if self.use_implicit_valence else [] o += one_hot(atom.GetFormalCharge(), [-3, -2, -1, 0, 1, 2, 3]) if self.use_degree else [] # o += [atom.GetProp("_GasteigerCharge")] if self.use_partial_charge else [] # some molecules return NaN o += [atom.GetIsAromatic()] if self.use_aromaticity else [] o += [ring.IsAtomInRingOfSize(atom_idx, 3), ring.IsAtomInRingOfSize(atom_idx, 4), ring.IsAtomInRingOfSize(atom_idx, 5), ring.IsAtomInRingOfSize(atom_idx, 6), ring.IsAtomInRingOfSize(atom_idx, 7), ring.IsAtomInRingOfSize(atom_idx, 8)] if self.use_ring_size else [] o += one_hot(atom.GetTotalNumHs(), [0, 1, 2, 3, 4]) if self.use_num_hydrogen else [] if self.use_chirality: try: o += one_hot(atom.GetProp('_CIPCode'), ["R", "S"]) + [atom.HasProp("_ChiralityPossible")] except: o += [False, False] + [atom.HasProp("_ChiralityPossible")] if self.use_hydrogen_bonding: o += [atom_idx in hydrogen_donor_match] o += [atom_idx in hydrogen_acceptor_match] if self.use_acid_base: o += [atom_idx in acidic_match] o += [atom_idx in basic_match] m.append(o) return np.array(m, dtype=float)