[Chimera-users] Subclass chimera.Molecule

Jaime Rodríguez-Guerra jaime.rogue at gmail.com
Fri Jun 13 00:55:40 PDT 2014

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 at cgl.ucsf.edu>:

> 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 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/20140613/d63829ca/attachment.html>

More information about the Chimera-users mailing list