本文整理汇总了Python中omero.gateway.BlitzGateway.getObjects方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getObjects方法的具体用法?Python BlitzGateway.getObjects怎么用?Python BlitzGateway.getObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.getObjects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_containers
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
def create_containers(self, cli, project, dataset):
"""
Creates containers with names provided if they don't exist already.
Returns Dataset ID.
"""
sessionId = cli._event_context.sessionUuid
conn = BlitzGateway(host='localhost')
conn.connect(sUuid = sessionId)
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
params.theFilter.ownerId = wrap(conn.getUser().getId())
d = None
dsId = None
if project is not None:
# We need to find or create a project
# This is not nice but we really shouldn't be dealing with large numbers of objects here
plist = list(conn.getObjects("Project", attributes={'name': project}, params=params))
if len(plist) == 0:
# Create project and dataset then link
p = self.create_project(conn, project)
d = self.create_dataset(conn, dataset)
dsId = d.id.val
self.link_dataset(conn, p.id.val, dsId)
else:
# Pick the first, it's as good as any
p = plist[0]
print "Using existing Project:", project
# Since Project already exists check children for dataset
for c in p.listChildren():
if c.getName() == dataset:
d = c
dsId = d.getId()
# No existing child dataset so create one and link
if d is None:
d = self.create_dataset(conn, dataset)
dsId = d.id.val
self.link_dataset(conn, p.getId(), dsId)
else:
print "Using existing Dataset:", dataset
else:
# There may be more than one dataset with the same name
# This is not nice but we really shouldn't be dealing with large numbers of objects here
dlist = list(conn.getObjects("Dataset", attributes={'name': dataset}, params=params))
if len(dlist) != 0:
# We want one without a parent, the first will do
for c in dlist:
if len(c.listParents()) == 0:
d = c
dsId = d.getId()
if d is None:
dsId = self.create_dataset(conn, dataset).id.val
else:
print "Using existing Dataset:", dataset
return dsId
示例2: processImages
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
def processImages(client, scriptParams):
message = ''
# for params with default values, we can get the value directly
dataType = scriptParams['Data_Type']
ids = scriptParams['IDs']
# Get the datasets
conn = BlitzGateway(client_obj = client)
objects, logMessage = script_utils.getObjects(conn, scriptParams)
message += logMessage
if not objects:
return message
datasets = conn.getObjects(dataType, ids)
good, chNames, msg = checkChannels(datasets)
message += msg
if not good:
raise omero.ServerError(
'Channel check failed, ' +
'all images must have the same channels: %s' % message)
return message
示例3: create_screen
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
def create_screen(self, cli, screen):
"""
Creates screen with name provided if it doesn't exist already.
Returns Screen ID.
"""
sessionId = cli._event_context.sessionUuid
conn = BlitzGateway(host='localhost')
conn.connect(sUuid = sessionId)
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
params.theFilter.ownerId = wrap(conn.getUser().getId())
slist = list(conn.getObjects("Screen", attributes={'name': screen}, params=params))
if len(slist) == 0:
print "Creating Screen:", screen
s = ScreenI()
s.name = wrap(screen.encode('ascii','ignore'))
scrId = conn.getUpdateService().saveAndReturnObject(s).id.val
else:
scrId = slist[0].getId()
print "Using Screen:", screen
return scrId
示例4: print_obj
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
print_obj(dataset, 2)
for image in dataset.listChildren():
print_obj(image, 4)
# Retrieve the datasets owned by the user currently logged in
# ===========================================================
# Here we create an omero.sys.ParametersI instance which we
# can use to filter the results that are returned. If we did
# not pass the params argument to getObjects, then all Datasets
# in the current group would be returned.
print "\nList Datasets:"
print "=" * 50
params = omero.sys.ParametersI()
params.exp(conn.getUser().getId()) # only show current user's Datasets
datasets = conn.getObjects("Dataset", params=params)
for dataset in datasets:
print_obj(dataset)
# Retrieve the images contained in a dataset
# ==========================================
print "\nDataset:%s" % datasetId
print "=" * 50
dataset = conn.getObject("Dataset", datasetId)
print "\nImages in Dataset:", dataset.getName()
for image in dataset.listChildren():
print_obj(image)
# Retrieve an image by ID
示例5: BlitzGateway
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
conn = BlitzGateway('root', 'omero', host='localhost')
conn.connect()
conn.SERVICE_OPTS.setOmeroGroup(-1)
# ---- CONFIGURATION ----
TAG_COUNT = 1 # Number of tags each user should use (link)
TAG_TARGETS = ['Project', 'Dataset', 'Image', "Screen", "Plate"]
ROI_COUNT = 3
allUsers = []
for exp in conn.getObjects("Experimenter"):
n = exp.getName()
if n not in ["root", "guest"]:
print n
allUsers.append(exp)
def addRect(roi, x=10, y=10, w=100, h=50, theZ=0, theT=0, label=None):
""" create and save a rectangle shape, add it to roi """
rect = omero.model.RectI()
rect.x = rdouble(x)
rect.y = rdouble(y)
rect.width = rdouble(w)
rect.height = rdouble(h)
if theZ is not None:
rect.theZ = rint(theZ)
示例6: TableConnection
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
class TableConnection(object):
"""
A basic client-side wrapper for OMERO.tables which handles opening
and closing tables.
"""
def __init__(self, user = None, passwd = None, host = 'localhost',
client = None, tableName = None, tableId = None):
"""
Create a new table handler, either by specifying user and passwd or by
providing a client object (for scripts)
@param user Username
@param passwd Password
@param host The server hostname
@param client Client object with an active session
@param tableName The name of the table file
@param tableId The OriginalFile ID of the table file
"""
if not client:
client = omero.client(host)
sess = client.createSession(user, passwd)
client.enableKeepAlive(60)
else:
sess = client.getSession()
self.conn = BlitzGateway(client_obj = client)
self.res = sess.sharedResources()
if (not self.res.areTablesEnabled()):
raise TableConnectionError('OMERO.tables not enabled')
repos = self.res.repositories()
self.rid = repos.descriptions[0].id.val
self.tableName = tableName
self.tableId = tableId
self.table = None
def __enter__(self):
print 'Entering Connection'
return self
def __exit__(self, type, value, traceback):
print 'Exiting Connection'
self.close()
def close(self):
print 'Closing Connection'
try:
self.closeTable()
finally:
self.conn._closeSession()
def openTable(self, tableId = None, tableName = None):
"""
Opens an existing table by ID or name.
If there are multiple tables with the same name this throws an error
(should really use an annotation to keep track of this).
If tableId is supplied it will be used in preference to tableName
@param tableName The name of the table file
@param tableId The OriginalFile ID of the table file
@return handle to the table
"""
if not tableId and not tableName:
tableId = self.tableId
tableName = self.tableName
if not tableId:
if not tableName:
tableName = self.tableName
attrs = {'name': tableName}
ofiles = list(
self.conn.getObjects("OriginalFile", attributes = attrs))
if len(ofiles) > 1:
raise TableConnectionError(
'Multiple tables with name:%s found' % tableName)
if not ofiles:
raise TableConnectionError(
'No table found with name:%s' % tableName)
ofile = ofiles[0]
else:
attrs = {'id': long(tableId)}
if tableName:
attrs['name'] = tableName
ofile = self.conn.getObject("OriginalFile", attributes = attrs)
if not ofile:
raise TableConnectionError('No table found with name:%s id:%s' %
(tableName, tableId))
if self.tableId == ofile.getId():
print 'Using existing connection to table name:%s id:%d' % \
(tableName, tableId)
else:
self.closeTable()
self.table = self.res.openTable(ofile._obj)
self.tableId = ofile.getId()
print 'Opened table name:%s id:%d' % (tableName, self.tableId)
#.........这里部分代码省略.........
示例7: print_obj
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
def print_obj(obj, indent=0):
"""
Helper method to display info about OMERO objects.
Not all objects will have a "name" or owner field.
"""
print >> sys.stderr, """%s%s:%s Name:"%s" (owner=%s)""" % (\
" " * indent,
obj.OMERO_CLASS,\
obj.getId(),\
obj.getName(),\
obj.getOwnerOmeName())
conn.SERVICE_OPTS.setOmeroGroup('-1')
# Retrieve a list of all projects owned by user:
# =================================================================
print "\nList Projects:"
print "=" * 50
for project in conn.getObjects("Project"):
print_obj(project)
for dataset in project.listChildren():
print_obj(dataset, 2)
datasetId = dataset.getId()
# Close connection:
# =================================================================
# When you're done, close the session to free up server resources.
conn._closeSession()
示例8: list
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
# Create Tags
# =================================================================
object_array = list()
for i in xrange(3):
tag = omero.model.TagAnnotationI()
tag.setTextValue(rstring(tag_name))
tag.setDescription(rstring("%s %i" % (tag_name, i)))
object_array.append(tag)
conn.getUpdateService().saveArray(object_array)
# Find the datasets by name.
# =================================================================
datasets = conn.getObjects("Dataset", attributes={'name': dataset_name})
print "\nList Datasets:"
for d in datasets:
print "ID:", d.getId(), "Name:", d.getName()
# Find the tag by textValue
# =================================================================
Tags = conn.getObjects("TagAnnotation", attributes={'textValue': tag_name})
print "\nList Tags:"
for t in Tags:
print "ID:", t.getId(), "Text:", t.getTextValue(), "Desc:", t.getDescription()
# Close connection:
# =================================================================
示例9: xrange
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObjects [as 别名]
Helper method to display info about OMERO objects.
Not all objects will have a "name" or owner field.
"""
# print >> sys.stderr, """%s%s:%s Name:"%s" (owner=%s)""" % (\
# " " * indent,
# obj.OMERO_CLASS,\
# obj.getId(),\
# obj.getName(),\
# obj.getOwnerOmeName())
# Retrieve Screening data:
# =================================================================
conn.SERVICE_OPTS.setOmeroGroup('-1') ### Set the group to search within. -1 for all groups.
print "ScreenID,Screen Name,PlateID,Plate Name,Image,ImageID"
for screen in conn.getObjects("Screen"):
print_obj(screen)
for plate in screen.listChildren():
print_obj(plate, 5)
plateId = plate.getId()
for well in plate.listChildren():
index = well.countWellSample()
for index in xrange(0, index):
print ",".join(map(str, [\
screen.getId(),\
screen.getName(),\
plateId, '"' + \
plate.getName(),\
well.getImage(index).getName() + '"',\
well.getImage(index).getId()]))