def checkConflicts(self): self.rundata = apTomo.getFullTomoRunById(self.params["samplerunid"]) if self.rundata["method"] != "etomo": apDisplay.printError("The fulltomoram run is not made for ETOMO manual reconstruction") paramfile = os.path.join(self.rundata["path"]["path"], "%s_sample.params" % (self.rundata["runname"])) sampleparams = apParam.readRunParameters(paramfile) self.params["alignerid"] = sampleparams["alignerid"] self.params["description"] = sampleparams["description"] + "\n" + self.params["description"] self.params["method"] = self.rundata["method"] self.params["runname"] = self.rundata["runname"] self.params["rundir"] = self.rundata["path"]["path"]
def checkConflicts(self): self.rundata = apTomo.getFullTomoRunById(self.params['samplerunid']) if self.rundata['method'] != 'etomo': apDisplay.printError( 'The fulltomoram run is not made for ETOMO manual reconstruction' ) paramfile = os.path.join( self.rundata['path']['path'], '%s_sample.params' % (self.rundata['runname'])) sampleparams = apParam.readRunParameters(paramfile) self.params['alignerid'] = sampleparams['alignerid'] self.params['description'] = sampleparams[ 'description'] + '\n' + self.params['description'] self.params['method'] = self.rundata['method'] self.params['runname'] = self.rundata['runname'] self.params['rundir'] = self.rundata['path']['path']
def start(self): ### simple is written in Fortran, which cannot take inputs of certain length, therefore one needs ### to change to the directory to minimize the filename length, in particular for the stack os.chdir(self.params['rundir']) ### stack needs to be centered if self.params['no_center'] is False: if os.path.isfile(os.path.join(self.params['rundir'], "ali.hed")): apFile.removeStack( os.path.join(self.params['rundir'], "ali.hed")) centstack = os.path.join(self.params['rundir'], "ali.hed") centcmd = "cenalignint %s > cenalignint.log" % (self.stack['file']) apParam.runCmd(centcmd, "EMAN") ### process stack to local file if self.params['timestamp'] is None: apDisplay.printMsg("creating timestamp") self.params['timestamp'] = self.timestamp self.params['localstack'] = os.path.join( self.params['rundir'], self.params['timestamp'] + ".spi") if os.path.isfile(self.params['localstack']): apFile.removeFile(self.params['localstack']) if self.params['no_center'] is False: proccmd = "proc2d " + centstack + " " + self.params[ 'localstack'] + " apix=" + str(self.stack['apix']) else: proccmd = "proc2d " + self.stack['file'] + " " + self.params[ 'localstack'] + " apix=" + str(self.stack['apix']) if self.params['bin'] > 1 or self.params['clipsize'] is not None: proccmd += " shrink=%d clip=%d,%d " % (self.params['bin'], self.boxsize, self.boxsize) proccmd += " last=" + str(self.params['numpart'] - 1) proccmd += " spiderswap" # if self.params['highpass'] is not None and self.params['highpass'] > 1: # proccmd += " hp="+str(self.params['highpass']) # if self.params['lowpass'] is not None and self.params['lowpass'] > 1: # proccmd += " lp="+str(self.params['lowpass']) apParam.runCmd(proccmd, "EMAN", verbose=True) # if self.params['numpart'] != int(spider.getSpiderHeader(self.params['localstack'])[-2]): # apDisplay.printError("Missing particles in stack") ### setup Simple command aligntime = time.time() simpleopts = ( "" + " stk=%s" % os.path.basename(self.params['localstack']) + " box=%d" % self.boxsize + " nptcls=%d" % self.params['numpart'] + " smpd=%.3f" % self.apix + " ring2=%d" % self.params['ring2'] + " ncls=%d" % self.params['ncls'] + " minp=%d" % self.params['minp'] + " nvars=%d" % self.params['nvars'] + " nthr=%d" % self.params['nproc']) if self.params['no_kmeans'] is True: simpleopts += " kmeans=off" if self.params['nran'] is not None: simpleopts += "nran=%d" % self.params['nran'] ### SIMPLE 2D clustering apDisplay.printColor( "Using " + str(self.params['nproc']) + " processors!", "green") simpleexe = apParam.getExecPath("cluster", die=True) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="cluster.std") self.params['runtime'] = time.time() - aligntime apDisplay.printMsg("Alignment & Classification time: " + apDisplay.timeString(self.params['runtime'])) ### SIMPLE spider to Fourier format clsavgs = "cavgstk.spi" if not os.path.isfile(os.path.join(self.params['rundir'], clsavgs)): apDisplay.printError( "class averages were not created! try rerunning with centering, more particles, or less ppc" ) try: nptcls = spider.getSpiderHeader(clsavgs)[-2] except: nptcls = self.params['ncls'] apDisplay.printWarning( "class average file may not have been created! Please check existence of file cavgstk.spi" ) projfile = "projs" projext = ".fim" simpleexe = apParam.getExecPath("spi_to_fim", die=True) simpleopts = ("" + " stk=%s" % clsavgs + " box=%d" % self.boxsize + " nptcls=%d" % nptcls + " smpd=%.3f" % self.apix + " outbdy=%s" % projfile + " msk=%d" % self.params['mask']) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="spi_to_fim.std") ### SIMPLE origami, ab initio 3D reconstruction refinetime = time.time() simpleexe = apParam.getExecPath("origami", die=True) simpleopts = ( "" + " fstk=%s" % projfile + projext + " froms=%d" % self.params['froms'] + " tos=%d" % self.params['tos'] + " lp=%d" % self.params['lp'] + " hp=%d" % self.params['hp'] + " maxits=%d" % self.params['maxits'] + " msk=%d" % self.params['mask'] + " mw=%d" % self.params['mw'] + " frac=%.3f" % self.params['frac'] + " amsklp=%d" % self.params['amsklp'] + " edge=%d" % self.params['edge'] + " trs=%d" % self.params['trs'] + " nthr=%d" % self.params['nproc']) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="origami.std") refinetime = time.time() - refinetime apDisplay.printMsg("Origami reconstruction time: " + apDisplay.timeString(refinetime)) # ''' ### minor post-processing self.clearIntermediateFiles() apParam.dumpParameters( self.params, "simple-" + self.params['timestamp'] + "-params.pickle") ### upload results self.runparams = apParam.readRunParameters("simple-" + self.params['timestamp'] + "-params.pickle") ### create average of aligned and clustered stacks, convert to IMAGIC alignedStackSpi = "inplalgnstk.spi" alignedStack = "inplalgnstk.hed" if os.path.isfile(alignedStack): apFile.removeStack(alignedStack) emancmd = "proc2d %s %s flip" % (alignedStackSpi, alignedStack) apParam.runCmd(emancmd, "EMAN") clusterStackSpi = "cavgstk.spi" clusterStack = "cavgstk.hed" if os.path.isfile(clusterStack): apFile.removeStack(clusterStack) emancmd = "proc2d %s %s flip" % (clusterStackSpi, clusterStack) apParam.runCmd(emancmd, "EMAN") # apStack.averageStack(alignedStack) ### parse alignment and classification results if self.params['no_center'] is False: self.alignD = self.getAlignParameters(centparams="cenalignint.log") else: self.alignD = self.getAlignParameters() if self.params['no_kmeans'] is False: self.classD = self.getClassification("kmeans.spi", clusterStack) else: self.classD = self.getClassification("hcl.spi", clusterStack) ### upload to database self.insertSIMPLEAlignParamsIntoDatabase() self.insertAlignStackRunIntoDatabase(alignedStack, clusterStack) self.calcResolution(alignedStack) self.insertAlignParticlesIntoDatabase() self.insertClusterRunIntoDatabase() self.insertClusterStackIntoDatabase(clusterStack, len(self.classD)) self.insertSIMPLEOrigamiParamsIntoDatabase()
def start(self): ### simple is written in Fortran, which cannot take inputs of certain length, therefore one needs ### to change to the directory to minimize the filename length, in particular for the stack os.chdir(self.params['rundir']) ### stack needs to be centered if self.params['no_center'] is False: if os.path.isfile(os.path.join(self.params['rundir'], "ali.hed")): apFile.removeStack(os.path.join(self.params['rundir'], "ali.hed")) centstack = os.path.join(self.params['rundir'], "ali.hed") centcmd = "cenalignint %s > cenalignint.log" % (self.stack['file']) apParam.runCmd(centcmd, "EMAN") ### process stack to local file if self.params['timestamp'] is None: apDisplay.printMsg("creating timestamp") self.params['timestamp'] = self.timestamp self.params['localstack'] = os.path.join(self.params['rundir'], self.params['timestamp']+".spi") if os.path.isfile(self.params['localstack']): apFile.removeFile(self.params['localstack']) if self.params['no_center'] is False: proccmd = "proc2d "+centstack+" "+self.params['localstack']+" apix="+str(self.stack['apix']) else: proccmd = "proc2d "+self.stack['file']+" "+self.params['localstack']+" apix="+str(self.stack['apix']) if self.params['bin'] > 1 or self.params['clipsize'] is not None: proccmd += " shrink=%d clip=%d,%d " % (self.params['bin'], self.boxsize, self.boxsize) proccmd += " last="+str(self.params['numpart']-1) proccmd += " spiderswap" # if self.params['highpass'] is not None and self.params['highpass'] > 1: # proccmd += " hp="+str(self.params['highpass']) # if self.params['lowpass'] is not None and self.params['lowpass'] > 1: # proccmd += " lp="+str(self.params['lowpass']) apParam.runCmd(proccmd, "EMAN", verbose=True) # if self.params['numpart'] != int(spider.getSpiderHeader(self.params['localstack'])[-2]): # apDisplay.printError("Missing particles in stack") ### setup Simple command aligntime = time.time() simpleopts = ("" +" stk=%s" % os.path.basename(self.params['localstack']) +" box=%d" % self.boxsize +" nptcls=%d" % self.params['numpart'] +" smpd=%.3f" % self.apix +" ring2=%d" % self.params['ring2'] +" ncls=%d" % self.params['ncls'] +" minp=%d" % self.params['minp'] +" nvars=%d" % self.params['nvars'] +" nthr=%d" % self.params['nproc'] ) if self.params['no_kmeans'] is True: simpleopts += " kmeans=off" if self.params['nran'] is not None: simpleopts += "nran=%d" % self.params['nran'] ### SIMPLE 2D clustering apDisplay.printColor("Using "+str(self.params['nproc'])+" processors!", "green") simpleexe = apParam.getExecPath("cluster", die=True) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="cluster.std") self.params['runtime'] = time.time() - aligntime apDisplay.printMsg("Alignment & Classification time: "+apDisplay.timeString(self.params['runtime'])) ### SIMPLE spider to Fourier format clsavgs = "cavgstk.spi" if not os.path.isfile(os.path.join(self.params['rundir'], clsavgs)): apDisplay.printError("class averages were not created! try rerunning with centering, more particles, or less ppc") try: nptcls = spider.getSpiderHeader(clsavgs)[-2] except: nptcls = self.params['ncls'] apDisplay.printWarning("class average file may not have been created! Please check existence of file cavgstk.spi") projfile = "projs" projext = ".fim" simpleexe = apParam.getExecPath("spi_to_fim", die=True) simpleopts = ("" +" stk=%s" % clsavgs +" box=%d" % self.boxsize +" nptcls=%d" % nptcls +" smpd=%.3f" % self.apix +" outbdy=%s" % projfile +" msk=%d" % self.params['mask'] ) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="spi_to_fim.std") ### SIMPLE origami, ab initio 3D reconstruction refinetime = time.time() simpleexe = apParam.getExecPath("origami", die=True) simpleopts = ("" +" fstk=%s" % projfile+projext +" froms=%d" % self.params['froms'] +" tos=%d" % self.params['tos'] +" lp=%d" % self.params['lp'] +" hp=%d" % self.params['hp'] +" maxits=%d" % self.params['maxits'] +" msk=%d" % self.params['mask'] +" mw=%d" % self.params['mw'] +" frac=%.3f" % self.params['frac'] +" amsklp=%d" % self.params['amsklp'] +" edge=%d" % self.params['edge'] +" trs=%d" % self.params['trs'] +" nthr=%d" % self.params['nproc'] ) simplecmd = "%s %s" % (simpleexe, simpleopts) self.writeSimpleLog(simplecmd) apParam.runCmd(simplecmd, package="SIMPLE", verbose=True, showcmd=True, logfile="origami.std") refinetime = time.time() - refinetime apDisplay.printMsg("Origami reconstruction time: "+apDisplay.timeString(refinetime)) # ''' ### minor post-processing self.clearIntermediateFiles() apParam.dumpParameters(self.params, "simple-"+self.params['timestamp']+"-params.pickle") ### upload results self.runparams = apParam.readRunParameters("simple-"+self.params['timestamp']+"-params.pickle") ### create average of aligned and clustered stacks, convert to IMAGIC alignedStackSpi = "inplalgnstk.spi" alignedStack = "inplalgnstk.hed" if os.path.isfile(alignedStack): apFile.removeStack(alignedStack) emancmd = "proc2d %s %s flip" % (alignedStackSpi, alignedStack) apParam.runCmd(emancmd, "EMAN") clusterStackSpi = "cavgstk.spi" clusterStack = "cavgstk.hed" if os.path.isfile(clusterStack): apFile.removeStack(clusterStack) emancmd = "proc2d %s %s flip" % (clusterStackSpi, clusterStack) apParam.runCmd(emancmd, "EMAN") # apStack.averageStack(alignedStack) ### parse alignment and classification results if self.params['no_center'] is False: self.alignD = self.getAlignParameters(centparams="cenalignint.log") else: self.alignD = self.getAlignParameters() if self.params['no_kmeans'] is False: self.classD = self.getClassification("kmeans.spi", clusterStack) else: self.classD = self.getClassification("hcl.spi", clusterStack) ### upload to database self.insertSIMPLEAlignParamsIntoDatabase() self.insertAlignStackRunIntoDatabase(alignedStack, clusterStack) self.calcResolution(alignedStack) self.insertAlignParticlesIntoDatabase() self.insertClusterRunIntoDatabase() self.insertClusterStackIntoDatabase(clusterStack, len(self.classD)) self.insertSIMPLEOrigamiParamsIntoDatabase()
def start(self): # self.insertCL2DJob() self.stack = {} self.stack['apix'] = apStack.getStackPixelSizeFromStackId(self.params['stackid']) self.stack['part'] = apStack.getOneParticleFromStackId(self.params['stackid']) if self.params['virtualdata'] is not None: self.stack['file'] = self.params['virtualdata']['filename'] else: self.stack['file'] = os.path.join(self.stackdata['path']['path'], self.stackdata['name']) ### process stack to local file if self.params['timestamp'] is None: apDisplay.printMsg("creating timestamp") self.params['timestamp'] = self.timestamp self.params['localstack'] = os.path.join(self.params['rundir'], self.params['timestamp']+".hed") if os.path.isfile(self.params['localstack']): apFile.removeStack(self.params['localstack']) a = proc2dLib.RunProc2d() a.setValue('infile',self.stack['file']) a.setValue('outfile',self.params['localstack']) a.setValue('apix',self.stack['apix']) a.setValue('bin',self.params['bin']) a.setValue('last',self.params['numpart']-1) if self.params['lowpass'] is not None and self.params['lowpass'] > 1: a.setValue('lowpass',self.params['lowpass']) if self.params['highpass'] is not None and self.params['highpass'] > 1: a.setValue('highpass',self.params['highpass']) if self.params['invert'] is True: a.setValue('invert',True) # clip not yet implemented # if self.params['clipsize'] is not None: # clipsize = int(self.clipsize)*self.params['bin'] # if clipsize % 2 == 1: # clipsize += 1 ### making sure that clipped boxsize is even # a.setValue('clip',clipsize) if self.params['virtualdata'] is not None: vparts = self.params['virtualdata']['particles'] plist = [int(p['particleNumber'])-1 for p in vparts] a.setValue('list',plist) #run proc2d a.run() if self.params['numpart'] != apFile.numImagesInStack(self.params['localstack']): apDisplay.printError("Missing particles in stack") ### convert stack into single spider files self.partlistdocfile = apXmipp.breakupStackIntoSingleFiles(self.params['localstack']) ### setup Xmipp command aligntime = time.time() xmippopts = ( " " +" -i "+os.path.join(self.params['rundir'], self.partlistdocfile) +" -codes "+str(self.params['numrefs']) +" -iter "+str(self.params['maxiter']) +" -o "+os.path.join(self.params['rundir'], "part"+self.params['timestamp']) ) if self.params['fast']: xmippopts += " -fast " if self.params['correlation']: xmippopts += " -useCorrelation " if self.params['classical']: xmippopts += " -classicalMultiref " if self.params['align']: xmippopts += " -alignImages " ### use multi-processor command apDisplay.printColor("Using "+str(self.params['nproc'])+" processors!", "green") xmippexe = apParam.getExecPath("xmipp_mpi_class_averages", die=True) mpiruncmd = self.mpirun+" -np "+str(self.params['nproc'])+" "+xmippexe+" "+xmippopts self.writeXmippLog(mpiruncmd) apParam.runCmd(mpiruncmd, package="Xmipp", verbose=True, showcmd=True, logfile="xmipp.std") self.params['runtime'] = time.time() - aligntime apDisplay.printMsg("Alignment time: "+apDisplay.timeString(self.params['runtime'])) ### minor post-processing self.createReferenceStack() self.parseOutput() self.clearIntermediateFiles() # self.readyUploadFlag() apParam.dumpParameters(self.params, "cl2d-"+self.params['timestamp']+"-params.pickle") ### upload results ... this used to be two separate operations, I'm combining into one self.runparams = apParam.readRunParameters("cl2d-"+self.params['timestamp']+"-params.pickle") self.apix = apStack.getStackPixelSizeFromStackId(self.runparams['stackid'])*self.runparams['bin'] self.Nlevels=len(glob.glob("part"+self.params['timestamp']+"_level_??_.hed")) ### create average of aligned stacks & insert aligned stack info lastLevelStack = "part"+self.params['timestamp']+"_level_%02d_.hed"%(self.Nlevels-1) apStack.averageStack(lastLevelStack) self.boxsize = apFile.getBoxSize(lastLevelStack)[0] self.insertCL2DParamsIntoDatabase() if self.runparams['align'] is True: self.insertAlignStackRunIntoDatabase("alignedStack.hed") self.calcResolution(self.Nlevels-1) self.insertAlignParticlesIntoDatabase(level=self.Nlevels-1) ### loop over each class average stack & insert as clustering stacks self.insertClusterRunIntoDatabase() for level in range(self.Nlevels): ### NOTE: RESOLUTION CAN ONLY BE CALCULATED IF ALIGNED STACK EXISTS TO EXTRACT / READ THE PARTICLES if self.params['align'] is True: self.calcResolution(level) partdict = self.getClassificationAtLevel(level) for classnum in partdict: self.insertClusterStackIntoDatabase( "part"+self.params['timestamp']+"_level_%02d_.hed"%level, classnum+1, partdict[classnum], len(partdict))
def start(self): # self.insertCL2DJob() self.stack = {} self.stack['apix'] = apStack.getStackPixelSizeFromStackId(self.params['stackid']) self.stack['part'] = apStack.getOneParticleFromStackId(self.params['stackid']) self.stack['boxsize'] = apStack.getStackBoxsize(self.params['stackid']) if self.params['virtualdata'] is not None: self.stack['file'] = self.params['virtualdata']['filename'] else: self.stack['file'] = os.path.join(self.stackdata['path']['path'], self.stackdata['name']) ### process stack to local file if self.params['timestamp'] is None: apDisplay.printMsg("creating timestamp") self.params['timestamp'] = self.timestamp self.params['localstack'] = os.path.join(self.params['rundir'], self.params['timestamp']+".hed") if os.path.isfile(self.params['localstack']): apFile.removeStack(self.params['localstack']) a = proc2dLib.RunProc2d() a.setValue('infile',self.stack['file']) a.setValue('outfile',self.params['localstack']) a.setValue('apix',self.stack['apix']) a.setValue('bin',self.params['bin']) a.setValue('last',self.params['numpart']-1) if self.params['lowpass'] is not None and self.params['lowpass'] > 1: a.setValue('lowpass',self.params['lowpass']) if self.params['highpass'] is not None and self.params['highpass'] > 1: a.setValue('highpass',self.params['highpass']) if self.params['invert'] is True: a.setValue('invert',True) # clip not yet implemented # if self.params['clipsize'] is not None: # clipsize = int(self.clipsize)*self.params['bin'] # if clipsize % 2 == 1: # clipsize += 1 ### making sure that clipped boxsize is even # a.setValue('clip',clipsize) if self.params['virtualdata'] is not None: vparts = self.params['virtualdata']['particles'] plist = [int(p['particleNumber'])-1 for p in vparts] a.setValue('list',plist) #run proc2d a.run() if self.params['numpart'] != apFile.numImagesInStack(self.params['localstack']): apDisplay.printError("Missing particles in stack") ### setup Xmipp command aligntime = time.time() xmippopts = (" -i "+os.path.join(self.params['rundir'], self.params['localstack']) +" --nref "+str(self.params['numrefs']) +" --iter "+str(self.params['maxiter']) +" --odir "+str(self.params['rundir']) +" --oroot "+ "part"+str(self.params['timestamp']) +" --classifyAllImages" ) if self.params['correlation']: xmippopts += " --distance correlation" if self.params['classical']: xmippopts += " --classicalMultiref" ### use multi-processor command apDisplay.printColor("Using "+str(self.params['nproc'])+" processors!", "green") xmippexe = apParam.getExecPath(self.execFile, die=True) mpiruncmd = self.mpirun+" -np "+str(self.params['nproc'])+" "+xmippexe+" "+xmippopts self.writeXmippLog(mpiruncmd) apParam.runCmd(mpiruncmd, package="Xmipp 3", verbose=True, showcmd=True, logfile="xmipp.std") self.params['runtime'] = time.time() - aligntime apDisplay.printMsg("Alignment time: "+apDisplay.timeString(self.params['runtime'])) ### post-processing # Create a stack for the class averages at each level Nlevels=glob.glob("level_*") for level in Nlevels: digits = level.split("_")[1] apParam.runCmd("xmipp_image_convert -i "+level+"/part"+self.params['timestamp']+"*xmd -o part" +self.params['timestamp']+"_level_"+digits+"_.hed", package="Xmipp 3", verbose=True) if self.params['align']: apParam.runCmd("xmipp_transform_geometry -i images.xmd -o %s_aligned.stk --apply_transform" % self.params['timestamp'], package="Xmipp 3", verbose=True) apParam.runCmd("xmipp_image_convert -i %s_aligned.xmd -o alignedStack.hed" % self.params['timestamp'], package="Xmipp 3", verbose=True) apFile.removeFile("%s_aligned.xmd" % self.params['timestamp']) apFile.removeFile("%s_aligned.stk" % self.params['timestamp']) self.parseOutput() apParam.dumpParameters(self.params, "cl2d-"+self.params['timestamp']+"-params.pickle") ### upload results ... this used to be two separate operations, I'm combining into one self.runparams = apParam.readRunParameters("cl2d-"+self.params['timestamp']+"-params.pickle") self.apix = apStack.getStackPixelSizeFromStackId(self.runparams['stackid'])*self.runparams['bin'] self.Nlevels=len(glob.glob("part"+self.params['timestamp']+"_level_??_.hed")) ### create average of aligned stacks & insert aligned stack info lastLevelStack = "part"+self.params['timestamp']+"_level_%02d_.hed"%(self.Nlevels-1) apStack.averageStack(lastLevelStack) self.boxsize = apFile.getBoxSize(lastLevelStack)[0] self.insertCL2DParamsIntoDatabase() if self.runparams['align'] is True: self.insertAlignStackRunIntoDatabase("alignedStack.hed") self.calcResolution(self.Nlevels-1) self.insertAlignParticlesIntoDatabase(level=self.Nlevels-1) ### loop over each class average stack & insert as clustering stacks self.insertClusterRunIntoDatabase() for level in range(self.Nlevels): ### NOTE: RESOLUTION CAN ONLY BE CALCULATED IF ALIGNED STACK EXISTS TO EXTRACT / READ THE PARTICLES if self.params['align'] is True: self.calcResolution(level) partdict = self.getClassificationAtLevel(level) for classnum in partdict: self.insertClusterStackIntoDatabase( "part"+self.params['timestamp']+"_level_%02d_.hed"%level, classnum+1, partdict[classnum], len(partdict)) self.clearIntermediateFiles()
def start(self): # self.insertCL2DJob() self.stack = {} self.stack['data'] = apStack.getOnlyStackData(self.params['stackid']) self.stack['apix'] = apStack.getStackPixelSizeFromStackId( self.params['stackid']) self.stack['part'] = apStack.getOneParticleFromStackId( self.params['stackid']) self.stack['boxsize'] = apStack.getStackBoxsize(self.params['stackid']) self.stack['file'] = os.path.join(self.stack['data']['path']['path'], self.stack['data']['name']) ### process stack to local file if self.params['timestamp'] is None: apDisplay.printMsg("creating timestamp") self.params['timestamp'] = self.timestamp self.params['localstack'] = os.path.join( self.params['rundir'], self.params['timestamp'] + ".hed") if os.path.isfile(self.params['localstack']): apFile.removeStack(self.params['localstack']) proccmd = "proc2d " + self.stack['file'] + " " + self.params[ 'localstack'] + " apix=" + str(self.stack['apix']) if self.params['bin'] > 1 or self.params['clipsize'] is not None: clipsize = int(self.clipsize) * self.params['bin'] if clipsize % 2 == 1: clipsize += 1 ### making sure that clipped boxsize is even proccmd += " shrink=%d clip=%d,%d " % (self.params['bin'], clipsize, clipsize) proccmd += " last=" + str(self.params['numpart'] - 1) if self.params['highpass'] is not None and self.params['highpass'] > 1: proccmd += " hp=" + str(self.params['highpass']) if self.params['lowpass'] is not None and self.params['lowpass'] > 1: proccmd += " lp=" + str(self.params['lowpass']) apParam.runCmd(proccmd, "EMAN", verbose=True) if self.params['numpart'] != apFile.numImagesInStack( self.params['localstack']): apDisplay.printError("Missing particles in stack") ### convert stack into single spider files self.partlistdocfile = apXmipp.breakupStackIntoSingleFiles( self.params['localstack']) ### setup Xmipp command aligntime = time.time() xmippopts = ( " " + " -i " + os.path.join(self.params['rundir'], self.partlistdocfile) + " -codes " + str(self.params['numrefs']) + " -iter " + str(self.params['maxiter']) + " -o " + os.path.join( self.params['rundir'], "part" + self.params['timestamp'])) if self.params['fast']: xmippopts += " -fast " if self.params['correlation']: xmippopts += " -useCorrelation " if self.params['classical']: xmippopts += " -classicalMultiref " if self.params['align']: xmippopts += " -alignImages " ### use multi-processor command apDisplay.printColor( "Using " + str(self.params['nproc']) + " processors!", "green") xmippexe = apParam.getExecPath("xmipp_mpi_class_averages", die=True) mpiruncmd = self.mpirun + " -np " + str( self.params['nproc']) + " " + xmippexe + " " + xmippopts self.writeXmippLog(mpiruncmd) apParam.runCmd(mpiruncmd, package="Xmipp", verbose=True, showcmd=True, logfile="xmipp.std") self.params['runtime'] = time.time() - aligntime apDisplay.printMsg("Alignment time: " + apDisplay.timeString(self.params['runtime'])) ### minor post-processing self.createReferenceStack() self.parseOutput() self.clearIntermediateFiles() # self.readyUploadFlag() apParam.dumpParameters( self.params, "cl2d-" + self.params['timestamp'] + "-params.pickle") ### upload results ... this used to be two separate operations, I'm combining into one self.runparams = apParam.readRunParameters("cl2d-" + self.params['timestamp'] + "-params.pickle") self.apix = apStack.getStackPixelSizeFromStackId( self.runparams['stackid']) * self.runparams['bin'] self.Nlevels = len( glob.glob("part" + self.params['timestamp'] + "_level_??_.hed")) ### create average of aligned stacks & insert aligned stack info lastLevelStack = "part" + self.params[ 'timestamp'] + "_level_%02d_.hed" % (self.Nlevels - 1) apStack.averageStack(lastLevelStack) self.boxsize = apFile.getBoxSize(lastLevelStack)[0] self.insertCL2DParamsIntoDatabase() if self.runparams['align'] is True: self.insertAlignStackRunIntoDatabase("alignedStack.hed") self.calcResolution(self.Nlevels - 1) self.insertAlignParticlesIntoDatabase(level=self.Nlevels - 1) ### loop over each class average stack & insert as clustering stacks self.insertClusterRunIntoDatabase() for level in range(self.Nlevels): ### NOTE: RESOLUTION CAN ONLY BE CALCULATED IF ALIGNED STACK EXISTS TO EXTRACT / READ THE PARTICLES if self.params['align'] is True: self.calcResolution(level) partdict = self.getClassificationAtLevel(level) for classnum in partdict: self.insertClusterStackIntoDatabase( "part" + self.params['timestamp'] + "_level_%02d_.hed" % level, classnum + 1, partdict[classnum], len(partdict))