Skip to main content

Given an RDKit molecule that does not sanitise, correct it until it does, regardless of the severity of the change.

Project description

Molecular Rectifier

Given an RDKit molecule that does not sanitise, correct it until it does, regardless of the severity of the change.

horror

Install

Requires RDKit.

pip3 install molecular-rectifier

Beyond RDKit Sanitisation

The command rdkit.Chem.SanitizeMol fixes minor issues with the molecule. However, more drastic changes such as valence correction and removal of weird bonds is not done, hence the molecular rectifier!

from molecular_rectifier import Rectifier

recto = Rectifier(wrong_mol)
recto.fix()
fixed_mol = recto.mol
# this works:
Chem.SanitizeMol(fixed_mol, sanitizeOps=Chem.SanitizeFlags.SANITIZE_ALL)

A lot of the corrections are based on arbitrary choices. These choices are manually encoded. I am sure that sooner or later some ML module will do this, but for now the Rectifier does the job.

The attribute valence_correction controls how the valence is fixed up —either by shifting the element ('element') or by adding a charge ('charge')

  • protonating ring nitrogens if required
  • forcing all atoms/bonds in a ring to be aromatic or not (unless part of another ring)
  • Texas carbon -> Sulfur
  • Hydrogen -> Fluoride shifted downwards
  • Carbon in aromatic ring -> single bond ring
  • kills bridging bonds with no atoms in the bridge within rings.
  • correcting BondType.UNSPECIFIED
  • preventing 3- and 4- membered rings fused to another ring
  • preventing allene

For more see (rules note)[rules.md].

Rationale

This is used by Fragmenstein in the automatic merging mode (combine). Originally part of it, but moved apart because it may be useful for other uses, outside of Fragmenstein. Or a better module is found to fix the molecules.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

molecular_rectifier-1.0.1.tar.gz (17.0 kB view details)

Uploaded Source

File details

Details for the file molecular_rectifier-1.0.1.tar.gz.

File metadata

  • Download URL: molecular_rectifier-1.0.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for molecular_rectifier-1.0.1.tar.gz
Algorithm Hash digest
SHA256 76ac7cdbee8ade1e7acb89b373ba55ccc9b8b07bb8e1fadc5239f59ef77d941f
MD5 5afc56cb75da627d55bd455e91cc608d
BLAKE2b-256 449900a2d3d4646d7a470944bb3b356d47f8355b6556c2def6d086a01a440447

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page