def _createMicsSubSetFromCTF(self, inputCTFs): """ Create a subset of Micrographs and CTFs when analyzing the CTFs. """ outputMics = self._createSetOfMicrographs() outputCtfs = self._createSetOfCTF() setOfMics = inputCTFs.getMicrographs() if setOfMics is None: raise Exception('Could not create SetOfMicrographs subset from ' 'this SetOfCTF, the micrographs were not set.') outputMics.copyInfo(setOfMics) modifiedSet = emobj.SetOfCTF(filename=self._dbName, prefix=self._dbPrefix) count = 0 for ctf in modifiedSet: if ctf.isEnabled(): mic = ctf.getMicrograph() outputMics.append(mic) outputCtfs.append(ctf) count += 1 # Register outputs outputCtfs.setMicrographs(outputMics) # NOTE: I've split the define output in 2 steps. # It seems with python3 outputCTF was processed first and needs mics to be saved first. self._defineOutputs(outputMicrographs=outputMics) self._defineOutputs(outputCTF=outputCtfs) self._defineTransformRelation(setOfMics, outputMics) self._defineCtfRelation(outputMics, outputCtfs) msg = 'From input %s of size %s created output ' % ( inputCTFs.getClassName(), inputCTFs.getSize()) msg += 'SetOfMicrographs and SetOfCTF of size %d' % count self.summaryVar.set(msg) return outputMics, outputCtfs
def getMicCTF(self, mic): """ Retrieve the CTF associated to this micrograph. """ # The first time this function is called, the set of micrographs # will be loaded from the given sqlite file if not hasattr(self, 'ctfSet'): self.ctfSet = emobj.SetOfCTF(filename=self._sqliteFile) return self.ctfSet[mic.getObjId()]
def _insertRecalculateSteps(self): recalDeps = [] # For each psd insert the steps to process it self.recalculateSet = emobj.SetOfCTF(filename=self.sqliteFile.get(), objDoStore=False) inputMics = self.getInputMicrographs() for ctf in self.recalculateSet: line = ctf.getObjComment() if ctf.isEnabled() and line: # CTF Re-estimation # Make estimation steps independent between them objId = ctf.getObjId() stepId = self._insertFunctionStep('reEstimateCtfStep', objId, prerequisites=[]) recalDeps.append(stepId) self.micDict[objId] = inputMics[objId].clone() return recalDeps
def checkOutputs(prot): t0 = time.time() while not (prot.isFinished() or prot.isFailed()): # Time out 6 minutes, just in case tdelta = time.time() - t0 if tdelta > 6*60: break time.sleep(10) prot = self._updateProtocol(prot) # Check if the protocol is still launched if prot.isLaunched(): continue elif prot.isScheduled(): continue if prot.hasAttribute("outputCTF"): ctfSet = emobj.SetOfCTF(filename=prot._getPath(CTF_SQLITE)) baseFn = prot._getPath(CTF_SQLITE) self.assertTrue(os.path.isfile(baseFn)) counter = 0 if ctfSet.getSize() > counter: counter += 1 for ctf in ctfSet: self.assertNotEqual(ctf._resolution.get(), None) self.assertNotEqual(ctf._fitQuality.get(), None) self.assertNotEqual(ctf.isEnabled(), None) self.assertNotEqual(ctf._defocusU.get(), None) self.assertNotEqual(ctf._defocusV.get(), None) self.assertNotEqual(ctf._defocusRatio.get(), None) if ctf.getPhaseShift(): self.assertNotEqual(ctf.getPhaseShift(), None) self.assertIsNotNone(prot.outputCTF, "Error: outputCTF is not produced " "in %s." % prot.getClassName()) self.assertEqual(prot.outputCTF.getSize(), MICS)