Skip to content

Instantly share code, notes, and snippets.

@atarkowska
Created March 15, 2016 16:13
Show Gist options
  • Save atarkowska/d636a7e788d0634c1c32 to your computer and use it in GitHub Desktop.
Save atarkowska/d636a7e788d0634c1c32 to your computer and use it in GitHub Desktop.
Load all genes
import omero
import omero.gateway
import time, datetime
from omero.rtypes import *
host = "localhost"
port = 4064
passwd = "SECRET"
user = "USER"
c = omero.client(host=host, port=port)
s = c.createSession(user, passwd)
expId = s.getAdminService().getEventContext().userId
query = s.getQueryService()
sql = """
select new map(mv.value as value,
a.ns as ns,
count(distinct s.id) as childCount,
count(distinct i.id) as imgCount)
from ImageAnnotationLink ial join ial.child a join a.mapValue mv
join ial.parent i join i.wellSamples ws join ws.well w
join w.plate p join p.screenLinks sl join sl.parent s
where mv.name in (:filter)
and a.ns = :ns
and a.details.owner.id = :id
group by mv.value, a.ns
order by count(i.id) DESC
"""
page = 1
limit = 10
p = omero.sys.ParametersI()
p.addString("ns", "openmicroscopy.org/omero/bulk_annotations")
p.add("filter", rlist([rstring("Gene Symbol")]))
p.addId(expId)
#p.page((page-1) * limit, limit)
import time
start = time.time()
rv = query.projection(sql, p)
rv = unwrap(rv)
print 'It took', time.time()-start, 'seconds.'
print len(rv)
#for row in rv:
# print row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment