Skip to content

Commit

Permalink
offset WellSample index for plateAcq
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-TBT committed Mar 13, 2024
1 parent 46b2b8d commit 6338985
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
17 changes: 17 additions & 0 deletions omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,23 @@ def load_plate(request, o1_type=None, o1_id=None, conn=None, **kwargs):
template = None
if "plate" in kw or "acquisition" in kw:
fields = manager.getNumberOfFields()
if "acquisition" in kw:
# need to offset the index for 0-indexing at acquisition level
qs = conn.getQueryService()
p = omero.sys.ParametersI()
p.add("acqid", rlong(o1_id))
query = (
"SELECT max(index(ws)) - min(index(ws)) "
"FROM Well w "
"JOIN w.wellSamples ws "
"WHERE ws.plateAcquisition.id = :acqid "
"GROUP BY w.id"
)
res = [r[0].getValue() for r in qs.projection(query, p, conn.SERVICE_OPTS)]
if len(res) >= 1:
# The range of the fields is set for the current acquisition
fields = (0, max(res))

if fields is not None:
form_well_index = WellIndexForm(initial={"index": index, "range": fields})
if index == 0:
Expand Down
20 changes: 17 additions & 3 deletions omeroweb/webgateway/plategrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ class PlateGrid(object):
methods useful for displaying the contents of the plate as a grid.
"""

def __init__(self, conn, pid, fid, acqid, thumbprefix="", plate_layout=None):
def __init__(self, conn, pid, fid, thumbprefix="", plate_layout=None, acqid=0):
"""
Constructor
param: plate_layout is "expand" to expand plate to multiple of 8 x 12
or "shrink" to ignore all wells before the first row/column
acqid: the acquisition ID. Using it, the field index (fid) must
be in the range [0, max_sample_per_well] for that acquisition.
"""
self.plate = conn.getObject("plate", int(pid))
self._conn = conn
Expand Down Expand Up @@ -58,11 +61,22 @@ def metadata(self):
"join ws.image img "
"join img.details.owner author "
"where well.plate.id = :id "
"and index(ws) = :wsidx"
)
if self.acquisition > 0:
# Offseting index per well for the plateacquisition
query += (
"and ws.plateAcquisition.id = :acqid "
"and index(ws) - ("
" SELECT MIN(index(ws_inner)) "
" FROM Well well_inner "
" JOIN well_inner.wellSamples ws_inner "
" WHERE ws_inner.plateAcquisition.id = :acqid "
" AND well_inner.id = well.id "
") = :wsidx "
)
params.add("acqid", rlong(self.acquisition))
query += " and ws.plateAcquisition.id = :acqid"
else:
query += "and index(ws) = :wsidx "

results = q.projection(query, params, self._conn.SERVICE_OPTS)
min_row = 0
Expand Down
2 changes: 1 addition & 1 deletion omeroweb/webgateway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,9 @@ def get_thumb_url(iid):
conn,
pid,
field,
acquisition,
thumbprefix=kwargs.get("urlprefix", get_thumb_url),
plate_layout=layout,
acqid=acquisition
)

plate = plateGrid.plate
Expand Down

0 comments on commit 6338985

Please sign in to comment.