Skip to content

Instantly share code, notes, and snippets.

@atarkowska
Last active August 23, 2016 15:28
Show Gist options
  • Save atarkowska/a2b38c50cc5830aaec455f9e8e658279 to your computer and use it in GitHub Desktop.
Save atarkowska/a2b38c50cc5830aaec455f9e8e658279 to your computer and use it in GitHub Desktop.
mapr hql script
import omero
from omero.rtypes import *
host = "localhost"
port = 4064
userpass = "ome"
user = "demo"
c = omero.client(host=host, port=port)
s = c.createSession(user, userpass)
expId = 2 #s.getAdminService().getEventContext().userId
sql = """
select count( distinct mv.value) as childCount
from ImageAnnotationLink ial join ial.child a join a.mapValue mv
join ial.parent i join i.datasetLinks dsl
join dsl.parent ds join ds.projectLinks pl join pl.parent p
where mv.name in (:filter) and a.ns in (:ns) and mv.value = :value
"""
p = omero.sys.ParametersI()
p.addString("ns", "openmicroscopy.org/omero/bulk_annotations")
p.addId(expId)
p.add("filter", rlist([rstring("Gene Symbol")]))
p.addString("value", "KIF11")
query = s.getQueryService()
rv = query.projection(sql, p)
rv = unwrap(rv)
print rv[0][0]
s.closeOnDestroy()
c.closeSession()
c.__del__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment