Skip to main content

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.

Metadata

Release files for molecular-rectifier 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for molecular-rectifier 1.0.1
File Size Uploaded Provenance Actions
molecular_rectifier-1.0.1.tar.gz 17.0 kB Without provenance Details for molecular_rectifier-1.0.1.tar.gz

Release files / molecular_rectifier-1.0.1.tar.gz

Download URL molecular_rectifier-1.0.1.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
76ac7cdbee8ade1e7acb89b373ba55ccc9b8b07bb8e1fadc5239f59ef77d941f
BLAKE2b-256 checksum
How to use checksums
449900a2d3d4646d7a470944bb3b356d47f8355b6556c2def6d086a01a440447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for molecular-rectifier 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page