Package rdkit :: Package Chem :: Package MolKey :: Module MolKey
[hide private]
[frames] | no frames]

Module MolKey

source code

Classes [hide private]
  MolIdentifierException
  BadMoleculeException
Functions [hide private]
 
_fix_all(pat, sbt, my_string) source code
 
_fix_line_ends(my_string) source code
 
_fix_chemdraw_header(my_string) source code
 
_ctab_has_atoms(ctab_lines)
look at atom count position (line 4, characters 0:3) Return True if the count is >0, False if 0.
source code
 
_ctab_remove_chiral_flag(ctab_lines)
read the chiral flag (line 4, characters 12:15) and set it to 0.
source code
 
initStruchk(configDir=None, logFile=None) source code
 
CheckCTAB(ctab, isSmiles=True) source code
 
GetInchiForCTAB(ctab)
>>> from rdkit.Chem.MolKey import MolKey...
source code
 
_make_racemate_inchi(inchi)
Normalize the stereo information (t-layer) to one selected isomer.
source code
 
_get_identification_string(err, ctab, inchi, stereo_category=None, extra_stereo=None) source code
 
_get_null_mol_identification_string(extra_stereo) source code
 
_get_bad_mol_identification_string(ctab, stereo_category, extra_stereo) source code
 
_identify(err, ctab, inchi, stereo_category, extra_structure_desc=None)
Compute the molecule key based on the inchi string,...
source code
 
_get_chiral_identification_string(n_def, n_udf) source code
 
ErrorBitsToText(err)
returns a list of error bit descriptions for the error code provided
source code
 
GetKeyForCTAB(ctab, stereo_info=None, stereo_comment=None, logger=None)
>>> from rdkit.Chem.MolKey import MolKey...
source code
 
_test() source code
Variables [hide private]
  MOL_KEY_VERSION = '1'
  ERROR_DICT = dict(BAD_MOLECULE= 1, ALIAS_CONVERSION_FAILED= 2,...
  INCHI_COMPUTATION_ERROR = ERROR_DICT ['INCHI_COMPUTATION_ERROR']
  RDKIT_CONVERSION_ERROR = ERROR_DICT ['RDKIT_CONVERSION_ERROR']
  INCHI_READWRITE_ERROR = ERROR_DICT ['INCHI_READWRITE_ERROR']
  NULL_MOL = ERROR_DICT ['NULL_MOL']
  BAD_SET = pyAvalonTools.StruChkResult.bad_set | INCHI_COMPUTAT...
  GET_STEREO_RE = re.compile(r'^InChI=1S(.*?)/(t.*?)/m\d/s1(.*$)')
  NULL_SMILES_RE = re.compile(r'^\s*$|^\s*NO_STRUCTURE\s*$', re....
  PATTERN_NULL_MOL = r'^([\s0]+[1-9]+[\s]+V[\w]*)'
  CHIRAL_POS = 12
  T_NULL_MOL = NULL_MOL, ''
  stereo_code_dict = {}
  __initCalled = False
  InchiResult = namedtuple('InchiResult', ['error', 'inchi', 'fi...
  MolKeyResult = namedtuple('MolKeyResult', ['mol_key', 'error',...

Imports: pyAvalonTools, InchiInfo, RDConfig, Chem, namedtuple, logging, os, re, uuid, base64, hashlib, tempfile


Function Details [hide private]

_ctab_has_atoms(ctab_lines)

source code 
look at atom count position (line 4, characters 0:3)
Return True if the count is >0, False if 0.
Throw BadMoleculeException if there are no characters
at the required position or if they cannot be converted
to a positive integer

_ctab_remove_chiral_flag(ctab_lines)

source code 
read the chiral flag (line 4, characters 12:15)
and set it to 0. Return True if it was 1, False if 0.
Throw BadMoleculeException if there are no characters
at the required position or if they where not 0 or 1

GetInchiForCTAB(ctab)

source code 

>>> from rdkit.Chem.MolKey import MolKey
>>> from rdkit.Avalon import pyAvalonTools
>>> res = MolKey.GetInchiForCTAB(pyAvalonTools.Generate2DCoords('c1cn[nH]c1C(Cl)Br',True))
>>> res.inchi
'InChI=1/C4H4BrClN2/c5-4(6)3-1-2-7-8-3/h1-2,4H,(H,7,8)/t4?/f/h8H'
>>> res = MolKey.GetInchiForCTAB(pyAvalonTools.Generate2DCoords('c1c[nH]nc1C(Cl)Br',True))
>>> res.inchi
'InChI=1/C4H4BrClN2/c5-4(6)3-1-2-7-8-3/h1-2,4H,(H,7,8)/t4?/f/h7H'
>>>

_identify(err, ctab, inchi, stereo_category, extra_structure_desc=None)

source code 
Compute the molecule key based on the inchi string,
stereo category as well as extra structure
information 

GetKeyForCTAB(ctab, stereo_info=None, stereo_comment=None, logger=None)

source code 

>>> from rdkit.Chem.MolKey import MolKey
>>> from rdkit.Avalon import pyAvalonTools
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1ccccc1C(F)Cl',True))
>>> res.mol_key
'1|L7676nfGsSIU33wkx//NCg=='
>>> res.stereo_code
'R_ONE'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1ccccc1[C@H](F)Cl',True))
>>> res.mol_key
'1|Aj38EIxf13RuPDQG2A0UMw=='
>>> res.stereo_code
'S_ABS'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1ccccc1[C@@H](F)Cl',True))
>>> res.mol_key
'1|9ypfMrhxn1w0ncRooN5HXw=='
>>> res.stereo_code
'S_ABS'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1cccc(C(Br)Cl)c1[C@@H](F)Cl',True))
>>> res.mol_key
'1|c96jMSlbn7O9GW5d5uB9Mw=='
>>> res.stereo_code
'S_PART'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1cccc([C@H](Br)Cl)c1[C@@H](F)Cl',True))
>>> res.mol_key
'1|+B+GCEardrJteE8xzYdGLA=='
>>> res.stereo_code
'S_ABS'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1cccc(C(Br)Cl)c1C(F)Cl',True))
>>> res.mol_key
'1|5H9R3LvclagMXHp3Clrc/g=='
>>> res.stereo_code
'S_UNKN'
>>> res=MolKey.GetKeyForCTAB(pyAvalonTools.Generate2DCoords('c1cccc(C(Br)Cl)c1C(F)Cl',True),stereo_info='S_REL')
>>> res.mol_key
'1|cqKWVsUEY6QNpGCbDaDTYA=='
>>> res.stereo_code
'S_REL'
>>> res.inchi
'InChI=1/C8H6BrCl2F/c9-7(10)5-3-1-2-4-6(5)8(11)12/h1-4,7-8H/t7?,8?'


Variables Details [hide private]

ERROR_DICT

Value:
dict(BAD_MOLECULE= 1, ALIAS_CONVERSION_FAILED= 2, TRANSFORMED= 4, FRAG\
MENTS_FOUND= 8, EITHER_WARNING= 16, STEREO_ERROR= 32, DUBIOUS_STEREO_R\
EMOVED= 64, ATOM_CLASH= 128, ATOM_CHECK_FAILED= 256, SIZE_CHECK_FAILED\
= 512, RECHARGED= 1024, STEREO_FORCED_BAD= 2048, STEREO_TRANSFORMED= 4\
096, TEMPLATE_TRANSFORMED= 8192, INCHI_COMPUTATION_ERROR= 65536, RDKIT\
_CONVERSION_ERROR= 131072, INCHI_READWRITE_ERROR= 262144, NULL_MOL= 52\
4288)

BAD_SET

Value:
pyAvalonTools.StruChkResult.bad_set | INCHI_COMPUTATION_ERROR | RDKIT_\
CONVERSION_ERROR | INCHI_READWRITE_ERROR | NULL_MOL

NULL_SMILES_RE

Value:
re.compile(r'^\s*$|^\s*NO_STRUCTURE\s*$', re.IGNORECASE)

InchiResult

Value:
namedtuple('InchiResult', ['error', 'inchi', 'fixed_ctab'])

MolKeyResult

Value:
namedtuple('MolKeyResult', ['mol_key', 'error', 'inchi', 'fixed_ctab',\
 'stereo_code', 'stereo_comment'])