Skip to content

Commit

Permalink
renamed run to plate_acquisition
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-TBT committed Jun 1, 2024
1 parent 51131d8 commit 0f12dae
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
4 changes: 2 additions & 2 deletions ezomero/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
get_screen_ids,
get_plate_ids,
get_well_ids,
get_run_ids,
get_plate_acquisition_ids,
get_map_annotation_ids,
get_map_annotation,
get_file_annotation_ids,
Expand Down Expand Up @@ -65,7 +65,7 @@
'get_screen_ids',
'get_plate_ids',
'get_well_ids',
'get_run_ids',
'get_plate_acquisition_ids',
'get_map_annotation_ids',
'get_map_annotation',
'get_file_annotation_ids',
Expand Down
54 changes: 29 additions & 25 deletions ezomero/_gets.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None,
dataset: Optional[int] = None,
plate: Optional[int] = None,
well: Optional[int] = None,
run: Optional[int] = None,
plate_acquisition: Optional[int] = None,
across_groups: Optional[bool] = True) -> List[int]:
"""Return a list of image ids based on image container
Expand All @@ -352,8 +352,8 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None,
all images contained in all Wells belonging to the specified Plate.
well : int, optional
ID of Well from which to return image IDs.
run : int, optional
ID of Run from which to return image IDs.
plate_acquisition : int, optional
ID of Plate acquisition from which to return image IDs.
across_groups : bool, optional
Defines cross-group behavior of function - set to
``False`` to disable it.
Expand All @@ -369,8 +369,8 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None,
``ezomero.set_group`` to specify group prior to passing
the `conn` object to this function.
Only one of Project, Dataset, Plate, Well or Run can be specified. If
none of those are specified, orphaned images are returned.
Only one of Project, Dataset, Plate, Well or Plate acquisition can be
specified. If none of those are specified, orphaned images are returned.
Examples
--------
Expand All @@ -383,12 +383,12 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None,
>>> ds_ims = get_image_ids(conn, dataset=448)
"""
arg_counter = 0
for arg in [project, dataset, plate, well, run]:
for arg in [project, dataset, plate, well, plate_acquisition]:
if arg is not None:
arg_counter += 1
if arg_counter > 1:
raise ValueError('Only one of Project/Dataset/Plate/Well/Run'
' can be specified')
raise ValueError('Only one of Project/Dataset/Plate/Well'
'/PlateAcquisition can be specified')

q = conn.getQueryService()
params = Parameters()
Expand Down Expand Up @@ -444,15 +444,15 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None,
params,
conn.SERVICE_OPTS
)
elif run is not None:
if not isinstance(run, int):
raise TypeError('Run ID must be integer')
params.map = {"run": rlong(run)}
elif plate_acquisition is not None:
if not isinstance(plate_acquisition, int):
raise TypeError('Plate acquisition ID must be integer')
params.map = {"plate_acquisition": rlong(plate_acquisition)}
results = q.projection(
"SELECT i.id FROM WellSample ws"
" JOIN ws.image i"
" JOIN ws.plateAcquisition pa"
" WHERE pa.id=:run",
" WHERE pa.id=:plate_acquisition",
params,
conn.SERVICE_OPTS
)
Expand Down Expand Up @@ -731,35 +731,39 @@ def get_well_ids(conn: BlitzGateway, screen: Optional[int] = None,


@do_across_groups
def get_run_ids(conn: BlitzGateway, screen: Optional[int] = None,
plate: Optional[int] = None,
across_groups: Optional[bool] = True) -> List[int]:
"""Return a list of run ids based on a container
def get_plate_acquisition_ids(
conn: BlitzGateway, screen: Optional[int] = None,
plate: Optional[int] = None,
across_groups: Optional[bool] = True
) -> List[int]:
"""Return a list of plate acquisition ids based on a container
Parameters
----------
conn : ``omero.gateway.BlitzGateway`` object
OMERO connection.
screen : int, optional
ID of Screen from which to return run IDs. This will return IDs of
all runs contained in the specified Screen.
ID of Screen from which to return plate acquisition IDs.
This will return IDs of all plate acquisitions contained
in the specified Screen.
plate : int, optional
ID of Plate from which to return run IDs. This will return IDs of
all runs belonging to the specified Plate.
ID of Plate from which to return plate acquisition IDs.
This will return IDs of all plate acquisitions belonging
to the specified Plate.
across_groups : bool, optional
Defines cross-group behavior of function - set to
``False`` to disable it.
Returns
-------
run_ids : list of ints
List of runs IDs contained in the specified container.
plate_acquisition_ids : list of ints
List of plate acquisitions IDs contained in the specified container.
Examples
--------
# Return IDs of all runs from Screen with ID 224:
# Return IDs of all plate acquisitions from Screen with ID 224:
>>> run_ids = get_run_ids(conn, screen=224)
>>> plate_acquisition_ids = get_plate_acquisition_ids(conn, screen=224)
"""
arg_counter = 0
for arg in [screen, plate]:
Expand Down
48 changes: 24 additions & 24 deletions tests/test_gets.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def test_get_image_ids(conn, project_structure, screen_structure,
plate_id = screen_structure[1]
plate2_id = screen_structure[2]
plate3_id = screen_structure[3]
run1_id = screen_structure[4]
run2_id = screen_structure[5]
run3_id = screen_structure[6]
pacq_1_id = screen_structure[4]
pacq_2_id = screen_structure[5]
pacq_3_id = screen_structure[6]
well_id1 = screen_structure[7]
well_im_id1 = screen_structure[8]
well_im_id3 = screen_structure[9]
Expand All @@ -257,13 +257,13 @@ def test_get_image_ids(conn, project_structure, screen_structure,
well_im_ids = ezomero.get_image_ids(conn, well=well_id4)
assert set(well_im_ids) == set([well_im_id6])

# Based on run ID
run_im_ids = ezomero.get_image_ids(conn, run=run1_id)
assert set(run_im_ids) == set([well_im_id1, well_im_id2])
run_im_ids = ezomero.get_image_ids(conn, run=run2_id)
assert set(run_im_ids) == set([well_im_id3, well_im_id4])
run_im_ids = ezomero.get_image_ids(conn, run=run3_id)
assert set(run_im_ids) == set([well_im_id5])
# Based on plateAcquistion ID
pacq_im_ids = ezomero.get_image_ids(conn, plate_acquisition=pacq_1_id)
assert set(pacq_im_ids) == set([well_im_id1, well_im_id2])
pacq_im_ids = ezomero.get_image_ids(conn, plate_acquisition=pacq_2_id)
assert set(pacq_im_ids) == set([well_im_id3, well_im_id4])
pacq_im_ids = ezomero.get_image_ids(conn, plate_acquisition=pacq_3_id)
assert set(pacq_im_ids) == set([well_im_id5])

# Based on plate ID
plate_im_ids = ezomero.get_image_ids(conn, plate=plate_id)
Expand All @@ -290,7 +290,7 @@ def test_get_image_ids(conn, project_structure, screen_structure,
with pytest.raises(TypeError):
_ = ezomero.get_image_ids(conn, well='test')
with pytest.raises(TypeError):
_ = ezomero.get_image_ids(conn, run='test')
_ = ezomero.get_image_ids(conn, plate_acquisition='test')


def test_get_project_ids(conn, project_structure, users_groups):
Expand Down Expand Up @@ -397,32 +397,32 @@ def test_get_well_ids(conn, screen_structure):
assert not bad_ids


def test_get_run_ids(conn, screen_structure):
def test_get_plate_acquisition_ids(conn, screen_structure):

screen_id = screen_structure[0]
plate_id = screen_structure[1]
plate2_id = screen_structure[2]
run_id1 = screen_structure[4]
run_id2 = screen_structure[5]
run_id3 = screen_structure[6]
pacq_id1 = screen_structure[4]
pacq_id2 = screen_structure[5]
pacq_id3 = screen_structure[6]

with pytest.raises(TypeError):
_ = ezomero.get_run_ids(conn, screen='test')
_ = ezomero.get_plate_acquisition_ids(conn, screen='test')
with pytest.raises(TypeError):
_ = ezomero.get_run_ids(conn, plate='test')
_ = ezomero.get_plate_acquisition_ids(conn, plate='test')

# Based on screen ID
screen_run_ids = ezomero.get_run_ids(conn, screen=screen_id)
assert set(screen_run_ids) == set([run_id1, run_id2, run_id3])
screen_pacq_ids = ezomero.get_plate_acquisition_ids(conn, screen=screen_id)
assert set(screen_pacq_ids) == set([pacq_id1, pacq_id2, pacq_id3])

# Based on plate ID
plate_run_ids = ezomero.get_run_ids(conn, plate=plate_id)
assert set(plate_run_ids) == set([run_id1, run_id2])
plate_run_ids = ezomero.get_run_ids(conn, plate=plate2_id)
assert set(plate_run_ids) == set([run_id3])
plate_pacq_ids = ezomero.get_plate_acquisition_ids(conn, plate=plate_id)
assert set(plate_pacq_ids) == set([pacq_id1, pacq_id2])
plate_pacq_ids = ezomero.get_plate_acquisition_ids(conn, plate=plate2_id)
assert set(plate_pacq_ids) == set([pacq_id3])

# Return nothing on bad input
bad_ids = ezomero.get_run_ids(conn, screen=999999)
bad_ids = ezomero.get_plate_acquisition_ids(conn, screen=999999)
assert not bad_ids


Expand Down

0 comments on commit 0f12dae

Please sign in to comment.