def __init__(self, name=None, id=None, atoms=0): """ Creating a new Molecule instance with no arguments will create a new empty molecule in VMD. Passing a valid molecule id will make the Molecule instance mirror the state of the corresponding molecule in VMD. If id is None, and a name is given, the new molecule will have that name. """ if id is None: if name is None: name = "molecule" self.id = molecule.new(name, atoms) else: self.id = id self.atoms = molecule.numatoms(self.id) if not molecule.exists(self.id): raise ValueError, "Molecule with id %d does not exist." % self.id
def numAtoms(self): """ Returns the number of atoms in the molecule.""" return molecule.numatoms(self.id)