I don't know if this fits in the Getting Started, or Cookbook, or if TPTB decide to wikify the docs and it should go there, but anyway, here goes. With thanks to everyone responsible, of course.
It does need corrections/clarifications. --------------------------------- # MOL/SDF FindChiralCenters howto ```python # list chiral centers in molecule sts=rdkit.Chem.FindMolChiralCenters(mol,includeUnassigned=True,force=False) for s in sts: lbl=mol.GetAtomWithIdx(s[0]).GetSymbol() + str(s[0]+1) print label, ":", s[1] ``` The values for `s[1]` are 'R', 'S', or '?' for unknown/unassigned. So how do you get rid of question marks? ## Best: use coordinates 3D coordinates are stored in `rdkit.Chem.rdchem.Conformer` and every `rdkit.Chem.rdmol.Mol` has at least one -- **question** is that always the case? ```python # get molecule's list of conformers, # if the 1st one has 3D coordinates, # flag chiral centers based on those c=mol.GetConformers() if c[0].Is3D(): rdkit.Chem.rdmolops.AssignAtomChiralTagsFromStructure(mol) ``` ## CTFiles parity flags CTFile (MOL, SDF) can include stereo flags as either bond annotation ("up" or "down"), or atom parity annotation ("cw", "ccw", or undefined), or both. According to the specification, atom parity should be ignored when reading the file, so bond annotation is the only one that actually matters. RDKit will do the right thing and read the flags from the bond block (and write them out when exporting MOL blocks). The problem is there's plenty of broken software that does not do that and populates atom parity flags instead. RDKit will read the atom parity flags also, and store them in `molParity` property of the `rdkit.Chem.rdchem.Atom` (but not turn them into chirality tags). The values are * 1 for clockwise, * 2 for counter-clockwise, and * 3 for unspecified. **Note** that the winding is relative to atom order in the atom list. If you did anything to the molecule that changed the original atom order, the flags are most likely no longer valid. ```python # assign chiral tags from atom parity flags for a in mol.GetAtoms(): if a.HasProp("molParity"): try: parity=int(a.GetProp("molParity")) except ValueError: parity=None if parity==1: a.SetChiralTag(rdkit.Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CW) elif parity==2: a.SetChiralTag(rdkit.Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CCW) elif parity==3: a.SetChiralTag(rdkit.Chem.rdchem.ChiralType.CHI_UNSPECIFIED) ``` ## Still unassigned That may be deliberate. For example, PubChem CID 602 (as of the time of this writing) is for "DL-Alanine" describing *either* D- or L-Alanine. In this case "unspecified" is the correct value for chirality tag. (And in the case of "2D" SDF it will be; unfortunately PubChem software will generate a "3D" SDF for CID 602 and it will have a single conformer: L-Alanine.) --------------------------------- -- Dimitri Maziuk Programmer/sysadmin BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss