本文整理汇总了Python中omero.gateway.BlitzGateway.getObject方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getObject方法的具体用法?Python BlitzGateway.getObject怎么用?Python BlitzGateway.getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_canDoAction
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def test_canDoAction(self, func):
"""
Test if canEdit returns appropriate flag
"""
client, user = self.new_client_and_user()
image = self.make_image()
share_id = self.create_share(
objects=[image], description="description", experimenters=[user])
share = self.sf.getShareService()
assert len(share.getContents(share_id)) == 1
# test action by member
user_conn = BlitzGateway(client_obj=client)
# user CANNOT see image if not in share
assert None == user_conn.getObject("Image", image.id.val)
# activate share
user_conn.SERVICE_OPTS.setOmeroShare(share_id)
assert False == getattr(user_conn.getObject("Image",
image.id.val), func)()
# test action by owner
owner_conn = BlitzGateway(client_obj=self.client)
# owner CAN do action on the object when not in share
assert True == getattr(owner_conn.getObject("Image",
image.id.val), func)()
# activate share
owner_conn.SERVICE_OPTS.setOmeroShare(share_id)
# owner CANNOT do action on the object when in share
assert False == getattr(owner_conn.getObject("Image",
image.id.val), func)()
示例2: testFakeImport
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def testFakeImport(self):
# TODO: should likely be in the "fs" namespace
req = omero.cmd.OriginalMetadataRequest()
client = self.new_client()
rsp = self.fullImport(client) # Note: fake test produces no metadata!
image = rsp.objects[0]
req.imageId = image.id.val
gateway = BlitzGateway(client_obj=client)
# Load via the gateway
image = gateway.getObject("Image", image.id.val)
assert 3 == len(image.loadOriginalMetadata())
# Load via raw request
handle = client.sf.submit(req)
try:
gateway._waitOnCmd(handle, failonerror=True)
rsp = handle.getResponse()
assert dict == type(rsp.globalMetadata)
assert dict == type(rsp.seriesMetadata)
finally:
handle.close()
示例3: main
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def main(argv):
parser = make_parser()
args = parser.parse_args(argv[1:])
if not args.out_file:
args.out_file = "map_screen_%d.tsv" % args.screen_id
passwd = getpass.getpass()
conn = BlitzGateway(
args.user, passwd, host=args.host, port=args.port, group=args.group
)
conn.connect()
screen = conn.getObject("Screen", args.screen_id)
print "writing to %s" % args.out_file
print "SCREEN: %s" % screen.name
with open(args.out_file, "w") as fo:
fo.write("PLATE\tSERIES\tWELL\tFIELD\tImageID\tWellID\n")
for p in screen.listChildren():
rows = []
print " plate: %s" % p.name
for w in p.listChildren():
n_fields = sum(1 for _ in w.listChildren())
for i in xrange(n_fields):
img = w.getImage(i)
well_tag = "%s%02d" % (LETTERS[w.row], w.column + 1)
rows.append((
p.name, img.getSeries(), well_tag, i + 1, img.id, w.id
))
rows.sort(key=itemgetter(1))
rows.sort()
for r in rows:
fo.write("%s\t%d\t%s\t%d\t%d\t%d\n" % r)
示例4: create_containers
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def create_containers(cli, dataset, project=None):
"""
Creates containers with names provided if they don't exist already.
Returns Dataset ID.
"""
sessionId = cli._event_context.sessionUuid
conn = BlitzGateway()
conn.connect(sUuid = sessionId)
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
params.theFilter.ownerId = wrap(conn.getUser().getId())
d = None
prId = None
if project is not None:
p = conn.getObject("Project", attributes={'name': project}, params=params)
if p is None:
print "Creating Project:", project
p = omero.model.ProjectI()
p.name = wrap(project)
prId = conn.getUpdateService().saveAndReturnObject(p).id.val
else:
print "Using Project:", project, p
prId = p.getId()
# Since Project already exists, check children for Dataset
for c in p.listChildren():
if c.getName() == dataset:
d = c
if d is None:
d = conn.getObject("Dataset", attributes={'name': dataset}, params=params)
if d is None:
print "Creating Dataset:", dataset
d = omero.model.DatasetI()
d.name = wrap(dataset)
dsId = conn.getUpdateService().saveAndReturnObject(d).id.val
if prId is not None:
print "Linking Project-Dataset..."
link = omero.model.ProjectDatasetLinkI()
link.child = omero.model.DatasetI(dsId, False)
link.parent = omero.model.ProjectI(prId, False)
conn.getUpdateService().saveObject(link)
else:
print "Using Dataset:", dataset, d
dsId = d.getId()
return dsId
示例5: test_chgrp_new_container
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def test_chgrp_new_container(self, dataset, credentials):
"""
Performs a chgrp POST, polls the activities json till done,
then checks that Dataset has moved to new group and has new
Project as parent.
"""
django_client = self.get_django_client(credentials)
request_url = reverse('chgrp')
projectName = "chgrp-project%s" % (self.uuid())
data = {
"group_id": self.group2.id.val,
"Dataset": dataset.id.val,
"new_container_name": projectName,
"new_container_type": "project",
}
data = _csrf_post_response_json(django_client, request_url, data)
expected = {"update": {"childless": {"project": [],
"orphaned": False,
"dataset": []},
"remove": {"project": [],
"plate": [],
"screen": [],
"image": [],
"dataset": [dataset.id.val]}}}
assert data == expected
activities_url = reverse('activities_json')
data = _get_response_json(django_client, activities_url, {})
# Keep polling activities until no jobs in progress
while data['inprogress'] > 0:
time.sleep(0.5)
data = _get_response_json(django_client, activities_url, {})
# individual activities/jobs are returned as dicts within json data
for k, o in data.items():
if hasattr(o, 'values'): # a dict
if 'report' in o:
print o['report']
assert o['status'] == 'finished'
assert o['job_name'] == 'Change group'
assert o['to_group_id'] == self.group2.id.val
# Dataset should now be in new group, contained in new Project
conn = BlitzGateway(client_obj=self.client)
userId = conn.getUserId()
conn.SERVICE_OPTS.setOmeroGroup('-1')
d = conn.getObject("Dataset", dataset.id.val)
assert d is not None
assert d.getDetails().group.id.val == self.group2.id.val
p = d.getParent()
assert p is not None
assert p.getName() == projectName
# Project owner should be current user
assert p.getDetails().owner.id.val == userId
示例6: ls
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def ls(self, args):
"""List all the original files contained in a fileset"""
client = self.ctx.conn(args)
gateway = BlitzGateway(client_obj=client)
gateway.SERVICE_OPTS.setOmeroGroup("-1")
fileset = gateway.getObject("Fileset", args.fileset.id.val)
defaultdict(list)
for ofile in fileset.listFiles():
print ofile.path + ofile.name
示例7: setup_method
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def setup_method(self, method):
super(MetadataTestBase, self).setup_method(method)
self.name = self.uuid()
self.image = self.importSingleImage(
GlobalMetadata={'gmd-' + self.name: 'gmd-' + self.name})
conn = BlitzGateway(client_obj=self.client)
self.imageid = unwrap(self.image.getId())
assert type(self.imageid) == long
wrapper = conn.getObject("Image", self.imageid)
self.md = Metadata(wrapper)
示例8: check_file_annotation
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def check_file_annotation(client, file_annotation,
parent_type="Image", link_count=0):
"""
Check validity of file annotation. If hasFileAnnotation, check the size,
name and number of objects linked to the original file.
"""
assert file_annotation is not None
id = file_annotation.getId().getValue()
assert id > 0
orig_file = file_annotation.getFile()
assert orig_file.getSize().getValue() > 0
assert orig_file.getName().getValue() is not None
conn = BlitzGateway(client_obj=client)
wrapper = conn.getObject("FileAnnotation", id)
links = sum(1 for i in wrapper.getParentLinks(parent_type))
conn.close()
assert links == link_count
示例9: checkFileAnnotation
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def checkFileAnnotation(self, fileAnnotation, hasFileAnnotation=True, parentType="Image", isLinked=True, client=None):
"""
Check validity of file annotation. If hasFileAnnotation, check the size, name and number of objects linked to the original file.
"""
if hasFileAnnotation:
self.assertNotEqual(fileAnnotation,None)
self.assertTrue(fileAnnotation.val._file._size._val>0)
self.assertNotEqual(fileAnnotation.val._file._name._val,None)
if client is None: client = self.root
conn = BlitzGateway(client_obj = client)
faWrapper = conn.getObject("FileAnnotation", fileAnnotation.val.id.val)
nLinks = sum(1 for i in faWrapper.getParentLinks(parentType))
if isLinked:
self.assertEqual(nLinks,1)
else:
self.assertEqual(nLinks,0)
else:
self.assertEqual(fileAnnotation,None)
示例10: user_exists
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def user_exists(self, user):
if user in self.known_users.keys():
print "User:", user,
return True
try:
try:
conn = BlitzGateway("root", "omero", host='localhost')
conn.connect()
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
u = conn.getObject("Experimenter", attributes={'omeName': user}, params=params)
except:
print "Error getting user - ignoring."
return False
if u is None:
print "User:", user, "does not exist - ignoring."
return False
else:
print "User:", user,
self.known_users[user] = []
return True
finally:
conn.seppuku()
示例11: BlitzGateway
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
# Create a connection
# =================================================================
conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
conn.connect()
# Configuration
# =================================================================
imageId = 101
# Get the 'Fileset' for an Image
# =================================================================
# A Fileset is a collection of the original files imported to
# create an image or set of images in OMERO.
image = conn.getObject("Image", imageId)
fileset = image.getFileset() # will be None for pre-FS images
fsId = fileset.getId()
# List all images that are in this fileset
for fsImage in fileset.copyImages():
print fsImage.getId(), fsImage.getName()
# List original imported files
for origFile in fileset.listFiles():
name = origFile.getName()
path = origFile.getPath()
print path, name
# Get Original Imported Files directly from the image
# =================================================================
# this will include pre-FS data IF images were archived on import
示例12: next
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
sys.exit(1)
else:
print "Login successful.\n"
# Set our default group so we can see the data.
# (I thought I had to do this, but now I am not sure it's needed.
# -JLM 2013/12/04)
try:
group = next(g for g in conn.listGroups() if g.getName() == GROUP)
except StopIteration:
print >> sys.stderr, "Error: could not find group '%s'" % GROUP
conn.setGroupForSession(group.getId())
# Get plate of interest.
# (ID 1552 is "RTK ligands induce differing FOXO3a translocation dynamics")
plate = conn.getObject('Plate', 1552)
# Get list of lists of well objects from the plate.
well_grid = plate.getWellGrid()
# Loop over all wells in the plate.
for (raw_row_num, row) in enumerate(well_grid):
for (raw_col_num, well) in enumerate(row):
# Fix up row and column numbers to match Pat's nomenclature.
row_num = raw_row_num + 1
col_num = raw_col_num + 2
# Construct paths and create output directory. (I dislike this naming
# format but it's what Pat has chosen. -JLM)
output_dir = 'r%dc%d' % (row_num, col_num)
full_output_dir = os.path.join(frame_dir, output_dir)
makedirs_exist_ok(full_output_dir)
# Get image object and a few of its useful attributes.
示例13: test_chgrp_old_container
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def test_chgrp_old_container(self, dataset, credentials):
"""
Tests Admin moving user's Dataset to their Private group and
linking it to an existing Project there.
Bug from https://github.com/openmicroscopy/openmicroscopy/pull/3420
"""
django_client = self.get_django_client(credentials)
# user creates project in their target group
project = ProjectI()
projectName = "chgrp-target-%s" % self.client.getSessionId()
project.name = rstring(projectName)
ctx = {"omero.group": str(self.group2.id.val)}
project = self.sf.getUpdateService().saveAndReturnObject(project, ctx)
request_url = reverse('chgrp')
data = {
"group_id": self.group2.id.val,
"Dataset": dataset.id.val,
"target_id": "project-%s" % project.id.val,
}
data = _csrf_post_response_json(django_client, request_url, data)
expected = {"update": {"childless": {"project": [],
"orphaned": False,
"dataset": []},
"remove": {"project": [],
"plate": [],
"screen": [],
"image": [],
"dataset": [dataset.id.val]}}}
assert data == expected
activities_url = reverse('activities_json')
data = _get_response_json(django_client, activities_url, {})
# Keep polling activities until no jobs in progress
while data['inprogress'] > 0:
time.sleep(0.5)
data = _get_response_json(django_client, activities_url, {})
# individual activities/jobs are returned as dicts within json data
for k, o in data.items():
if hasattr(o, 'values'): # a dict
if 'report' in o:
print o['report']
assert o['status'] == 'finished'
assert o['job_name'] == 'Change group'
assert o['to_group_id'] == self.group2.id.val
# Dataset should now be in new group, contained in Project
conn = BlitzGateway(client_obj=self.client)
userId = conn.getUserId()
conn.SERVICE_OPTS.setOmeroGroup('-1')
d = conn.getObject("Dataset", dataset.id.val)
assert d is not None
assert d.getDetails().group.id.val == self.group2.id.val
p = d.getParent()
assert p is not None
assert p.getName() == projectName
# Project owner should be current user
assert p.getDetails().owner.id.val == userId
assert p.getId() == project.id.val
示例14: BlitzGateway
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
# process the list of args above. Not scrictly necessary, but useful for more complex scripts
scriptParams = {}
for key in client.getInputKeys():
if client.getInput(key):
scriptParams[key] = client.getInput(key, unwrap=True) # unwrap rtypes to String, Integer etc
print scriptParams # handy to have inputs in the std-out log
# wrap client to use the Blitz Gateway
conn = BlitzGateway(client_obj=client)
# do the editing...
editedImgIds = editDescriptions(conn, scriptParams)
# now handle the result, displaying message and returning image if appropriate
if editedImgIds is None:
message = "Script failed. See 'error' or 'info' for more details"
else:
if len(editedImgIds) == 1:
img = conn.getObject("Image", editedImgIds[0]) # image-wrapper
message = "One Image edited: %s" % img.getName()
omeroImage = img._obj # omero.model object
client.setOutput("Edited Image", robject(omeroImage)) # Insight will display 'View' link to image
elif len(editedImgIds) > 1:
message = "%s Images edited" % len(editedImgIds)
else:
message = "No images edited. See 'error' or 'info' for more details"
client.setOutput("Message", rstring(message)) # Insight will display the 'Message' parameter
finally:
client.closeSession()
示例15: copy
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getObject [as 别名]
def copy(client, copy_from, copy_type, copy_to):
gateway = BlitzGateway(client_obj=client)
print gateway.applySettingsToSet(copy_from, copy_type, [copy_to])
gateway.getObject("Image", copy_to).getThumbnail(size=(96,), direct=False)