Beispiel #1
0
def runCreateOutputStep(self):
    ''' Create standard output results_images, result_classes'''
    #creating results files
    imgSet = self.inputParticles.get()
    lastIter = self.numberOfIterations.get()
    if self.numberOfReferences != 1:
        inDocfile = self._getFileName('docfileInputAnglesIters', iter=lastIter)
        ClassFnTemplate = '%(rootDir)s/reconstruction_Ref3D_%(ref)03d.vol'
        
        allExpImagesinDocfile = xmipp.FileName()
        all_exp_images="all_exp_images"
        allExpImagesinDocfile.compose(all_exp_images, inDocfile)
        
        dataClasses = self._getFileName('sqliteClasses')
        
        createClassesFromImages(imgSet, str(allExpImagesinDocfile), dataClasses, 
                                SetOfClasses3D, xmipp.MDL_REF3D, ClassFnTemplate, lastIter)
        
        classes = self._createSetOfClasses3D(imgSet)
        clsSet = SetOfClasses3D(dataClasses)
        classes.appendFromClasses(clsSet)
        
        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(imgSet.getSamplingRate())
        
        for refN in self.allRefs():
            volFn = self._getFileName('reconstructedFileNamesIters', iter=lastIter, ref=refN)
            vol = Volume()
            vol.setFileName(volFn)
            volumes.append(vol)
    
        self._defineOutputs(outputVolumes=volumes)
        self._defineOutputs(outputClasses=classes)
        self._defineSourceRelation(self.inputParticles, volumes)
        self._defineSourceRelation(self.inputParticles, classes)
        self._defineSourceRelation(self.input3DReferences, volumes)
        self._defineSourceRelation(self.input3DReferences, classes)
    else:
        volFn = self._getFileName('reconstructedFileNamesIters',
                                  iter=lastIter, ref=1)
        halfMap1 = self._getFileName('reconstructedFileNamesItersSplit1',
                                     iter=lastIter, ref=1)
        halfMap2 = self._getFileName('reconstructedFileNamesItersSplit2',
                                     iter=lastIter, ref=1)

        vol = Volume()
        vol.setFileName(volFn)
        vol.setSamplingRate(imgSet.getSamplingRate())
        vol.setHalfMaps([halfMap1, halfMap2])
        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
        self._defineSourceRelation(self.input3DReferences, vol)
        
        #create set of images
        imgSetOut = self._createSetOfParticles("_iter_%03d" %lastIter)
        self._fillParticlesFromIter(imgSetOut, lastIter)
        
        self._defineOutputs(outputParticles=imgSetOut)
        self._defineSourceRelation(self.inputParticles, imgSetOut)
        self._defineSourceRelation(self.input3DReferences, imgSetOut)
Beispiel #2
0
    def createOutputStep(self):
        volInput = self.inputVolumes.get()
        if self._isSingleInput():
            # Create the output with the same class as
            # the input, that should be Volume or a subclass
            # of Volume like VolumeMask
            volClass = volInput.getClass()
            vol = volClass()  # Create an instance with the same class of input
            vol.copyInfo(volInput)
            vol.setLocation(1, self.outputStk)
            self._postprocessOutput(vol)
            self._defineOutputs(outputVol=vol)
        else:
            # ToDo: createSetOfVolumes not work properly when the protocol is resumed.
            volumes = self._createSetOfVolumes()
            volumes.copyInfo(volInput)
            self._preprocessOutput(volumes)
            numberOfVols = self.inputVolumes.get().getSize()
            for i in range(1, numberOfVols + 1):
                vol = Volume()
                vol.setLocation(i, self.outputStk)
                volumes.append(vol)
            self._postprocessOutput(volumes)
            self._defineOutputs(outputVol=volumes)

        self._defineTransformRelation(self.inputVolumes, self.outputVol)
    def createOutputStep(self):
        numberOfClasses = self.numberOfRef
        imgSet = self._getInputParticles()
        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(imgSet.getSamplingRate())
        
        for ref in range(1, numberOfClasses + 1):
            vol = Volume()
            volFn = self._getFileName('iter_vol_class', iter=self._getLastIter(), ref=ref)
            vol.setFileName(volFn)
            volumes.append(vol)
        
        clsSet = self._createSetOfClasses3D(imgSet)
        self._fill3DClasses(clsSet, numberOfClasses)

        # Define the outputs and relations
        self._defineOutputs(outputClasses=clsSet)
        self._defineOutputs(outputVolumes=volumes)
        #TODO: save alignment

        self._defineSourceRelation(self._getInputParticlesPointer(), clsSet)
        self._defineSourceRelation(self._getInputParticlesPointer(), volumes)
        if not self.doContinue:
            self._defineSourceRelation(self.input3DReference, clsSet)
            self._defineSourceRelation(self.input3DReference, volumes)
    def createOutputStep(self):
        numberOfClasses = self.numberOfRef
        imgSet = self._getInputParticles()
        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(imgSet.getSamplingRate())

        for ref in range(1, numberOfClasses + 1):
            vol = Volume()
            volFn = self._getFileName('iter_vol_class',
                                      iter=self._getLastIter(),
                                      ref=ref)
            vol.setFileName(volFn)
            volumes.append(vol)

        clsSet = self._createSetOfClasses3D(imgSet)
        self._fill3DClasses(clsSet, numberOfClasses)

        # Define the outputs and relations
        self._defineOutputs(outputClasses=clsSet)
        self._defineOutputs(outputVolumes=volumes)
        #TODO: save alignment

        self._defineSourceRelation(self._getInputParticlesPointer(), clsSet)
        self._defineSourceRelation(self._getInputParticlesPointer(), volumes)
        if not self.doContinue:
            self._defineSourceRelation(self.input3DReference, clsSet)
            self._defineSourceRelation(self.input3DReference, volumes)
    def createOutputStep(self):
        volume=Volume()
        volume.setFileName(self._getExtraPath('sharpenedMap_last.mrc'))
        volume.setSamplingRate(self.inputVolume.get().getSamplingRate())

        self._defineOutputs(sharpened_map=volume)
        self._defineSourceRelation(self.inputVolume, volume)          
Beispiel #6
0
 def createOutputStep(self):
     volInput = self.inputVolumes.get()
     if self._isSingleInput():
         # Create the output with the same class as
         # the input, that should be Volume or a subclass
         # of Volume like VolumeMask
         volClass = volInput.getClass()
         vol = volClass() # Create an instance with the same class of input 
         vol.copyInfo(volInput)
         vol.setLocation(1, self.outputStk)
         self._postprocessOutput(vol)
         self._defineOutputs(outputVol=vol)
     else:
         # ToDo: createSetOfVolumes not work properly when the protocol is resumed.
         volumes = self._createSetOfVolumes()
         volumes.copyInfo(volInput)
         self._preprocessOutput(volumes)
         numberOfVols = self.inputVolumes.get().getSize()
         for i in range(1, numberOfVols + 1):
             vol = Volume()
             vol.setLocation(i, self.outputStk)
             volumes.append(vol)
         self._postprocessOutput(volumes)
         self._defineOutputs(outputVol=volumes)
         
     self._defineTransformRelation(volInput, self.outputVol)
Beispiel #7
0
 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)
Beispiel #8
0
 def createOutputStep(self):
     volume = Volume()
     volume.setFileName(self._getFileName("finalMap"))
     vol = self.protRefine.get().outputVolume
     pxSize = vol.getSamplingRate()
     volume.setSamplingRate(pxSize)
     self._defineOutputs(outputVolume=volume)
     self._defineSourceRelation(vol, volume)
Beispiel #9
0
def runCreateOutputStep(self):
    ''' Create standard output results_images, result_classes'''
    #creating results files
    imgSet = self.inputParticles.get()
    lastIter = self.numberOfIterations.get()
    if self.numberOfReferences != 1:
        inDocfile = self._getFileName('docfileInputAnglesIters', iter=lastIter)
        ClassFnTemplate = '%(rootDir)s/reconstruction_Ref3D_%(ref)03d.vol'

        allExpImagesinDocfile = xmipp.FileName()
        all_exp_images = "all_exp_images"
        allExpImagesinDocfile.compose(all_exp_images, inDocfile)

        dataClasses = self._getFileName('sqliteClasses')

        createClassesFromImages(imgSet, str(allExpImagesinDocfile),
                                dataClasses, SetOfClasses3D, xmipp.MDL_REF3D,
                                ClassFnTemplate, lastIter)

        classes = self._createSetOfClasses3D(imgSet)
        clsSet = SetOfClasses3D(dataClasses)
        classes.appendFromClasses(clsSet)

        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(imgSet.getSamplingRate())

        for refN in self.allRefs():
            volFn = self._getFileName('reconstructedFileNamesIters',
                                      iter=lastIter,
                                      ref=refN)
            vol = Volume()
            vol.setFileName(volFn)
            volumes.append(vol)

        self._defineOutputs(outputVolumes=volumes)
        self._defineOutputs(outputClasses=classes)
        self._defineSourceRelation(self.inputParticles, volumes)
        self._defineSourceRelation(self.inputParticles, classes)
        self._defineSourceRelation(self.input3DReferences, volumes)
        self._defineSourceRelation(self.input3DReferences, classes)
    else:
        volFn = self._getFileName('reconstructedFileNamesIters',
                                  iter=lastIter,
                                  ref=1)
        vol = Volume()
        vol.setFileName(volFn)
        vol.setSamplingRate(imgSet.getSamplingRate())
        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
        self._defineSourceRelation(self.input3DReferences, vol)

        #create set of images
        imgSetOut = self._createSetOfParticles("_iter_%03d" % lastIter)
        self._fillParticlesFromIter(imgSetOut, lastIter)

        self._defineOutputs(outputParticles=imgSetOut)
        self._defineSourceRelation(self.inputParticles, imgSetOut)
        self._defineSourceRelation(self.input3DReferences, imgSetOut)
    def createOutputStep(self):
        inputParticles = self.inputParticles.get()
        if not self._useSeveralClasses():
            newTs = inputParticles.getSamplingRate()
        else:
            newTs = self.readInfoField(self._getExtraPath(),"sampling",xmippLib.MDL_SAMPLINGRATE)

        self.mdClasses = xmippLib.MetaData(self._getDirectionalClassesFn())
        self.mdImages = xmippLib.MetaData(self._getDirectionalImagesFn())

        classes2D = self._createSetOfClasses2D(inputParticles)
        classes2D.getImages().setSamplingRate(newTs)

        self.averageSet = self._createSetOfAverages()
        self.averageSet.copyInfo(inputParticles)
        self.averageSet.setAlignmentProj()
        self.averageSet.setSamplingRate(newTs)

        # Let's use a SetMdIterator because it should be less particles
        # in the metadata produced than in the input set
        iterator = md.SetMdIterator(self.mdImages, sortByLabel=md.MDL_ITEM_ID,
                                    updateItemCallback=self._updateParticle,
                                    skipDisabled=True)

        fnHomogeneous = self._getExtraPath("images_homogeneous.xmd")
        if exists(fnHomogeneous):
            homogeneousSet = self._createSetOfParticles()
            homogeneousSet.copyInfo(inputParticles)
            homogeneousSet.setSamplingRate(newTs)
            homogeneousSet.setAlignmentProj()
            self.iterMd = md.iterRows(fnHomogeneous, md.MDL_PARTICLE_ID)
            self.lastRow = next(self.iterMd) 
            homogeneousSet.copyItems(inputParticles,
                                     updateItemCallback=self._updateHomogeneousItem)
            self._defineOutputs(outputHomogeneous=homogeneousSet)
            self._defineSourceRelation(self.inputParticles, homogeneousSet)

        classes2D.classifyItems(updateItemCallback=iterator.updateItem,
                                updateClassCallback=self._updateClass)

        self._defineOutputs(outputClasses=classes2D)
        self._defineOutputs(outputAverages=self.averageSet)
        self._defineSourceRelation(self.inputParticles, classes2D)
        self._defineSourceRelation(self.inputParticles, self.averageSet)

        if self.splitVolume and self.directionalClasses.get()>1:
            volumesSet = self._createSetOfVolumes()
            volumesSet.setSamplingRate(newTs)
            for i in range(2):
                vol = Volume()
                vol.setLocation(1, self._getExtraPath("split_v%d.vol"%(i+1)))
                volumesSet.append(vol)

            self._defineOutputs(outputVolumes=volumesSet)
            self._defineSourceRelation(inputParticles, volumesSet)
Beispiel #11
0
 def createOutput(self):
     inputParticles = self.directionalClasses.get()
     volumesSet = self._createSetOfVolumes()
     volumesSet.setSamplingRate(inputParticles.getSamplingRate())
     for i in range(2):
         vol = Volume()
         vol.setLocation(1, self._getExtraPath("split_v%d.vol"%(i+1)))
         volumesSet.append(vol)
     
     self._defineOutputs(outputVolumes=volumesSet)
     self._defineSourceRelation(inputParticles, volumesSet)
    def createOutput(self):
        inputParticles = self.directionalClasses.get()
        volumesSet = self._createSetOfVolumes()
        volumesSet.setSamplingRate(inputParticles.getSamplingRate())
        for i in range(2):
            vol = Volume()
            vol.setLocation(1, self._getExtraPath("split_v%d.vol" % (i + 1)))
            volumesSet.append(vol)

        self._defineOutputs(outputVolumes=volumesSet)
        self._defineSourceRelation(inputParticles, volumesSet)
    def _appendOutputVolume(self, volumeOut):
        vol = Volume()
        vol.setFileName(volumeOut)
        vol.setSamplingRate(self.sampling)
        self.volumesSet.append(vol)

        if self.doFilter.get():
            volumeFilterOut = volumeOut.replace('.vol', '_filtered.vol')
            volf = Volume()
            volf.setFileName(volumeFilterOut)
            volf.setSamplingRate(self.sampling)
            self.volumesFilterSet.append(volf)
 def createOutput(self):
     volumesSet = self._createSetOfVolumes()
     volumesSet.setSamplingRate(self.inputParticles.get().getSamplingRate())
     Nvols = len(self.splitPercentiles.get().split())
     fnStack = self._getPath("splittedVolumes.stk")
     for i in range(Nvols):
         vol = Volume()
         vol.setLocation(i+1, fnStack)
         volumesSet.append(vol)
     
     self._defineOutputs(outputVolumes=volumesSet)
     self._defineSourceRelation(self.inputParticles.get(), volumesSet)
Beispiel #15
0
    def createOutput(self):
        volumesSet = self._createSetOfVolumes()
        volumesSet.setSamplingRate(self.inputParticles.get().getSamplingRate())
        Nvols = len(self.splitPercentiles.get().split())
        fnStack = self._getPath("splittedVolumes.stk")
        for i in range(Nvols):
            vol = Volume()
            vol.setLocation(i + 1, fnStack)
            volumesSet.append(vol)

        self._defineOutputs(outputVolumes=volumesSet)
        self._defineSourceRelation(self.inputParticles.get(), volumesSet)
    def createOutputStep(self):
        volume = Volume()
        volume.setFileName(self._getExtraPath('postprocess.mrc'))
        volume.setSamplingRate(self.samplingRate)
        vol = self.protRelionRefine.get().outputVolume
        mask = VolumeMask()
        mask.setFileName(self._getExtraPath('postprocess_automask.mrc'))
        mask.setSamplingRate(self.samplingRate)

        self._defineOutputs(outputVolume=volume)
        self._defineOutputs(outputMask=mask)
        self._defineSourceRelation(vol, volume)
        self._defineSourceRelation(vol, mask)
 def _appendOutputVolume(self, volumeOut):  
                               
     vol = Volume()
     vol.setFileName(volumeOut)
     vol.setSamplingRate(self.inputParticlesTiltPair.get().getUntilted().getSamplingRate())
     self.volumesSet.append(vol)
     
     if self.doFilter.get():
         volumeFilterOut = volumeOut.replace('.vol','_filtered.vol')  
         volf = Volume()
         volf.setFileName(volumeFilterOut)
         volf.setSamplingRate(self.inputParticlesTiltPair.get().getUntilted().getSamplingRate())
         self.volumesFilterSet.append(volf)
Beispiel #18
0
    def createOutputStep(self):

        if not self.realignMovieFrames:
            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())
            blockName = 'model_class_%d@' % 1
            fn = blockName + self._getExtraPath("relion_model.star")
            mData = md.MetaData(fn)
            fsc.loadFromMd(mData, md.RLN_RESOLUTION,
                           md.RLN_MLMODEL_FSC_HALVES_REF)
            self._defineOutputs(outputFSC=fsc)
            self._defineSourceRelation(vol, fsc)

        else:
            pass
Beispiel #19
0
    def createOutputStep(self):
        imgSet = self._getInputParticles()
        vol = Volume()
        fnVol = self._getExtraPath('relion_it%03d_class001.mrc') % self._lastIter()
        vol.setFileName(fnVol)
        vol.setSamplingRate(imgSet.getSamplingRate())

        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)
Beispiel #20
0
    def createOutputStep(self):
        imgSet = self._getInputParticles()
        vol = Volume()
        vol.setFileName(self._getFileName('volume_shiny'))
        vol.setSamplingRate(imgSet.getSamplingRate())
        shinyPartSet = self._createSetOfParticles()
        shinyPartSet.copyInfo(imgSet)
        shinyPartSet.setAlignmentProj()
        readSetOfParticles(self._getFileName('shiny'), shinyPartSet,
                           alignType=ALIGN_PROJ)

        self._defineOutputs(outputParticles=shinyPartSet)
        self._defineOutputs(outputVolume=vol)
        
        self._defineSourceRelation(imgSet, shinyPartSet)
        self._defineSourceRelation(imgSet, vol)
Beispiel #21
0
 def createOutputStep(self):
     from pyworkflow.em import ALIGN_PROJ
     from pyworkflow.em.packages.relion.convert import readSetOfParticles
     imgSet = self.refineRun.get()._getInputParticles()
     vol = Volume()
     vol.setFileName(self._getFileName('volume_shiny', iter=self.refineRun._lastIter()))
     vol.setSamplingRate(imgSet.getSamplingRate())
     
     shinyPartSet = self._createSetOfParticles()
     
     shinyPartSet.copyInfo(imgSet)
     readSetOfParticles(self._getFileName('shiny'), shinyPartSet, alignType=ALIGN_PROJ)
     
     self._defineOutputs(outputParticles=shinyPartSet)
     self._defineSourceRelation(imgSet, shinyPartSet)
     self._defineOutputs(outputVolume=vol)
     self._defineSourceRelation(imgSet, vol)
 def createOutputStep(self):
     iterN = self.numberOfIterations.get()
     partSet = self._getInputParticles()
     numRun = self._getRun()
     
     vol = Volume()
     vol.setFileName(self._getFileName("volume",run=numRun, iter=iterN))
     vol.copyInfo(partSet)
     
     newPartSet = self._createSetOfParticles()
     newPartSet.copyInfo(partSet)
     self._fillDataFromIter(newPartSet, iterN)
     
     self._defineOutputs(outputVolume=vol)
     self._defineSourceRelation(self._getInputParticlesPointer(), vol)
     self._defineOutputs(outputParticles=newPartSet)
     self._defineTransformRelation(self._getInputParticlesPointer(), newPartSet)
Beispiel #23
0
def runCreateOutputStep(self):
    import pyworkflow.em.metadata as md
    ''' Create standard output results_images, result_classes'''
    #creating results files
    imgSet = self.inputParticles.get()
    lastIter = self.numberOfIterations.get()
    if self.numberOfReferences != 1:
        inDocfile = self._getFileName('docfileInputAnglesIters', iter=lastIter)
        ClassFnTemplate = '%(rootDir)s/reconstruction_Ref3D_%(ref)03d.vol'
        
        allExpImagesinDocfile = xmipp.FileName()
        all_exp_images="all_exp_images"
        allExpImagesinDocfile.compose(all_exp_images, inDocfile)
        
        dataClasses = self._getFileName('sqliteClasses')
        
        createClassesFromImages(imgSet, str(allExpImagesinDocfile), dataClasses, 
                                SetOfClasses3D, xmipp.MDL_REF3D, ClassFnTemplate, lastIter)
        
        classes = self._createSetOfClasses3D(imgSet)
        clsSet = SetOfClasses3D(dataClasses)
        classes.appendFromClasses(clsSet)
        
        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(imgSet.getSamplingRate())
        
        for refN in self.allRefs():
            volFn = self._getFileName('reconstructedFileNamesIters', iter=lastIter, ref=refN)
            vol = Volume()
            vol.setFileName(volFn)
            volumes.append(vol)
    
        self._defineOutputs(outputVolumes=volumes)
        self._defineOutputs(outputClasses=classes)
        self._defineSourceRelation(self.inputParticles, volumes)
        self._defineSourceRelation(self.inputParticles, classes)
    else:
        volFn = self._getFileName('reconstructedFileNamesIters', iter=lastIter, ref=1)
        vol = Volume()
        vol.setFileName(volFn)
        vol.setSamplingRate(imgSet.getSamplingRate())
        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
        
        #create set of images
        imgSetOut = self._createSetOfParticles()
        imgFn = "all_exp_images@" + self._getFileName('docfileInputAnglesIters', iter=lastIter, ref=1)
        
        imgSetOut.copyInfo(imgSet)
        imgSetOut.setAlignmentProj()
        imgSetOut.copyItems(imgSet,
                            updateItemCallback=self._createItemMatrix,
                            itemDataIterator=md.iterRows(imgFn))
        self._defineOutputs(outputParticles=imgSetOut)
        self._defineSourceRelation(self.inputParticles, imgSetOut)
Beispiel #24
0
    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):

        if not self.realignMovieFrames:
            imgSet = self._getInputParticles()
            vol = Volume()
            vol.setFileName(self._getExtraPath("relion_class001.mrc"))
            vol.setSamplingRate(imgSet.getSamplingRate())

            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)
        else:
            pass
    def createOutputStep(self):
        from glob import glob
        classes2DSet = self.inputSet.get()
        #volumes = EmanSetOfVolumes(self._getPath('scipion_volumes.json'))
        volumes = self._createSetOfVolumes()
        if isinstance(self.inputSet.get(), SetOfClasses2D):
            volumes.setSamplingRate(classes2DSet.getImages().getSamplingRate())
        else:
            volumes.setSamplingRate(self.inputSet.get().getSamplingRate())
        
        outputVols = glob(self._getExtraPath('initial_models/model_??_??.hdf'))
        outputVols.sort()
        for k, volFn in enumerate(outputVols):
            vol = Volume()
            vol.setFileName(volFn)
            vol.setObjComment('eman initial model %02d' % (k+1))
            volumes.append(vol)

        self._defineOutputs(outputVolumes=volumes)
        self._defineSourceRelation(classes2DSet, volumes)
 def createOutputStep(self):
     iterN = self.numberOfIterations.get()
     partSet = self._getInputParticles()
     numRun = self._getRun()
     
     vol = Volume()
     vol.setFileName(self._getFileName("volume",run=numRun, iter=iterN))
     vol.copyInfo(partSet)
     
     self._execEmanProcess(numRun, iterN)
     newPartSet = self._createSetOfParticles()
     newPartSet.copyInfo(partSet)
     newPartSet.setAlignment(em.ALIGN_PROJ)
     newPartSet.copyItems(partSet,
                          updateItemCallback=self._createItemMatrix,
                          itemDataIterator=self._iterTextFile(iterN))
     
     self._defineOutputs(outputVolume=vol)
     self._defineSourceRelation(self._getInputParticlesPointer(), vol)
     self._defineOutputs(outputParticles=newPartSet)
     self._defineTransformRelation(self._getInputParticlesPointer(), newPartSet)
    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):
     partSet = self.inputParticles.get()
     vol = Volume()
     vol.setFileName(self._getFileName("volume"))
     vol.copyInfo(partSet)
     self._defineOutputs(outputVolume=vol)
     self._defineSourceRelation(self.inputParticles, vol)
    def createOutputStep(self):
        volume = Volume()
        volume.setFileName(self._getExtraPath('sharpenedMap_last.mrc'))
        volume.setSamplingRate(self.inputVolume.get().getSamplingRate())

        self._defineOutputs(sharpened_map=volume)
        self._defineSourceRelation(self.inputVolume, 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)
Beispiel #32
0
 def createOutputStep(self):
     volume = Volume()
     volume.setFileName(self._getFileName("finalMap"))
     vol = self.protRefine.get().outputVolume
     pxSize = vol.getSamplingRate()
     volume.setSamplingRate(pxSize)
     self._defineOutputs(outputVolume=volume)
     self._defineSourceRelation(vol, volume)
Beispiel #33
0
 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)
Beispiel #34
0
 def createOutputStep(self):
     
     if not self.realignMovieFrames:
         imgSet = self._getInputParticles()
         vol = Volume()
         vol.setFileName(self._getExtraPath('relion_class001.mrc'))
         vol.setSamplingRate(imgSet.getSamplingRate())
         
         outImgSet = self._createSetOfParticles()
         outImgsFn = self._getFileName('data', iter=self._lastIter())
         
         outImgSet.copyInfo(imgSet)
         outImgSet.setAlignmentProj()
         outImgSet.copyItems(imgSet,
                             updateItemCallback=self._createItemMatrix,
                             itemDataIterator=md.iterRows(outImgsFn))
         
         self._defineOutputs(outputVolume=vol)
         self._defineSourceRelation(imgSet, vol)
         self._defineOutputs(outputParticles=outImgSet)
         self._defineTransformRelation(imgSet, outImgSet)
     else:
         pass
    def createOutputStep(self):
        imgSet = self.inputParticles.get()
        vol = Volume()
        #FIXME: return the last completed iteration
        vol.setFileName(self._getExtraPath('Refinement/final/bpr%02d.stk' % (self.numberOfIterations.get() + 1)))
        vol.setSamplingRate(imgSet.getSamplingRate())

        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
    def createOutputStep(self):
        imgSet = self.inputParticles.get()
        vol = Volume()
        # FIXME: return two half-volumes as well
        vol.setFileName(self._getPath('volume.stk'))
        vol.setSamplingRate(imgSet.getSamplingRate())

        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
    def createOutputStep(self):
        inputVol = self.inputStructure.get()
        samplingRate = inputVol.getSamplingRate()
        volume = Volume()
        volume.setFileName(self._getExtraPath("pseudoatoms_approximation.vol"))
        volume.setSamplingRate(samplingRate)
        x, y, z = volume.getDim()
        xv, yv, zv = inputVol.getOrigin(force=True).getShifts()
        t = Transform()
        t.setShifts((x / 2. * samplingRate) - xv, (y / 2. * samplingRate) - yv,
                    (z / 2. * samplingRate) - zv)
        volume.setOrigin(inputVol.getOrigin())

        self._defineOutputs(outputVolume=volume)
        self._defineSourceRelation(self.inputStructure.get(), volume)

        pdb = AtomStruct(self._getPath('pseudoatoms.pdb'), pseudoatoms=True)
        pdb.setVolume(volume)
        pdb.setOrigin(t)
        self.createChimeraScript(inputVol, pdb)
        self._defineOutputs(outputPdb=pdb)
        self._defineSourceRelation(self.inputStructure, pdb)
Beispiel #38
0
    def createOutputStep(self):
        inputVol = self.inputStructure.get()
        pdb = PdbFile(self._getPath('pseudoatoms.pdb'), pseudoatoms=True)
        self.createChimeraScript(inputVol, pdb)
        self._defineOutputs(outputPdb=pdb)
        self._defineSourceRelation(self.inputStructure, pdb)

        volume=Volume()
        volume.setFileName(self._getExtraPath("pseudoatoms_approximation.vol"))
        volume.setSamplingRate(inputVol.getSamplingRate())
        self._defineOutputs(outputVolume=volume)
        self._defineSourceRelation(self.inputStructure.get(),volume)
Beispiel #39
0
    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)
Beispiel #40
0
    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)
Beispiel #41
0
    def createOutputStep(self):
        volume = Volume()
        volume.setFileName(self._getExtraPath('postprocess.mrc'))
        volume.setSamplingRate(self.samplingRate)
        vol = self.protRelionRefine.get().outputVolume
        mask = VolumeMask()
        mask.setFileName(self._getExtraPath('postprocess_automask.mrc'))
        mask.setSamplingRate(self.samplingRate)

        self._defineOutputs(outputVolume=volume)
        self._defineOutputs(outputMask=mask)
        self._defineSourceRelation(vol, volume)
        self._defineSourceRelation(vol, mask)
    def createOutputStep(self):
        iterN = self.numberOfIterations.get()
        partSet = self._getInputParticles()
        numRun = self._getRun()

        vol = Volume()
        vol.setFileName(self._getFileName("mapFull", run=numRun, iter=iterN))
        halfMap1 = self._getFileName("mapEvenUnmasked", run=numRun)
        halfMap2 = self._getFileName("mapOddUnmasked", run=numRun)
        vol.setHalfMaps([halfMap1, halfMap2])
        vol.copyInfo(partSet)

        newPartSet = self._createSetOfParticles()
        newPartSet.copyInfo(partSet)
        self._fillDataFromIter(newPartSet, iterN)

        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self._getInputParticlesPointer(), vol)
        self._defineOutputs(outputParticles=newPartSet)
        self._defineTransformRelation(self._getInputParticlesPointer(), newPartSet)
Beispiel #43
0
    def createOutputStep(self):
        volume = Volume()
        volume.setFileName(self._getFileName(OUTPUT_RESOLUTION_FILE))

        volume.setSamplingRate(self.inputVolume.get().getSamplingRate())
        self._defineOutputs(resolution_Volume=volume)
        self._defineSourceRelation(self.inputVolume, volume)

        #Setting the min max for the summary
        imageFile = self._getFileName(OUTPUT_RESOLUTION_FILE)
        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)
Beispiel #44
0
    def createOutputStep(self):
        imgSet = self._getInputParticles()
        vol = Volume()
        fnVol = self._getExtraPath(
            'relion_it%03d_class001.mrc') % self._lastIter()
        vol.setFileName(fnVol)
        vol.setSamplingRate(imgSet.getSamplingRate())

        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)
Beispiel #45
0
    def createOutputStep(self):
        imgSet = self._getInputParticles()
        vol = Volume()
        vol.setFileName(self._getFileName('volume_shiny'))
        vol.setSamplingRate(imgSet.getSamplingRate())
        shinyPartSet = self._createSetOfParticles()
        shinyPartSet.copyInfo(imgSet)
        shinyPartSet.setAlignmentProj()
        readSetOfParticles(self._getFileName('shiny'),
                           shinyPartSet,
                           alignType=ALIGN_PROJ)

        self._defineOutputs(outputParticles=shinyPartSet)
        self._defineOutputs(outputVolume=vol)

        self._defineSourceRelation(imgSet, shinyPartSet)
        self._defineSourceRelation(imgSet, vol)
    def createOutputStep(self):
        iterN = self.numberOfIterations.get()
        partSet = self._getInputParticles()
        numRun = self._getRun()

        vol = Volume()
        vol.setFileName(self._getFileName("volume", run=numRun, iter=iterN))
        vol.copyInfo(partSet)

        newPartSet = self._createSetOfParticles()
        newPartSet.copyInfo(partSet)
        self._fillDataFromIter(newPartSet, iterN)

        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self._getInputParticlesPointer(), vol)
        self._defineOutputs(outputParticles=newPartSet)
        self._defineTransformRelation(self._getInputParticlesPointer(),
                                      newPartSet)
Beispiel #47
0
 def createOutputStep(self):
     iterN = self.numberOfIterations.get()
     partSet = self._getInputParticles()
     numRun = self._getRun()
     
     vol = Volume()
     
     
     vol.setFileName(self._getFileName("mapFull",run=numRun, iter=iterN))
     halfMap1 = self._getFileName("mapEvenUnmasked", run=numRun)
     halfMap2 = self._getFileName("mapOddUnmasked", run=numRun)
     vol.setHalfMaps([halfMap1, halfMap2])
     vol.copyInfo(partSet)
     
     newPartSet = self._createSetOfParticles()
     newPartSet.copyInfo(partSet)
     self._fillDataFromIter(newPartSet, iterN)
     
     self._defineOutputs(outputVolume=vol)
     self._defineSourceRelation(self._getInputParticlesPointer(), vol)
     self._defineOutputs(outputParticles=newPartSet)
     self._defineTransformRelation(self._getInputParticlesPointer(), newPartSet)
    def createOutputStep(self):
        classes2DSet = self.inputSet.get()
        volumes = self._createSetOfVolumes()
        shrink = self.shrink.get()
        if isinstance(self.inputSet.get(), SetOfClasses2D):
            volumes.setSamplingRate(
                classes2DSet.getImages().getSamplingRate() * shrink)
        else:
            volumes.setSamplingRate(self.inputSet.get().getSamplingRate() *
                                    shrink)
        outputVols = self._getVolumes()
        for k, volFn in enumerate(outputVols):
            vol = Volume()
            vol.setFileName(volFn)
            vol.setObjComment('eman initial model %02d' % (k + 1))
            volumes.append(vol)

        self._defineOutputs(outputVolumes=volumes)
        self._defineSourceRelation(self.inputSet, volumes)
    def createOutputStep(self):

        id = self.idx.get()
        # inputSetOfVolumes=self.inputSetOfVolumes.get()
        inputSetOfClasses3D = self.inputSetOfClasses3D.get()

        newVolume = Volume()
        #newVolume.setFileName(inputSetOfVolumes[id].getFileName())
        #newVolume.setSamplingRate(inputSetOfVolumes[id].getSamplingRate())
        newVolume.setFileName(
            inputSetOfClasses3D[id].getRepresentative().getFileName())
        newVolume.setSamplingRate(inputSetOfClasses3D[id].getSamplingRate())

        newParticles = self._createSetOfParticles()
        newParticles.setSamplingRate(inputSetOfClasses3D[id].getSamplingRate())
        if inputSetOfClasses3D[id].hasAlignmentProj():
            newParticles.setAlignmentProj()
        newParticles.copyItems(inputSetOfClasses3D[id])
        self._defineOutputs(**{'outputAuxVolumes': newVolume})
        self._store(newVolume)
        self._defineOutputs(**{'outputAuxParticles': newParticles})
        self._store(newParticles)
    def createOutputStep(self):
        from pyworkflow.em import ALIGN_PROJ
        from pyworkflow.em.packages.relion.convert import readSetOfParticles
        refineRun = self.refineRun.get()

        imgSet = refineRun._getInputParticles()
        vol = Volume()
        vol.setFileName(
            self._getFileName('volume_shiny', iter=refineRun._lastIter()))
        vol.setSamplingRate(imgSet.getSamplingRate())
        shinyPartSet = self._createSetOfParticles()
        shinyPartSet.copyInfo(imgSet)
        readSetOfParticles(self._getFileName('shiny'),
                           shinyPartSet,
                           alignType=ALIGN_PROJ)

        self._defineOutputs(outputParticles=shinyPartSet)
        self._defineOutputs(outputVolume=vol)

        self._defineSourceRelation(refineRun.inputParticles, shinyPartSet)
        self._defineSourceRelation(refineRun.inputMovieParticles, shinyPartSet)
        self._defineSourceRelation(refineRun.inputParticles, vol)
        self._defineSourceRelation(refineRun.inputMovieParticles, vol)
    def createOutputStep(self):
        volume=Volume()
        volume.setFileName(self._getFileName(OUTPUT_RESOLUTION_FILE))
        if (self.halfVolumes):
            volume.setSamplingRate(self.inputVolume.get().getSamplingRate())
            self._defineOutputs(resolution_Volume=volume)
            self._defineSourceRelation(self.inputVolume, volume)
        else:
            volume.setSamplingRate(self.inputVolumes.get().getSamplingRate())
            self._defineOutputs(resolution_Volume=volume)
            self._defineSourceRelation(self.inputVolumes, volume)
            
            
        #Setting the min max for the summary
        imageFile = self._getFileName(OUTPUT_RESOLUTION_FILE_CHIMERA)
        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)

        if self.filterInput.get():
            print 'Saving filtered map'
            volume.setFileName(self._getFileName(FN_FILTERED_MAP))
            if (self.halfVolumes):
                volume.setSamplingRate(self.inputVolume.get().getSamplingRate())
                self._defineOutputs(outputVolume_Filtered=volume)
                self._defineSourceRelation(self.inputVolume, volume)
            else:
                volume.setSamplingRate(self.inputVolumes.get().getSamplingRate())
                self._defineOutputs(outputVolume_Filtered=volume)
                self._defineSourceRelation(self.inputVolumes, volume)
    def createOutputStep(self):
        volSet = self.inputVolumes.get()
        if self._isSingleInput():
            vol = Volume()
            vol.copyInfo(volSet)
            if self.doResize:
                vol.setSamplingRate(self.samplingRate)
            vol.setFileName(self.outputStk)
            self._defineOutputs(outputVol=vol)
        else:
            volumes = self._createSetOfVolumes()
            volumes.copyInfo(volSet)
            if self.doResize:
                volumes.setSamplingRate(self.samplingRate)
            for i, vol in enumerate(volSet):
                j = i + 1
                vol.setSamplingRate(self.samplingRate)
                vol.setLocation(j, self.outputStk)
                volumes.append(vol)
            self._defineOutputs(outputVol=volumes)

        self._defineTransformRelation(volSet, self.outputVol)
Beispiel #53
0
    def importVolumesStep(self, pattern, samplingRate):
        """ Copy images matching the filename pattern
        Register other parameters.
        """
        self.info("Using pattern: '%s'" % pattern)

        # Create a Volume template object
        vol = Volume()
        vol.setSamplingRate(self.samplingRate.get())
        copyOrLink = self.getCopyOrLink()
        imgh = ImageHandler()

        volSet = self._createSetOfVolumes()
        volSet.setSamplingRate(self.samplingRate.get())

        for fileName, fileId in self.iterFiles():
            dst = self._getExtraPath(basename(fileName))
            copyOrLink(fileName, dst)
            x, y, z, n = imgh.getDimensions(dst)
            # First case considers when reading mrc without volume flag
            # Second one considers single volumes (not in stack)
            if (z == 1 and n != 1) or (z !=1 and n == 1):
                vol.setObjId(fileId)
                vol.setLocation(dst)
                volSet.append(vol)
            else:
                for index in range(1, n+1):
                    vol.cleanObjId()
                    vol.setLocation(index, dst)
                    volSet.append(vol)

        if volSet.getSize() > 1:
            self._defineOutputs(outputVolumes=volSet)
        else:
            self._defineOutputs(outputVolume=vol)
Beispiel #54
0
    def createOutputStep(self):

        classListProtocols = []
        classListIds = []
        classListSizes = []

        fnOutFile = self.inputMetaProt.get()._getExtraPath('auxOutputFile.txt')
        outFile = open(fnOutFile, 'r')
        nameRead = outFile.readline()
        while nameRead != '':
            nameRead = nameRead[:-1]
            for i, item in enumerate(self.inputSignifProts):
                if nameRead == self.inputSignifProts[i].get()._objLabel:
                    classListProtocols.append(self.inputSignifProts[i].get())
                    idRead = outFile.readline()
                    classListIds.append(int(idRead))
                    sizeRead = outFile.readline()
                    classListSizes.append(int(sizeRead))
                    break
            nameRead = outFile.readline()
        # print(classListProtocols)
        # print(classListIds)
        # print(classListSizes)

        inputVolume = self.inputMetaProt.get().inputVolume
        myVolList = []
        # outputVolumes = self._createSetOfVolumes('Def')
        # outputVolumes.setDim(inputVolume.get().getDim())
        # outputVolumes.setSamplingRate(inputVolume.get().getSamplingRate())
        origDim = inputVolume.get().getDim()[0]
        for i, prot in enumerate(classListProtocols):
            # print("createOutputStep ", i)
            classItem = prot.outputClasses[classListIds[i]]
            volFn = str(classItem._representative._filename)
            volFnOut = self._getExtraPath('outVol%d.vol' % (i + 1))
            volDim = classItem._representative.getDim()[0]
            if volDim != origDim:
                self.runJob("xmipp_image_resize",
                            "-i %s -o %s --fourier %d" %
                            (volFn, volFnOut, origDim),
                            numberOfMpi=self.numberOfMpi.get() *
                            self.numberOfThreads.get())
            else:
                copy(volFn, volFnOut)
            vol = Volume()
            vol.setLocation(volFnOut)
            vol.setSamplingRate(inputVolume.get().getSamplingRate())
            myVolList.append(vol)
        #     outputVolumes.append(vol)
        # self._defineOutputs(** {'outputVolumesDef': outputVolumes})
        # self._store(outputVolumes)

        inputParticles = self.inputMetaProt.get().inputParticles
        outputDefClasses = self._createSetOfClasses3D(inputParticles.get(),
                                                      'Def')
        for i, prot in enumerate(classListProtocols):
            classItem = prot.outputClasses[classListIds[i]]

            signifInputParts = inputParticles.get()
            partIds = classItem.getIdSet()
            newClass = Class3D()
            newClass.copyInfo(signifInputParts)
            newClass.setAcquisition(signifInputParts.getAcquisition())
            newClass.setRepresentative(myVolList[i])

            outputDefClasses.append(newClass)

            enabledClass = outputDefClasses[newClass.getObjId()]
            enabledClass.enableAppend()
            for itemId in partIds:
                enabledClass.append(signifInputParts[itemId])

            outputDefClasses.update(enabledClass)
        self._defineOutputs(**{'outputClasses3DDef': outputDefClasses})
        self._store(outputDefClasses)
Beispiel #55
0
 def createOutputStep(self, outputVol):
     vol = Volume()
     vol.setFileName(outputVol)
     vol.setSamplingRate(self.outputParticles.getSamplingRate())
     self._defineOutputs(outputVol=vol)