Пример #1
0
    def __init__(self, volfile, sendEnd=True, **kwargs):
        if volfile.endswith('.mrc'):
            volfile += ':mrc'

        self.kwargs = kwargs
        if volfile is None:
            raise ValueError(volfile)
        if '@' in volfile:
            [index, file] = volfile.split('@')
        else:
            file = volfile
        if ':' in file:
            file = file[0:file.rfind(':')]
        if not os.path.exists(file):
            raise Exception("File %s does not exists" % file)

        self.volfile = volfile
        self.voxelSize = self.kwargs.get('voxelSize', None)
        # ChimeraServer is the basic server. There are other
        # than inherit from it.
        serverName = self.kwargs.get('ChimeraServer', 'ChimeraServer')
        self.address = ''
        self.port = getFreePort()

        serverfile = pw.join('em', 'chimera_server.py')
        command = CommandView(
            "chimera --script '%s %s %s' &" %
            (serverfile, self.port, serverName),
            env=getChimeraEnviron(),
        ).show()
        self.authkey = 'test'
        self.client = Client((self.address, self.port), authkey=self.authkey)
        self.initVolumeData()
        self.openVolumeOnServer(self.vol, sendEnd)
        self.initListenThread()
Пример #2
0
    def _visualize(self, obj, **args):
        cls = type(obj)
        if issubclass(cls, Volume) or issubclass(cls, Image):
            fn = obj.getFileName()
            if pwutils.getExt(fn) in ['.stk', '.vol', '.xmp']:
                # eman2 expects spider files with .spi extension only
                pwutils.createLink(fn, pwutils.replaceExt(fn, 'spi'))
                fn = pwutils.replaceExt(fn, 'spi')
            view = CommandView("%s %s &" %
                               (Plugin.getProgram('e2display.py'), fn),
                               env=Plugin.getEnviron())
            return [view]

        elif isinstance(obj, EmanProtBoxing):
            coords = obj.getCoords()
            if coords:
                return DataViewer._visualize(self, obj.outputCoordinates)

        elif isinstance(obj, EmanProtInitModel):
            obj = obj.outputVolumes
            fn = obj.getFileName()
            labels = 'id enabled comment _filename '
            objCommands = "'%s' '%s' '%s'" % (OBJCMD_CLASSAVG_PROJS,
                                              OBJCMD_PROJS, OBJCMD_INITVOL)

            self._views.append(
                ObjectView(self._project,
                           obj.strId(),
                           fn,
                           viewParams={
                               showj.MODE: showj.MODE_MD,
                               showj.VISIBLE: labels,
                               showj.RENDER: '_filename',
                               showj.OBJCMDS: objCommands
                           }))
            return self._views

        elif isinstance(obj, EmanProtInitModelSGD):
            obj = obj.outputVolumes
            fn = obj.getFileName()
            labels = 'id enabled comment _filename '
            objCommands = "'%s'" % OBJCMD_CLASSAVG_PROJS

            self._views.append(
                ObjectView(self._project,
                           obj.strId(),
                           fn,
                           viewParams={
                               showj.MODE: showj.MODE_MD,
                               showj.VISIBLE: labels,
                               showj.RENDER: '_filename',
                               showj.OBJCMDS: objCommands
                           }))
            return self._views