def _loadInputCoords(self, micDict): """ Load coordinates from the input streaming. """ coordsFn = self.getCoords().getFileName() self.debug("Loading input db: %s" % coordsFn) coordSet = SetOfCoordinates(filename=coordsFn) # FIXME: Temporary to avoid loadAllPropertiesFail coordSet._xmippMd = String() coordSet.loadAllProperties() for micKey, mic in micDict.iteritems(): micId = mic.getObjId() coordList = [] self.debug("Loading coords for mic: %s (%s)" % (micId, micKey)) for coord in coordSet.iterItems(where='_micId=%s' % micId): # TODO: Check performance penalty of using this clone coordList.append(coord.clone()) self.debug(" Coords found: %s" % len(coordList)) if coordList: self.coordDict[micId] = coordList else: del micDict[micKey] self.coordsClosed = coordSet.isStreamClosed() coordSet.close() self.debug("Coords are closed? %s" % self.coordsClosed) self.debug("Closed db.") return micDict
def _checkNewInput(self): newMics = [] for idx, coordSet in enumerate(self.inputCoordinates): coorSet = SetOfCoordinates(filename=coordSet.get().getFileName()) coorSet._xmippMd = String() coorSet.loadAllProperties() self.streamClosed = coorSet.isStreamClosed() coorSet.close() if self.check[idx] == "": newMics.append( [c.clone() for c in coordSet.get().getMicrographs()]) else: newMics.append([ c.clone() for c in coordSet.get().getMicrographs().iterItems( orderBy='creation', where='creation>"' + str(self.check[idx]) + '"') ]) if len(newMics[idx]) < 1: continue else: for p in coordSet.get().getMicrographs().iterItems( orderBy='creation', direction='DESC'): self.check[idx] = p.getObjCreation() break newMics[:] = [item for item in newMics if len(item) > 0] if len(newMics) > 0: fDeps = self.insertNewCoorsSteps(min(newMics, key=len)) self.inputMics = self.inputMics + len(min(newMics, key=len)) outputStep = self._getFirstJoinStep() if outputStep is not None: outputStep.addPrerequisites(*fDeps) self.updateSteps()
def _loadInputCoords(self, micDict): """ Load coordinates from the input streaming. """ # TODO: this takes for ever if you are NOT # doing streaming and have several thousands of mics # so I add a counter to keep the user entertained import sys a = datetime.now() counter = 1 coordsFn = self.getCoords().getFileName() self.debug("Loading input db: %s" % coordsFn) coordSet = SetOfCoordinates(filename=coordsFn) # FIXME: Temporary to avoid loadAllPropertiesFail coordSet._xmippMd = String() coordSet.loadAllProperties() # TODO: horrible code. Rewrite using # for coord in coordSet.iterItems(orderBy='_micId', # direction='ASC'): # micId = coord.getMicId() # if micId != lastMicId: # lastMicId = micId # ... # ... for micKey, mic in micDict.iteritems(): if counter % 50 == 0: b = datetime.now() print(b - a, 'reading coordinates for mic number', "%06d" % counter) sys.stdout.flush() # force buffer to print counter += 1 micId = mic.getObjId() coordList = [] self.debug("Loading coords for mic: %s (%s)" % (micId, micKey)) for coord in coordSet.iterItems(where='_micId=%s' % micId): # TODO: Check performance penalty of using this clone coordList.append(coord.clone()) self.debug("Coords found: %s" % len(coordList)) if coordList: self.coordDict[micId] = coordList else: del micDict[micKey] self.coordsClosed = coordSet.isStreamClosed() coordSet.close() self.debug("Coords are closed? %s" % self.coordsClosed) self.debug("Closed db.") return micDict