Exemplo n.º 1
0
    def uploadTemplateStack(self, insert=False):
        sessiondata = apDatabase.getSessionDataFromSessionName(
            self.params['sessionname'])

        uploadq = appiondata.ApTemplateStackData()
        uploadq['REF|projectdata|projects|project'] = self.params['projectid']
        if self.params['clusterId'] is not None:
            uploadq[
                'clusterstack'] = appiondata.ApClusteringStackData.direct_query(
                    self.params['clusterId'])
        elif self.params['alignId'] is not None:
            uploadq['alignstack'] = appiondata.ApAlignStackData.direct_query(
                self.params['alignId'])
        elif self.params['templatestack'] is not None:
            uploadq['origfile'] = self.params['templatestack'] + ".hed"
        uploadq['templatename'] = self.params['runname'] + ".hed"
        if self.params['templatetype'] == "clsavg":
            uploadq['cls_avgs'] = True
        if self.params['templatetype'] == "forward_proj":
            uploadq['forward_proj'] = True
        uploadq['description'] = self.params['description']
        uploadq['session'] = sessiondata
        uploadq['apix'] = self.params['apix']
        uploadq['boxsize'] = self.params['boxsize']
        uploadq['numimages'] = self.numimages
        uploadq['path'] = appiondata.ApPathData(
            path=os.path.abspath(self.params['rundir']))
        if insert is True:
            uploadq.insert()
Exemplo n.º 2
0
	def checkConflicts(self):
		### make sure the necessary parameters are set
		if self.params['description'] is None:
			apDisplay.printError("enter a template description")
		if self.params['templatestack'] is None and self.params['clusterId'] is None and self.params['alignId'] is None:
			apDisplay.printError("enter a template stack file or a clusterId or an alignId")
		if self.params['templatetype'] is None and self.params['templatetype'] is not "clsavg" and self.params['templatetype'] is not "forward_proj":
			apDisplay.printError("enter the template type (i.e. class averages / forward projections)")
		if self.params['runname'] is None:
			templatestacksq = appiondata.ApTemplateStackData()
			templatestacks = templatestacksq.query()
			num_templatestacks = len(templatestacks)
			new_num = num_templatestacks + 1
			self.params['runname'] = "templatestack"+str(new_num)+"_"+str(self.params['sessionname'])

		### get apix value
		if (self.params['apix'] is None and self.params['clusterId'] is None and self.params['alignId'] is None):
			apDisplay.printError("Enter value for angstroms per pixel")
		elif (self.params['apix'] is None and self.params['clusterId'] is not None or self.params['alignId'] is not None):
			if self.params['clusterId'] is not None:
				clusterdata = appiondata.ApClusteringStackData.direct_query(self.params['clusterId'])
				self.params['apix'] = clusterdata['clusterrun']['pixelsize']
			else:
				aligndata = appiondata.ApAlignStackData.direct_query(self.params['alignId'])
				self.params['apix'] = aligndata['pixelsize']

		### get boxsize if not specified
		if self.params['boxsize'] is None and self.params['templatestack'] is not None:
			emancmd = "iminfo "+self.params['templatestack']
			proc = subprocess.Popen(emancmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			results = proc.stdout
			proc.wait()
			for line in results:
				res = re.search("([0-9]+)x([0-9]+)x([0-9])", line)
				if res:
					num1 = int(res.groups()[0])
					num2 = int(res.groups()[1])
					if num1 == num2:
						self.params['boxsize'] = num1
		elif self.params['boxsize'] is None and self.params['clusterId'] is not None or self.params['alignId'] is not None:
			if self.params['clusterId'] is not None:
				clusterdata = appiondata.ApClusteringStackData.direct_query(self.params['clusterId'])
				self.params['boxsize'] = clusterdata['clusterrun']['boxsize']
			else:
				aligndata = appiondata.ApAlignStackData.direct_query(self.params['alignId'])
				self.params['boxsize'] = aligndata['boxsize']

		### check for session
		if self.params['sessionname'] is None:
			if self.params['clusterId'] is not None:
				clusterdata = appiondata.ApClusteringStackData.direct_query(self.params['clusterId'])
				stackid = clusterdata['clusterrun']['alignstack']['stack'].dbid
				sessiondata = apStack.getSessionDataFromStackId(stackid)
				self.params['sessionname'] = sessiondata['name']	
			elif self.params['alignId'] is not None:
				aligndata = appiondata.ApAlignStackData.direct_query(self.params['alignId'])
				stackid = aligndata['stack'].dbid	
				sessiondata = apStack.getSessionDataFromStackId(stackid)
				self.params['sessionname'] = sessiondata['name']		
			else:
				apDisplay.printError("Could not find session")

		if self.params['templatestack'] is not None:
			self.params['templatestack'] = os.path.abspath(self.params['templatestack'])

		### exclusions and inclusions, if modifying previous stack
		if self.params['clusterId'] is not None or self.params['alignId'] is not None:
			if self.params['first'] is None and self.params['last'] is None:
				if self.params['keepfile'] is None and self.params['exclude'] is None and self.params['include'] is None:
					apDisplay.printError("Please define either keepfile, exclude or include")
				elif self.params['keepfile']:
					self.params['keepfile'] = os.path.abspath(self.params['keepfile'])
					if not os.path.isfile(self.params['keepfile']):
						apDisplay.printError("Could not find keep file: "+self.params['keepfile'])
			if self.params['keepfile'] and (self.params['exclude'] is not None or self.params['include'] is not None):
				apDisplay.printError("Please define only either keepfile, exclude or include")
			if self.params['exclude'] and (self.params['keepfile'] is not None or self.params['include'] is not None):
				apDisplay.printError("Please define only either keepfile, exclude or include")
			if self.params['include'] and (self.params['exclude'] is not None or self.params['keepfile'] is not None):
				apDisplay.printError("Please define only either keepfile, exclude or include")