def runRmeasure(self, volfile): emancmd = "proc3d %s %s"%(volfile, "rmeasure.mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) apix = apStack.getStackPixelSizeFromStackId(self.params['tiltstackid'])*self.params['tiltbin'] self.rmeasureresolution = apRecon.runRMeasure(apix, "rmeasure.mrc") #apDisplay.printColor("Final Rmeasure resolution: "+str(self.rmeasureresolution), "cyan") apFile.removeFile("rmeasure.mrc")
def runRmeasure(self): finalrawvolfile = os.path.join(self.params['rundir'], "rawvolume%s-%03d.spi"%(self.timestamp, self.params['numiters'])) emancmd = "proc3d %s %s"%(finalrawvolfile, "rmeasure.mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) apix = apStack.getStackPixelSizeFromStackId(self.params['tiltstackid'])*self.params['tiltbin'] self.rmeasureresolution = apRecon.runRMeasure(apix, "rmeasure.mrc") #apDisplay.printColor("Final Rmeasure resolution: "+str(self.rmeasureresolution), "cyan") apFile.removeFile("rmeasure.mrc")
def runRmeasure(self): finalrawvolfile = os.path.join( self.params['rundir'], "rawvolume%s-%03d.spi" % (self.timestamp, self.params['numiters'])) emancmd = "proc3d %s %s" % (finalrawvolfile, "rmeasure.mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) apix = apStack.getStackPixelSizeFromStackId( self.params['tiltstackid']) * self.params['tiltbin'] self.rmeasureresolution = apRecon.runRMeasure(apix, "rmeasure.mrc") #apDisplay.printColor("Final Rmeasure resolution: "+str(self.rmeasureresolution), "cyan") apFile.removeFile("rmeasure.mrc")
def getRMeasureData(self, volumeDensity): volPath = os.path.join(self.params['rundir'], volumeDensity) if not os.path.exists(volPath): apDisplay.printWarning("R Measure failed, volume density not found: "+volPath) return None resolution = apRecon.runRMeasure(self.apix, volPath) if resolution is None: return None rmesq = appiondata.ApRMeasureData() rmesq['volume']=os.path.basename(volumeDensity) rmesq['rMeasure']=resolution return rmesq
def getRMeasureData(self, iteration): volumeDensity='threed.'+iteration['num']+'a.mrc' volPath = os.path.join(self.params['rundir'], volumeDensity) if not os.path.exists(volPath): apDisplay.printWarning("R Measure failed, volume density not found: "+volPath) return None resolution = apRecon.runRMeasure(self.params['apix'], volPath) if resolution is None: return None rmesq=appiondata.ApRMeasureData() rmesq['volume']=volumeDensity rmesq['rMeasure']=resolution return rmesq
def getRMeasureData(self, iteration, reference_number=1): ''' run rMeasure resolution and return database object ''' volumeDensity = os.path.join(self.resultspath, "recon_%s_it%.3d_vol%.3d.mrc" \ % (self.params['timestamp'], iteration, reference_number)) if not os.path.exists(volumeDensity): apDisplay.printWarning("R Measure failed, volume density not found: "+volumeDensity) return None resolution = apRecon.runRMeasure(self.runparams['apix'], volumeDensity) if resolution is None: return None ### database object rmesq = appiondata.ApRMeasureData() rmesq['volume'] = "recon_%s_it%.3d_vol%.3d.mrc" % (self.params['timestamp'], iteration, reference_number) rmesq['rMeasure'] = resolution return rmesq
def getRMeasureData(self, iteration, reference_number=1): ''' run rMeasure resolution and return database object ''' volumeDensity = os.path.join(self.resultspath, "recon_%s_it%.3d_vol%.3d.mrc" \ % (self.params['timestamp'], iteration, reference_number)) if not os.path.exists(volumeDensity): apDisplay.printWarning( "R Measure failed, volume density not found: " + volumeDensity) return None resolution = apRecon.runRMeasure(self.runparams['apix'], volumeDensity) if resolution is None: return None ### database object rmesq = appiondata.ApRMeasureData() rmesq['volume'] = "recon_%s_it%.3d_vol%.3d.mrc" % ( self.params['timestamp'], iteration, reference_number) rmesq['rMeasure'] = resolution return rmesq
def start(self): self.params['outputstack'] = os.path.join(self.params['rundir'], self.params['stackname']) particles, self.params['refineiter'] = getParticleInfo( self.params['reconid'], self.params['iter']) stackdata = particles[0]['particle']['stack'] stack = os.path.join(stackdata['path']['path'], stackdata['name']) classes, cstats = determineClasses(particles) rejectlst = [] if self.params['sigma'] is not None: cutoff = cstats[ 'meanquality'] + self.params['sigma'] * cstats['stdquality'] apDisplay.printMsg("Cutoff = " + str(cutoff)) rejectlst = self.removePtclsByQualityFactor( particles, rejectlst, cutoff) if self.params['avgjump'] is not None: rejectlst = self.removePtclsByJumps(particles, rejectlst) if self.params['rejectlst']: rejectlst = removePtclsByLst(rejectlst, self.params) classkeys = classes.keys() classkeys.sort() classnum = 0 totalptcls = 0 keepfile = open('keep.lst', 'w') keepfile.write('#LST\n') reject = open('reject.lst', 'w') reject.write('#LST\n') apDisplay.printMsg("Processing classes") #loop through classes for key in classkeys: # file to hold particles of this class clsfile = open('clstmp.lst', 'w') clsfile.write('#LST\n') classnum += 1 if classnum % 10 == 1: apDisplay.printMsg( str(classnum) + " of " + (str(len(classkeys)))) images = EMAN.EMData() #loop through particles in class nptcls = 0 for ptcl in classes[key]['particles']: if ptcl['mirror']: mirror = 1 else: mirror = 0 rot = ptcl['euler3'] rot = rot * math.pi / 180 if ptcl['particle']['particleNumber'] not in rejectlst: l = '%d\t%s\t%f,\t%f,%f,%f,%d\n' % ( ptcl['particle']['particleNumber'] - 1, stack, ptcl['quality_factor'], rot, ptcl['shiftx'], ptcl['shifty'], mirror) keepfile.write(l) clsfile.write(l) totalptcls += 1 nptcls += 1 else: reject.write('%d\t%s\t%f,\t%f,%f,%f,%d\n' % (ptcl['particle']['particleNumber'] - 1, stack, ptcl['quality_factor'], rot, ptcl['shiftx'], ptcl['shifty'], mirror)) #if ptcl['quality_factor']>cstats['meanquality']+3*cstats['stdquality']: # high.write('%d\t%s\t%f,\t%f,%f,%f,%d\n' % (ptcl['particle']['particleNumber']-1, # stack,ptcl['quality_factor'],rot,ptcl['shiftx'],ptcl['shifty'],mirror)) clsfile.close() if nptcls < 1: continue if self.params['skipavg'] is False: makeClassAverages('clstmp.lst', self.params['outputstack'], classes[key], self.params) if self.params['eotest'] is True: self.makeEvenOddClasses('clstmp.lst', classes[key]) apDisplay.printMsg("\n") reject.close() keepfile.close() os.remove('clstmp.lst') # make 3d density file if specified: if self.params['make3d'] is not None: self.params['make3d'] = os.path.basename(self.params['make3d']) outfile = os.path.join(self.params['rundir'], self.params['make3d']) apEMAN.make3d(self.params['stackname'], outfile, sym=self.params['sym'], mode=self.params['mode'], hard=self.params['hard']) apEMAN.executeEmanCmd("proc3d %s %s mask=%d norm" % (outfile, outfile, self.params['mask'])) if self.params['eotest'] is True: apEMAN.make3d(self.params['oddstack'], "odd.mrc", sym=self.params['sym'], mode=self.params['mode'], hard=self.params['hard']) apEMAN.make3d(self.params['evenstack'], "even.mrc", sym=self.params['sym'], mode=self.params['mode'], hard=self.params['hard']) apEMAN.executeEmanCmd("proc3d odd.mrc even.mrc fsc=fsc.eotest") if os.path.exists(outfile): # run rmeasure apix = apStack.getStackPixelSizeFromStackId(self.params['stackid']) box = apVolume.getModelDimensions(outfile) apDisplay.printMsg('inserting density into database') symdata = apSymmetry.findSymmetry(self.params['sym']) if not symdata: apDisplay.printError('no symmetry associated with this model') modq = appiondata.Ap3dDensityData() modq['session'] = apStack.getSessionDataFromStackId( self.params['stackid']) modq['name'] = self.params['make3d'] modq['path'] = appiondata.ApPathData( path=os.path.abspath(self.params['rundir'])) modq['boxsize'] = box modq['mask'] = self.params['mask'] modq['pixelsize'] = apix fscres = apRecon.getResolutionFromFSCFile('fsc.eotest', box, apix, msg=True) modq['resolution'] = fscres modq['rmeasure'] = apRecon.runRMeasure(apix, outfile) modq['md5sum'] = apFile.md5sumfile(outfile) modq['maxjump'] = self.params['avgjump'] modq['sigma'] = self.params['sigma'] modq['hard'] = self.params['hard'] modq['symmetry'] = symdata modq['refineIter'] = self.params['refineiter'] if self.params['commit'] is True: modq.insert() apChimera.filterAndChimera(outfile, res=fscres, apix=apix, box=box, chimtype='snapshot', zoom=self.params['zoom'], sym=self.params['sym'], mass=self.params['mass']) else: apDisplay.printError( 'no 3d volume was generated - check the class averages:') apDisplay.printError(self.params['stackname']) apDisplay.printError( 'hard may be set too high, or avg euler jump set too low for the # of particles' ) stackstr = str(stackdata.dbid) reconstr = str(self.params['reconid']) apDisplay.printColor( "Make a new stack with only non-jumpers:\n" + "subStack.py --projectid=" + str(self.params['projectid']) + " -s " + stackstr + " \\\n " + " -k " + os.path.join(self.params['rundir'], "keep.lst") + " \\\n " + " -d 'recon " + reconstr + " sitters' -n sitters" + reconstr + " -C ", "purple")
def start(self): self.params["outputstack"] = os.path.join(self.params["rundir"], self.params["stackname"]) particles, self.params["refineiter"] = getParticleInfo(self.params["reconid"], self.params["iter"]) stackdata = particles[0]["particle"]["stack"] stack = os.path.join(stackdata["path"]["path"], stackdata["name"]) classes, cstats = determineClasses(particles) rejectlst = [] if self.params["sigma"] is not None: cutoff = cstats["meanquality"] + self.params["sigma"] * cstats["stdquality"] apDisplay.printMsg("Cutoff = " + str(cutoff)) rejectlst = self.removePtclsByQualityFactor(particles, rejectlst, cutoff) if self.params["avgjump"] is not None: rejectlst = self.removePtclsByJumps(particles, rejectlst) if self.params["rejectlst"]: rejectlst = removePtclsByLst(rejectlst, self.params) classkeys = classes.keys() classkeys.sort() classnum = 0 totalptcls = 0 keepfile = open("keep.lst", "w") keepfile.write("#LST\n") reject = open("reject.lst", "w") reject.write("#LST\n") apDisplay.printMsg("Processing classes") # loop through classes for key in classkeys: # file to hold particles of this class clsfile = open("clstmp.lst", "w") clsfile.write("#LST\n") classnum += 1 if classnum % 10 == 1: apDisplay.printMsg(str(classnum) + " of " + (str(len(classkeys)))) images = EMAN.EMData() # loop through particles in class nptcls = 0 for ptcl in classes[key]["particles"]: if ptcl["mirror"]: mirror = 1 else: mirror = 0 rot = ptcl["euler3"] rot = rot * math.pi / 180 if ptcl["particle"]["particleNumber"] not in rejectlst: l = "%d\t%s\t%f,\t%f,%f,%f,%d\n" % ( ptcl["particle"]["particleNumber"] - 1, stack, ptcl["quality_factor"], rot, ptcl["shiftx"], ptcl["shifty"], mirror, ) keepfile.write(l) clsfile.write(l) totalptcls += 1 nptcls += 1 else: reject.write( "%d\t%s\t%f,\t%f,%f,%f,%d\n" % ( ptcl["particle"]["particleNumber"] - 1, stack, ptcl["quality_factor"], rot, ptcl["shiftx"], ptcl["shifty"], mirror, ) ) # if ptcl['quality_factor']>cstats['meanquality']+3*cstats['stdquality']: # high.write('%d\t%s\t%f,\t%f,%f,%f,%d\n' % (ptcl['particle']['particleNumber']-1, # stack,ptcl['quality_factor'],rot,ptcl['shiftx'],ptcl['shifty'],mirror)) clsfile.close() if nptcls < 1: continue if self.params["skipavg"] is False: makeClassAverages("clstmp.lst", self.params["outputstack"], classes[key], self.params) if self.params["eotest"] is True: self.makeEvenOddClasses("clstmp.lst", classes[key]) apDisplay.printMsg("\n") reject.close() keepfile.close() os.remove("clstmp.lst") # make 3d density file if specified: if self.params["make3d"] is not None: self.params["make3d"] = os.path.basename(self.params["make3d"]) outfile = os.path.join(self.params["rundir"], self.params["make3d"]) apEMAN.make3d( self.params["stackname"], outfile, sym=self.params["sym"], mode=self.params["mode"], hard=self.params["hard"], ) apEMAN.executeEmanCmd("proc3d %s %s mask=%d norm" % (outfile, outfile, self.params["mask"])) if self.params["eotest"] is True: apEMAN.make3d( self.params["oddstack"], "odd.mrc", sym=self.params["sym"], mode=self.params["mode"], hard=self.params["hard"], ) apEMAN.make3d( self.params["evenstack"], "even.mrc", sym=self.params["sym"], mode=self.params["mode"], hard=self.params["hard"], ) apEMAN.executeEmanCmd("proc3d odd.mrc even.mrc fsc=fsc.eotest") if os.path.exists(outfile): # run rmeasure apix = apStack.getStackPixelSizeFromStackId(self.params["stackid"]) box = apVolume.getModelDimensions(outfile) apDisplay.printMsg("inserting density into database") symdata = apSymmetry.findSymmetry(self.params["sym"]) if not symdata: apDisplay.printError("no symmetry associated with this model") modq = appiondata.Ap3dDensityData() modq["session"] = self.params["sessionname"] modq["name"] = self.params["make3d"] modq["path"] = appiondata.ApPathData(path=os.path.abspath(self.params["rundir"])) modq["boxsize"] = box modq["mask"] = self.params["mask"] modq["pixelsize"] = apix fscres = apRecon.getResolutionFromFSCFile("fsc.eotest", box, apix, msg=True) modq["resolution"] = fscres modq["rmeasure"] = apRecon.runRMeasure(apix, outfile) modq["md5sum"] = apFile.md5sumfile(outfile) modq["maxjump"] = self.params["avgjump"] modq["sigma"] = self.params["sigma"] modq["hard"] = self.params["hard"] modq["symmetry"] = symdata modq["refineIter"] = self.params["refineiter"] if self.params["commit"] is True: modq.insert() apChimera.filterAndChimera( outfile, res=fscres, apix=apix, box=box, chimtype="snapshot", zoom=self.params["zoom"], sym=self.params["sym"], mass=self.params["mass"], ) else: apDisplay.printError("no 3d volume was generated - check the class averages:") apDisplay.printError(self.params["stackname"]) apDisplay.printError("hard may be set too high, or avg euler jump set too low for the # of particles") stackstr = str(stackdata.dbid) reconstr = str(self.params["reconid"]) apDisplay.printColor( "Make a new stack with only non-jumpers:\n" + "subStack.py --projectid=" + str(self.params["projectid"]) + " -s " + stackstr + " \\\n " + " -k " + os.path.join(self.params["rundir"], "keep.lst") + " \\\n " + " -d 'recon " + reconstr + " sitters' -n sitters" + reconstr + " -C ", "purple", )