Partial Charge Setting

Not quite sure if this list or avogadro-devel is the place for this, but
I’ve been trying to make an Extension to let me paste in charges off the
clipboard (using the SetPartialCharge method) and it all seems to work
correctly except for the actual charges turning up in Avogadro.

I had a look in the Python terminal, and it seems this call isn’t included
in the Avogadro primitive version of the Atom class, but didn’t raise any
sort of error when I called it from the script. Having a further look
around the classes I couldn’t find a way to properly set partial charges.
I tried setting the attribute on the atom objects directly, which seemed
to have no effect on the atoms in the GUI, although this did work from the
Python terminal. Looking at the molecule object, there seems to be a call
on there which recalculates them, which I imagine I might have to override
somehow.

So, does anyone know whether there’s a proper way to set partial charges
from an extension like this?

Many thanks,
-Ian

(A simpler version of what I’m doing is below - I’ve also tried it using
iterators rather than pop():slight_smile:

def pasteCharges(self, glwidget):
charges = list()
mol = glwidget.molecule
atomList = mol.atoms

   ... (some text processing to get the charges)

   # Pop elements off the lists until one is empty
   while (len(atomList)!=0) and (len(chargeList)!=0):
     thisAtom = atomList.pop()
     thisCharge = chargeList.pop()

     thisAtom.SetPartialCharge(thisCharge) # One way suggested by the  

OB Atom object
thisAtom.partialCharge = thisCharge # Suggested by the Atom object help
from the terminal