On Jan 26, 2018, at 07:27, Sundar <jubilantsun...@gmail.com> wrote:
> How to calculate the net charge of a molecule in openbabel?

The OBMolecule object has a method called "GetTotalCharge()":

  
http://openbabel.org/api/2.3.0/classOpenBabel_1_1OBMol.shtml#ab78d46b60f04702fa6f450ef6f8dae62


Or, if you are using the pybel interface, use the '.charge' attribute:

>>> import pybel
>>> mol = pybel.readstring("smi", "[NH4+]")
>>> mol.charge
1

Or, if you want it from the command-line, you can use the 'report' output 
format and look for the line starting "TOTAL CHARGE"

% echo "[NH4+]" | obabel -ismi - -oreport - | grep "^TOTAL CHARGE"
1 molecule converted
TOTAL CHARGE: 1



                                Andrew
                                da...@dalkescientific.com



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to