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 processVolume(self, spivolfile, iternum=0):
        ### set values
        apix = apStack.getStackPixelSizeFromStackId(
            self.params['tiltstackid']) * self.params['tiltbin']
        boxsize = self.getBoxSize()
        rawspifile = os.path.join(
            self.params['rundir'],
            "rawvolume%s-%03d.spi" % (self.timestamp, iternum))
        mrcvolfile = os.path.join(
            self.params['rundir'],
            "volume%s-%03d.mrc" % (self.timestamp, iternum))
        lowpass = self.params['lowpassvol']
        ### copy original to raw file
        shutil.copy(spivolfile, rawspifile)

        ### convert to mrc
        emancmd = ("proc3d " + spivolfile + " " + mrcvolfile +
                   " norm=0,1 apix=" + str(apix))
        apEMAN.executeEmanCmd(emancmd, verbose=False)

        ### median filter
        rawvol = mrc.read(mrcvolfile)
        medvol = ndimage.median_filter(rawvol, size=self.params['median'])
        mrc.write(medvol, mrcvolfile)

        ### low pass filter
        emancmd = ("proc3d " + mrcvolfile + " " + mrcvolfile +
                   " center norm=0,1 apix=" + str(apix) + " lp=" +
                   str(lowpass))
        apEMAN.executeEmanCmd(emancmd, verbose=False)

        ### set origin
        emancmd = "proc3d " + mrcvolfile + " " + mrcvolfile + " origin=0,0,0 "
        apEMAN.executeEmanCmd(emancmd, verbose=False)

        ### mask volume
        emancmd = "proc3d " + mrcvolfile + " " + mrcvolfile + " mask=" + str(
            self.params['radius'])
        apEMAN.executeEmanCmd(emancmd, verbose=False)

        ### convert to spider
        apFile.removeFile(spivolfile)
        emancmd = "proc3d " + mrcvolfile + " " + spivolfile + " spidersingle"
        apEMAN.executeEmanCmd(emancmd, verbose=False)

        ### image with chimera
        if self.params['skipchimera'] is False:
            if self.params['mass'] is not None:
                apDisplay.printMsg("Using scale by mass method")
                apChimera.setVolumeMass(mrcvolfile,
                                        apix=apix,
                                        mass=self.params['mass'])
            apChimera.renderSnapshots(mrcvolfile, self.params['contour'],
                                      self.params['zoom'], 'c1')
        return mrcvolfile
	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 processVolume(self, spivolfile, iternum=0):
		### set values
		apix = apStack.getStackPixelSizeFromStackId(self.params['tiltstackid'])*self.params['tiltbin']
		boxsize = self.getBoxSize()
		rawspifile = os.path.join(self.params['rundir'], "rawvolume%s-%03d.spi"%(self.timestamp, iternum))
		mrcvolfile = os.path.join(self.params['rundir'], "volume%s-%03d.mrc"%(self.timestamp, iternum))
		lowpass = self.params['lowpassvol']
		### copy original to raw file
		shutil.copy(spivolfile, rawspifile)

		### convert to mrc
		emancmd = ("proc3d "+spivolfile+" "+mrcvolfile+" norm=0,1 apix="+str(apix))
		apEMAN.executeEmanCmd(emancmd, verbose=False)

		### median filter
		rawvol = mrc.read(mrcvolfile)
		medvol = ndimage.median_filter(rawvol, size=self.params['median'])
		mrc.write(medvol, mrcvolfile)

		### low pass filter
		emancmd = ("proc3d "+mrcvolfile+" "+mrcvolfile+" center norm=0,1 apix="
			+str(apix)+" lp="+str(lowpass))
		apEMAN.executeEmanCmd(emancmd, verbose=False)

		### set origin
		emancmd = "proc3d "+mrcvolfile+" "+mrcvolfile+" origin=0,0,0 "
		apEMAN.executeEmanCmd(emancmd, verbose=False)

		### mask volume
		emancmd = "proc3d "+mrcvolfile+" "+mrcvolfile+" mask="+str(self.params['radius'])
		apEMAN.executeEmanCmd(emancmd, verbose=False)

		### convert to spider
		apFile.removeFile(spivolfile)
		emancmd = "proc3d "+mrcvolfile+" "+spivolfile+" spidersingle"
		apEMAN.executeEmanCmd(emancmd, verbose=False)

		### image with chimera
		if self.params['skipchimera'] is False:
			if self.params['mass'] is not None:
				apDisplay.printMsg("Using scale by mass method")
				apChimera.setVolumeMass(mrcvolfile, apix=apix, mass=self.params['mass'])
			apChimera.renderSnapshots(mrcvolfile, self.params['contour'], self.params['zoom'], 'c1')
		return mrcvolfile
    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)
Example #6
0
    def start(self):
        self.apix = None
        self.mass = None
        self.setFileName()

        mrcname = self.params['name'] + ".mrc"
        ccp4name = self.params['name'] + ".ccp4"

        ### get emdb from web
        emdbfile = self.fetchEMDB(self.params['emdbid'], ccp4name)

        ### create density from emdb
        self.getXMLInfoFromEMDB(self.params['emdbid'])
        emancmd = ("proc3d " + ccp4name + " " + mrcname)
        apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True)
        apFile.removeFile(ccp4name)

        if self.params['viper2eman'] is True:
            apVolume.viper2eman(mrcname, mrcname, apix=self.apix)

        ### lowpass filter, do both atan2 and Gaussian filter to sum up to requested lowpass
        ### total lowpass = sqrt( lp1^2 + lp2^2 )
        if self.params['lowpass'] is not None:
            lp = self.params['lowpass'] / math.sqrt(2.0)
        emancmd = "proc3d %s %s apix=%.3f origin=0,0,0 norm=0,1 " % (
            mrcname, mrcname, self.apix)
        if self.params['lowpass'] is not None:
            emancmd += "tlp=%.2f lp=%.2f" % (lp, lp)
        apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True)

        if self.mass is not None:
            apChimera.setVolumeMass(mrcname, apix=self.apix, mass=self.mass)

        ### chimera imaging
        apChimera.renderSnapshots(mrcname,
                                  contour=1.0,
                                  zoom=1.0,
                                  sym=self.params['symdata']['eman_name'])

        ### upload it
        self.uploadDensity(mrcname)
	def start(self):
		self.apix = None
		self.mass = None
		self.setFileName()

		mrcname = self.params['name']+".mrc"
		ccp4name = self.params['name']+".ccp4"

		### get emdb from web
		emdbfile = self.fetchEMDB(self.params['emdbid'], ccp4name)

		### create density from emdb
		self.getXMLInfoFromEMDB(self.params['emdbid'])
		emancmd = ("proc3d "+ccp4name+" "+mrcname)
		apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True)
		apFile.removeFile(ccp4name)

		if self.params['viper2eman'] is True:
			apVolume.viper2eman(mrcname, mrcname, apix=self.apix)

		### lowpass filter, do both atan2 and Gaussian filter to sum up to requested lowpass
		### total lowpass = sqrt( lp1^2 + lp2^2 )
		if self.params['lowpass'] is not None:
			lp = self.params['lowpass']/math.sqrt(2.0)
		emancmd = "proc3d %s %s apix=%.3f origin=0,0,0 norm=0,1 " %(mrcname, mrcname, self.apix)
		if self.params['lowpass'] is not None:
			emancmd += "tlp=%.2f lp=%.2f" % (lp, lp)
		apEMAN.executeEmanCmd(emancmd, verbose=False, showcmd=True)

		if self.mass is not None:
			apChimera.setVolumeMass(mrcname, apix=self.apix, mass=self.mass)

		### chimera imaging
		apChimera.renderSnapshots(mrcname, contour=1.0, zoom=1.0, sym=self.params['symdata']['eman_name'])

		### upload it
		self.uploadDensity(mrcname)
    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)