Esempio n. 1
0
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 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"})
Esempio n. 3
0
    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"})
Esempio n. 4
0
 def screen_plate_run_well(self):
     """
     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(self.uuid())
     plate = PlateI()
     plate.name = rstring(self.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 = self.new_image(name=self.uuid())
     ws_a.image = image_a
     ws_b = WellSampleI()
     image_b = self.new_image(name=self.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 self.update.saveAndReturnObject(screen)
Esempio n. 5
0
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)
Esempio n. 6
0
 def screen_plate(self):
     """
     Returns a new OMERO Screen and linked Plate with required fields set.
     """
     screen = ScreenI()
     screen.name = rstring(self.uuid())
     plate = PlateI()
     plate.name = rstring(self.uuid())
     screen.linkPlate(plate)
     return self.update.saveAndReturnObject(screen)
Esempio n. 7
0
 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
Esempio n. 8
0
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
Esempio n. 10
0
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)
Esempio n. 11
0
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
Esempio n. 12
0
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)
Esempio n. 13
0
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)
Esempio n. 14
0
 def screen_plate_run(self):
     """
     Returns a new OMERO Screen, linked Plate, and linked PlateAcquisition
     with all required fields set.
     """
     screen = ScreenI()
     screen.name = rstring(self.uuid())
     plate = PlateI()
     plate.name = rstring(self.uuid())
     plate_acquisition = PlateAcquisitionI()
     plate.addPlateAcquisition(plate_acquisition)
     screen.linkPlate(plate)
     return self.update.saveAndReturnObject(screen)
 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(plate_rows=row_count,
                                    plate_cols=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)
Esempio n. 16
0
 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)
Esempio n. 17
0
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
Esempio n. 18
0
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)
Esempio n. 19
0
 def screen_plate_well(self):
     """
     Returns a new OMERO Screen, linked Plate and linked Well with required
     fields set.
     """
     screen = ScreenI()
     screen.name = rstring(self.uuid())
     plate = PlateI()
     plate.name = rstring(self.uuid())
     # Well A10
     well = WellI()
     well.row = rint(0)
     well.column = rint(9)
     plate.addWell(well)
     screen.linkPlate(plate)
     return self.update.saveAndReturnObject(screen)
Esempio n. 20
0
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 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 create_screen(self, cli, screen):
        """
        Creates screen with name provided if it doesn't exist already.
        Returns Screen ID.
        """
        conn = self.use_connection(cli, host)
        params = self.get_params(conn)

        slist = list(conn.getObjects("Screen", attributes={'name': screen}, params=params))
        if len(slist) == 0:
            print "Creating Screen:", screen
            s = ScreenI()
            s.name = wrap(screen.encode('ascii','ignore'))
            scrId = conn.getUpdateService().saveAndReturnObject(s).id.val
        else:
            scrId = slist[0].getId()
            print "Using Screen:", screen

        return scrId
Esempio n. 23
0
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)
Esempio n. 24
0
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)
Esempio n. 25
0
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
Esempio n. 26
0
 def screens_different_users(self):
     """
     Returns two new OMERO Screens created by different users with
     required fields set.
     """
     client = self.conn.c
     group = self.conn.getGroupFromContext()._obj
     screens = list()
     # User that has already been created by the "client" fixture
     user, name = self.user_and_name(client)
     self.add_experimenters(group, [user])
     for name in (rstring(self.uuid()), rstring(self.uuid())):
         client, user = self.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
Esempio n. 27
0
    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
Esempio n. 28
0
    def create_screen(self, cli, screen):
        """
        Creates screen with name provided if it doesn't exist already.
        Returns Screen ID.
        """
        sessionId = cli._event_context.sessionUuid
        conn = BlitzGateway(host='localhost')
        conn.connect(sUuid = sessionId)
        params = omero.sys.Parameters()
        params.theFilter = omero.sys.Filter()
        params.theFilter.ownerId = wrap(conn.getUser().getId())

        slist = list(conn.getObjects("Screen", attributes={'name': screen}, params=params))
        if len(slist) == 0:
            print "Creating Screen:", screen
            s = ScreenI()
            s.name = wrap(screen.encode('ascii','ignore'))
            scrId = conn.getUpdateService().saveAndReturnObject(s).id.val
        else:
            scrId = slist[0].getId()
            print "Using Screen:", screen

        return scrId
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()
Esempio n. 30
0
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)
Esempio n. 31
0
    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
Esempio n. 32
0
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
    })
Esempio n. 33
0
 def screen(self):
     """Returns a new OMERO Screen with required fields set."""
     screen = ScreenI()
     screen.name = rstring(self.uuid())
     return self.update.saveAndReturnObject(screen)
Esempio n. 34
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)
Esempio n. 35
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)