Problem when reading a Spider EM map in Python
Hi everybody.
I've written a class to read and write EM maps in Spider format in IMP. Runs perfect in C++ when combined with DensityMap and MRCReaderWriter from EMbed:
#include "IMP/em/SpiderReaderWriter.h" #include "DensityMap.h" #include "MRCReaderWriter.h"
int main() { // Constructor IMP::em::SpiderMapReaderWriter rw("media_mon_iter3.xmp",false,false,true); MRCReaderWriter rw2; DensityMap m; m.Read("media_mon_iter3.xmp",rw); m.Write("test.xmp",rw); m.Write("test.mrc",rw2); }
When wrapped in Python, after modifying modules/em/pyext/em.i with this: %import "MapReaderWriter.h" %include "IMP/em/SpiderReaderWriter.h"
And trying to do exactly the same thing: def test_em_maps(self): """Check volume reading and writing""" rw1=em.SpiderMapReaderWriter("media_mon_iter3.xmp",False,False,True) rw2=EM.MRCReaderWriter() m=EM.DensityMap() m.Read("media_mon_iter3.xmp",rw1) m.Write("test.mrc",rw2) m.Write("test.xmp",rw1)
I obtain this error:
====================================================================== ERROR: Check volume reading and writing ---------------------------------------------------------------------- Traceback (most recent call last): File "test_volumes_and_images.py", line 74, in test_em_maps m.Read("media_mon_iter3.xmp",rw1) File "/diva1/home/modeller/SVN/modlib/EM.py", line 698, in Read def Read(*args): return _EM.DensityMap_Read(*args) TypeError: in method 'DensityMap_Read', argument 3 of type 'MapReaderWriter &'
----------------------------------------------------------------------
Seems that SWIG is not wrapping properly MapReaderWriter or is getting confused by passing a IMP object like SpiderMapReaderWriter to the EMbed class DensityMap. Any help?
Thanks
Javier Ángel Velázquez Muriel wrote: > TypeError: in method 'DensityMap_Read', argument 3 of type > 'MapReaderWriter &' > > ---------------------------------------------------------------------- > > Seems that SWIG is not wrapping properly MapReaderWriter or is getting > confused by passing a IMP object like SpiderMapReaderWriter to the EMbed > class DensityMap. Any help?
It seems to think that SpiderMapReaderWriter is not a subclass of MapReaderWriter. Usually the solution to this problem is to tell SWIG about the base class, using %import if it's a different module (as it is in this case). But you seem to be doing that already. Does SWIG run without warning about missing base classes, etc.? If not, the warnings should point you towards the problem. Does the problem still occur with the code you checked in to IMP? If so, I can take a look at it.
Ben
participants (2)
-
Ben Webb
-
Javier Ángel Velázquez Muriel