[Chimera-users] Subclass chimera.Molecule

Greg Couch gregc at cgl.ucsf.edu
Thu Jun 12 15:49:36 PDT 2014

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.



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.

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

More information about the Chimera-users mailing list