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 _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 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): 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): lastIter = self.getLastIteration(1) Ts = self.inputSet.get().getSamplingRate() # To recover the original size of the volume if it was changed fnVol = self.getIterVolume(lastIter) Xdim = self.inputSet.get().getDimensions()[0] if self.useMaxRes and self.newXdim != Xdim: self.runJob('xmipp_image_resize', "-i %s --fourier %d" % (fnVol, Xdim), numberOfMpi=1) fnMrc = fnVol.replace(".vol", ".mrc") self.runJob("xmipp_image_convert", "-i %s -o %s -t vol" % (fnVol, fnMrc), numberOfMpi=1) cleanPath(fnVol) self.runJob("xmipp_image_header", "-i %s --sampling_rate %f" % (fnMrc, Ts), numberOfMpi=1) vol = Volume() vol.setObjComment('significant volume 1') vol.setLocation(fnMrc) vol.setSamplingRate(Ts) self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputSet, vol)
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 createOutputStep(self): outVolFn = self._getExtraPath("inputVolumeAligned.mrc") Ts = self.inputVolume.get().getSamplingRate() self.runJob("xmipp_image_header", "-i %s --sampling_rate %f" % (outVolFn, Ts)) outVol = Volume() outVol.setLocation(outVolFn) #set transformation matrix fhInputTranMat = self._getExtraPath('transformation-matrix.txt') transMatFromFile = np.loadtxt(fhInputTranMat) transformationMat = np.reshape(transMatFromFile, (4, 4)) transform = Transform() transform.setMatrix(transformationMat) outVol.setTransform(transform) outVol.setSamplingRate(Ts) outputArgs = {'outputVolume': outVol} self._defineOutputs(**outputArgs) self._defineSourceRelation(self.inputVolume, outVol) #particles.... outParticlesFn = self._getExtraPath('outputParticles.xmd') outputParticles = self._createSetOfParticles() outputParticles.copyInfo(self.inputParticles.get()) outputParticles.setAlignmentProj() readSetOfParticles(outParticlesFn, outputParticles) outputArgs = {'outputParticles': outputParticles} self._defineOutputs(**outputArgs) self._defineSourceRelation(self.inputParticles, outputParticles)
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): 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 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): 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): 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): 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): 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): 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 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): 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 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 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): 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 _getVolumes(self): """ Return the list of volumes generated. The number of volumes in the list will be equal to the number of classes requested by the user in the protocol. """ # Provide 1 as default value for making it backward compatible k = self.getAttributeValue('numberOfClasses', 1) pixelSize = self._getInputParticles().getSamplingRate() lastIter = self._lastIter() volumes = [] for i in range(1, k + 1): vol = Volume(self._getExtraPath('relion_it%03d_class%03d.mrc') % (lastIter, i)) vol.setSamplingRate(pixelSize) volumes.append(vol) return volumes
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)
def createOutputStep(self): vol = Volume() vol.setLocation(self._getOutputVol()) sampling = self.inputVolumes.get().getSamplingRate() vol.setSamplingRate(sampling) # ccp4header = Ccp4Header(self._getOutputVol(), readHeader=True) t = Transform() x, y, z = ccp4header.getOrigin() # origin output vol # coordinates t.setShifts(x, y, z) vol.setOrigin(t) # self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputVolumes, self.outputVolume)
def createOutputStep(self): if self.targetResolution.get() != 3.0: correctionFactor = self.targetResolution.get() / 3.0 with open(self._getExtraPath('Volumes_clnm.txt'), 'r') as fid: lines = fid.readlines() basisParams = np.fromstring(lines[0], sep=' ') if self.Rmax.get() != 0: basisParams[2] = self.Rmax.get() else: basisParams[2] = self.refVolume.get().getDim()[0] / 2 clnm = np.fromstring(lines[1], sep=' ') * correctionFactor with open(self._getExtraPath('Volumes_clnm.txt'), 'w') as fid: fid.write(' '.join(map(str, basisParams)) + "\n") fid.write(' '.join(map(str, clnm)) + "\n") vol = Volume() vol.setLocation(self._getFileName('fnOutVol')) vol.setSamplingRate(self.newTs) self._defineOutputs(outputVolume=vol) self._defineSourceRelation(self.inputVolume, vol)