[Chimera-users] Subclass chimera.Molecule

Eric Pettersen pett at cgl.ucsf.edu
Thu Jun 12 15:58:40 PDT 2014

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…


On Jun 12, 2014, at 3:49 PM, Greg Couch <gregc at cgl.ucsf.edu> wrote:

> 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:
>> 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.
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20140612/bda0b294/attachment.html>

More information about the Chimera-users mailing list