Ejemplo n.º 1
0
    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):
        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)
Ejemplo n.º 3
0
    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 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)
Ejemplo n.º 6
0
    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 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 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)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    def createOutput(self):
        inputParticles = self.directionalClasses.get()
        Ts = inputParticles.getSamplingRate()
        volumesSet = self._createSetOfVolumes()
        volumesSet.setSamplingRate(Ts)
        for i in range(2):
            vol = Volume()
            fnVol = self._getExtraPath("split_v%d.vol" % (i + 1))
            fnMrc = self._getExtraPath("split_v%d.mrc" % (i + 1))
            self.runJob("xmipp_image_convert",
                        "-i %s -o %s -t vol" % (fnVol, fnMrc),
                        numberOfMpi=1)
            self.runJob("xmipp_image_header",
                        "-i %s --sampling_rate %f" % (fnMrc, Ts),
                        numberOfMpi=1)
            cleanPath(fnVol)
            vol.setLocation(1, fnMrc)
            volumesSet.append(vol)

        self._defineOutputs(outputVolumes=volumesSet)
        self._defineSourceRelation(inputParticles, volumesSet)
    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 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))
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
    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
Ejemplo n.º 17
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)
Ejemplo n.º 18
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)
    def _fillVolSetFromIter(self, volSet, it):
        volSet.setSamplingRate(self._getInputParticles().getSamplingRate())
        modelStar = md.MetaData('model_classes@' +
                                self._getFileName('model', iter=it))
        for row in md.iterRows(modelStar):
            fn = row.getValue('rlnReferenceImage')
            fnMrc = fn + ":mrc"
            itemId = self._getClassId(fn)
            classDistrib = row.getValue('rlnClassDistribution')
            accurracyRot = row.getValue('rlnAccuracyRotations')
            accurracyTras = row.getValue('rlnAccuracyTranslations')
            resol = row.getValue('rlnEstimatedResolution')

            if classDistrib > 0:
                vol = Volume()
                self._invertScaleVol(fnMrc)
                vol.setFileName(self._getOutputVolFn(fnMrc))
                vol.setObjId(itemId)
                vol._rlnClassDistribution = Float(classDistrib)
                vol._rlnAccuracyRotations = Float(accurracyRot)
                vol._rlnAccuracyTranslations = Float(accurracyTras)
                vol._rlnEstimatedResolution = Float(resol)
                volSet.append(vol)
Ejemplo n.º 20
0
    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):
        imgSet = self.inputParticles.get()
        vol = Volume()
        lastIter = self._getLastIterNumber()
        if self.protType == GOLD_STD:
            vol.setFileName(
                self._getExtraPath('Refinement/final/vol_%02d.stk' % lastIter))
            half1 = self._getExtraPath('Refinement/final/vol_%02d_s1.stk' %
                                       lastIter)
            half2 = self._getExtraPath('Refinement/final/vol_%02d_s2.stk' %
                                       lastIter)
        else:
            vol.setFileName(
                self._getExtraPath('Refinement/final/bpr%02d.stk' % lastIter))
            half1 = self._getExtraPath('Refinement/final/bpr%02d_sub1.stk' %
                                       lastIter)
            half2 = self._getExtraPath('Refinement/final/bpr%02d_sub2.stk' %
                                       lastIter)
        vol.setSamplingRate(imgSet.getSamplingRate())
        vol.setHalfMaps([half1, half2])

        outImgSet = self._createSetOfParticles()
        outImgSet.copyInfo(imgSet)
        self._fillDataFromDoc(outImgSet)

        self._defineOutputs(outputVolume=vol)
        self._defineSourceRelation(self.inputParticles, vol)
        self._defineOutputs(outputParticles=outImgSet)
        self._defineTransformRelation(self.inputParticles, outImgSet)

        fsc = FSC(objLabel=self.getRunName())
        resolution, fscData = self._getFscData(it=lastIter)
        fsc.setData(resolution, fscData)

        self._defineOutputs(outputFSC=fsc)
        self._defineSourceRelation(vol, fsc)
Ejemplo n.º 22
0
 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 createOutputStep(self):
        protRefine = self.protRefine.get()
        sampling = protRefine._getInputParticles().getSamplingRate()
        volumes = self._createSetOfVolumes()
        volumes.setSamplingRate(sampling)

        self._loadVolsInfo()

        for item in range(1, self._getNumberOfBodies() + 1):
            vol = Volume()
            self._updateVolume(item, vol)
            volumes.append(vol)

        self._defineOutputs(outputVolumes=volumes)
        vol = self.protRefine.get().outputVolume
        self._defineSourceRelation(vol, volumes)
    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)
Ejemplo n.º 25
0
    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)
Ejemplo n.º 26
0
    def createOutputStep(self):
        Ts = self.inputReference.get().getSamplingRate()

        vols = []
        idx = 1
        for vol in self._iterInputVolumes():
            outVol = Volume()
            fnOutVol = self._getExtraPath("vol%02d.mrc" % idx)
            outVol.setLocation(fnOutVol)
            outVol.setObjComment(vol.getObjComment())
            #set transformation matrix
            fhInputTranMat = self._getExtraPath(
                'transformation-matrix_vol%06d.txt' % idx)
            transMatFromFile = np.loadtxt(fhInputTranMat)
            transformationMat = np.reshape(transMatFromFile, (4, 4))
            transform = Transform()
            transform.setMatrix(transformationMat)
            outVol.setTransform(transform)
            vols.append(outVol)

            # Set the sampling rate in the mrc header
            self.runJob("xmipp_image_header",
                        "-i %s --sampling_rate %f" % (fnOutVol, Ts))

            idx += 1

        if len(vols) > 1:
            volSet = self._createSetOfVolumes()
            volSet.setSamplingRate(Ts)
            for vol in vols:
                volSet.append(vol)
            outputArgs = {'outputVolumes': volSet}
        else:
            vols[0].setSamplingRate(Ts)
            outputArgs = {'outputVolume': vols[0]}

        self._defineOutputs(**outputArgs)
        if len(vols) > 1:
            for pointer in self.inputVolumes:
                self._defineSourceRelation(pointer,
                                           outputArgs['outputVolumes'])
        else:
            for pointer in self.inputVolumes:
                self._defineSourceRelation(pointer, outputArgs['outputVolume'])
Ejemplo n.º 27
0
    def createOutputStep(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 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)

        # upodate config file flag enablebundle
        # so scipionwrite is disabled
        config = configparser.ConfigParser()
        config.read(self._getExtraPath(CHIMERA_CONFIG_FILE))
        config.set('chimerax', 'enablebundle', 'False')
        with open(self._getExtraPath(CHIMERA_CONFIG_FILE), 'w') as configfile:
            config.write(configfile)
Ejemplo n.º 28
0
    def projectZStep(self):
        input = self.input.get()
        x, y, z = input.getDim()
        dir = self.dirParam.get()
        if self.rangeParam.get() == 1:
            cropParam = self.cropParam.get()

        fnProj = self._getExtraPath("projections.mrcs")
        lib.createEmptyFile(fnProj, x, y, 1, input.getSize())

        for i, subtomo in enumerate(input.iterItems()):
            fn = subtomo.getLocation()
            if fn[1].endswith('.mrc'):
                fn = list(fn)
                fn[1] += ':mrc'
                fn = tuple(fn)
                subtomo.setFileName(fn[1])
            vol = Volume()
            vol.setLocation('%d@%s' % fn)
            vol = ih().read(vol.getLocation())
            img = ih().createImage()
            if self.radAvg.get():
                img = vol.radialAverageAxis()
            else:
                volData = vol.getData()
                proj = np.empty([x, y])
                if dir == 0:
                    if self.rangeParam.get() == 1:
                        volData = volData[:, :, int(x/2 - cropParam):int(x/2 + cropParam):1]
                    for zi in range(z):
                        for yi in range(y):
                            proj[zi, yi] = np.sum(volData[zi, yi, :])
                elif dir == 1:
                    if self.rangeParam.get() == 1:
                        volData = volData[:, int(x/2 - cropParam):int(x/2 + cropParam):1, :]
                    for zi in range(z):
                        for xi in range(x):
                            proj[zi, xi] = np.sum(volData[zi, :, xi])
                elif dir == 2:
                    if self.rangeParam.get() == 1:
                        volData = volData[int(x/2 - cropParam):int(x/2 + cropParam):1, :, :]
                    for xi in range(x):
                        for yi in range(y):
                            proj[xi, yi] = np.sum(volData[:, yi, xi])
                img.setData(proj)

            img.write('%d@%s' % (i+1, fnProj))
    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)
Ejemplo n.º 30
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)