Python rdkit.Chem.AllChem.MolFragmentToSmiles() Examples
The following are 5
code examples of rdkit.Chem.AllChem.MolFragmentToSmiles().
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.AllChem
, or try the search function
.
Example #1
Source File: createsmartsdescriptors.py From qsar-tools with Apache License 2.0 | 7 votes |
def computesubgraphsmarts(mol, size): '''Given an rdkit mol, extract all the paths up to length size (if zero, use default length). Return smarts expressions for these paths.''' if size <= 0: size = 6 #default to 6 bonds #find all paths of various sizes paths = Chem.FindAllSubgraphsOfLengthMToN(mol,1,size) #paths is a list of lists, each of which is the bond indices for paths of a different length paths = [path for subpath in paths for path in subpath] ret = set() for path in paths: atoms=set() for bidx in path: atoms.add(mol.GetBondWithIdx(bidx).GetBeginAtomIdx()) atoms.add(mol.GetBondWithIdx(bidx).GetEndAtomIdx()) smi = Chem.MolFragmentToSmiles(mol, atoms, canonical=True, allBondsExplicit=True) ret.add(smi) return ret
Example #2
Source File: createsmartsdescriptors.py From qsar-tools with Apache License 2.0 | 5 votes |
def computepathsmarts(mol, size): if size <= 0: size = 7 # default to 7 atoms ret = set() for length in range(2,size+1): paths = Chem.FindAllPathsOfLengthN(mol, length, useBonds=False) for path in paths: smi = Chem.MolFragmentToSmiles(mol, path, canonical=True, allBondsExplicit=True) ret.add(smi) return ret
Example #3
Source File: createsmartsdescriptors.py From qsar-tools with Apache License 2.0 | 5 votes |
def computecircularsmarts(mol, size): '''Given an rdkit mol, extract all the circular type descriptors up to radius size (if zero, use default length). Return smarts expressions for these fragments.''' if size <= 0: size = 2 ret = set() for a in mol.GetAtoms(): for r in range(1,size+1): env = Chem.FindAtomEnvironmentOfRadiusN(mol,r,a.GetIdx()) atoms=set() for bidx in env: atoms.add(mol.GetBondWithIdx(bidx).GetBeginAtomIdx()) atoms.add(mol.GetBondWithIdx(bidx).GetEndAtomIdx()) smi = Chem.MolFragmentToSmiles(mol, atoms, canonical=True, allBondsExplicit=True) ret.add(smi) return ret
Example #4
Source File: template_extractor.py From GLN with MIT License | 5 votes |
def get_frag_around_tetrahedral_center(mol, idx): '''Builds a MolFragment using neighbors of a tetrahedral atom, where the molecule has already been updated to include isotopes''' ids_to_include = [idx] for neighbor in mol.GetAtomWithIdx(idx).GetNeighbors(): ids_to_include.append(neighbor.GetIdx()) symbols = ['[{}{}]'.format(a.GetIsotope(), a.GetSymbol()) if a.GetIsotope() != 0\ else '[#{}]'.format(a.GetAtomicNum()) for a in mol.GetAtoms()] return Chem.MolFragmentToSmiles(mol, ids_to_include, isomericSmiles=True, atomSymbols=symbols, allBondsExplicit=True, allHsExplicit=True)
Example #5
Source File: reaxys_generate_retro_templates_v9_chiral.py From ASKCOS with Mozilla Public License 2.0 | 5 votes |
def get_frag_around_tetrahedral_center(mol, idx): '''Builds a MolFragment using neighbors of a tetrahedral atom, where the molecule has already been updated to include isotopes''' ids_to_include = [idx] for neighbor in mol.GetAtomWithIdx(idx).GetNeighbors(): ids_to_include.append(neighbor.GetIdx()) symbols = ['[{}{}]'.format(a.GetIsotope(), a.GetSymbol()) if a.GetIsotope() != 0\ else '[#{}]'.format(a.GetAtomicNum()) for a in mol.GetAtoms()] return Chem.MolFragmentToSmiles(mol, ids_to_include, isomericSmiles=True, atomSymbols=symbols, allBondsExplicit=True, allHsExplicit=True)