Scripting tutorial

Can anyone recommend a good starting point to implement python scripting in Avogadro. Could not find much material. And the discussion in this forum on this topic seems to date back quite a while.
Thank you

What in particular are you interested in doing?

  • Automating Avogadro from Python
  • Having a Python console in Avogadro
  • Using Python scripts to build / edit / tweak things in Avogadro?

I’m more than happy to have some help and get you going if you can be a bit more specific.


Right now, I would like to assign residue id numbers based on selection.

At the moment, there’s no way to do that, but I can certainly merge in an update.

If I understand correctly, you want to select a bunch of atoms and create a new residue from the selection?

Or do you want to select some atoms currently in a residue and edit the id number?

Just trying to make sure I understand exactly what you need. The first is pretty easy and I can add the feature in a new Avogadro2 build, along with eventual script support.

Super! Thank you! The first option would be best. The situation where I need this is as follows: I load a PDB file of a molecule which has all atoms unsorted. Then I would like to assign new residue IDs and residue names to specific atom groups, and then write out the whole thing as PDB again (with the atoms renumbered and listed as one residue after another). It seems that selecting atoms and assigning to the selected group would give most flexibility. Thank you very much for considering this.