本文整理汇总了Python中omero.gateway.BlitzGateway.getQueryService方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getQueryService方法的具体用法?Python BlitzGateway.getQueryService怎么用?Python BlitzGateway.getQueryService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.getQueryService方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Omg
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getQueryService [as 别名]
#.........这里部分代码省略.........
"""
downloads = []
wdir = os.getcwd()
proj_name = self.conn.getObject("Project", project_id).getName()
proj_path = os.path.join(wdir, proj_name + "_P" + str(project_id))
os.mkdir(proj_path)
os.chdir(proj_path)
for dset_id, dset_name in self._ls_datasets(project_id):
downloads.extend(self.dget(dset_id))
os.chdir(wdir)
return downloads
def put(self, filename, name=None, dataset=None):
"""
Import filename using OMERO CLI, optionally with a specified name
to a specified dataset (dataset_id).
Return : OMERO image Id
"""
cli = omero.cli.CLI()
cli.loadplugins()
import_args = ["import"]
import_args.extend(["-s", str(self._server)])
import_args.extend(["-k", str(self._key)])
if dataset is not None:
import_args.extend(["-d", str(dataset)])
if name is not None:
import_args.extend(["-n", str(name)])
clio = "cli.out"
clie = "cli.err"
import_args.extend(["---errs=" + clie, "---file=" + clio, "--"])
import_args.append(filename)
cli.invoke(import_args, strict=True)
pix_id = int(open(clio, 'r').read().rstrip())
im_id = self.conn.getQueryService().get("Pixels", pix_id).image.id.val
os.remove(clio)
os.remove(clie)
return im_id
def describe(self, im_id, description):
"""
Append to image description.
"""
img = self.conn.getObject("Image", oid=im_id)
old_description = img.getDescription() or ""
img.setDescription(old_description + "\n" + description)
img.save()
def attach(self, im_id, attachments):
"""
Attach a list of files to an image.
"""
img = self.conn.getObject("Image", oid=im_id)
for attachment in attachments.split():
fann = self.conn.createFileAnnfromLocalFile(attachment)
img.linkAnnotation(fann)
img.save()
# TODO: ls_tags() and tag() methods?
def mkp(self, project_name, description=None):
"""
Make new OMERO project in current group, returning the new project Id.
"""
# see: omero/lib/python/omeroweb/webclient/controller/container.py
proj = omero.model.ProjectI()
proj.name = omero.rtypes.rstring(str(project_name))
示例2: enumerate
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getQueryService [as 别名]
colors = []
for ch in image.getChannels():
cNames.append(ch.getLabel())
colors.append(ch.getColor().getRGB())
# Save channel names and colors
# =================================================================
print "Applying channel Names:", cNames, " Colors:", colors
for i, c in enumerate(newImg.getChannels()):
lc = c.getLogicalChannel()
lc.setName(cNames[i])
lc.save()
r, g, b = colors[i]
# need to reload channels to avoid optimistic lock on update
cObj = conn.getQueryService().get("Channel", c.id)
cObj.red = rint(r)
cObj.green = rint(g)
cObj.blue = rint(b)
cObj.alpha = rint(255)
conn.getUpdateService().saveObject(cObj)
newImg.resetRDefs() # reset based on colors above
# Apply pixel sizes from original image
# =================================================================
newPix = conn.getQueryService().get("Pixels", newImg.getPixelsId())
physicalSizeX = pixels.getPhysicalSizeX()
if physicalSizeX is not None:
newPix.setPhysicalSizeX(rdouble(physicalSizeX))
示例3: run
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getQueryService [as 别名]
def run():
"""
"""
dataTypes = [rstring("Plate")]
client = scripts.client(
"Manage_Plate_Acquisitions.py",
"Add or remove PlateAcquisition(s) in a given Plate",
scripts.String("Data_Type", optional=False, grouping="1",
description="The data type you want to work with.",
values=dataTypes,
default="Plate"),
scripts.List("IDs", optional=False, grouping="2",
description="List of Plate IDs").ofType(rlong(0)),
scripts.String("Mode", optional=False, grouping="3",
description="Select if you want to add or "
"remove PlateAcquisitions",
values=[rstring("Add"), rstring("Remove")],
default="Add"),
version="0.2",
authors=["Niko Klaric"],
institutions=["Glencoe Software Inc."],
contact="[email protected]",
)
try:
scriptParams = {}
for key in client.getInputKeys():
if client.getInput(key):
scriptParams[key] = client.getInput(key, unwrap=True)
connection = BlitzGateway(client_obj=client)
updateService = connection.getUpdateService()
queryService = connection.getQueryService()
processedMessages = []
for plateId in scriptParams["IDs"]:
plateObj = connection.getObject("Plate", plateId)
if plateObj is None:
client.setOutput(
"Message",
rstring("ERROR: No Plate with ID %s" % plateId))
return
if scriptParams["Mode"] == "Add":
plateAcquisitionObj = PlateAcquisitionI()
plateAcquisitionObj.setPlate(PlateI(plateObj.getId(), False))
wellGrid = plateObj.getWellGrid()
for axis in wellGrid:
for wellObj in axis:
wellSampleList = wellObj.copyWellSamples()
plateAcquisitionObj.addAllWellSampleSet(wellSampleList)
plateAcquisitionObj = updateService.saveAndReturnObject(
plateAcquisitionObj)
plateAcquisitionId = plateAcquisitionObj.getId()._val
processedMessages.append(
"Linked new PlateAcquisition with ID %d"
" to Plate with ID %d." % (plateAcquisitionId, plateId))
else:
params = ParametersI()
params.addId(plateId)
queryString = """
FROM PlateAcquisition AS pa
LEFT JOIN FETCH pa.wellSample
LEFT OUTER JOIN FETCH pa.annotationLinks
WHERE pa.plate.id = :id
"""
plateAcquisitionList = queryService.findAllByQuery(
queryString, params, connection.SERVICE_OPTS)
if plateAcquisitionList:
updateList = []
for plate_acquisition in plateAcquisitionList:
for well_sample in plate_acquisition.copyWellSample():
well_sample.setPlateAcquisition(None)
updateList.append(well_sample)
updateService.saveArray(updateList)
plate_acquisition.clearWellSample()
plate_acquisition.clearAnnotationLinks()
plate_acquisition = updateService.saveAndReturnObject(
plate_acquisition)
updateService.deleteObject(plate_acquisition)
processedMessages.append(
"%d PlateAcquisition(s) removed from Plate with ID %d." %
(len(plateAcquisitionList), plateId))
client.setOutput("Message", rstring("No errors. %s" %
#.........这里部分代码省略.........
示例4: BlitzGateway
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getQueryService [as 别名]
HOST = config.get('OMERODetails', 'host')
PORT = config.getint('OMERODetails', 'port')
USERNAME = config.get('OMERODetails', 'username')
PASSWORD = config.get('OMERODetails', 'password')
conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT)
connected = conn.connect()
if not connected:
import sys
sys.stderr.write("Error: Connection not available, please check your user name and password.\n")
sys.exit(1)
session = conn.getSession()
queryService = conn.getQueryService()
params = Parameters()
ldapSearch = LDAPSearch(ldap_details)
# Check users
query = "from Experimenter"
experimenters = queryService.findAllByQuery(query, params)
print('Experimenters')
for experimenter in experimenters:
output = '%s' %experimenter.omeName.getValue()
if experimenter.email and experimenter.email.getValue().strip() != '':
output = output + ', %s ' %experimenter.email.getValue()
if len(ldapSearch.userSearch(experimenter.omeName.getValue())) == 1: