Giter Club home page Giter Club logo

molecular_rectifier's Introduction

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

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.

molecular_rectifier's People

Contributors

matteoferla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.