Subclass chimera.Molecule

Hello, I am trying to extend the chimera.Molecule class() to add a few methods and attributes, but the followin error arises: TypeError: Error when calling the metaclass bases type '_molecule.Molecule' is not an acceptable base type File "/home/jr/x/gaudi/gaudi/molecule.py", line 51, in <module> class Compound(chimera.Molecule): Is there any workaround? I want my Compound objects to behave like standard chimera Molecules (with all their attributes and stuff), and also be able to call custom methods on that Molecule. Thanks in advance, Jaime.

Molecules can not be subclassed (it is a Python wrapper around a C++ class), but they can be extended with custom methods and attributes by adding those methods and attributes to the Python Molecule class. You can see some examples of that in chimera/__init__.py, Molecule.sequence is from another module, and Molecule.metalComplexGroup is defined within the file. Unfortunately, it is not possible to extend Molecule's __init__ function. HTH, Greg On 06/12/2014 09:33 AM, Jaime Rodríguez-Guerra wrote:

If you had to do something during Compound/Molecule initialization, you might be able to fake it by listening to the Molecule trigger and doing something to Molecules in the 'created' category. Pretty horrible I know, but desperate times call for desperate measures… --Eric On Jun 12, 2014, at 3:49 PM, Greg Couch <gregc@cgl.ucsf.edu> wrote:

Oh, I see. I am not familiar with wrappers and those "nasty" things, but I do guess they're a nightmare to deal with! For now, I will stick with a dirty workaround I figured out last night. The molecule itself will be an attribute of the Compound, so it is now available as `Compound.m`. Not perfect, but close :) Thanks for the help! 2014-06-13 0:58 GMT+02:00 Eric Pettersen <pett@cgl.ucsf.edu>:
participants (3)
-
Eric Pettersen
-
Greg Couch
-
Jaime Rodríguez-Guerra