def createScipionPartView(self, filename, viewParams={}): inputParticlesId = self.protocol.inputParticles.get().strId() labels = 'enabled id _size _filename _transform._matrix' viewParams = { showj.ORDER: labels, showj.VISIBLE: labels, showj.RENDER: '_filename', 'labels': 'id', } return em.ObjectView(self._project, self.protocol.strId(), filename, other=inputParticlesId, env=self._env, viewParams=viewParams)
def _createVolumesSqlite(self): """ Write an sqlite with all volumes selected for visualization. """ path = self.protocol._getExtraPath('frealign_viewer_volumes.sqlite') samplingRate = self.protocol.inputParticles.get().getSamplingRate() files = [] if self.protocol.IS_REFINE: for it in self._iterations: volFn = self.protocol._getFileName('iter_vol', iter=it) if exists(volFn): files.append(volFn) else: for it in self._iterations: for ref3d in self._refsList: volFn = self.protocol._getFileName('iter_vol_class', iter=it, ref=ref3d) if exists(volFn): files.append(volFn) self.createVolumesSqlite(files, path, samplingRate) return [em.ObjectView(self._project, self.protocol.strId(), path)]
def _visualize(self, obj, **args): cls = type(obj) def _getMicrographDir(mic): """ Return an unique dir name for results of the micrograph. """ from pyworkflow.utils.path import removeBaseExt return obj._getExtraPath(removeBaseExt(mic.getFileName())) def iterMicrographs(mics): """ Iterate over micrographs and yield micrograph name and a directory to process. """ for mic in mics: micFn = mic.getFileName() micDir = _getMicrographDir(mic) yield (micFn, micDir, mic) def visualizeObjs(obj, setOfMics): if exists(obj._getPath("ctfs_temporary.sqlite")): os.remove(obj._getPath("ctfs_temporary.sqlite")) ctfSet = self.protocol._createSetOfCTF("_temporary") for fn, micDir, mic in iterMicrographs(setOfMics): samplingRate = mic.getSamplingRate( ) * self.protocol.ctfDownFactor.get() mic.setSamplingRate(samplingRate) out = self.protocol._getCtfOutPath(micDir) psdFile = self.protocol._getPsdPath(micDir) if exists(out) and exists(psdFile): ctfModel = em.CTFModel() readCtfModel(ctfModel, out) ctfModel.setPsdFile(psdFile) ctfModel.setMicrograph(mic) ctfSet.append(ctfModel) if ctfSet.getSize() < 1: raise Exception( "Has not been completed the CTF estimation of any micrograph" ) else: ctfSet.write() ctfSet.close() self._visualize(ctfSet) if issubclass(cls, ProtGctf) and not obj.hasAttribute("outputCTF"): mics = obj.inputMicrographs.get() visualizeObjs(obj, mics) elif obj.hasAttribute("outputCTF"): self._visualize(obj.outputCTF) else: fn = obj.getFileName() if obj.strId() == "None": objName = fn else: objName = obj.strId() psdLabels = '_psdFile' labels = 'id enabled comment %s _defocusU _defocusV _defocusAngle _defocusRatio' % psdLabels labels = labels + ' _gctf_ctfResolution _gctf_crossCorrelation _micObj._filename' print "objName, ", objName self._views.append( em.ObjectView(self._project, objName, fn, viewParams={ showj.MODE: showj.MODE_MD, showj.ORDER: labels, showj.VISIBLE: labels, showj.ZOOM: 50, showj.RENDER: psdLabels, showj.OBJCMDS: "'%s'" % OBJCMD_GCTF })) return self._views
def createView(self, filename, viewParams={}): return em.ObjectView(self._project, self.protocol.strId(), filename, viewParams=viewParams)