Skip to content

baoilleach/nocharge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nocharge

A simple Python module that attempts to neutralize all atoms with +1 or -1 charge in a molecule.

For more information, see https://baoilleach.blogspot.com/2019/12/no-charge-simple-approach-to.html.

Usage:

from openbabel import pybel
from nocharge import neutralize

for smi in ["CC(=O)[O-]", "C[N+](C)(C)C"]:
    mol = pybel.readstring("smi", smi).OBMol
    altered = neutralize(mol)
    if altered:
    outsmi = pybel.Molecule(mol).write("smi", opt={"n": True, "nonewline": True})
    print("{} changed to {}".format(smi, outsmi))
    else:
    print("{} was unaltered by neutralize".format(smi))

which gives:

CC(=O)[O-] changed to CC(=O)O
C[N+](C)(C)C was unaltered by neutralize

About

Attempt to neutralize all atoms with +1 or -1 charge in a molecule

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages