def runEoTest(self, corrSelectOdd, corrSelectEven, cnum, apshstack, apsheuler, iternum): apshOddVolfile = os.path.join(self.params['rundir'], str(cnum), "apshVolume_Odd-%03d.spi"%(iternum)) apshEvenVolfile = os.path.join(self.params['rundir'], str(cnum), "apshVolume_Even-%03d.spi"%(iternum)) self.APSHbackProject(apshstack, apsheuler, apshOddVolfile, cnum, corrSelectOdd) self.APSHbackProject(apshstack, apsheuler, apshEvenVolfile, cnum, corrSelectEven) fscout = os.path.join(self.params['rundir'], str(cnum), "FSCout-%03d.spi"%(iternum)) backproject.calcFSC(apshOddVolfile, apshEvenVolfile, fscout) ### Calculate FSC - taken from Neil's RCT script apix = apStack.getStackPixelSizeFromStackId(self.params['tiltstackid'])*self.params['tiltbin'] emancmd = "proc3d %s %s"%(apshEvenVolfile, apshEvenVolfile+".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) emancmd = "proc3d %s %s"%(apshOddVolfile, apshOddVolfile+".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) fscfile = os.path.join(self.params['rundir'], "fscdata%s.fsc"%(self.timestamp)) emancmd = "proc3d %s %s fsc=%s"%(apshEvenVolfile+".mrc", apshOddVolfile+".mrc", fscfile) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) if not os.path.isfile(fscfile): apDisplay.printError("Even-Odd fsc calculation failed") boxsize = self.getBoxSize() self.fscresolution = apRecon.getResolutionFromFSCFile(fscfile, boxsize, apix, msg=True) apDisplay.printColor( ("Final FSC resolution: %.5f" % (self.fscresolution)), "cyan") return fscout
def start(self): res = apRecon.getResolutionFromFSCFile(self.params['fscfile'], self.params['boxsize'], self.params['apix'], self.params['criteria']) apDisplay.printColor(("resolution: %.5f at criteria %.3f" % (res, self.params['criteria'])), "cyan") sys.stdout.write( "%s resolution %.5f (%.3f)\n" % (self.params['fscfile'], res, self.params['criteria']))
def start(self): res = apRecon.getResolutionFromFSCFile(self.params['fscfile'], self.params['boxsize'], self.params['apix'], self.params['criteria']) apDisplay.printColor( ("resolution: %.5f at criteria %.3f" % (res, self.params['criteria'])), "cyan") sys.stdout.write("%s resolution %.5f (%.3f)\n"%(self.params['fscfile'], res, self.params['criteria']))
def runEoTest(self, alignstack, eulerfile): evenvolfile = os.path.join(self.params['rundir'], "evenvolume%s.spi" % (self.timestamp)) oddvolfile = os.path.join(self.params['rundir'], "oddvolume%s.spi" % (self.timestamp)) eveneulerfile = os.path.join(self.params['rundir'], "eveneulers%s.spi" % (self.timestamp)) oddeulerfile = os.path.join(self.params['rundir'], "oddeulers%s.spi" % (self.timestamp)) evenpartlist = os.path.join(self.params['rundir'], "evenparts%s.lst" % (self.timestamp)) oddpartlist = os.path.join(self.params['rundir'], "oddparts%s.lst" % (self.timestamp)) ### Create New Doc Files of = open(oddeulerfile, "w") ef = open(eveneulerfile, "w") op = open(oddpartlist, "w") ep = open(evenpartlist, "w") inf = open(eulerfile, "r") evenpart = 0 oddpart = 0 for line in inf: spidict = operations.spiderInLine(line) if spidict: partnum = spidict['row'] if partnum % 2 == 0: ep.write("%d\n" % (partnum - 1)) evenpart += 1 outline = operations.spiderOutLine(evenpart, spidict['floatlist']) ef.write(outline) elif partnum % 2 == 1: op.write("%d\n" % (partnum - 1)) oddpart += 1 outline = operations.spiderOutLine(oddpart, spidict['floatlist']) of.write(outline) inf.close() of.close() ef.close() op.close() ep.close() ### Create stacks evenstack = os.path.join(self.params['rundir'], "evenstack%s.spi" % (self.timestamp)) emancmd = "proc2d %s %s list=%s spiderswap" % (alignstack, evenstack, evenpartlist) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) oddstack = os.path.join(self.params['rundir'], "oddstack%s.spi" % (self.timestamp)) emancmd = "proc2d %s %s list=%s spiderswap" % (alignstack, oddstack, oddpartlist) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) ### Create Volumes backproject.backproject3F(evenstack, eveneulerfile, evenvolfile, evenpart) backproject.backproject3F(oddstack, oddeulerfile, oddvolfile, oddpart) if not os.path.isfile(evenvolfile) or not os.path.isfile(oddvolfile): apDisplay.printError("Even-Odd volume creation failed") ### Calculate FSC apix = apStack.getStackPixelSizeFromStackId( self.params['tiltstackid']) * self.params['tiltbin'] emancmd = "proc3d %s %s" % (evenvolfile, evenvolfile + ".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) emancmd = "proc3d %s %s" % (oddvolfile, oddvolfile + ".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) fscfile = os.path.join(self.params['rundir'], "fscdata%s.fsc" % (self.timestamp)) emancmd = "proc3d %s %s fsc=%s" % (evenvolfile + ".mrc", oddvolfile + ".mrc", fscfile) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) if not os.path.isfile(fscfile): apDisplay.printError("Even-Odd fsc calculation failed") boxsize = self.getBoxSize() self.fscresolution = apRecon.getResolutionFromFSCFile(fscfile, boxsize, apix, msg=True) apDisplay.printColor( ("Final FSC resolution: %.5f" % (self.fscresolution)), "cyan") for fname in (evenvolfile, oddvolfile, evenstack, oddstack, eveneulerfile, oddeulerfile, evenpartlist, oddpartlist): apFile.removeFile(fname)
def runEoTest(self, alignstack, eulerfile): evenvolfile = os.path.join(self.params['rundir'], "evenvolume%s.spi"%(self.timestamp)) oddvolfile = os.path.join(self.params['rundir'], "oddvolume%s.spi"%(self.timestamp)) eveneulerfile = os.path.join(self.params['rundir'], "eveneulers%s.spi"%(self.timestamp)) oddeulerfile = os.path.join(self.params['rundir'], "oddeulers%s.spi"%(self.timestamp)) evenpartlist = os.path.join(self.params['rundir'], "evenparts%s.lst"%(self.timestamp)) oddpartlist = os.path.join(self.params['rundir'], "oddparts%s.lst"%(self.timestamp)) ### Create New Doc Files of = open(oddeulerfile, "w") ef = open(eveneulerfile, "w") op = open(oddpartlist, "w") ep = open(evenpartlist, "w") inf = open(eulerfile, "r") evenpart = 0 oddpart = 0 for line in inf: spidict = operations.spiderInLine(line) if spidict: partnum = spidict['row'] if partnum % 2 == 0: ep.write("%d\n"%(partnum-1)) evenpart += 1 outline = operations.spiderOutLine(evenpart, spidict['floatlist']) ef.write(outline) elif partnum % 2 == 1: op.write("%d\n"%(partnum-1)) oddpart += 1 outline = operations.spiderOutLine(oddpart, spidict['floatlist']) of.write(outline) inf.close() of.close() ef.close() op.close() ep.close() ### Create stacks evenstack = os.path.join(self.params['rundir'], "evenstack%s.spi"%(self.timestamp)) emancmd = "proc2d %s %s list=%s spiderswap"%(alignstack,evenstack,evenpartlist) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) oddstack = os.path.join(self.params['rundir'], "oddstack%s.spi"%(self.timestamp)) emancmd = "proc2d %s %s list=%s spiderswap"%(alignstack,oddstack,oddpartlist) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) ### Create Volumes backproject.backproject3F(evenstack, eveneulerfile, evenvolfile, evenpart) backproject.backproject3F(oddstack, oddeulerfile, oddvolfile, oddpart) if not os.path.isfile(evenvolfile) or not os.path.isfile(oddvolfile): apDisplay.printError("Even-Odd volume creation failed") ### Calculate FSC apix = apStack.getStackPixelSizeFromStackId(self.params['tiltstackid'])*self.params['tiltbin'] emancmd = "proc3d %s %s"%(evenvolfile, evenvolfile+".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) emancmd = "proc3d %s %s"%(oddvolfile, oddvolfile+".mrc") apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) fscfile = os.path.join(self.params['rundir'], "fscdata%s.fsc"%(self.timestamp)) emancmd = "proc3d %s %s fsc=%s"%(evenvolfile+".mrc", oddvolfile+".mrc", fscfile) apEMAN.executeEmanCmd(emancmd, verbose=True, showcmd=True) if not os.path.isfile(fscfile): apDisplay.printError("Even-Odd fsc calculation failed") boxsize = self.getBoxSize() self.fscresolution = apRecon.getResolutionFromFSCFile(fscfile, boxsize, apix, msg=True) apDisplay.printColor( ("Final FSC resolution: %.5f" % (self.fscresolution)), "cyan") for fname in (evenvolfile, oddvolfile, evenstack, oddstack, eveneulerfile, oddeulerfile, evenpartlist, oddpartlist): apFile.removeFile(fname)
def start(self): self.rootname = self.params['stackname'].split(".")[0] self.params['outputstack'] = os.path.join(self.params['rundir'], self.params['stackname']) if os.path.isfile(self.params['outputstack']): apFile.removeStack(self.params['outputstack']) if self.params['eotest'] is True: self.params['evenstack'] = os.path.splitext( self.params['outputstack'])[0] + '.even.hed' if os.path.isfile(self.params['evenstack']): apFile.removeStack(self.params['evenstack']) self.params['oddstack'] = os.path.splitext( self.params['outputstack'])[0] + '.odd.hed' if os.path.isfile(self.params['oddstack']): apFile.removeStack(self.params['oddstack']) classes = self.getClassData(self.params['reconid'], self.params['iter']) stackid = apStack.getStackIdFromRecon(self.params['reconid']) stackdata = apStack.getOnlyStackData(stackid) stackpath = os.path.join(stackdata['path']['path'], stackdata['name']) classkeys = classes.keys() classkeys.sort() classnum = 0 keeplist = self.procKeepList() finallist = [] apDisplay.printMsg("Processing " + str(len(classes)) + " classes") #loop through classes for key in classkeys: classnum += 1 if classnum % 10 == 1: sys.stderr.write("\b\b\b\b\b\b\b\b\b\b\b\b\b\b") sys.stderr.write( str(classnum) + " of " + (str(len(classkeys)))) # loop through particles in class classfile = self.rootname + "-class.lst" classf = open(classfile, 'w') classf.write('#LST\n') nptcls = 0 for ptcl in classes[key]['particles']: # translate DB into EMAN partnum = ptcl['particle']['particleNumber'] - 1 if partnum in keeplist: if ptcl['mirror']: mirror = 1 else: mirror = 0 rot = ptcl['euler3'] * math.pi / 180.0 classf.write("%d\t%s\t%f,\t%f,%f,%f,%d\n" % (partnum, stackpath, ptcl['quality_factor'], rot, ptcl['shiftx'], ptcl['shifty'], mirror)) nptcls += 1 finallist.append(partnum) classf.close() if nptcls < 1: continue self.makeClassAverages(classfile, self.params['outputstack'], classes[key], self.params['mask']) if self.params['eotest'] is True: self.makeEvenOddClasses(classfile, self.params['outputstack'], classes[key], self.params['mask']) apFile.removeFile(classfile) sys.stderr.write("\n") finalfilename = self.rootname + "-keep.lst" finalf = open(finalfilename, 'w') finallist.sort() for partnum in finallist: finalf.write('%d\n' % (partnum, )) finalf.close() stackstr = str(stackdata.dbid) reconstr = str(self.params['reconid']) ### recon 3d volumes threedname = os.path.join( self.params['rundir'], self.rootname + "." + str(self.params['iter']) + "a.mrc") emancmd = ("make3d " + self.params['outputstack'] + " out=" + threedname + " hard=50 sym=" + self.params['symmname'] + " pad=240 mask=" + str(self.params['mask']) + "; echo ''") #print emancmd apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True, logfile=self.rootname + "-eman.log") threednameb = os.path.join( self.params['rundir'], self.rootname + "." + str(self.params['iter']) + "b.mrc") emancmd = ("proc3d " + threedname + " " + threednameb + " apix=1.63 norm=0,1 lp=8 origin=0,0,0 mask=" + str(self.params['mask']) + "; echo '' ") apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True, logfile=self.rootname + "-eman.log") if self.params['eotest'] is True: # even evenname = os.path.join( self.params['rundir'], self.rootname + "-even." + str(self.params['iter']) + "a.mrc") if os.path.isfile(self.params['evenstack']): evenemancmd = ("make3d " + self.params['evenstack'] + " out=" + evenname + " hard=50 sym=" + self.params['symmname'] + " pad=240 mask=" + str(self.params['mask']) + "; echo ''") #print evenemancmd apEMAN.executeEmanCmd(evenemancmd, verbose=False, showcmd=True, logfile=self.rootname + "-eveneman.log") else: apDisplay.printWarning("file " + self.params['evenstack'] + " does not exist") # odd oddname = os.path.join( self.params['rundir'], self.rootname + "-odd." + str(self.params['iter']) + "a.mrc") if os.path.isfile(self.params['oddstack']): oddemancmd = ("make3d " + self.params['oddstack'] + " out=" + oddname + " hard=50 sym=" + self.params['symmname'] + " pad=240 mask=" + str(self.params['mask']) + "; echo ''") #print oddemancmd apEMAN.executeEmanCmd(oddemancmd, verbose=False, showcmd=True, logfile=self.rootname + "-oddeman.log") else: apDisplay.printWarning("file " + self.params['oddstack'] + " does not exist") #eotest fscout = os.path.join(self.params['rundir'], self.rootname + "-fsc.eotest") if os.path.isfile(oddname) and os.path.isfile(evenname): eotestcmd = "proc3d " + oddname + " " + evenname + " fsc=" + fscout apEMAN.executeEmanCmd(eotestcmd, verbose=True, showcmd=True) else: apDisplay.printWarning("could not perform eotest") if os.path.isfile(fscout): res = apRecon.getResolutionFromFSCFile(fscout, 160.0, 1.63) apDisplay.printColor(("resolution: %.5f" % (res)), "cyan") resfile = self.rootname + "-res.txt" f = open(resfile, 'a') f.write("[ %s ]\nresolution: %.5f\n" % (time.asctime(), res)) f.close()
def start(self): res = apRecon.getResolutionFromFSCFile(self.params['fscfile'], self.params['boxsize'], self.params['apix']) apDisplay.printColor(("resolution: %.5f" % (res)), "cyan")
def start(self): res = apRecon.getResolutionFromFSCFile(self.params['fscfile'], self.params['boxsize'], self.params['apix']) apDisplay.printColor( ("resolution: %.5f" % (res)), "cyan")
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", )
def start(self): self.rootname = self.params['stackname'].split(".")[0] self.params['outputstack'] = os.path.join(self.params['rundir'], self.params['stackname']) if os.path.isfile(self.params['outputstack']): apFile.removeStack(self.params['outputstack']) if self.params['eotest'] is True: self.params['evenstack'] = os.path.splitext(self.params['outputstack'])[0]+'.even.hed' if os.path.isfile(self.params['evenstack']): apFile.removeStack(self.params['evenstack']) self.params['oddstack'] = os.path.splitext(self.params['outputstack'])[0]+'.odd.hed' if os.path.isfile(self.params['oddstack']): apFile.removeStack(self.params['oddstack']) classes = self.getClassData(self.params['reconid'], self.params['iter']) stackid = apStack.getStackIdFromRecon(self.params['reconid']) stackdata = apStack.getOnlyStackData(stackid) stackpath = os.path.join(stackdata['path']['path'], stackdata['name']) classkeys = classes.keys() classkeys.sort() classnum=0 keeplist = self.procKeepList() finallist = [] apDisplay.printMsg("Processing "+str(len(classes))+" classes") #loop through classes for key in classkeys: classnum+=1 if classnum%10 == 1: sys.stderr.write("\b\b\b\b\b\b\b\b\b\b\b\b\b\b") sys.stderr.write(str(classnum)+" of "+(str(len(classkeys)))) # loop through particles in class classfile = self.rootname+"-class.lst" classf = open(classfile, 'w') classf.write('#LST\n') nptcls=0 for ptcl in classes[key]['particles']: # translate DB into EMAN partnum = ptcl['particle']['particleNumber'] - 1 if partnum in keeplist: if ptcl['mirror']: mirror=1 else: mirror=0 rot = ptcl['euler3']*math.pi/180.0 classf.write( "%d\t%s\t%f,\t%f,%f,%f,%d\n" % (partnum, stackpath, ptcl['quality_factor'], rot, ptcl['shiftx'], ptcl['shifty'], mirror)) nptcls+=1 finallist.append(partnum) classf.close() if nptcls<1: continue self.makeClassAverages(classfile, self.params['outputstack'], classes[key], self.params['mask']) if self.params['eotest'] is True: self.makeEvenOddClasses(classfile, self.params['outputstack'], classes[key], self.params['mask']) apFile.removeFile(classfile) sys.stderr.write("\n") finalfilename = self.rootname+"-keep.lst" finalf = open(finalfilename, 'w') finallist.sort() for partnum in finallist: finalf.write('%d\n' % (partnum,) ) finalf.close() stackstr = str(stackdata.dbid) reconstr = str(self.params['reconid']) ### recon 3d volumes threedname = os.path.join(self.params['rundir'], self.rootname+"."+str(self.params['iter'])+"a.mrc") emancmd = ( "make3d "+self.params['outputstack']+" out=" +threedname+" hard=50 sym="+self.params['symmname']+" pad=240 mask="+str(self.params['mask'])+"; echo ''" ) #print emancmd apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True, logfile=self.rootname+"-eman.log") threednameb = os.path.join(self.params['rundir'], self.rootname+"."+str(self.params['iter'])+"b.mrc") emancmd = ( "proc3d "+threedname+" "+threednameb +" apix=1.63 norm=0,1 lp=8 origin=0,0,0 mask="+str(self.params['mask'])+"; echo '' " ) apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True, logfile=self.rootname+"-eman.log") if self.params['eotest'] is True: # even evenname = os.path.join(self.params['rundir'], self.rootname+"-even."+str(self.params['iter'])+"a.mrc") if os.path.isfile(self.params['evenstack']): evenemancmd = ( "make3d "+self.params['evenstack']+" out=" +evenname+" hard=50 sym="+self.params['symmname']+" pad=240 mask="+str(self.params['mask'])+"; echo ''" ) #print evenemancmd apEMAN.executeEmanCmd(evenemancmd, verbose=False, showcmd=True, logfile=self.rootname+"-eveneman.log") else: apDisplay.printWarning("file "+self.params['evenstack']+" does not exist") # odd oddname = os.path.join(self.params['rundir'], self.rootname+"-odd."+str(self.params['iter'])+"a.mrc") if os.path.isfile(self.params['oddstack']): oddemancmd = ( "make3d "+self.params['oddstack']+" out=" +oddname+" hard=50 sym="+self.params['symmname']+" pad=240 mask="+str(self.params['mask'])+"; echo ''" ) #print oddemancmd apEMAN.executeEmanCmd(oddemancmd, verbose=False, showcmd=True, logfile=self.rootname+"-oddeman.log") else: apDisplay.printWarning("file "+self.params['oddstack']+" does not exist") #eotest fscout = os.path.join(self.params['rundir'], self.rootname+"-fsc.eotest") if os.path.isfile(oddname) and os.path.isfile(evenname): eotestcmd = "proc3d "+oddname+" "+evenname+" fsc="+fscout apEMAN.executeEmanCmd(eotestcmd, verbose=True, showcmd=True) else: apDisplay.printWarning("could not perform eotest") if os.path.isfile(fscout): res = apRecon.getResolutionFromFSCFile(fscout, 160.0, 1.63) apDisplay.printColor( ("resolution: %.5f" % (res)), "cyan") resfile = self.rootname+"-res.txt" f = open(resfile, 'a') f.write("[ %s ]\nresolution: %.5f\n" % (time.asctime(), res)) f.close()