def start(self): self.setFileName() scale = float(self.params['oldapix'])/self.params['newapix'] mrcname = os.path.join(self.params['rundir'], self.params['name']+".mrc") origmodel = self.params['file'] if os.path.isfile(mrcname): apDisplay.printError("File exists") if (abs(self.params['oldapix'] - self.params['newapix']) > 1.0e-2 or abs(self.params['oldbox'] - self.params['newbox']) > 1.0e-1): ### rescale old model to a new size apDisplay.printWarning("rescaling original model to a new size") scale = float(self.params['oldapix'])/self.params['newapix'] apDisplay.printMsg("rescaling model by scale factor of %.4f"%(scale)) apVolume.rescaleVolume(origmodel, mrcname, self.params['oldapix'], self.params['newapix'], self.params['newbox']) else: ### simple upload, just copy file to models folder apDisplay.printMsg("copying original model to a new location: "+mrcname) shutil.copyfile(origmodel, mrcname) if self.params['viper2eman'] is True: apVolume.viper2eman(mrcname, mrcname, apix=self.params['newapix']) ### render chimera images of model contour = self.params['contour'] if self.params['mass'] is not None: apChimera.setVolumeMass(mrcname, self.params['newapix'], self.params['mass']) contour = 1.0 apChimera.renderSnapshots(mrcname, contour=contour, zoom=self.params['zoom'], sym=self.params['symdata']['eman_name']) self.insertModel(mrcname)
def preprocessModelWithProc3d(self, rescale=True): ''' Use EMAN proc3d to scale initial or mask model to that of the refinestack and format ''' extname = self.proc3dFormatConversion() if self.model['ismask'] is False: modelname = "initmodel" else: modelname = "maskvol" outmodelfile = os.path.join( self.params['rundir'], "%s%04d.%s" % (modelname, self.model['id'], extname)) apFile.removeStack(outmodelfile, warn=False) if rescale: apVolume.rescaleVolume(self.model['file'], outmodelfile, self.model['apix'], self.stack['apix'], self.stack['boxsize'], spider=self.modelspidersingle) symmetry_description = self.model['data']['symmetry']['symmetry'] if 'Icos' in symmetry_description: self.convertRefineModelIcosSymmetry(modelname, extname, outmodelfile, self.stack['apix']) self.model['file'] = outmodelfile self.model['apix'] = self.stack['apix'] self.model['format'] = extname return outmodelfile
def rescaleModel(modelid, outfile, newbox=None, newapix=None, spider=None): """ take an existing model id and rescale it """ modeldata = getModelFromId(modelid) modelapix = modeldata['pixelsize'] modelfile = os.path.join(modeldata['path']['path'], modeldata['name']) apVolume.rescaleVolume(modelfile, outfile, modelapix, newapix, newbox, spider=spider) return
def start(self): self.setFileName() scale = float(self.params['oldapix']) / self.params['newapix'] mrcname = os.path.join(self.params['rundir'], self.params['name'] + ".mrc") origmodel = self.params['file'] if os.path.isfile(mrcname): apDisplay.printError("File exists") if (abs(self.params['oldapix'] - self.params['newapix']) > 1.0e-2 or abs(self.params['oldbox'] - self.params['newbox']) > 1.0e-1): ### rescale old model to a new size apDisplay.printWarning("rescaling original model to a new size") scale = float(self.params['oldapix']) / self.params['newapix'] apDisplay.printMsg("rescaling model by scale factor of %.4f" % (scale)) apVolume.rescaleVolume(origmodel, mrcname, self.params['oldapix'], self.params['newapix'], self.params['newbox']) else: ### simple upload, just copy file to models folder apDisplay.printMsg("copying original model to a new location: " + mrcname) shutil.copyfile(origmodel, mrcname) if self.params['viper2eman'] is True: apVolume.viper2eman(mrcname, mrcname, apix=self.params['newapix']) ### render chimera images of model contour = self.params['contour'] if self.params['mass'] is not None: apChimera.setVolumeMass(mrcname, self.params['newapix'], self.params['mass']) contour = 1.0 apChimera.renderSnapshots(mrcname, contour=contour, zoom=self.params['zoom'], sym=self.params['symdata']['eman_name']) self.insertModel(mrcname)
def preprocessModelWithProc3d(self, rescale=True): ''' Use EMAN proc3d to scale initial or mask model to that of the refinestack and format ''' extname = self.proc3dFormatConversion() if self.model['ismask'] is False: modelname = "initmodel" else: modelname = "maskvol" outmodelfile = os.path.join(self.params['rundir'], "%s%04d.%s" % (modelname,self.model['id'],extname)) apFile.removeStack(outmodelfile, warn=False) if rescale: apVolume.rescaleVolume(self.model['file'], outmodelfile, self.model['apix'], self.stack['apix'], self.stack['boxsize'], spider=self.modelspidersingle) symmetry_description = self.model['data']['symmetry']['symmetry'] if 'Icos' in symmetry_description: self.convertRefineModelIcosSymmetry(modelname,extname,outmodelfile,self.stack['apix']) self.model['file'] = outmodelfile self.model['apix'] = self.stack['apix'] self.model['format'] = extname return outmodelfile