Exemplo n.º 1
0
 def getEMGrid(self, gridname):
     if self.projectid is not None:
         emgridq = leginondata.EMGridData(project=self.projectid,
                                          name=gridname)
     else:
         emgridq = leginondata.EMGridData(name=gridname)
     results = emgridq.query(results=1)
     if results:
         return results[0]
     else:
         return None
Exemplo n.º 2
0
 def getGridNames(self):
     gridnames = []
     if self.projectid is not None:
         emgridq = leginondata.EMGridData(project=self.projectid)
     else:
         emgridq = leginondata.EMGridData()
     results = emgridq.query()
     if results:
         for result in results:
             newname = result['name']
             if newname not in gridnames:
                 gridnames.append(newname)
             else:
                 self.logger.warning(
                     'Duplicated grid name "%s" not included' % newname)
     return gridnames
    def publishImageData(self, imagedata, save):
        acquisitionimagedata = leginondata.AcquisitionImageData(
            initializer=imagedata)
        if save:
            griddata = leginondata.GridData()
            if self.grid is not None:
                gridinfo = self.gridmapping[self.grid]
                griddata['grid ID'] = gridinfo['gridId']
                emgriddata = leginondata.EMGridData(
                    name=gridinfo['label'], project=gridinfo['projectId'])
                griddata['emgrid'] = emgriddata
                griddata['insertion'] = self.insertion
                acquisitionimagedata['grid'] = griddata
                self.gridlabel = gridlabeler.getGridLabel(griddata)
            elif self.emgrid is not None:
                # New style that uses emgridata only for grid entry
                griddata['emgrid'] = self.emgrid
                griddata['insertion'] = self.insertion
                acquisitionimagedata['grid'] = griddata
            else:
                self.gridlabel = ''
            acquisitionimagedata['label'] = self.settings['image label']

            self.setImageFilename(acquisitionimagedata)
            acquisitionimagedata.attachPixelSize()

            try:
                self.publish(imagedata['scope'], database=True)
                self.publish(imagedata['camera'], database=True)
                self.publish(acquisitionimagedata, database=True)
            except RuntimeError:
                raise node.PublishError

        ## publish event even if no save
        self.publish(acquisitionimagedata, pubevent=True)
Exemplo n.º 4
0
 def getGridMakingPrintTrialNumber(self):
     q = leginondata.EMGridData(project=self.projectid, plate=self.plate)
     r = q.query()
     if r:
         trials = map((lambda x: x['print trial']), r)
         return max(trials) + 1
     else:
         return 1
Exemplo n.º 5
0
 def publishNewEMGrid(self, newgrid):
     emgridq = leginondata.EMGridData()
     emgridq['name'] = newgrid
     emgridq['project'] = self.projectid
     try:
         self.publish(emgridq, database=True)
     except node.PublishError:
         raise
     self.settings['grid name'] = newgrid
     self.logger.info('new grid inserted into the database')
Exemplo n.º 6
0
    def makeGrid(self, grid_index=0):
        '''
		make grid at given grid_index and print trial number.
		Filenaming: p stands for print trial number. g is well group
		in the database. known to users as grid number
		'''
        grid_number = int(grid_index) + 1
        gridname = self.plate['name'] + 'p%dg%d' % (self.trial_number,
                                                    grid_number)
        q = leginondata.EMGridData(project=self.projectid,
                                   mapping=self.maptype,
                                   plate=self.plate)
        q['well group'] = grid_number
        q['print trial'] = self.trial_number
        q['name'] = gridname
        q.insert()
        return q
Exemplo n.º 7
0
		gridlocations = projectdata.getGridLocations()
		gridboxidindex = gridlocations.Index(['gridboxId'])
		gridlocations = gridboxidindex[gridboxid].fetchall()
		for gridlocation in gridlocations:
			if gridlocation['location'] == gridnumber:
				return gridlocation['gridId']
		return self.newGrid(gridboxid, gridnumber)

	def publishEMGridData(self,gridid):
		try:
			projectdata = project.ProjectData()
		except project.NotConnectedError, e:
			self.logger.error('Failed to get grid labels: %s' % e)
			return None
		gridinfo = projectdata.getGridInfo(gridid)
		emgriddata = leginondata.EMGridData()
		emgriddata['name'] = gridinfo['label']
		emgriddata['project'] = gridinfo['projectId']
		self.publish(emgriddata, database=True)
		return emgriddata

	def makeGridData(self, gridnumber):
		gridid = self.getGridID(self.gridtrayid, gridnumber)
		if gridid is None:
			return None
		emgriddata = self.publishEMGridData(gridid)
		initializer = {'grid ID': gridid}
		querydata = leginondata.GridData(initializer=initializer)
		griddatalist = self.research(querydata)
		insertion = 0
		for griddata in griddatalist: