def screens(request, itest, update_service, names): """ Returns four new OMERO Screens with required fields set and with names that can be used to exercise sorting semantics. """ to_save = [ScreenI(), ScreenI(), ScreenI(), ScreenI()] for index, screen in enumerate(to_save): screen.name = rstring(names[index]) return update_service.saveAndReturnArray(to_save)
def screens_plates(request, itest, update_service, names): """ Returns four new OMERO Screens and four linked Plates with required fields set and with names that can be used to exercise sorting semantics. """ screens = [ScreenI(), ScreenI(), ScreenI(), ScreenI()] for index, screen in enumerate(screens): screen.name = rstring(names[index]) plates = [PlateI(), PlateI(), PlateI(), PlateI()] for index, plate in enumerate(plates): plate.name = rstring(names[index]) screen.linkPlate(plate) return update_service.saveAndReturnArray(screens)
def screens_plates_runs(request, itest, update_service): """ Returns a two new OMERO Screens, two linked Plates, and two linked PlateAcquisitions with all required fields set. """ screens = [ScreenI(), ScreenI()] for screen in screens: screen.name = rstring(itest.uuid()) plates = [PlateI(), PlateI()] for plate in plates: plate.name = rstring(itest.uuid()) plate_acquisitions = [PlateAcquisitionI(), PlateAcquisitionI()] for plate_acquisition in plate_acquisitions: plate.addPlateAcquisition(plate_acquisition) screen.linkPlate(plate) return update_service.saveAndReturnArray(screens)
def screen_plate_run_well(request, itest, update_service): """ Returns a new OMERO Screen, linked Plate, linked Well, linked WellSample, linked Image populate by an L{test.integration.library.ITest} instance and linked PlateAcquisition with all required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) # Well A10 (will have two WellSamples) well_a = WellI() well_a.row = rint(0) well_a.column = rint(9) # Well A11 (will not have a WellSample) well_b = WellI() well_b.row = rint(0) well_b.column = rint(10) ws_a = WellSampleI() image_a = itest.new_image(name=itest.uuid()) ws_a.image = image_a ws_b = WellSampleI() image_b = itest.new_image(name=itest.uuid()) ws_b.image = image_b plate_acquisition = PlateAcquisitionI() plate_acquisition.plate = plate ws_a.plateAcquisition = plate_acquisition ws_b.plateAcquisition = plate_acquisition well_a.addWellSample(ws_a) well_a.addWellSample(ws_b) plate.addWell(well_a) plate.addWell(well_b) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def screen_plates(self, user1): """Return Screen with Plates and an orphaned Plate.""" # Create and name all the objects screen = ScreenI() screen.name = rstring('screen') for i in range(5): plate1 = PlateI() plate1.name = rstring('Plate%s' % i) screen.linkPlate(plate1) # Create single orphaned Plate plate = PlateI() plate.name = rstring('plate') screen = get_update_service(user1).saveAndReturnObject(screen) plate = get_update_service(user1).saveAndReturnObject(plate) # Add well to first plate plates = screen.linkedPlateList() plates.sort(cmp_name_insensitive) plate_id = plates[0].id.val well = WellI() well.column = rint(0) well.row = rint(0) well.plate = PlateI(plate_id, False) image = self.create_test_image(size_x=5, size_y=5, session=user1[0].getSession()) ws = WellSampleI() ws.image = ImageI(image.id, False) ws.well = well well.addWellSample(ws) well = get_update_service(user1).saveAndReturnObject(well) return screen, plate
def testChgrp11109(self): """ Place a plate in a single screen and attempt to move it. """ # One user in two groups client, user = self.new_client_and_user(perms=PRIVATE) admin = client.sf.getAdminService() target_grp = self.new_group([user], perms=PRIVATE) target_gid = target_grp.id.val admin.getEventContext() # Refresh update = client.sf.getUpdateService() plate = PlateI() plate.name = rstring("testChgrp11109") screen = ScreenI() screen.name = rstring("testChgrp11109") link = screen.linkPlate(plate) link = update.saveAndReturnObject(link) # Now chgrp, should succeed chgrp = Chgrp2(targetObjects={"Plate": [link.child.id.val]}, groupId=target_gid) self.doSubmit(chgrp, client) # Check that the links have been destroyed query = client.sf.getQueryService() with pytest.raises(omero.ValidationException): query.get("ScreenPlateLink", link.id.val, {"omero.group": "-1"})
def parse_target_object(target_object): type, id = target_object.split(':') if 'Dataset' == type: return DatasetI(long(id), False) if 'Plate' == type: return PlateI(long(id), False) if 'Screen' == type: return ScreenI(long(id), False) raise ValueError('Unsupported target object: %s' % target_object)
def screen_plate(request, itest, update_service): """ Returns a new OMERO Screen and linked Plate with required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def user_screens(self, user1): """Create screens belonging to user1.""" screens = [] for i in range(5): screen = ScreenI() screen.name = rstring('Screen%s' % i) screens.append(screen) screens = get_update_service(user1).saveAndReturnArray(screens) screens.sort(key=lambda x: lower_or_none(unwrap(x.name))) return screens
def user_screens(self, user1): """Create screens belonging to user1.""" screens = [] for i in range(5): screen = ScreenI() screen.name = rstring('Screen%s' % i) screens.append(screen) screens = get_update_service(user1).saveAndReturnArray(screens) screens.sort(cmp_name_insensitive) return screens
def screen(): o = ScreenI() o.id = rlong(4L) o.name = rstring('the_name') o.description = rstring('the_description') o.protocolDescription = rstring('the_protocol_description') o.protocolIdentifier = rstring('the_protocol_identifier') o.reagentSetDescription = rstring('the_reagent_set_description') o.reagentSetIdentifier = rstring('the_reagent_set_identifier') o.type = rstring('the_type') return o
def screen_plate_run(request, itest, update_service): """ Returns a new OMERO Screen, linked Plate, and linked PlateAcquisition with all required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) plate_acquisition = PlateAcquisitionI() plate.addPlateAcquisition(plate_acquisition) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def populate_metadata(client, conn, script_params): object_id = int(script_params["IDs"]) file_id = int(script_params["File_ID"]) original_file = get_original_file(conn, script_params["Data_Type"], object_id, file_id) provider = DownloadingOriginalFileProvider(conn) file_handle = provider.get_original_file_data(original_file) if script_params["Data_Type"] == "Plate": omero_object = PlateI(int(object_id), False) else: omero_object = ScreenI(int(object_id), False) ctx = ParsingContext(client, omero_object, "") ctx.parse_from_handle(file_handle) ctx.write_to_omero()
def create_screen(self, row_count, col_count): # TODO: remove 5.2 vs 5.3 compatibility try: plate = self.importPlates(plateRows=row_count, plateCols=col_count)[0] except AttributeError: plate = self.import_plates(plateRows=row_count, plateCols=col_count)[0] plate = self.set_name(plate, "Plate001") screen = ScreenI() screen.name = rstring("Screen001") screen.linkPlate(plate.proxy()) return (self.client.sf.getUpdateService().saveAndReturnObject(screen), plate)
def screen_plate_well(request, itest, update_service): """ Returns a new OMERO Screen, linked Plate and linked Well with required fields set. """ screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) # Well A10 well = WellI() well.row = rint(0) well.column = rint(9) plate.addWell(well) screen.linkPlate(plate) return update_service.saveAndReturnObject(screen)
def populate_metadata(client, conn, script_params): object_ids = script_params["IDs"] object_id = object_ids[0] file_ann_id = None if "File_Annotation" in script_params: file_ann_id = long(script_params["File_Annotation"]) data_type = script_params["Data_Type"] original_file = get_original_file(conn, data_type, object_id, file_ann_id) provider = DownloadingOriginalFileProvider(conn) file_handle = provider.get_original_file_data(original_file) if data_type == "Plate": omero_object = PlateI(long(object_id), False) else: omero_object = ScreenI(long(object_id), False) ctx = ParsingContext(client, omero_object, "") ctx.parse_from_handle(file_handle) ctx.write_to_omero() return "Table data populated for %s: %s" % (data_type, object_id)
def plates_runs(request, itest, update_service, names): """ Returns a four new Plates, and two linked PlateAcquisitions with required fields set and with names that can be used to exercise sorting semantics. """ plates = [PlateI(), PlateI(), PlateI(), PlateI()] for index, plate in enumerate(plates): plate.name = rstring(names[index]) plate_acquisitions = [PlateAcquisitionI(), PlateAcquisitionI()] for plate_acquisition in plate_acquisitions: plate.addPlateAcquisition(plate_acquisition) # Non-orphaned Plate to catch issues with queries where non-orphaned # plates are included in the results. screen = ScreenI() screen.name = rstring(itest.uuid()) plate = PlateI() plate.name = rstring(itest.uuid()) screen.linkPlate(plate) update_service.saveAndReturnObject(screen) return update_service.saveAndReturnArray(plates)
def screens_different_users(request, itest, conn): """ Returns two new OMERO Screens created by different users with required fields set. """ client = conn.c group = conn.getGroupFromContext()._obj screens = list() # User that has already been created by the "client" fixture user, name = itest.user_and_name(client) itest.add_experimenters(group, [user]) for name in (rstring(itest.uuid()), rstring(itest.uuid())): client, user = itest.new_client_and_user(group=group) try: screen = ScreenI() screen.name = name update_service = client.getSession().getUpdateService() screens.append(update_service.saveAndReturnObject(screen)) finally: client.closeSession() return screens
def testListParentsSPW(self): """Test listParents() for Image in WellSample""" client, exp = self.new_client_and_user() conn = BlitzGateway(client_obj=client) # setup SPW-WS-Img... s = ScreenI() s.name = wrap('ScreenA') p = PlateI() p.name = wrap('PlateA') s.linkPlate(p) w = WellI() w.column = wrap(0) w.row = wrap(0) p.addWell(w) s = client.sf.getUpdateService().saveAndReturnObject(s) p = s.linkedPlateList()[0] w = p.copyWells()[0] i = self.make_image(name="SPW listParents", client=client) ws = WellSampleI() ws.image = i ws.well = WellI(w.id.val, False) w.addWellSample(ws) ws = client.sf.getUpdateService().saveAndReturnObject(ws) # Traverse from Image -> Screen image = conn.getObject("Image", i.id.val) wellSample = image.listParents()[0] well = wellSample.listParents()[0] assert well.id == w.id.val plate = well.listParents()[0] assert plate.id == p.id.val screen = plate.listParents()[0] assert screen.id == s.id.val # Screen has no parent assert len(screen.listParents()) == 0
def screen(request, itest, update_service): """Returns a new OMERO Screen with required fields set.""" screen = ScreenI() screen.name = rstring(itest.uuid()) return update_service.saveAndReturnObject(screen)
def project_structure(conn, timestamp, image_fixture): """ Project Dataset Image ------- ------- ----- proj ----> ds ----> im0 Screen Plate Well Image ------ ----- ---- ----- screen ----> plate ----> well -----> im1 """ proj_name = "proj_" + timestamp proj_id = ezomero.post_project(conn, proj_name) ds_name = "ds_" + timestamp ds_id = ezomero.post_dataset(conn, ds_name, project_id=proj_id) im_name = 'im_' + timestamp im_id = ezomero.post_image(conn, image_fixture, im_name, dataset_id=ds_id) update_service = conn.getUpdateService() # Create Screen screen_name = "screen_" + timestamp screen = ScreenWrapper(conn, ScreenI()) screen.setName(screen_name) screen.save() screen_id = screen.getId() # Create Plate plate_name = "plate_" + timestamp plate = PlateWrapper(conn, PlateI()) plate.setName(plate_name) plate.save() plate_id = plate.getId() link = ScreenPlateLinkI() link.setParent(ScreenI(screen_id, False)) link.setChild(PlateI(plate_id, False)) update_service.saveObject(link) # Create Well well = WellI() well.setPlate(PlateI(plate_id, False)) well.setColumn(rint(1)) well.setRow(rint(1)) well.setPlate(PlateI(plate_id, False)) # Create Well Sample with Image ws = WellSampleI() im_id1 = ezomero.post_image(conn, image_fixture, "well image") ws.setImage(ImageI(im_id1, False)) well.addWellSample(ws) well_obj = update_service.saveAndReturnObject(well) well_id = well_obj.getId().getValue() return ({ 'proj': proj_id, 'ds': ds_id, 'im': im_id, 'screen': screen_id, 'plate': plate_id, 'well': well_id, 'im1': im_id1 })