1
$\begingroup$

The documentation for the indigo module can be found here

http://ggasoftware.com/opensource/indigo/api#inputoutput

So for instance if I have a molecule object for some SMILES string, e.g. "[C](=[O])", I wish to calculate the valency of each atom, for instance here the desired output would be [atom=C, unbound_electrons=2],[atom=O, valency=0]

If I consider the atom "[C]" Can anyone explain why is this code printing [atom=C, unbound_electrons=0] not [atom=C, unbound_electrons=4]

from indigo import *
indigo = Indigo()

mol=indigo.loadMolecule("[C]")

print(mol.grossFormula(),"\n")

for atom in mol.iterateAtoms():
        print([atom.symbol(),atom.radicalElectrons()])

I could work it out if I could generate a list of the types of bonds on the atom in conjuction with atom.atomicNumber(). E.g. if I could say [C] has a double bond I could take it's atomic number - 2 (second shell) - 2 (double bond)

This might be useful for visualising what i'm talking about

from indigo_renderer import *
renderer = IndigoRenderer(indigo)
renderer.renderToFile(mol,"mol.png")
$\endgroup$

migrated from physics.stackexchange.com Jul 19 '13 at 17:22

This question came from our site for active researchers, academics and students of physics.

1
$\begingroup$

I'm not familiar with Indigo, but from reading the documentation, it looks like it should be possible to do the manual calculation you mention, using something like:

for atom in mol.iterateAtoms():
    bond_count = 0
    for nei in atom.iterateNeighbors():
       bond_count += nei.bond().bondOrder()
    print([atom.symbol(),atom.atomicNumber() - bond_count])

It's just missing the calculation of number of shells; I'm not sure how to do that part.

$\endgroup$

Your Answer

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