def _writeXmippPosFile(self, movie, coordinatesName, shiftX, shiftY): """ Create an Xmipp coordinates files to be extracted from the frames of the movie. """ coordSet = self.inputCoordinates.get() # to support multiple access to db coordToIter = SetOfCoordinates() coordToIter.copy(coordSet) coordSet.close() mData = md.MetaData() coordRow = XmippMdRow() for coord in coordToIter.iterCoordinates(movie.getObjId()): coord.shiftX(int(round(float(shiftX)))) coord.shiftY(int(round(float(shiftY)))) coordinateToRow(coord, coordRow) coordRow.writeToMd(mData, mData.addObject()) coordToIter.close() if mData.isEmpty(): return False else: self.info("Writing coordinates metadata: %s, with shifts: %s %s" % (coordinatesName, shiftX, shiftY)) mData.write('particles@' + coordinatesName) return True
def _writeXmippPosFile(self, movieId, movieName, coordinatesName, shiftX, shiftY): """ Create an Xmipp coordinates files to be extracted from the frames of the movie. """ ##### import em abre una nueva conexion? #TODO ROB move this import to the header from pyworkflow.em import SetOfCoordinates inputCoords = self.inputCoordinates.get() coordinates = SetOfCoordinates(filename=inputCoords.getFileName()) #####coordinates = self.inputCoordinates.get() #####micrograph = coordinates.getMicrographs()[movieId] ####if micrograph is None: #####raise Exception("Micrograph with id %d was not found in SetOfCoordinates!!!" % movieId) mData = md.MetaData() coordRow = XmippMdRow() #### for coord in coordinates.iterCoordinates(micrograph): for coord in coordinates.iterCoordinates(movieId): coord.shiftX(int(round(float(shiftX)))) coord.shiftY(int(round(float(shiftY)))) coordinateToRow(coord, coordRow) coordRow.writeToMd(mData, mData.addObject()) if mData.isEmpty(): return False else: self.info("Writing coordinates metadata: %s, with shifts: %s %s" % (coordinatesName, shiftX, shiftY)) mData.write('particles@' + coordinatesName) return True
def _writeXmippPosFile(self, movieId, movieName, coordinatesName, shiftX, shiftY): """ Create an Xmipp coordinates files to be extracted from the frames of the movie. """ ##### import em abre una nueva conexion? #TODO ROB move this import to the header from pyworkflow.em import SetOfCoordinates inputCoords = self.inputCoordinates.get() coordinates = SetOfCoordinates(filename=inputCoords.getFileName()) #####coordinates = self.inputCoordinates.get() #####micrograph = coordinates.getMicrographs()[movieId] ####if micrograph is None: #####raise Exception("Micrograph with id %d was not found in SetOfCoordinates!!!" % movieId) mData = md.MetaData() coordRow = XmippMdRow() #### for coord in coordinates.iterCoordinates(micrograph): for coord in coordinates.iterCoordinates(movieId): coord.shiftX( int(round(float(shiftX)))) coord.shiftY( int(round(float(shiftY)))) coordinateToRow(coord, coordRow) coordRow.writeToMd(mData, mData.addObject()) if mData.isEmpty(): return False else: self.info("Writing coordinates metadata: %s, with shifts: %s %s" % (coordinatesName, shiftX, shiftY)) mData.write('particles@' + coordinatesName) return True
def createOutputStep(self): fnSqlite = self._getPath('modes.sqlite') nmSet = SetOfNormalModes(filename=fnSqlite) md = xmipp.MetaData(self._getPath('modes.xmd')) row = XmippMdRow() for objId in md: row.readFromMd(md, objId) nmSet.append(rowToMode(row)) inputPdb = self.inputStructure.get() nmSet.setPdb(inputPdb) self._defineOutputs(outputModes=nmSet) self._defineSourceRelation(self.inputStructure, nmSet)
def _writeXmippPosFile(self, movie, coordinatesName, shiftX, shiftY): """ Create Xmipp coordinate files to be extracted from the frames of the movie. """ coordSet = self.getCoords() mData = md.MetaData() coordRow = XmippMdRow() for coord in coordSet.iterCoordinates(movie.getObjId()): coord.shiftX( int(round(float(shiftX)))) coord.shiftY( int(round(float(shiftY)))) coordinateToRow(coord, coordRow) coordRow.writeToMd(mData, mData.addObject()) self.info("Writing coordinates metadata: %s, with shifts: %s %s" % (coordinatesName, shiftX, shiftY)) mData.write('particles@' + coordinatesName)
def _writeXmippPosFile(self, movie, coordinatesName, shiftX, shiftY): """ Create Xmipp coordinate files to be extracted from the frames of the movie. """ coordSet = self.getCoords() mData = md.MetaData() coordRow = XmippMdRow() for coord in coordSet.iterCoordinates(movie.getObjId()): coord.shiftX(int(round(float(shiftX)))) coord.shiftY(int(round(float(shiftY)))) coordinateToRow(coord, coordRow) coordRow.writeToMd(mData, mData.addObject()) self.info("Writing coordinates metadata: %s, with shifts: %s %s" % (coordinatesName, shiftX, shiftY)) mData.write('particles@' + coordinatesName)
def writeModesMetaData(self): """ Iterate over the input SetOfNormalModes and write the proper Xmipp metadata. Take into account a possible selection of modes (This option is just a shortcut for testing. The recommended way is just create a subset from the GUI and use that as input) """ modeSelection = [] if self.modeList.empty(): modeSelection = [] else: modeSelection = getListFromRangeString(self.modeList.get()) md = xmipp.MetaData() inputModes = self.inputModes.get() for mode in inputModes: # If there is a mode selection, only # take into account those selected if not modeSelection or mode.getObjId() in modeSelection: row = XmippMdRow() modeToRow(mode, row) row.writeToMd(md, md.addObject()) md.write(self.modesFn)
def writeModesMetaData(self): """ Iterate over the input SetOfNormalModes and write the proper Xmipp metadata. Take into account a possible selection of modes (This option is just a shortcut for testing. The recommended way is just create a subset from the GUI and use that as input) """ modeSelection = [] if self.modeList.empty(): modeSelection = [] else: modeSelection = getListFromRangeString(self.modeList.get()) mdModes = md.MetaData() inputModes = self.inputModes.get() for mode in inputModes: # If there is a mode selection, only # take into account those selected if not modeSelection or mode.getObjId() in modeSelection: row = XmippMdRow() modeToRow(mode, row) row.writeToMd(mdModes, mdModes.addObject()) mdModes.write(self.modesFn)