def _summaryNormal(self): """ Should be overwritten in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] if not hasattr(self, 'outputVolume'): summary.append("Output volume not ready yet.") it = self._lastIter() if it >= 1: row = md.getFirstRow('model_general@' + self._getFileName('half1_model', iter=it)) resol = row.getValue("rlnCurrentResolution") summary.append("Current resolution: *%0.2f A*" % resol) else: row = md.getFirstRow('model_general@' + self._getFileName('modelFinal')) resol = row.getValue("rlnCurrentResolution") summary.append("Final resolution: *%0.2f A*" % resol) if self.realignMovieFrames: summary.append('\nMovie refinement:') summary.append(' Running average window: %d frames' % self.movieAvgWindow.get()) summary.append(' Stddev on the translations: %0.2f px' % self.movieStdTrans) if self.movieIncludeRotSearch: summary.append(' Stddev on the rotations: %0.2f deg' % self.movieStdRot) return summary
def _findImagesPath(self, label, warnings=True): row = md.getFirstRow(self._starFile) if row is None: raise Exception("Can not import from an empty metadata: %s" % self._starFile) if not row.containsLabel(label): raise Exception("Label *%s* is missing in metadata: %s" % (md.label2Str(label), self._starFile)) index, fn = relionToLocation(row.getValue(label)) self._imgPath = findRootFrom(self._starFile, fn) if warnings and self._imgPath is None: self.protocol.warning( "Binary data was not found from metadata: %s" % self._starFile) if (self._starFile.endswith('_data.star') and self._getModelFile(self._starFile)): self._modelStarFile = self._getModelFile(self._starFile) modelRow = md.getFirstRow(self._modelStarFile) classDimensionality = modelRow.getValue( 'rlnReferenceDimensionality') self._optimiserFile = self._starFile.replace( '_data.star', '_optimiser.star') if not exists(self._optimiserFile): raise Exception("Missing required optimiser star file: %s" % self._optimiserFile) optimiserRow = md.getFirstRow(self._optimiserFile) autoRefine = optimiserRow.containsLabel('rlnModelStarFile2') self.alignType = ALIGN_PROJ if not autoRefine: if classDimensionality == 3: self._classesFunc = self.protocol._createSetOfClasses3D else: self._classesFunc = self.protocol._createSetOfClasses2D self.alignType = ALIGN_2D else: self._classesFunc = None else: self.alignType = ALIGN_NONE self._classesFunc = None self._modelStarFile = None modelRow = None # Check if the MetaData contains either MDL_MICROGRAPH_ID # or MDL_MICROGRAPH, this will be used when imported # particles to keep track of the particle's micrograph self._micIdOrName = (row.containsLabel('rlnMicrographName') or row.containsLabel('rlnMicrographId')) #init dictionary. It will be used in the preprocessing self.micDict = {} return row, modelRow
def _findImagesPath(self, label, warnings=True): row = md.getFirstRow(self._starFile) if row is None: raise Exception("Can not import from an empty metadata: %s" % self._starFile) if not row.containsLabel(label): raise Exception("Label *%s* is missing in metadata: %s" % (md.label2Str(label), self._starFile)) index, fn = relionToLocation(row.getValue(label)) self._imgPath = findRootFrom(self._starFile, fn) if warnings and self._imgPath is None: self.protocol.warning("Binary data was not found from metadata: %s" % self._starFile) if (self._starFile.endswith('_data.star') and self._getModelFile(self._starFile)): self._modelStarFile = self._getModelFile(self._starFile) modelRow = md.getFirstRow(self._modelStarFile) classDimensionality = modelRow.getValue('rlnReferenceDimensionality') self._optimiserFile = self._starFile.replace('_data.star', '_optimiser.star') if not exists(self._optimiserFile): raise Exception("Missing required optimiser star file: %s" % self._optimiserFile) optimiserRow = md.getFirstRow(self._optimiserFile) autoRefine = optimiserRow.containsLabel('rlnModelStarFile2') self.alignType = ALIGN_PROJ if not autoRefine: if classDimensionality == 3: self._classesFunc = self.protocol._createSetOfClasses3D else: self._classesFunc = self.protocol._createSetOfClasses2D self.alignType = ALIGN_2D else: self._classesFunc = None else: self.alignType = ALIGN_NONE self._classesFunc = None self._modelStarFile = None modelRow = None # Check if the MetaData contains either MDL_MICROGRAPH_ID # or MDL_MICROGRAPH, this will be used when imported # particles to keep track of the particle's micrograph self._micIdOrName = (row.containsLabel('rlnMicrographName') or row.containsLabel('rlnMicrographId')) #init dictionary. It will be used in the preprocessing self.micDict = {} return row, modelRow
def getBoxSize(self, coordFile): """ Try to infer the box size from the given coordinate file. """ configFile = join(dirname(coordFile), 'config.xmd') if exists(configFile): firstRow = md.getFirstRow('properties@' + configFile) return firstRow.getValue(md.MDL_PICKING_PARTICLE_SIZE) return None
def _summaryNormal(self): """ Should be overriden in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] it = self._lastIter() if it >= 1: row = md.getFirstRow('model_general@' + self._getFileName('half1_model', iter=it)) resol = row.getValue("rlnCurrentResolution") summary.append("Current resolution: *%0.2f*" % resol) return summary
def _summaryNormal(self): """ Should be overriden in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] it = self._lastIter() if it >= 1: row = md.getFirstRow("model_general@" + self._getFileName("half1_model", iter=it)) resol = row.getValue("rlnCurrentResolution") summary.append("Current resolution: *%0.2f*" % resol) return summary
def createOutputStep(self): outputVols = self._createSetOfVolumes() for i, vol in enumerate(self._iterInputVols()): volDir = self._getVolDir(i + 1) volume = vol.clone() volPrefix = 'vol%03d_' % (i + 1) m_pruned = md.MetaData() m_pruned.read(volDir + '/pruned_particles_alignability.xmd') prunedMd = self._getExtraPath(volPrefix + 'pruned_particles_alignability.xmd') moveFile(join(volDir, 'pruned_particles_alignability.xmd'), prunedMd) m_volScore = md.MetaData() m_volScore.read(volDir + '/validationAlignability.xmd') validationMd = self._getExtraPath(volPrefix + 'validation_alignability.xmd') moveFile(join(volDir, 'validationAlignability.xmd'), validationMd) imgSet = self.inputParticles.get() outImgSet = self._createSetOfParticles(volPrefix) outImgSet.copyInfo(imgSet) outImgSet.copyItems(imgSet, updateItemCallback=self._setWeight, itemDataIterator=md.iterRows( prunedMd, sortByLabel=md.MDL_ITEM_ID)) mdValidatoin = md.getFirstRow(validationMd) weight = mdValidatoin.getValue( md.MDL_WEIGHT_PRECISION_ALIGNABILITY) volume.weightAlignabilityPrecision = Float(weight) weight = mdValidatoin.getValue(md.MDL_WEIGHT_ACCURACY_ALIGNABILITY) volume.weightAlignabilityAccuracy = Float(weight) weight = mdValidatoin.getValue(md.MDL_WEIGHT_PRECISION_MIRROR) volume.weightMirror = Float(weight) volume.cleanObjId( ) # clean objects id to assign new ones inside the set outputVols.append(volume) self._defineOutputs(outputParticles=outImgSet) self.createPlot2D(volPrefix, m_pruned) outputVols.setSamplingRate(volume.getSamplingRate()) self._defineOutputs(outputVolumes=outputVols)
def loadAcquisitionInfo(self): """ Return a dictionary with acquisition values and the sampling rate information. In the case of Xmipp, they are stored in files: acquisition_info.xmd and microscope.xmd """ acqDict = OrderedDict() if exists(self._mdFile): dirName = dirname(self._mdFile) acquisitionFile = join(dirName, 'acquisition_info.xmd') microscopeFile = join(dirName, 'microscope.xmd') if exists(microscopeFile): row = md.getFirstRow(microscopeFile) acqDict['voltage'] = row.getValue(md.MDL_CTF_VOLTAGE) acqDict['sphericalAberration'] = row.getValue(md.MDL_CTF_CS) if exists(acquisitionFile): row = md.getFirstRow(acquisitionFile) acqDict['samplingRate'] = row.getValue(md.MDL_SAMPLINGRATE) return acqDict
def _summaryNormal(self): """ Should be overriden in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] it = self._lastIter() if it >= 1: row = md.getFirstRow('model_general@' + self._getFileName('model', iter=it)) resol = row.getValue("rlnCurrentResolution") summary.append("Current resolution: *%0.2f*" % resol) summary.append("Input Particles: *%d*\nClassified into *%d* 3D classes\n" % (self.inputParticles.get().getSize(), self.numberOfClasses.get())) return summary
def _summary(self): """ Should be overwritten in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] if not hasattr(self, 'outputVolume'): summary.append("Output is not ready yet.") else: if self.performBfactorWeighting: summary.append('Performed B-factor weighting') row = md.getFirstRow('general@' + self._getExtraPath('shiny/shiny_post.star')) res = row.getValue('rlnFinalResolution') summary.append('Resolution of reconstructions from shiny particles: *%0.2f A*' % res) return summary
def createOutputStep(self): outputVols = self._createSetOfVolumes() for i, vol in enumerate(self._iterInputVols()): volDir = self._getVolDir(i+1) volume = vol.clone() volPrefix = 'vol%03d_' % (i+1) m_pruned = md.MetaData() m_pruned.read(volDir+'/pruned_particles_alignability.xmd') prunedMd = self._getExtraPath(volPrefix + 'pruned_particles_alignability.xmd') moveFile(join(volDir, 'pruned_particles_alignability.xmd'), prunedMd) m_volScore = md.MetaData() m_volScore.read(volDir+'/validationAlignability.xmd') validationMd = self._getExtraPath(volPrefix + 'validation_alignability.xmd') moveFile(join(volDir, 'validationAlignability.xmd'), validationMd) imgSet = self.inputParticles.get() outImgSet = self._createSetOfParticles(volPrefix) outImgSet.copyInfo(imgSet) outImgSet.copyItems(imgSet, updateItemCallback=self._setWeight, itemDataIterator=md.iterRows(prunedMd, sortByLabel=md.MDL_ITEM_ID)) mdValidatoin = md.getFirstRow(validationMd) weight = mdValidatoin.getValue(md.MDL_WEIGHT_PRECISION_ALIGNABILITY) volume.weightAlignabilityPrecision = Float(weight) weight = mdValidatoin.getValue(md.MDL_WEIGHT_ACCURACY_ALIGNABILITY) volume.weightAlignabilityAccuracy = Float(weight) weight = mdValidatoin.getValue(md.MDL_WEIGHT_PRECISION_MIRROR) volume.weightMirror = Float(weight) volume.cleanObjId() # clean objects id to assign new ones inside the set outputVols.append(volume) self._defineOutputs(outputParticles=outImgSet) self.createPlot2D(volPrefix,m_pruned) outputVols.setSamplingRate(volume.getSamplingRate()) self._defineOutputs(outputVolumes=outputVols)
def _findPathAndCtf(self, label, warnings=True): """ Find the relative path from which the micrographs exists repect to the metadata location. Also check if it contains CTF information and their relative root. """ row = md.getFirstRow(self._mdFile) if row is None: raise Exception("Can not import from an empty metadata: " "%s" % self._mdFile) if not row.containsLabel(label): raise Exception("Label *%s* is missing in metadata: " "%s" % (md.label2Str(label), self._mdFile)) # take only the filename part after the @ index, fn = xmippToLocation(row.getValue(label)) self._imgPath = findRootFrom(self._mdFile, fn) if warnings and self._imgPath is None: self.protocol.warning("Binary data was not found from metadata: " "%s" % self._mdFile) if row.containsLabel(md.MDL_CTF_MODEL): self._ctfPath = findRootFrom(self._mdFile, row.getValue(md.MDL_CTF_MODEL)) else: self._ctfPath = None # means no CTF info from micrographs metadata if row.containsLabel(md.MDL_REF): self._classFunc = self.protocol._createSetOfClasses2D elif row.containsLabel(md.MDL_REF3D): self._classFunc = self.protocol._createSetOfClasses3D else: self._classLabel = None self._classFunc = None # Check if the MetaData contains either MDL_MICROGRAPH_ID # or MDL_MICROGRAPH, this will be used when imported # particles to keep track of the particle's micrograph self._micIdOrName = (row.containsLabel(md.MDL_MICROGRAPH_ID) or row.containsLabel(md.MDL_MICROGRAPH)) #init dictionary. It will be used in the preprocessing self.micDict = {} return row
def _summary(self): """ Should be overwritten in subclasses to return summary message for NORMAL EXECUTION. """ summary = [] if not hasattr(self, 'outputVolume'): summary.append("Output is not ready yet.") else: if self.performBfactorWeighting: summary.append('Performed B-factor weighting') row = md.getFirstRow('general@' + self._getExtraPath('shiny/shiny_post.star')) res = row.getValue('rlnFinalResolution') summary.append( 'Resolution of reconstructions from shiny particles: *%0.2f A*' % res) return summary