From 1870d8508f9fc5eb3b1e4f8a1714b4930817c3a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Mar 2024 09:55:02 +0100 Subject: [PATCH 1/5] get by annotation id image/dataset/project --- ezomero/_gets.py | 81 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/ezomero/_gets.py b/ezomero/_gets.py index 2131e3b..ad8acbb 100644 --- a/ezomero/_gets.py +++ b/ezomero/_gets.py @@ -332,6 +332,7 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None, dataset: Optional[int] = None, plate: Optional[int] = None, well: Optional[int] = None, + annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list of image ids based on image container @@ -351,6 +352,9 @@ 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. + annotation : int, optional + ID of Annotation from which to return image IDs. This will return IDs + of all images linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -366,8 +370,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, or Well can be specified. If none of - those are specified, orphaned images are returned. + Only one of Project, Dataset, Plate, Well or Annotation can be specified. + If none of those are specified, orphaned images are returned. Examples -------- @@ -378,13 +382,17 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None, # Return IDs of all images from Dataset with ID 448: >>> ds_ims = get_image_ids(conn, dataset=448) + + # Return IDs of all images annotated with Tag ID 876: + + >>> tag_ims = get_image_ids(conn, annotation=876) """ arg_counter = 0 - for arg in [project, dataset, plate, well]: + for arg in [project, dataset, plate, well, annotation]: if arg is not None: arg_counter += 1 if arg_counter > 1: - raise ValueError('Only one of Project/Dataset/Plate/Well' + raise ValueError('Only one of Project/Dataset/Plate/Well/Annotation' ' can be specified') q = conn.getQueryService() @@ -441,6 +449,16 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None, params, conn.SERVICE_OPTS ) + elif annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM ImageAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) else: results = q.projection( "SELECT i.id FROM Image i" @@ -461,6 +479,7 @@ def get_image_ids(conn: BlitzGateway, project: Optional[int] = None, @do_across_groups def get_project_ids(conn: BlitzGateway, + annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list with IDs for all available Projects. @@ -468,6 +487,9 @@ def get_project_ids(conn: BlitzGateway, ---------- conn : ``omero.gateway.BlitzGateway`` object OMERO connection. + annotation : int, optional + ID of Annotation from which to return project IDs. This will return IDs + of all projects linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -482,19 +504,41 @@ def get_project_ids(conn: BlitzGateway, # Return IDs of all projects accessible by current user: >>> proj_ids = get_project_ids(conn) + + # Return IDs of all projects annotated with tag id 576: + + >>> proj_ids = get_project_ids(conn, annotation=576) """ - proj_ids = [] - for p in conn.listProjects(): - proj_ids.append(p.getId()) + + q = conn.getQueryService() + params = Parameters() + + if annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM ProjectAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) + proj_ids = [r[0].val for r in results] + else: + proj_ids = [] + for p in conn.listProjects(): + proj_ids.append(p.getId()) return proj_ids @do_across_groups def get_dataset_ids(conn: BlitzGateway, project: Optional[int] = None, + annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list of dataset ids based on project ID. - If no project is specified, function will return orphan datasets. + If no project or annotation is specified, function will return + orphan datasets. Parameters ---------- @@ -503,6 +547,9 @@ def get_dataset_ids(conn: BlitzGateway, project: Optional[int] = None, project : int, optional ID of Project from which to return dataset IDs. This will return IDs of all datasets contained in the specified Project. + annotation : int, optional + ID of Annotation from which to return dataset IDs. This will return IDs + of all datasets linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -522,6 +569,14 @@ def get_dataset_ids(conn: BlitzGateway, project: Optional[int] = None, >>> ds_ids = get_dataset_ids(conn, project=224) """ + arg_counter = 0 + for arg in [project, annotation]: + if arg is not None: + arg_counter += 1 + if arg_counter > 1: + raise ValueError('Only one of Project/Annotation' + ' can be specified') + q = conn.getQueryService() params = Parameters() @@ -537,6 +592,16 @@ def get_dataset_ids(conn: BlitzGateway, project: Optional[int] = None, params, conn.SERVICE_OPTS ) + elif annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM DatasetAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) else: results = q.projection( "SELECT d.id FROM Dataset d" From 9b8bdedb926dab3890697b0cb62b54aa64815b1a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Jun 2024 11:42:59 +0200 Subject: [PATCH 2/5] tests get from annotation --- tests/test_gets.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/test_gets.py b/tests/test_gets.py index 9046c03..763f349 100644 --- a/tests/test_gets.py +++ b/tests/test_gets.py @@ -241,11 +241,35 @@ def test_get_image_ids(conn, project_structure, screen_structure, plate_im_ids = ezomero.get_image_ids(conn, plate=plate_id) assert set(plate_im_ids) == set([plate_im_id1, plate_im_id2]) + # Test get from tag annotation + username = users_groups[1][0][0] # test_user1 + groupname = users_groups[0][1][0] # test_group_2 + current_conn = conn.suConn(username, groupname) + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + im_o = current_conn.getObject('Image', im2_id) + im_o.linkAnnotation(tag_ann) + im_o = current_conn.getObject('Image', im3_id) + im_o.linkAnnotation(tag_ann) + tag_im_ids = ezomero.get_image_ids(conn, annotation=tag_id) + assert set(tag_im_ids) == set([im2_id, im3_id]) + current_conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + current_conn.close() + def test_get_project_ids(conn, project_structure, users_groups): project_info = project_structure[0] + with pytest.raises(TypeError): + _ = ezomero.get_project_ids(conn, annotation="test") + proj_ids = ezomero.get_project_ids(conn) assert len(proj_ids) == len(project_info) @@ -257,6 +281,29 @@ def test_get_project_ids(conn, project_structure, users_groups): assert len(pj_ids) == len(project_info) - 1 current_conn.close() + # Test get from tag annotation + username = users_groups[1][1][0] # test_user2 + groupname = users_groups[1][1][0] # test_group_1 + current_conn = conn.suConn(username, groupname) + proj4_id = project_info[4][1] + proj5_id = project_info[5][1] + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + pr_o = current_conn.getObject('Project', proj4_id) + pr_o.linkAnnotation(tag_ann) + pr_o = current_conn.getObject('Project', proj5_id) + pr_o.linkAnnotation(tag_ann) + tag_pr_ids = ezomero.get_dataset_ids(conn, annotation=tag_id) + assert set(tag_pr_ids) == set([proj4_id, proj5_id]) + current_conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + current_conn.close() + def test_get_dataset_ids(conn, project_structure, users_groups): @@ -265,6 +312,8 @@ def test_get_dataset_ids(conn, project_structure, users_groups): with pytest.raises(TypeError): _ = ezomero.get_dataset_ids(conn, project='test') + with pytest.raises(TypeError): + _ = ezomero.get_dataset_ids(conn, annotation="test") # Test orphans orphan_ids = ezomero.get_dataset_ids(conn) @@ -281,6 +330,29 @@ def test_get_dataset_ids(conn, project_structure, users_groups): bad_im_ids = ezomero.get_dataset_ids(conn, project=999999) assert not bad_im_ids + # Test get from tag annotation + username = users_groups[1][1][0] # test_user2 + groupname = users_groups[1][1][0] # test_group_1 + current_conn = conn.suConn(username, groupname) + ds4_id = dataset_info[4][1] + ds5_id = dataset_info[5][1] + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + ds_o = current_conn.getObject('Dataset', ds4_id) + ds_o.linkAnnotation(tag_ann) + ds_o = current_conn.getObject('Dataset', ds5_id) + ds_o.linkAnnotation(tag_ann) + tag_ds_ids = ezomero.get_dataset_ids(conn, annotation=tag_id) + assert set(tag_ds_ids) == set([ds4_id, ds5_id]) + current_conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + current_conn.close() + def test_get_image_ids_params(conn): with pytest.raises(ValueError): From 6a18ac287a8b3c06e741008527bd76484e292a37 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jun 2024 11:18:20 +0200 Subject: [PATCH 3/5] get hcs objects by annotation --- ezomero/_gets.py | 93 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/ezomero/_gets.py b/ezomero/_gets.py index 4fa0da8..779211e 100644 --- a/ezomero/_gets.py +++ b/ezomero/_gets.py @@ -633,7 +633,7 @@ def get_dataset_ids(conn: BlitzGateway, project: Optional[int] = None, @do_across_groups -def get_screen_ids(conn: BlitzGateway, +def get_screen_ids(conn: BlitzGateway, annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list with IDs for all available Screens. @@ -641,6 +641,9 @@ def get_screen_ids(conn: BlitzGateway, ---------- conn : ``omero.gateway.BlitzGateway`` object OMERO connection. + annotation : int, optional + ID of Annotation from which to return screen IDs. This will return IDs + of all screens linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -655,16 +658,36 @@ def get_screen_ids(conn: BlitzGateway, # Return IDs of all screens accessible by current user: >>> scrn_ids = get_screen_ids(conn) + + # Return IDs of all screens annotated with tag id 913: + + >>> proj_ids = get_screen_ids(conn, annotation=913) """ - scrn_ids = [] - for s in conn.listScreens(): - scrn_ids.append(s.getId()) + q = conn.getQueryService() + params = Parameters() + + if annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM ScreenAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) + scrn_ids = [r[0].val for r in results] + else: + scrn_ids = [] + for s in conn.listScreens(): + scrn_ids.append(s.getId()) return scrn_ids @do_across_groups def get_plate_ids(conn: BlitzGateway, screen: Optional[int] = None, + annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list of plate ids based on screen ID. @@ -677,6 +700,9 @@ def get_plate_ids(conn: BlitzGateway, screen: Optional[int] = None, screen : int, optional ID of Screen from which to return plate IDs. This will return IDs of all plates contained in the specified Screen. + annotation : int, optional + ID of Annotation from which to return plate IDs. This will return IDs + of all plates linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -696,6 +722,13 @@ def get_plate_ids(conn: BlitzGateway, screen: Optional[int] = None, >>> pl_ids = get_plate_ids(conn, screen=224) """ + arg_counter = 0 + for arg in [screen, annotation]: + if arg is not None: + arg_counter += 1 + if arg_counter > 1: + raise ValueError('Only one of Screen/Annotation' + ' can be specified') q = conn.getQueryService() params = Parameters() @@ -712,6 +745,16 @@ def get_plate_ids(conn: BlitzGateway, screen: Optional[int] = None, params, conn.SERVICE_OPTS ) + elif annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM PlateAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) else: results = q.projection( "SELECT p.id FROM Plate p" @@ -727,7 +770,7 @@ def get_plate_ids(conn: BlitzGateway, screen: Optional[int] = None, @do_across_groups def get_well_ids(conn: BlitzGateway, screen: Optional[int] = None, - plate: Optional[int] = None, + plate: Optional[int] = None, annotation: Optional[int] = None, across_groups: Optional[bool] = True) -> List[int]: """Return a list of well ids based on a container @@ -741,6 +784,9 @@ def get_well_ids(conn: BlitzGateway, screen: Optional[int] = None, plate : int, optional ID of Plate from which to return well IDs. This will return IDs of all wells belonging to the specified Plate. + annotation : int, optional + ID of Annotation from which to return well IDs. This will return IDs + of all wells linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -757,14 +803,14 @@ def get_well_ids(conn: BlitzGateway, screen: Optional[int] = None, >>> wl_ids = get_well_ids(conn, screen=224) """ arg_counter = 0 - for arg in [screen, plate]: + for arg in [screen, plate, annotation]: if arg is not None: arg_counter += 1 if arg_counter > 1: - raise ValueError('Only one of Screen/Plate' + raise ValueError('Only one of Screen/Plate/Annotation' ' can be specified') elif arg_counter == 0: - raise ValueError('One of Screen/Plate' + raise ValueError('One of Screen/Plate/Annotation' ' must be specified') q = conn.getQueryService() @@ -794,13 +840,23 @@ def get_well_ids(conn: BlitzGateway, screen: Optional[int] = None, params, conn.SERVICE_OPTS ) + elif annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM WellAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) return [r[0].val for r in results] @do_across_groups def get_plate_acquisition_ids( conn: BlitzGateway, screen: Optional[int] = None, - plate: Optional[int] = None, + plate: Optional[int] = None, annotation: Optional[int] = None, across_groups: Optional[bool] = True ) -> List[int]: """Return a list of plate acquisition ids based on a container @@ -817,6 +873,9 @@ def get_plate_acquisition_ids( ID of Plate from which to return plate acquisition IDs. This will return IDs of all plate acquisitions belonging to the specified Plate. + annotation : int, optional + ID of Annotation from which to return run IDs. This will return IDs + of all runs linked to the specified annotation. across_groups : bool, optional Defines cross-group behavior of function - set to ``False`` to disable it. @@ -833,14 +892,14 @@ def get_plate_acquisition_ids( >>> plate_acquisition_ids = get_plate_acquisition_ids(conn, screen=224) """ arg_counter = 0 - for arg in [screen, plate]: + for arg in [screen, plate, annotation]: if arg is not None: arg_counter += 1 if arg_counter > 1: - raise ValueError('Only one of Screen/Plate' + raise ValueError('Only one of Screen/Plate/Annotation' ' can be specified') elif arg_counter == 0: - raise ValueError('One of Screen/Plate' + raise ValueError('One of Screen/Plate/Annotation' ' must be specified') q = conn.getQueryService() @@ -870,6 +929,16 @@ def get_plate_acquisition_ids( params, conn.SERVICE_OPTS ) + elif annotation is not None: + if not isinstance(annotation, int): + raise TypeError('Annotation ID must be integer') + params.map = {"annotation": rlong(annotation)} + results = q.projection( + "SELECT l.parent.id FROM PlateAcquisitionAnnotationLink l" + " WHERE l.child.id=:annotation", + params, + conn.SERVICE_OPTS + ) return [r[0].val for r in results] From 72c9e29d03a95fe5726c56948a51e263dfbb23db Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Jun 2024 16:03:45 +0200 Subject: [PATCH 4/5] test of getting objects by annotation --- tests/test_gets.py | 101 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 17 deletions(-) diff --git a/tests/test_gets.py b/tests/test_gets.py index 26b8852..7c2728a 100644 --- a/tests/test_gets.py +++ b/tests/test_gets.py @@ -293,19 +293,19 @@ def test_get_image_ids(conn, project_structure, screen_structure, _ = ezomero.get_image_ids(conn, plate_acquisition='test') # Test get from tag annotation - username = users_groups[1][0][0] # test_user1 + username = users_groups[1][1][0] # test_user2 groupname = users_groups[0][1][0] # test_group_2 current_conn = conn.suConn(username, groupname) - tag_ann = TagAnnotationWrapper(conn) + tag_ann = TagAnnotationWrapper(current_conn) tag_ann.setValue('test_tag') tag_ann.save() tag_id = tag_ann.getId() - im_o = current_conn.getObject('Image', im2_id) + im_o = current_conn.getObject('Image', im6_id) im_o.linkAnnotation(tag_ann) - im_o = current_conn.getObject('Image', im3_id) + im_o = current_conn.getObject('Image', im7_id) im_o.linkAnnotation(tag_ann) - tag_im_ids = ezomero.get_image_ids(conn, annotation=tag_id) - assert set(tag_im_ids) == set([im2_id, im3_id]) + tag_im_ids = ezomero.get_image_ids(current_conn, annotation=tag_id) + assert set(tag_im_ids) == set([im6_id, im7_id]) current_conn.deleteObjects("Annotation", [tag_id], deleteAnns=True, @@ -334,11 +334,11 @@ def test_get_project_ids(conn, project_structure, users_groups): # Test get from tag annotation username = users_groups[1][1][0] # test_user2 - groupname = users_groups[1][1][0] # test_group_1 + groupname = users_groups[0][0][0] # test_group_1 current_conn = conn.suConn(username, groupname) proj4_id = project_info[4][1] proj5_id = project_info[5][1] - tag_ann = TagAnnotationWrapper(conn) + tag_ann = TagAnnotationWrapper(current_conn) tag_ann.setValue('test_tag') tag_ann.save() tag_id = tag_ann.getId() @@ -346,7 +346,7 @@ def test_get_project_ids(conn, project_structure, users_groups): pr_o.linkAnnotation(tag_ann) pr_o = current_conn.getObject('Project', proj5_id) pr_o.linkAnnotation(tag_ann) - tag_pr_ids = ezomero.get_dataset_ids(conn, annotation=tag_id) + tag_pr_ids = ezomero.get_project_ids(current_conn, annotation=tag_id) assert set(tag_pr_ids) == set([proj4_id, proj5_id]) current_conn.deleteObjects("Annotation", [tag_id], @@ -382,12 +382,12 @@ def test_get_dataset_ids(conn, project_structure, users_groups): assert not bad_im_ids # Test get from tag annotation - username = users_groups[1][1][0] # test_user2 - groupname = users_groups[1][1][0] # test_group_1 + username = users_groups[1][0][0] # test_user1 + groupname = users_groups[0][0][0] # test_group_1 current_conn = conn.suConn(username, groupname) ds4_id = dataset_info[4][1] ds5_id = dataset_info[5][1] - tag_ann = TagAnnotationWrapper(conn) + tag_ann = TagAnnotationWrapper(current_conn) tag_ann.setValue('test_tag') tag_ann.save() tag_id = tag_ann.getId() @@ -395,7 +395,7 @@ def test_get_dataset_ids(conn, project_structure, users_groups): ds_o.linkAnnotation(tag_ann) ds_o = current_conn.getObject('Dataset', ds5_id) ds_o.linkAnnotation(tag_ann) - tag_ds_ids = ezomero.get_dataset_ids(conn, annotation=tag_id) + tag_ds_ids = ezomero.get_dataset_ids(current_conn, annotation=tag_id) assert set(tag_ds_ids) == set([ds4_id, ds5_id]) current_conn.deleteObjects("Annotation", [tag_id], @@ -405,15 +405,30 @@ def test_get_dataset_ids(conn, project_structure, users_groups): current_conn.close() -def test_get_screen_ids(conn, screen_structure): +def test_get_screen_ids(conn, screen_structure, users_groups): screen_id = screen_structure[0] screen_ids = ezomero.get_screen_ids(conn) assert set(screen_ids) == set([screen_id]) + # Test get from tag annotation + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + scr_o = conn.getObject('Screen', screen_id) + scr_o.linkAnnotation(tag_ann) + tag_scr_ids = ezomero.get_screen_ids(conn, annotation=tag_id) + assert set(tag_scr_ids) == set([screen_id]) + conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + -def test_get_plate_ids(conn, screen_structure): +def test_get_plate_ids(conn, screen_structure, users_groups): screen_id = screen_structure[0] plate_id = screen_structure[1] @@ -435,8 +450,25 @@ def test_get_plate_ids(conn, screen_structure): bad_pl_ids = ezomero.get_plate_ids(conn, screen=999999) assert not bad_pl_ids + # Test get from tag annotation + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + pl_o = conn.getObject('Plate', plate_id) + pl_o.linkAnnotation(tag_ann) + pl_o = conn.getObject('Plate', orphan_plate_id) + pl_o.linkAnnotation(tag_ann) + tag_pl_ids = ezomero.get_plate_ids(conn, annotation=tag_id) + assert set(tag_pl_ids) == set([plate_id, orphan_plate_id]) + conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + -def test_get_well_ids(conn, screen_structure): +def test_get_well_ids(conn, screen_structure, users_groups): screen_id = screen_structure[0] plate_id = screen_structure[1] @@ -468,8 +500,25 @@ def test_get_well_ids(conn, screen_structure): bad_ids = ezomero.get_well_ids(conn, screen=999999) assert not bad_ids + # Test get from tag annotation + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + wl_o = conn.getObject('Well', well_id1) + wl_o.linkAnnotation(tag_ann) + wl_o = conn.getObject('Well', well_id3) + wl_o.linkAnnotation(tag_ann) + tag_wl_ids = ezomero.get_well_ids(conn, annotation=tag_id) + assert set(tag_wl_ids) == set([well_id1, well_id3]) + conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + -def test_get_plate_acquisition_ids(conn, screen_structure): +def test_get_plate_acquisition_ids(conn, screen_structure, users_groups): screen_id = screen_structure[0] plate_id = screen_structure[1] @@ -497,6 +546,24 @@ def test_get_plate_acquisition_ids(conn, screen_structure): bad_ids = ezomero.get_plate_acquisition_ids(conn, screen=999999) assert not bad_ids + # Test get from tag annotation + tag_ann = TagAnnotationWrapper(conn) + tag_ann.setValue('test_tag') + tag_ann.save() + tag_id = tag_ann.getId() + paq_o = conn.getObject('PlateAcquisition', pacq_id1) + paq_o.linkAnnotation(tag_ann) + paq_o = conn.getObject('PlateAcquisition', pacq_id3) + paq_o.linkAnnotation(tag_ann) + tag_paq_ids = ezomero.get_plate_acquisition_ids(conn, + annotation=tag_id) + assert set(tag_paq_ids) == set([pacq_id1, pacq_id3]) + conn.deleteObjects("Annotation", + [tag_id], + deleteAnns=True, + deleteChildren=True, + wait=True) + def test_get_image_ids_params(conn): with pytest.raises(ValueError): From f190519aef408ef6271aac366f14deb741043b14 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Jun 2024 16:51:05 +0200 Subject: [PATCH 5/5] remove unused user_group --- tests/test_gets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_gets.py b/tests/test_gets.py index 7c2728a..8fdef17 100644 --- a/tests/test_gets.py +++ b/tests/test_gets.py @@ -405,7 +405,7 @@ def test_get_dataset_ids(conn, project_structure, users_groups): current_conn.close() -def test_get_screen_ids(conn, screen_structure, users_groups): +def test_get_screen_ids(conn, screen_structure): screen_id = screen_structure[0] @@ -428,7 +428,7 @@ def test_get_screen_ids(conn, screen_structure, users_groups): wait=True) -def test_get_plate_ids(conn, screen_structure, users_groups): +def test_get_plate_ids(conn, screen_structure): screen_id = screen_structure[0] plate_id = screen_structure[1] @@ -468,7 +468,7 @@ def test_get_plate_ids(conn, screen_structure, users_groups): wait=True) -def test_get_well_ids(conn, screen_structure, users_groups): +def test_get_well_ids(conn, screen_structure): screen_id = screen_structure[0] plate_id = screen_structure[1] @@ -518,7 +518,7 @@ def test_get_well_ids(conn, screen_structure, users_groups): wait=True) -def test_get_plate_acquisition_ids(conn, screen_structure, users_groups): +def test_get_plate_acquisition_ids(conn, screen_structure): screen_id = screen_structure[0] plate_id = screen_structure[1]