def _validate(self): errors = ProtAlignMovies._validate(self) # Although getFirstItem is not recommended in general, here it is # used only once, for validation purposes, so performance # problems not should be appear. if not self.inputMovies.get() is None: inputSet = self.inputMovies.get() movie = inputSet.getFirstItem() if (not movie.hasAlignment()) and self.useAlignment: errors.append( "Your movies have no alignment. Please, set *No* " "the parameter _Use previous movie alignment to SUM" " frames?_") if self.doApplyDoseFilter: doseFrame = inputSet.getAcquisition().getDosePerFrame() if doseFrame == 0.0 or doseFrame is None: errors.append( 'Dose per frame for input movies is 0 or not ' 'set. You cannot apply dose filter.') if self.numberOfThreads > 1 and self.useGpu: errors.append("GPU and Parallelization can not be used together") ofCpu = Plugin.getHome("bin", "xmipp_movie_optical_alignment_cpu") ofGpu = Plugin.getHome("bin", "xmipp_movie_optical_alignment_gpu") if not (exists(ofGpu) or exists(ofCpu)): errors.append( "It seems that Xmipp Optical Alignment is not installed. " "Please make sure that _scipion/config/scipion.config_ " "contains *OPENCV=True* and OpenCV is in your system.\n" "Then, re-install Xmipp by running " "'scipion installb xmippSrc'.") else: if self.useGpu and not exists(ofGpu): errors.append( "It seems that Xmipp Optical Alignment has not been " "compiled with CUDA.\nPlease, try with *GPU=No*.\n" "Error: '%s' not found." % ofGpu) if not self.useGpu and not exists(ofCpu): errors.append( "It seems that Xmipp Optical Alignment has been " "compiled with CUDA.\nPlease, try with *GPU=Yes*.\n" "Error: '%s' not found." % ofCpu) return errors
def getCLTomoEnviron(self): env = Plugin.getEnviron() env.set( 'PYTHONPATH', os.path.join(os.environ['SCIPION_HOME'], 'software', 'lib', 'python2.7', 'site-packages', 'sh_alignment'), Environ.BEGIN) return env
def applyCTF(self, setPartMd): writeSetOfParticles(self.partSet, setPartMd) md1 = xmippLib.MetaData() md1.setColumnFormat(False) idctf = md1.addObject() _acquisition = self.partSet.getAcquisition() for part in self.partSet: baseFnCtf = self.proj.getTmpPath( "kk") #self._getTmpPath("ctf_%d.param"%mic) md1.setValue(xmippLib.MDL_CTF_SAMPLING_RATE, samplingRate, idctf) md1.setValue(xmippLib.MDL_CTF_VOLTAGE, 200., idctf) ctf = part.getCTF() udefocus = ctf.getDefocusU() vdefocus = ctf.getDefocusV() angle = ctf.getDefocusAngle() md1.setValue(xmippLib.MDL_CTF_DEFOCUSU, udefocus, idctf) md1.setValue(xmippLib.MDL_CTF_DEFOCUSV, vdefocus, idctf) md1.setValue(xmippLib.MDL_CTF_DEFOCUS_ANGLE, 180.0 * random.random(), idctf) md1.setValue(xmippLib.MDL_CTF_CS, 2., idctf) md1.setValue(xmippLib.MDL_CTF_Q0, 0.07, idctf) md1.setValue(xmippLib.MDL_CTF_K, 1., idctf) md1.write(baseFnCtf) ##writeSetOfParticles(self.partSet, setPartMd) #apply ctf args = " -i %s" % setPartMd args += " -o %s" % self.proj.getTmpPath(setPartCtfName) args += " -f ctf %s" % baseFnCtf args += " --sampling %f" % samplingRate Plugin.runXmippProgram("xmipp_transform_filter", args) args = " -i %s" % setPartMd args += " -o %s" % self.proj.getTmpPath(setPartCtfPosName) args += " -f ctfpos %s" % baseFnCtf args += " --sampling %f" % samplingRate Plugin.runXmippProgram("xmipp_transform_filter", args)
def _validate(self): errors = [] nmaBin = Plugin.getVar(NMA_HOME) nma_programs = [ 'nma_check_modes', 'nma_diag_arpack', 'nma_diagrtb', 'nma_elnemo_pdbmat' ] # Check Xmipp was compiled with NMA flag to True and # some of the nma programs are under the Xmipp/bin/ folder for prog in nma_programs: if not exists(join(nmaBin, prog)): errors.append( "Some NMA programs are missing in the NMA folder.") errors.append( "Check that Scipion was installed with NMA: 'scipion install nma'" ) break from pyworkflow.utils.which import which if which("csh") == "": errors.append("Cannot find csh in the PATH") return errors
def _validate(self): errors = [] nmaBin = Plugin.getVar(NMA_HOME) nma_programs = [ 'nma_check_modes', 'nma_diag_arpack', 'nma_diagrtb', 'nma_elnemo_pdbmat' ] # Check Xmipp was compiled with NMA flag to True and # some of the nma programs are under the Xmipp/bin/ folder for prog in nma_programs: if not exists(join(nmaBin, prog)): errors.append( "Some NMA programs are missing in the NMA folder.") #errors.append("Check that Scipion was installed with NMA: 'scipion installb nma'") errors.append("Check that Scipion was installed with NMA") break from pyworkflow.utils.which import which if (which("csh") == "") and (which("bash") == ""): errors.append( "Please install csh (can be a link to tcsh) or bash (e.g., on Ubuntu 'sudo apt-get install csh' or 'sudo apt-get install bash')" ) return errors
def getNMAEnviron(): """ Create the needed environment for NMA programs. """ from xmipp3 import Plugin environ = Plugin.getEnviron() environ.update({'PATH': Plugin.getVar(NMA_HOME)}, position=Environ.BEGIN) return environ
def getMLTomoEnviron(self): env = Plugin.getEnviron() return env
def projectPhantom(featFileName, paramFileName, particlesFileName): args = "-i %s -o %s" % (featFileName, particlesFileName) args += " --params %s" % paramFileName runJob(None, "xmipp_phantom_project", args, env=Plugin.getEnviron())
def extractunitCell(self, sym, offset=0, cropZ=False): """ extract unit cell from icosahedral phantom using xmipp_i2 symmetry """ # create phantom (3D map) _samplingRate = 1.34 _, outputFile1 = mkstemp(suffix=".mrc") command = "xmipp_phantom_create " args = " -i %s" % self.filename[sym] args += " -o %s" % outputFile1 runJob(None, command, args, env=Plugin.getEnviron()) ccp4header = Ccp4Header(outputFile1, readHeader=True) x, y, z = ccp4header.getDims() t = Transform() if cropZ: _, outputFile2 = mkstemp(suffix=".mrc") args = "-i %s -o %s" % (outputFile1, outputFile2) args += " --corners " args += " %d " % (-x / 2.) args += " %d " % (-y / 2.) args += " %d " % (0.) args += " %d " % (+x / 2.) args += " %d " % (+y / 2.) args += " %d " % (+z / 2.) runJob(None, "xmipp_transform_window", args, env=Plugin.getEnviron()) t.setShifts(0, 0, 0) outputFile = outputFile2 ccp4header = Ccp4Header(outputFile2, readHeader=True) else: t.setShifts(0, 0, 0) outputFile = outputFile1 ccp4header.setSampling(_samplingRate) ccp4header.setOrigin(t.getShifts()) ccp4header.writeHeader() # import volume if cropZ: args = { 'filesPath': outputFile, 'filesPattern': '', 'samplingRate': _samplingRate, 'copyFiles': True, 'setOrigCoord': True, 'x': 90. * _samplingRate, 'y': 90. * _samplingRate, 'z': 0. # x, y, z in Angstroms } else: args = { 'filesPath': outputFile, 'filesPattern': '', 'samplingRate': _samplingRate, 'copyFiles': True, 'setDefaultOrigin': False, } prot = self.newProtocol(ProtImportVolumes, **args) prot.setObjLabel('import volume(%s)' % XMIPP_SYM_NAME[sym]) self.launchProtocol(prot) # execute protocol extract unitCell args = { 'inputVolumes': prot.outputVolume, 'symmetryGroup': sym, 'symmetryOrder': self.symOrder, 'innerRadius': self.innerRadius, 'outerRadius': self.outerRadius, 'expandFactor': .2, 'offset': offset } prot = self.newProtocol(XmippProtExtractUnit, **args) prot.setObjLabel('extract unit cell') self.launchProtocol(prot) # check results ih = ImageHandler() xdim, ydim, zdim, ndim = \ ih.getDimensions(prot.outputVolume.getFileName()) self.assertTrue(abs(xdim - self.box[sym][0]) < 2) self.assertTrue(abs(ydim - self.box[sym][1]) < 2) self.assertTrue(abs(zdim - self.box[sym][2]) < 2) # create pdb fileoutput args = { 'inputStructure': prot.outputVolume, 'maskMode': NMA_MASK_THRE, 'maskThreshold': 0.5, 'pseudoAtomRadius': 1.5 } prot = self.newProtocol(XmippProtConvertToPseudoAtoms, **args) prot.setObjLabel('get pdb') self.launchProtocol(prot) # check results filenamePdb = prot._getPath('pseudoatoms.pdb') self.assertTrue(os.path.isfile(filenamePdb)) # delete temporary files os.remove(self.filename[sym]) os.remove(outputFile)