def start(self): mrcfile = self.params['file'] ### bin the volume if self.params['bin'] is not None and self.params['bin'] > 1: apDisplay.printMsg("Binning volume") newmrcfile = os.path.join(os.getcwd(), "binned.mrc") voldata = mrc.read(mrcfile) voldata = imagefun.bin3(voldata, self.params['bin']) mrc.write(voldata, newmrcfile) del voldata self.params['apix'] *= self.params['bin'] if os.path.isfile(newmrcfile): mrcfile = newmrcfile ### scale by mass if self.params['mass'] is not None: apDisplay.printMsg("Using scale by mass method") newmrcfile = os.path.join(os.getcwd(), "setmass.mrc") shutil.copy(self.params['file'], newmrcfile) apChimera.setVolumeMass(newmrcfile, apix=self.params['apix'], mass=self.params['mass']) self.params['contour'] = 1.0 if os.path.isfile(newmrcfile): mrcfile = newmrcfile ### print stats box = apVolume.getModelDimensions(mrcfile) apDisplay.printColor("Box: %d Apix: %.2f File: %s"% (box, self.params['apix'], os.path.basename(mrcfile)), "green") ### animation if self.params['type'] != "snapshot": apDisplay.printMsg("Creating animation") apChimera.renderAnimation(mrcfile, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.params['sym'], color=self.params['color'], xvfb=self.params['xvfb'], name=self.params['file'], silhouette=self.params['silhouette']) ### snapshot if self.params['type'] != "animate": apDisplay.printMsg("Creating snapshots") apChimera.renderSnapshots(mrcfile, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.params['sym'], color=self.params['color'], xvfb=self.params['xvfb'], pdb=self.params['pdb'], name=self.params['file'], silhouette=self.params['silhouette']) ### clean up if self.params['mass'] is not None or self.params['bin'] is not None: images = glob.glob(mrcfile+"*") for img in images: newimg = re.sub(mrcfile, self.params['file'], img) shutil.move(img, newimg) apFile.removeFile(mrcfile)
def start(self): if self.params['method'] == 'any': ### startAny uses class averages clusterstack, numimages = self.getClusterStack() else: ### starticos, startoct, startcsym uses individual particles clusterstack, numimages = self.getClusterParticles() if self.params['method'] != 'any': if self.params['numkeep'] is not None and numimages/10 < int(self.params['numkeep']): apDisplay.printWarning("particle number of "+ self.params['numkeep'] + " is greater than 10% of the number of selected classes") elif self.params['numkeep'] is None: self.params['numkeep'] = int(math.floor(numimages/20.0))+1 apDisplay.printWarning("numkeep was not defined, using %d particles"%(self.params['numkeep'])) nproc = apParam.getNumProcessors() #construct command for each of the EMAN commonline method if self.params['method'] == 'any': startcmd = "startAny "+clusterstack+" proc="+str(nproc) startcmd +=" sym="+self.symmdata['eman_name'] if self.params['mask'] is not None: startcmd +=" mask="+str(self.params['mask']) else: maskrad = math.floor(self.clusterstackdata['clusterrun']['boxsize']/2.0) startcmd +=" mask=%d"%(maskrad) if self.params['rounds'] is not None: startcmd +=" rounds="+str(self.params['rounds']) elif self.params['method'] == 'csym': startcmd = "startcsym "+clusterstack+" " startcmd +=" "+str(self.params['numkeep']) startcmd +=" sym="+self.symmdata['eman_name'] if self.params['imask'] is not None: startcmd +=" imask="+self.params['imask'] elif self.params['method'] == 'oct': startcmd = "startoct "+clusterstack+" " startcmd +=" "+str(self.params['numkeep']) elif self.params['method'] == 'icos': startcmd = "starticos "+clusterstack+" " startcmd +=" "+str(self.params['numkeep']) if self.params['imask'] is not None: startcmd +=" imask="+self.params['imask'] apDisplay.printMsg("Creating 3D model with EMAN function: start"+self.params['method']) apFile.removeFile("threed.0a.mrc") apFile.removeFile("eman.log") apEMAN.executeEmanCmd(startcmd, verbose=False, logfile="eman.log") #apEMAN.executeEmanCmd(startcmd, verbose=True) finalmodelname = "threed-%s-eman_start%s.mrc"%(self.timestamp, self.params['method']) finalmodelpath = os.path.join(self.params['rundir'], finalmodelname) apDisplay.printMsg("Final model name: "+finalmodelname) finalmodel = "threed.0a.mrc" if os.path.isfile(finalmodel): emancmd = "proc3d %s %s norm=0,1 origin=0,0,0"%(finalmodel, finalmodelpath) #shutil.move(finalmodel, finalmodelpath) apEMAN.executeEmanCmd(emancmd, verbose=True) if not apVolume.isValidVolume(finalmodelpath): apDisplay.printError("Created volume is not valid") else: apDisplay.printError("No 3d model was created") ### upload it self.uploadDensity(finalmodelpath) ### chimera imaging apChimera.renderSnapshots(finalmodelpath, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.symmdata['eman_name']) apChimera.renderAnimation(finalmodelpath, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.symmdata['eman_name']) ### remove stack if apFile.stackSize(clusterstack)/1024**2 > 10: ### file bigger than 10MB apFile.removeStack(clusterstack) apFile.removeFile("threed.0a.mrc")
def start(self): mrcfile = self.params['file'] ### bin the volume if self.params['bin'] is not None and self.params['bin'] > 1: apDisplay.printMsg("Binning volume") newmrcfile = os.path.join(os.getcwd(), "binned.mrc") voldata = mrc.read(mrcfile) voldata = imagefun.bin3(voldata, self.params['bin']) mrc.write(voldata, newmrcfile) del voldata self.params['apix'] *= self.params['bin'] if os.path.isfile(newmrcfile): mrcfile = newmrcfile ### scale by mass if self.params['mass'] is not None: apDisplay.printMsg("Using scale by mass method") newmrcfile = os.path.join(os.getcwd(), "setmass.mrc") shutil.copy(self.params['file'], newmrcfile) apChimera.setVolumeMass(newmrcfile, apix=self.params['apix'], mass=self.params['mass']) self.params['contour'] = 1.0 if os.path.isfile(newmrcfile): mrcfile = newmrcfile ### print stats box = apVolume.getModelDimensions(mrcfile) apDisplay.printColor( "Box: %d Apix: %.2f File: %s" % (box, self.params['apix'], os.path.basename(mrcfile)), "green") ### animation if self.params['type'] != "snapshot": apDisplay.printMsg("Creating animation") apChimera.renderAnimation(mrcfile, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.params['sym'], color=self.params['color'], xvfb=self.params['xvfb'], name=self.params['file'], silhouette=self.params['silhouette']) ### snapshot if self.params['type'] != "animate": apDisplay.printMsg("Creating snapshots") apChimera.renderSnapshots(mrcfile, contour=self.params['contour'], zoom=self.params['zoom'], sym=self.params['sym'], color=self.params['color'], xvfb=self.params['xvfb'], pdb=self.params['pdb'], name=self.params['file'], silhouette=self.params['silhouette']) ### clean up if self.params['mass'] is not None or self.params['bin'] is not None: images = glob.glob(mrcfile + "*") for img in images: newimg = re.sub(mrcfile, self.params['file'], img) shutil.move(img, newimg) apFile.removeFile(mrcfile)