1
$\begingroup$

Consider ethanol, where each carbon atom has a valency of 4 and oxygen a valency of -2. I would like to determine these values for many compounds given their SMILES or InChI keys. (For the purpose of computing the degree of reduction, which in the case of ethanol is 6)

I would like to find a systematic method to calculate this for many molecules. I attempted to use Open Babel as described below, but I am open to any other programmatic solution.

Attempt with Open Babel on Python:

I attempted the following with openbabel.pybel (after installing the appropriate packages):

from openbabel import pybel

ethanol = 'CCO'  # SMILES

mol = pybel.readstring('smi', ethanol)

for atom in mol.atoms:
     print(f"type={atom.type} charge={atom.formalcharge} \
     degree(valence)={atom.degree} implicitvalence={atom.implicitvalence}")

This returns the error:

AttributeError: 'OBAtom' object has no attribute 'GetImplicitValence'

If I understand correctly the implicit valence is the value I am after. I am stuck and the documentation is not helping (is not even consistent with the behavior of the module) openbabel.__version__ returns 3.0.0. This is based on a 6 year old question

$\endgroup$
  • 1
    $\begingroup$ Possible duplicate of Counting valency of atoms, in a molecule with python $\endgroup$ – Mithoron Dec 5 '19 at 0:46
  • 1
    $\begingroup$ This seems to be some programming issue and therefore off-topic. Closing as dupe is another option. $\endgroup$ – Mithoron Dec 5 '19 at 0:48
  • 2
    $\begingroup$ I'm voting to close this question as off-topic because it's about using software and not about chemistry. $\endgroup$ – Todd Minehardt Dec 5 '19 at 1:20
  • 2
    $\begingroup$ Since this question has been up for a few days but still has no answer, perhaps it might be something that a dedicated computational chemical physics community would be interested in. There is a proposal for a Stack Exchange for Materials Modeling for example: area51.stackexchange.com/proposals/122958/…. Perhaps you might consider supporting it if you think it would be useful for you! $\endgroup$ – user1271772 Dec 10 '19 at 3:12
  • 1
    $\begingroup$ There's no 'implicit valence' in Open Babel 3 because we found it to be a very confusing concept. I think you should ask a more general question outside your specifics with Pybel. $\endgroup$ – Geoff Hutchison Dec 10 '19 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.