def createOutputStep(self): volume = Volume() volume.setFileName(self._getFileName('outputVolume')) vol = self.protRefine.get().outputVolume volume.setSamplingRate(self._getOutputPixelSize()) self._defineOutputs(outputVolume=volume) self._defineSourceRelation(vol, volume)
def createOutputStep(self): volume = Volume() volume.setFileName(self._getExtraPath(POSTPROCESS_VOL_BASENAME)) if self.useHalfMapsInsteadVol.get(): if self.halfMapsAttached.get(): inVol = self.inputVolume.get() else: inVol = self.inputHalf1.get() volume.setSamplingRate(inVol.getSamplingRate()) volume.setOrigin(inVol.getOrigin(force=True)) self._defineOutputs(Volume=volume) self._defineTransformRelation(inVol, volume) if not self.halfMapsAttached.get(): self._defineTransformRelation(self.inputHalf2, volume) else: inVol = self.inputVolume.get() volume.setSamplingRate(inVol.getSamplingRate()) volume.setOrigin(inVol.getOrigin(force=True)) self._defineOutputs(Volume=volume) self._defineTransformRelation(self.inputVolume, volume)
def _createRef3DProtBox(self, label, protocol): from pyworkflow.protocol.constants import STATUS_FINISHED prot = self.newProtocol(protocol) self.saveProtocol(prot) prot.setObjLabel(label) makePath(prot._getPath()) makePath(prot._getExtraPath()) makePath(prot._getTmpPath()) prot.inputParticles.set(self.importPartsFromScipion().outputParticles) outputVol = self.importVolume().outputVolume prot.referenceVolume.set(outputVol) volume = Volume() volume.setFileName(prot._getExtraPath('test.mrc')) pxSize = prot.inputParticles.get().getSamplingRate() volume.setSamplingRate(pxSize) prot._defineOutputs(outputVolume=volume) prot.setStatus(STATUS_FINISHED) # Create a mask protocol print(magentaStr("\n==> Running relion - create mask 3d:")) protMask = self.newProtocol(ProtRelionCreateMask3D) protMask.inputVolume.set(outputVol) self.launchProtocol(protMask) return prot, protMask
def createOutput(self): """ Copy the PDB structure and register the output object. """ # Check vol and pdb files directory = self._getExtraPath() for filename in sorted(os.listdir(directory)): if not filename.startswith("tmp"): # files starting with "tmp" will not be converted in scipion objects if filename.endswith(".mrc"): volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) vol.setOrigin(origin) vol.setSamplingRate(sampling) keyword = filename.split(".mrc")[0] kwargs = {keyword: vol} self._defineOutputs(**kwargs) if filename.endswith(".pdb") or filename.endswith(".cif"): path = os.path.join(directory, filename) pdb = AtomStruct() pdb.setFileName(path) if filename.endswith(".cif"): keyword = filename.split(".cif")[0].replace(".", "_") else: keyword = filename.split(".pdb")[0].replace(".", "_") kwargs = {keyword: pdb} self._defineOutputs(**kwargs)
def createOutputStep(self): if self.range == self.LOW_RESOL: sampling_new = 1.0 else: sampling_new = 0.5 volume = Volume() volume.setFileName(self._getFileName(OUTPUT_RESOLUTION_FILE)) volume.setSamplingRate(sampling_new) self._defineOutputs(resolution_Volume=volume) self._defineTransformRelation(self.inputVolume, volume) #Setting the min max and median for the summary imageFile = self._getFileName(OUTPUT_RESOLUTION_FILE) min_, max_, median_ = self.getMinMax(imageFile) self.min_res_init.set(round(min_ * 100) / 100) self.max_res_init.set(round(max_ * 100) / 100) self.median_res_init.set(round(median_ * 100) / 100) self._store(self.min_res_init) self._store(self.max_res_init) self._store(self.median_res_init) #create Resolution Map to visialize in Chimera #vol_chimera=Volume() vol_chimera = self.createChimeraOutput( self._getFileName(OUTPUT_RESOLUTION_FILE), self.median_res_init) # self.createChimeraOutput(self._getFileName(OUTPUT_RESOLUTION_FILE), # self.median_res_init, # self._getFileName(OUTPUT_RESOLUTION_FILE_CHIMERA)) vol_chimera.write(self._getFileName(OUTPUT_RESOLUTION_FILE_CHIMERA))
def createOutputStep(self): imgSet = self._getInputParticles() vol = Volume() vol.setFileName(self._getExtraPath('relion_class001.mrc')) vol.setSamplingRate(imgSet.getSamplingRate()) half1 = self._getFileName("final_half1_volume", ref3d=1) half2 = self._getFileName("final_half2_volume", ref3d=1) vol.setHalfMaps([half1, half2]) outImgSet = self._createSetOfParticles() outImgSet.copyInfo(imgSet) self._fillDataFromIter(outImgSet, self._lastIter()) self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputParticles, vol) self._defineOutputs(outputParticles=outImgSet) self._defineTransformRelation(self.inputParticles, outImgSet) fsc = FSC(objLabel=self.getRunName()) fn = self._getExtraPath("relion_model.star") table = Table(fileName=fn, tableName='model_class_1') resolution_inv = table.getColumnValues('rlnResolution') frc = table.getColumnValues('rlnGoldStandardFsc') fsc.setData(resolution_inv, frc) self._defineOutputs(outputFSC=fsc) self._defineSourceRelation(vol, fsc)
def shiftStep(self): """call xmipp program to shift the particles""" centermd = self._getExtraPath("center_particles.xmd") args = '-i "%s" -o "%s" ' % (self._getExtraPath("input_particles.xmd"), centermd) if self.option: self.x = self.xin.get() self.y = self.yin.get() self.z = self.zin.get() else: fnvol = self.inputMask.get().getFileName() if fnvol.endswith('.mrc'): fnvol += ':mrc' vol = Volume() vol.setFileName(fnvol) vol = ih().read(vol.getFileName()) masscenter = vol.centerOfMass() self.x = masscenter[0] self.y = masscenter[1] self.z = masscenter[2] args += '--shift_to %f %f %f ' % (self.x, self.y, self.z) program = "xmipp_transform_geometry" if not self.interp.get(): interp = 'linear' else: interp = 'spline' args += ' --apply_transform --dont_wrap --interp %s' % interp if self.inv.get(): args += ' --inverse' self.runJob(program, args) if not self.boxSizeBool.get(): box = self.boxSize.get() self.runJob('xmipp_transform_window', '-i "%s" -o "%s" --size %d %d %d --save_metadata_stack' % (centermd, self._getExtraPath("crop_particles.stk"), box, box, 1))
def createOutput(self): # Check vol and pdb files directory = self._getExtraPath() for filename in sorted(os.listdir(directory)): if filename.endswith(".mrc"): volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) vol.setOrigin(origin) vol.setSamplingRate(sampling) keyword = filename.split(".mrc")[0] kwargs = {keyword: vol} self._defineOutputs(**kwargs) elif filename.endswith(".pdb") or filename.endswith(".cif"): path = os.path.join(directory, filename) pdb = AtomStruct() pdb.setFileName(path) keyword = filename.split(".pdb")[0].replace(".","_") kwargs = {keyword: pdb} self._defineOutputs(**kwargs)
def createOutputStep(self): if self.estimate3DFSC: volume = Volume() volume.setFileName(self._getExtraPath("filteredMap.mrc")) #if self.filterHalfMaps: # half1filt = Volume() # half2filt = Volume() # fnhalfMap1 = self._getExtraPath("dirfiltered_half1.mrc") # fnhalfMap2 = self._getExtraPath("dirfiltered_half2.mrc") # half1filt.setFileName(fnhalfMap1) # half2filt.setFileName(fnhalfMap2) if self.halfVolumesFile: volume.setSamplingRate( self.inputHalves.get().getSamplingRate()) #if self.filterHalfMaps: # volume.setHalfMaps([fnhalfMap1, fnhalfMap2]) self._defineOutputs(directionalFilteredMap=volume) self._defineSourceRelation(self.inputHalves, volume) else: volume.setSamplingRate(self.half1.get().getSamplingRate()) #if self.filterHalfMaps: # volume.setHalfMaps([fnhalfMap1, fnhalfMap2]) self._defineOutputs(directionalFilteredMap=volume) self._defineSourceRelation(self.half1, volume)
def _visualize(self, obj, **args): """ Visualize any saved pdb and map if none were saved show the input files. """ _inputVolFlag = False _inputPDBFlag = False directory = self.protocol._getExtraPath() fnCmd = os.path.abspath(self.protocol._getTmpPath("chimera_output.cxc")) f = open(fnCmd, 'w') f.write('cd %s\n' % os.getcwd()) counter = 0 # Find all saved maps and pdbs from protocl. If none # are found show the input files to the protocol for filename in sorted(os.listdir(directory)): if filename.endswith(".mrc"): _inputVolFlag = True counter += 1 volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) f.write("open %s\n" % volFileName) f.write("volume #%d style surface voxelSize %f\n" "volume #%d origin %0.2f,%0.2f,%0.2f\n" % (counter, sampling, counter, shifts[0], shifts[1], shifts[2])) # Set volume to translucent f.write("volume #%d transparency 0.5\n" % counter) for filename in os.listdir(directory): if filename.endswith(".pdb") or filename.endswith(".cif"): _inputPDBFlag = True path = os.path.join(directory, filename) f.write("open %s\n" % path) # If no pdbs or maps found use inputs to protocol if not _inputVolFlag: counter += 1 f.write("open %s \n" % os.path.abspath(self.protocol.inputVolume.get().getFileName())) # Set volume to translucent f.write("volume #%d transparency 0.5\n" % counter) if not _inputPDBFlag: f.write("open %s \n" % os.path.abspath(self.protocol.pdbFileToBeRefined.get().getFileName())) f.close() # run in the background Chimera.runProgram(chimera.getProgram(), fnCmd + "&") return []
def createOutputStep(self): imgSet = self.inputParticles.get() volume = Volume() volume.setFileName(self._getFileName('output_volume')) volume.setSamplingRate(imgSet.getSamplingRate()) self._defineOutputs(outputVolume=volume) self._defineSourceRelation(self.inputParticles, volume)
def createOutputStep(self): """ Create the output volume """ outputVolume = Volume() outputVolume.setSamplingRate(self.getSampling()) outputVolume.setFileName(self.getOutputFn()) self._defineOutputs(outputVolume=outputVolume) self._defineTransformRelation(self.inputVolume, outputVolume)
def createOutputStep(self): metrics = self._getMetrics() volume = Volume() volume.setFileName(self._getFileName(RESTA_FILE_MRC)) volume.setSamplingRate(self.inputVolume.get().getSamplingRate()) volume.setOrigin(self.inputVolume.get().getOrigin(True).clone()) self._defineOutputs(fscq_Volume=volume, **metrics) self._defineTransformRelation(self.inputVolume, volume)
def createOutputStep(self): outputVolumeResmap = Volume() outputVolumeResmap.setSamplingRate( self.volumeHalf1.get().getSamplingRate()) outputVolumeResmap.setFileName(self._getFileName(RESMAP_VOL)) self._defineOutputs(outputVolume=outputVolumeResmap) self._defineTransformRelation(self.volumeHalf1, outputVolumeResmap) self._defineTransformRelation(self.volumeHalf2, outputVolumeResmap)
def createOutputStep(self): out_vol = Volume() in_vol = self.inputVol.get() out_vol.setSamplingRate(in_vol.getSamplingRate()) out_vol.setFileName(self._getExtraPath("shift_volume.mrc")) self._defineOutputs(outputVolume=out_vol) self._defineOutputs(shiftX=pwobj.Float(self.shiftx), shiftY=pwobj.Float(self.shifty), shiftZ=pwobj.Float(self.shiftz)) self._defineSourceRelation(in_vol, out_vol)
def createOutput(self): volume = Volume() volume.setSamplingRate(self.sampling.get()) volume.setFileName(self._getVolName()) if self.vol: origin = Transform() origin.setShiftsTuple(self.shifts) volume.setOrigin(origin) self._defineOutputs(outputVolume=volume) if self.inputPdbData == self.IMPORT_OBJ: self._defineSourceRelation(self.pdbObj, volume)
def createOutputStep(self): if os.path.exists(self._getFileName('out_vol3DFSC')): inputVol = self.inputVolume.get() vol = Volume() vol.setObjLabel('3D FSC') vol.setFileName(self._getFileName('out_vol3DFSC')) vol.setSamplingRate(inputVol.getSamplingRate()) # remove useless output cleanPath(self._getExtraPath('Results_vol/ResEMvolOut.mrc')) self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputVolume, vol)
def convertInputStep(self): outputParticles = self._createSetOfParticles() outputParticles.copyInfo(self.inputParticles.get()) outputParticles.copyItems(self.inputParticles.get()) self._defineOutputs(outputParticlesInit=outputParticles) self._store(outputParticles) # outputParticles.close() outputVolumes = Volume() outputVolumes.setFileName(self.inputVolume.get().getFileName()) outputVolumes.setSamplingRate(self.inputVolume.get().getSamplingRate()) self._defineOutputs(outputVolumesInit=outputVolumes) self._store(outputVolumes)
def createOutputStep(self): volume = Volume() volume.setFileName(self._getFileName(FN_RESOLMAP)) volume.setSamplingRate(self.inputVolume.get().getSamplingRate()) self._defineOutputs(resolution_Volume=volume) self._defineSourceRelation(self.inputVolume, volume) imageFile = self._getFileName(FN_RESOLMAP) min_, max_ = self.getMinMax(imageFile) self.min_res_init.set(round(min_ * 100) / 100) self.max_res_init.set(round(max_ * 100) / 100) self._store(self.min_res_init) self._store(self.max_res_init)
def createOutputStep(self): imgSet = self.inputParticles.get() # Let us use extension "vol" for the output vol # use stk creates visualization probrems. vol = Volume() volNameStk = self._getPath('volume.stk') volName = volNameStk.replace(".stk", ".vol") pwutils.createLink(volNameStk, volName) vol.setFileName(volName) vol.setSamplingRate(imgSet.getSamplingRate()) self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputParticles, vol)
def createOutput(self): Ts = self.inputVolume.get().getSamplingRate() self.runJob("xmipp_image_header","-i %s --sampling_rate %f" %(self.fnVolSym,Ts)) volume = Volume() volume.setFileName(self.fnVolSym) volume.copyInfo(self.inputVolume.get()) self._defineOutputs(outputVolume=volume) self._defineTransformRelation(self.inputVolume, self.outputVolume) rot0, tilt0 = self.getAngles() self._defineOutputs(rotSym=pwobj.Float(rot0), tiltSym=pwobj.Float(tilt0))
def createOutput(self): fnDir = self._getExtraPath() Ts = self.readInfoField(fnDir, "sampling", emlib.MDL_SAMPLINGRATE) # Remove files that will not be used any longer cleanPath(join(fnDir, "images.stk")) cleanPath(join(fnDir, "images.xmd")) # Final average TsOrig = self.inputParticles.get().getSamplingRate() XdimOrig = self.inputParticles.get().getDimensions()[0] fnAvg = self._getExtraPath("volumeAvg.vol") fnAvgMrc = self._getExtraPath("volumeAvg.mrc") self.runJob("xmipp_image_resize", "-i %s --dim %d" % (fnAvg, XdimOrig), numberOfMpi=1) self.runJob("xmipp_image_convert", "-i %s -o %s -t vol" % (fnAvg, fnAvgMrc), numberOfMpi=1) cleanPath(fnAvg) self.runJob("xmipp_image_header", "-i %s --sampling_rate %f" % (fnAvgMrc, TsOrig), numberOfMpi=1) volume = Volume() volume.setFileName(fnAvgMrc) volume.setSamplingRate(TsOrig) self._defineOutputs(outputVolume=volume) self._defineSourceRelation(self.inputParticles.get(), volume) self._defineSourceRelation(self.inputVolumes.get(), volume) # Swarm of volumes volSet = self._createSetOfVolumes() volSet.setSamplingRate(Ts) for i in range(self.inputVolumes.get().getSize()): fnVol = self._getExtraPath("volume%03d_best.vol" % i) fnMrc = self._getExtraPath("volume%03d_best.mrc" % i) self.runJob("xmipp_image_convert", "-i %s -o %s" % (fnVol, fnMrc), numberOfMpi=1) self.runJob("xmipp_image_header", "-i %s --sampling_rate %f" % (fnMrc, TsOrig), numberOfMpi=1) cleanPath(fnVol) vol = Volume() vol.setFileName(fnMrc) vol.setSamplingRate(Ts) volSet.append(vol) self._defineOutputs(outputVolumes=volSet) self._defineSourceRelation(self.inputParticles.get(), volSet) self._defineSourceRelation(self.inputVolumes.get(), volSet)
def _appendOutputVolume(self, volumeOut): fnMrc = convertToMrc(self, volumeOut, self.sampling, True) vol = Volume() vol.setFileName(fnMrc) vol.setSamplingRate(self.sampling) self.volumesSet.append(vol) if self.doFilter.get(): volumeFilterOut = volumeOut.replace('.vol', '_filtered.vol') fnMrc = convertToMrc(self, volumeFilterOut, self.sampling, True) volf = Volume() volf.setFileName(fnMrc) volf.setSamplingRate(self.sampling) self.volumesFilterSet.append(volf)
def _fillVolSetFromIter(self, volSet, rLev=None, it=None): it = self._lastIter() if it is None else it rLev = self._rLev if rLev is None else rLev volSet.setSamplingRate(self._getInputParticles().getSamplingRate()) modelFn = self._getFileName('model', ruNum=rLev, iter=it) print('modelFn: ', modelFn) modelStar = md.MetaData('model_classes@' + modelFn) idList = [] volFnList = [] clsDistList = [] accRotList = [] accTransList = [] resoList = [] for row in md.iterRows(modelStar): accurracyRot = row.getValue('rlnAccuracyRotations') if accurracyRot <= 90: fn = row.getValue('rlnReferenceImage') print('Volume: ', fn) fnMrc = fn + ":mrc" itemId = self._getClassId(fn) classDistrib = row.getValue('rlnClassDistribution') accurracyTras = row.getValue('rlnAccuracyTranslations') resol = row.getValue('rlnEstimatedResolution') idList.append(itemId) volFnList.append(fnMrc) clsDistList.append(classDistrib) accRotList.append(accurracyRot) accTransList.append(accurracyTras) resoList.append(resol) std = self.std if hasattr(self, 'std') else None score = self._estimateScore(accRotList, clsDistList, None, std) threshold = 1 / float(self.numOfVols.get()) print("score: ", score) for i, s in enumerate(score): vol = Volume() self._invertScaleVol(volFnList[i]) vol.setFileName(self._getOutputVolFn(volFnList[i])) vol.setObjId(idList[i]) if s <= threshold: vol._objEnabled = False vol._cmScore = pwObj.Float(s) vol._rlnClassDistribution = Float(clsDistList[i]) vol._rlnAccuracyRotations = Float(accRotList[i]) vol._rlnAccuracyTranslations = Float(accTransList[i]) vol._rlnEstimatedResolution = Float(resoList[i]) volSet.append(vol)
def createOutput(self): Ts = self.inputVol.get().getSamplingRate() if not self.downsample.get(): Ts = Ts / 2 volumeLafter = Volume() volumeLafter.setFileName(self._getPath("LAFTER_filtered.mrc")) volumeLafter.setSamplingRate(Ts) self._defineOutputs(outputVolumeLafter=volumeLafter) self._defineSourceRelation(self.inputVol.get(), volumeLafter) volumeSuppressed = Volume() volumeSuppressed.setFileName(self._getPath("noise_suppressed.mrc")) volumeSuppressed.setSamplingRate(Ts) self._defineOutputs(outputVolumeSuppresed=volumeSuppressed) self._defineSourceRelation(self.inputVol.get(), volumeSuppressed)
def createOutputStep(self): vol1 = self.vol1.get() volume = Volume() volume.setSamplingRate(vol1.getSamplingRate()) if vol1.getFileName().endswith('mrc'): origin = Transform() ccp4header = headers.Ccp4Header(vol1.getFileName(), readHeader=True) shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) volume.setOrigin(origin) volume.setFileName(self._getExtraPath("output_volume.mrc")) filename = volume.getFileName() if filename.endswith('.mrc') or filename.endswith('.map'): volume.setFileName(filename + ':mrc') self._defineOutputs(outputVolume=volume)
def createOutputStep(self): outVol = Volume() outVol.setSamplingRate(self.vols[0].get().getSamplingRate()) outVol.setFileName(self._getExtraPath("consensus_volume.mrc")) if not exists(self._getExtraPath("consensus_volume.mrc")): raise NoOutputGenerated( "Consensus volume NOT generated, please check input volumes to ensure they have " "equal box size, voxel size and origin.") else: outVol2 = Volume() outVol2.setSamplingRate(self.vols[0].get().getSamplingRate()) outVol2.setFileName( self._getExtraPath("consensus_volume_diff.mrc")) self._defineOutputs(outputVolume=outVol) self._defineOutputs(outputVolumeDiff=outVol2)
def createOutput(self): volume = Volume() volume.setFileName(self.fnVolSym) Ts = self.inputVolume.get().getSamplingRate() self.runJob("xmipp_image_header", "-i %s --sampling_rate %f" % (self.fnVolSym, Ts)) volume.copyInfo(self.inputVolume.get()) self._defineOutputs(outputVolume=volume) self._defineTransformRelation(self.inputVolume, self.outputVolume) md = MetaData(self._getFileName('fine')) objId = md.firstObject() self._defineOutputs(deltaRot=pwobj.Float( md.getValue(MDL_ANGLE_ROT, objId)), deltaZ=pwobj.Float(md.getValue(MDL_SHIFT_Z, objId)))
def createOutputStep(self): partSet = self._getInputParticles() vol = Volume() vol.setSamplingRate(partSet.getSamplingRate()) vol.setObjLabel('real space PSF') vol.setFileName(self._getFileName('real space PSF')) vol2 = Volume() vol2.setSamplingRate(partSet.getSamplingRate()) vol2.setObjLabel('fourier space PSF') vol2.setFileName(self._getFileName('fourier space PSF')) outputs = {'outputVolume1': vol, 'outputVolume2': vol2} self._defineOutputs(**outputs) self._defineSourceRelation(self.inputParticles, vol) self._defineSourceRelation(self.inputParticles, vol2)
def createOutputStep(self): inputVol = self.protRefine.get().outputVolume ps = inputVol.getSamplingRate() vol = Volume() vol.setSamplingRate(ps) vol.setObjLabel('Filtered half-map 1') vol.setFileName(self._getFileName('outHalf1Fn')) vol2 = Volume() vol2.setSamplingRate(ps) vol2.setObjLabel('Filtered half-map 2') vol2.setFileName(self._getFileName('outHalf2Fn')) outputs = {'outputVolume1': vol, 'outputVolume2': vol2} self._defineOutputs(**outputs) self._defineSourceRelation(inputVol, vol) self._defineSourceRelation(inputVol, vol2)