def xmippNormStack(self, inStackPath, outStackPath):
                ### convert stack into single spider files
                selfile = apXmipp.breakupStackIntoSingleFiles(inStackPath)      

                ### setup Xmipp command
                xmippexe = apParam.getExecPath("xmipp_normalize", die=True)
                apDisplay.printMsg("Using Xmipp to normalize particle stack")
                normtime = time.time()
                xmippopts = ( " "
                        +" -i %s"%os.path.join(self.params['rundir'],selfile)
                        +" -method Ramp "
                        +" -background circle %i"%(self.stack['boxsize']/self.params['bin']*0.4)
                        +" -remove_black_dust"
                        +" -remove_white_dust"
                        +" -thr_black_dust -%.2f"%(self.params['xmipp-norm'])
                        +" -thr_white_dust %.2f"%(self.params['xmipp-norm'])
                )
                xmippcmd = xmippexe+" "+xmippopts
                apParam.runCmd(xmippcmd, package="Xmipp", verbose=True, showcmd=True)
                normtime = time.time() - normtime
                apDisplay.printMsg("Xmipp normalization time: "+apDisplay.timeString(normtime))

                ### recombine particles to a single imagic stack
                tmpstack = "tmp.xmippStack.hed"
                apXmipp.gatherSingleFilesIntoStack(selfile,tmpstack)
                apFile.moveStack(tmpstack,outStackPath)

                ### clean up directory
                apFile.removeFile(selfile)
                apFile.removeDir("partfiles")
コード例 #2
0
    def start(self):
        # Path of the stack
        stackdata = apStack.getOnlyStackData(self.params['stackid'])
        fn_oldstack = os.path.join(stackdata['path']['path'],
                                   stackdata['name'])

        # Convert the stack to Xmipp
        apXmipp.breakupStackIntoSingleFiles(fn_oldstack)

        # Run sort junk
        cmd = "xmipp_sort_by_statistics -i partlist.sel"
        apDisplay.printColor(cmd, "cyan")
        proc = subprocess.Popen(cmd, shell=True)
        proc.wait()

        # Create sorted stack
        apXmipp.gatherSingleFilesIntoStack("sort_junk.sel", "sorted.hed")

        # Create average MRC
        apStack.averageStack("sorted.hed")

        # Remove intermediate stuff
        #os.unlink("partlist.sel")
        #shutil.rmtree("partfiles")

        # Upload results
        self.uploadResults()

        time.sleep(1)
        return
    def xmippNormStack(self, inStackPath, outStackPath):
        ### convert stack into single spider files
        selfile = apXmipp.breakupStackIntoSingleFiles(inStackPath)

        ### setup Xmipp command
        xmippexe = apParam.getExecPath("xmipp_normalize", die=True)
        apDisplay.printMsg("Using Xmipp to normalize particle stack")
        normtime = time.time()
        xmippopts = (" " +
                     " -i %s" % os.path.join(self.params['rundir'], selfile) +
                     " -method Ramp " + " -background circle %i" %
                     (self.stack['boxsize'] / self.params['bin'] * 0.4) +
                     " -remove_black_dust" + " -remove_white_dust" +
                     " -thr_black_dust -%.2f" % (self.params['xmipp-norm']) +
                     " -thr_white_dust %.2f" % (self.params['xmipp-norm']))
        xmippcmd = xmippexe + " " + xmippopts
        apParam.runCmd(xmippcmd, package="Xmipp", verbose=True, showcmd=True)
        normtime = time.time() - normtime
        apDisplay.printMsg("Xmipp normalization time: " +
                           apDisplay.timeString(normtime))

        ### recombine particles to a single imagic stack
        tmpstack = "tmp.xmippStack.hed"
        apXmipp.gatherSingleFilesIntoStack(selfile, tmpstack)
        apFile.moveStack(tmpstack, outStackPath)

        ### clean up directory
        apFile.removeFile(selfile)
        apFile.removeDir("partfiles")
コード例 #4
0
        def start(self):
                # Path of the stack
                stackdata = apStack.getOnlyStackData(self.params['stackid'])
                fn_oldstack = os.path.join(stackdata['path']['path'], stackdata['name'])

                # Convert the stack to Xmipp
                apXmipp.breakupStackIntoSingleFiles(fn_oldstack)

                # Run sort junk
                cmd = "xmipp_sort_by_statistics -i partlist.sel"
                apDisplay.printColor(cmd, "cyan")
                proc = subprocess.Popen(cmd, shell=True)
                proc.wait()

                # Create sorted stack
                apXmipp.gatherSingleFilesIntoStack("sort_junk.sel","sorted.hed")

                # Create average MRC
                apStack.averageStack("sorted.hed")

                # Remove intermediate stuff
                #os.unlink("partlist.sel")
                #shutil.rmtree("partfiles")

                # Upload results
                self.uploadResults()

                time.sleep(1)
                return
コード例 #5
0
	def applyEnvelopeAndCTF(self, stack):
		### get defocus lists
		numpart = self.params['projcount']
		cut = int(numpart/80.0)+1
		apDisplay.printMsg("%d particles per dot"%(cut))

		if len(self.deflist1) == 0:
			self.getListOfDefoci(numpart)

		### break up particles
		partlistdocfile = apXmipp.breakupStackIntoSingleFiles(stack, filetype="mrc")

		t0 = time.time()
		apDisplay.printMsg("Applying CTF and Envelop to particles")

		### apply CTF using ACE2
		ctfapplydocfile = self.applyCTFToDocFile(partlistdocfile)

		### apply Envelop using ACE2
		envelopdocfile = self.applyEnvelopToDocFile(ctfapplydocfile)

		### correct CTF using ACE2
		if self.params['ace2correct'] is True or self.params['ace2correct_rand'] is True:
			ctfcorrectdocfile = self.correctCTFToDocFile(envelopdocfile)
		else:
			ctfcorrectdocfile = envelopdocfile

		timeper = (time.time()-t0)/float(numpart)
		apDisplay.printColor("Total time %s"%(apDisplay.timeString(time.time()-t0)), "green")
		apDisplay.printColor("Time per particle %s"%(apDisplay.timeString(timeper)), "green")

		### write corrected particle list to doc file
		ctfpartlist = []
		ctfpartlistfile = os.path.join(self.params['rundir'], "ctfpartlist.lst")
		inf = open(ctfcorrectdocfile, 'r')
		outf = open(ctfpartlistfile, "w")
		for line in inf:
			### get filename
			filename = line.strip().split()[0]
			if not os.path.isfile(filename):
				apDisplay.printError("CTF and envelop apply failed")
			ctfpartlist.append(filename)
			outf.write(filename+"\t1\n")
		inf.close()
		outf.close()

		### merge individual files into a common stack
		ctfstack = os.path.join(self.params['rundir'], "ctfstack.hed")
		apXmipp.gatherSingleFilesIntoStack(ctfpartlistfile, ctfstack, filetype="mrc")
		if self.params['pad'] is True:
			emancmd = "proc2d %s %s.clip.hed clip=%d,%d" % (ctfstack, ctfstack[:-4], self.params['box'], self.params['box'])
			apParam.runCmd(emancmd, "EMAN")
			shutil.move("%s.clip.hed" % ctfstack[:-4], "%s.hed" % ctfstack[:-4])
			shutil.move("%s.clip.img" % ctfstack[:-4], "%s.img" % ctfstack[:-4])

		return ctfstack, ctfpartlist
コード例 #6
0
	def applyEnvelopeAndCTF(self, stack):
		### get defocus lists
		numpart = self.params['projcount']
		cut = int(numpart/80.0)+1
		apDisplay.printMsg("%d particles per dot"%(cut))

		if len(self.deflist1) == 0:
			self.getListOfDefoci(numpart)

		### break up particles
		partlistdocfile = apXmipp.breakupStackIntoSingleFiles(stack, filetype="mrc")

		t0 = time.time()
		apDisplay.printMsg("Applying CTF and Envelop to particles")

		### apply CTF using ACE2
		ctfapplydocfile = self.applyCTFToDocFile(partlistdocfile)

		### apply Envelop using ACE2
		envelopdocfile = self.applyEnvelopToDocFile(ctfapplydocfile)

		### correct CTF using ACE2
		if self.params['ace2correct'] is True or self.params['ace2correct_rand'] is True:
			ctfcorrectdocfile = self.correctCTFToDocFile(envelopdocfile)
		else:
			ctfcorrectdocfile = envelopdocfile

		timeper = (time.time()-t0)/float(numpart)
		apDisplay.printColor("Total time %s"%(apDisplay.timeString(time.time()-t0)), "green")
		apDisplay.printColor("Time per particle %s"%(apDisplay.timeString(timeper)), "green")

		### write corrected particle list to doc file
		ctfpartlist = []
		ctfpartlistfile = os.path.join(self.params['rundir'], "ctfpartlist.lst")
		inf = open(ctfcorrectdocfile, 'r')
		outf = open(ctfpartlistfile, "w")
		for line in inf:
			### get filename
			filename = line.strip().split()[0]
			if not os.path.isfile(filename):
				apDisplay.printError("CTF and envelop apply failed")
			ctfpartlist.append(filename)
			outf.write(filename+"\t1\n")
		inf.close()
		outf.close()

		### merge individual files into a common stack
		ctfstack = os.path.join(self.params['rundir'], "ctfstack.hed")
		apXmipp.gatherSingleFilesIntoStack(ctfpartlistfile, ctfstack, filetype="mrc")
		if self.params['pad'] is True:
			emancmd = "proc2d %s %s.clip.hed clip=%d,%d" % (ctfstack, ctfstack[:-4], self.params['box'], self.params['box'])
			apParam.runCmd(emancmd, "EMAN")
			shutil.move("%s.clip.hed" % ctfstack[:-4], "%s.hed" % ctfstack[:-4])
			shutil.move("%s.clip.img" % ctfstack[:-4], "%s.img" % ctfstack[:-4])

		return ctfstack, ctfpartlist
コード例 #7
0
 def createReferenceStack(self):
         # Create a stack for the class averages at each level
         Nlevels=len(glob.glob("part"+self.params['timestamp']+"_level_??_.sel"))
         for level in range(Nlevels):
                 stack=[]
                 for f in glob.glob("part"+self.params['timestamp']+"_level_%02d_[0-9]*.xmp"%level):
                         stack.append(spider.read(f))
                 apImagicFile.writeImagic(stack, "part"+self.params['timestamp']+"_level_%02d_.hed"%level)
         if self.params['align']:
                 apXmipp.gatherSingleFilesIntoStack("partlist.sel","alignedStack.hed")
         return
コード例 #8
0
 def createReferenceStack(self):
     # Create a stack for the class averages at each level
     Nlevels = len(
         glob.glob("part" + self.params['timestamp'] + "_level_??_.sel"))
     for level in range(Nlevels):
         stack = []
         for f in glob.glob("part" + self.params['timestamp'] +
                            "_level_%02d_[0-9]*.xmp" % level):
             stack.append(spider.read(f))
         apImagicFile.writeImagic(
             stack,
             "part" + self.params['timestamp'] + "_level_%02d_.hed" % level)
     if self.params['align']:
         apXmipp.gatherSingleFilesIntoStack("partlist.sel",
                                            "alignedStack.hed")
     return
コード例 #9
0
 def putFilesInStack(self):
     selfile = os.path.join(self.params["rundir"], "selfile.list")
     stackfile = os.path.join(self.params["rundir"], "start.hed")
     apXmipp.gatherSingleFilesIntoStack(selfile, stackfile, filetype="mrc")
     return stackfile
コード例 #10
0
 def putFilesInStack(self):
         selfile = os.path.join(self.params['rundir'], "selfile.list")
         stackfile = os.path.join(self.params['rundir'], "start.hed")
         apXmipp.gatherSingleFilesIntoStack(selfile, stackfile, filetype="mrc")
         return stackfile