コード例 #1
0
ファイル: test_show.py プロジェクト: stelfrich/openmicroscopy
 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)
コード例 #2
0
ファイル: test_tree.py プロジェクト: sbesson/openmicroscopy
def plate(request, itest, update_service):
    """
    Returns a new OMERO Plate with all required fields set.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    return update_service.saveAndReturnObject(plate)
コード例 #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"})
コード例 #4
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)
コード例 #5
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"})
コード例 #6
0
ファイル: test_tree.py プロジェクト: stelfrich/openmicroscopy
 def plate(self):
     """
     Returns a new OMERO Plate with all required fields set.
     """
     plate = PlateI()
     plate.name = rstring(self.uuid())
     return self.update.saveAndReturnObject(plate)
コード例 #7
0
def plate(request, itest, update_service):
    """
    Returns a new OMERO Plate with all required fields set.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    return update_service.saveAndReturnObject(plate)
コード例 #8
0
ファイル: test_tree.py プロジェクト: sbesson/openmicroscopy
def plate_run(request, itest, update_service):
    """
    Returns a new OMERO Plate and linked PlateAcquisition with all required
    fields set.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    plate_acquisition = PlateAcquisitionI()
    plate.addPlateAcquisition(plate_acquisition)
    return update_service.saveAndReturnObject(plate)
コード例 #9
0
ファイル: test_tree.py プロジェクト: stelfrich/openmicroscopy
 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)
コード例 #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)
コード例 #11
0
ファイル: test_tree.py プロジェクト: stelfrich/openmicroscopy
 def plate_run(self):
     """
     Returns a new OMERO Plate and linked PlateAcquisition with all
     required fields set.
     """
     plate = PlateI()
     plate.name = rstring(self.uuid())
     plate_acquisition = PlateAcquisitionI()
     plate.addPlateAcquisition(plate_acquisition)
     return self.update.saveAndReturnObject(plate)
コード例 #12
0
def plate_run(request, itest, update_service):
    """
    Returns a new OMERO Plate and linked PlateAcquisition with all required
    fields set.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    plate_acquisition = PlateAcquisitionI()
    plate.addPlateAcquisition(plate_acquisition)
    return update_service.saveAndReturnObject(plate)
コード例 #13
0
ファイル: test_tree.py プロジェクト: sbesson/openmicroscopy
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)
コード例 #14
0
def plate_wells(itest, well_grid_factory, plate_well_coords, update_service):
    """
    Returns a new OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{omeroweb.testlib.IWebTest} instance.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    wells = well_grid_factory(plate_well_coords)
    for well in wells:
        plate.addWell(well)
    return update_service.saveAndReturnObject(plate)
コード例 #15
0
ファイル: test_tree.py プロジェクト: stelfrich/openmicroscopy
 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)
コード例 #16
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)
コード例 #17
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)
コード例 #18
0
    def create_plate_wells(self, user1, rows, cols, plateacquisitions=1):
        """Return Plate with Wells."""
        updateService = get_update_service(user1)
        plate = PlateI()
        plate.name = rstring('plate')
        plate = updateService.saveAndReturnObject(plate)

        # PlateAcquisitions for plate
        plate_acqs = []
        for p in range(plateacquisitions):
            plate_acq = PlateAcquisitionI()
            plate_acq.name = rstring('plateacquisition_%s' % p)
            plate_acq.description = rstring('plateacquisition_description')
            plate_acq.maximumFieldCount = rint(3)
            plate_acq.startTime = rtime(1)
            plate_acq.endTime = rtime(2)
            plate_acq.plate = PlateI(plate.id.val, False)
            plate_acq = updateService.saveAndReturnObject(plate_acq)
            plate_acqs.append(plate_acq)

        # Create Wells for plate
        ref_frame = UnitsLength.REFERENCEFRAME
        for row in range(rows):
            for col in range(cols):
                # create Well
                well = WellI()
                well.column = rint(col)
                well.row = rint(row)
                well.plate = PlateI(plate.id.val, False)
                # Only wells in first Column have well-samples etc.
                if col == 0:
                    # Have 3 images/well-samples per plateacquisition
                    # (if no plateacquisitions, create 3 well-samples without)
                    for p in range(max(1, plateacquisitions)):
                        for i in range(3):
                            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
                            ws.posX = LengthI(i * 10, ref_frame)
                            ws.posY = LengthI(i, ref_frame)
                            if p < len(plate_acqs):
                                ws.setPlateAcquisition(
                                    PlateAcquisitionI(plate_acqs[p].id.val,
                                                      False))
                            well.addWellSample(ws)
                updateService.saveObject(well)
        return plate
コード例 #19
0
def plate_wells_with_description(itest, well_grid_factory, update_service):
    """
    Creates a plate with a single well containing an image with a description.
    Returns the plate and the description in a map.
    """
    description = "test description"
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    well.copyWellSamples()[0].image.description = rstring(description)
    plate.addWell(well)
    plate = update_service.saveAndReturnObject(plate)
    return {'plate': plate, 'description': description}
コード例 #20
0
def plate_wells(itest, well_grid_factory, update_service):
    """
    Returns a new OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{weblibrary.IWebTest} instance.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Well A10 has two WellSamples
    # Well A11 has no WellSamples
    # Well D3 has one WellSample
    wells = well_grid_factory({(0, 9): 2, (0, 10): 0, (3, 2): 1})
    for well in wells:
        plate.addWell(well)
    return update_service.saveAndReturnObject(plate)
コード例 #21
0
def plate_wells(itest, well_grid_factory, update_service):
    """
    Returns a new OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{weblibrary.IWebTest} instance.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Well A10 has two WellSamples
    # Well A11 has no WellSamples
    # Well D3 has one WellSample
    wells = well_grid_factory({(0, 9): 2, (0, 10): 0, (3, 2): 1})
    for well in wells:
        plate.addWell(well)
    return update_service.saveAndReturnObject(plate)
コード例 #22
0
def plate_wells_with_description(itest, well_grid_factory, update_service):
    """
    Creates a plate with a single well containing an image with a description.
    Returns the plate and the description in a map.
    """
    description = "test description"
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    well.copyWellSamples()[0].image.description = rstring(description)
    plate.addWell(well)
    plate = update_service.saveAndReturnObject(plate)
    return {'plate': plate,
            'description': description}
コード例 #23
0
def plate_wells_with_acq_date(itest, well_grid_factory, update_service):
    """
    Creates a plate with a single well containing an image with both an
    acquisition date set as well as a creation event with a date. Returns the
    plate and the acquisition date in a map.
    """
    acq_date = (time.time() - 60 * 60 * 24) * 1000
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    well.copyWellSamples()[0].image.acquisitionDate = rtime(int(acq_date))
    plate.addWell(well)
    plate = update_service.saveAndReturnObject(plate)
    return {'plate': plate, 'acq_date': int(acq_date / 1000)}
コード例 #24
0
def plate_wells_with_acq_date(itest, well_grid_factory, update_service):
    """
    Creates a plate with a single well containing an image with both an
    acquisition date set as well as a creation event with a date. Returns the
    plate and the acquisition date in a map.
    """
    acq_date = (time.time() - 60 * 60 * 24) * 1000
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    well.copyWellSamples()[0].image.acquisitionDate = rtime(int(acq_date))
    plate.addWell(well)
    plate = update_service.saveAndReturnObject(plate)
    return {'plate': plate,
            'acq_date': int(acq_date / 1000)}
コード例 #25
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)
コード例 #26
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)
コード例 #27
0
ファイル: test_show.py プロジェクト: stelfrich/openmicroscopy
 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)
コード例 #28
0
def plate_wells_with_no_acq_date(itest, well_grid_factory, update_service,
                                 conn):
    """
    Creates a plate with a single well containing an image with no acquisition
    date set. Returns the plate and the time from the creation event in a map.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    plate.addWell(well)
    well.copyWellSamples()[0].image.acquisitionDate = None
    plate = update_service.saveAndReturnObject(plate)
    image = plate.copyWells()[0].copyWellSamples()[0].image
    creation_date = image.details.creationEvent.time
    return {'plate': plate,
            'creation_date': creation_date.val / 1000}
コード例 #29
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
コード例 #30
0
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)
コード例 #31
0
def full_plate_wells(itest, update_service):
    """
    Returns a full OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{weblibrary.IWebTest} instance.
    """
    lett = map(chr, range(ord('A'), ord('Z')+1))
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    for row in range(8):
        for column in range(12):
            well = WellI()
            well.row = rint(row)
            well.column = rint(column)
            ws = WellSampleI()
            image = itest.new_image(name=lett[row]+str(column))
            ws.image = image
            well.addWellSample(ws)
            plate.addWell(well)
    return update_service.saveAndReturnObject(plate)
コード例 #32
0
def full_plate_wells(itest, update_service):
    """
    Returns a full OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{weblibrary.IWebTest} instance.
    """
    lett = map(chr, range(ord('A'), ord('Z') + 1))
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    for row in range(8):
        for column in range(12):
            well = WellI()
            well.row = rint(row)
            well.column = rint(column)
            ws = WellSampleI()
            image = itest.new_image(name=lett[row] + str(column))
            ws.image = image
            well.addWellSample(ws)
            plate.addWell(well)
    return update_service.saveAndReturnObject(plate)
コード例 #33
0
    def createPlate(self, rowCount, colCount):
        uuid = self.ctx.sessionUuid

        def createWell(row, column):
            well = WellI()
            well.row = rint(row)
            well.column = rint(column)
            ws = WellSampleI()
            image = self.new_image(name=uuid)
            ws.image = image
            well.addWellSample(ws)
            return well

        plate = PlateI()
        plate.name = rstring("TestPopulateMetadata%s" % uuid)
        for row in range(rowCount):
            for col in range(colCount):
                well = createWell(row, col)
                plate.addWell(well)
        return self.client.sf.getUpdateService().saveAndReturnObject(plate)
コード例 #34
0
ファイル: test_tree.py プロジェクト: sbesson/openmicroscopy
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)
コード例 #35
0
    def createPlate(self, rowCount, colCount):
        uuid = self.ctx.sessionUuid

        def createWell(row, column):
            well = WellI()
            well.row = rint(row)
            well.column = rint(column)
            ws = WellSampleI()
            image = self.new_image(name=uuid)
            ws.image = image
            well.addWellSample(ws)
            return well

        plate = PlateI()
        plate.name = rstring("TestPopulateMetadata%s" % uuid)
        for row in range(rowCount):
            for col in range(colCount):
                well = createWell(row, col)
                plate.addWell(well)
        return self.client.sf.getUpdateService().saveAndReturnObject(plate)
コード例 #36
0
ファイル: test_tree.py プロジェクト: stelfrich/openmicroscopy
 def plates_different_users(self):
     """
     Returns two new OMERO Plates created by different users with
     required fields set.
     """
     client = self.conn.c
     group = self.conn.getGroupFromContext()._obj
     plates = 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:
             plate = PlateI()
             plate.name = name
             update_service = client.getSession().getUpdateService()
             plates.append(update_service.saveAndReturnObject(plate))
         finally:
             client.closeSession()
     return plates
コード例 #37
0
def plate(request, gatewaywrapper):
    """Creates a Plate."""
    gatewaywrapper.loginAsAuthor()
    gw = gatewaywrapper.gateway
    update_service = gw.getUpdateService()
    plate = PlateI()
    plate.name = rstring(uuid())
    for well_index in range(3):
        well = WellI()
        well.row = rint(well_index**2)
        well.column = rint(well_index**3)
        for well_sample_index in range(2):
            well_sample = WellSampleI()
            image = ImageI()
            image.name = rstring('%s_%d' % (uuid(), well_sample_index))
            image.acquisitionDate = rtime(0)
            well_sample.image = image
            well.addWellSample(well_sample)
        plate.addWell(well)
    plate_id, = update_service.saveAndReturnIds([plate])
    return gw.getObject('Plate', plate_id)
コード例 #38
0
def plates_different_users(request, itest, conn):
    """
    Returns two new OMERO Plates created by different users with
    required fields set.
    """
    client = conn.c
    group = conn.getGroupFromContext()._obj
    plates = 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:
            plate = PlateI()
            plate.name = name
            update_service = client.getSession().getUpdateService()
            plates.append(update_service.saveAndReturnObject(plate))
        finally:
            client.closeSession()
    return plates
コード例 #39
0
def plate(request, gatewaywrapper):
    """Creates a Plate."""
    gatewaywrapper.loginAsAuthor()
    gw = gatewaywrapper.gateway
    update_service = gw.getUpdateService()
    plate = PlateI()
    plate.name = rstring(uuid())
    for well_index in range(3):
        well = WellI()
        well.row = rint(well_index**2)
        well.column = rint(well_index**3)
        for well_sample_index in range(2):
            well_sample = WellSampleI()
            image = ImageI()
            image.name = rstring('%s_%d' % (uuid(), well_sample_index))
            image.acquisitionDate = rtime(0)
            well_sample.image = image
            well.addWellSample(well_sample)
        plate.addWell(well)
    plate_id, = update_service.saveAndReturnIds([plate])
    return gw.getObject('Plate', plate_id)
コード例 #40
0
    def image_well_plate(self):
        """
        Returns a new OMERO Project, linked Dataset and linked Image populated
        by an L{test.integration.library.ITest} instance with required fields
        set.
        """
        plate = PlateI()
        plate.name = rstring(self.uuid())
        plate = self.update.saveAndReturnObject(plate)

        well = WellI()
        well.plate = plate
        well = self.update.saveAndReturnObject(well)

        image = self.new_image(name=self.uuid())

        ws = WellSampleI()
        ws.image = image
        ws.well = well
        well.addWellSample(ws)
        ws = self.update.saveAndReturnObject(ws)
        return plate, well, ws.image
コード例 #41
0
    def image_well_plate(self):
        """
        Returns a new OMERO Project, linked Dataset and linked Image populated
        by an L{test.integration.library.ITest} instance with required fields
        set.
        """
        plate = PlateI()
        plate.name = rstring(self.uuid())
        plate = self.update.saveAndReturnObject(plate)

        well = WellI()
        well.plate = plate
        well = self.update.saveAndReturnObject(well)

        image = self.new_image(name=self.uuid())

        ws = WellSampleI()
        ws.image = image
        ws.well = well
        well.addWellSample(ws)
        ws = self.update.saveAndReturnObject(ws)
        return plate, well, ws.image
コード例 #42
0
def plate_well_table(itest, well_grid_factory, update_service, conn):
    """
    Returns a new OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{weblibrary.IWebTest} instance.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Well A1 has one WellSample
    plate.addWell(well_grid_factory({(0, 0): 1})[0])
    plate = update_service.saveAndReturnObject(plate)

    col1 = WellColumn('Well', '', [])
    col2 = StringColumn('TestColumn', '', 64, [])

    columns = [col1, col2]
    tablename = "plate_well_table_test:%s" % str(random())
    table = conn.c.sf.sharedResources().newTable(1, tablename)
    table.initialize(columns)

    wellIds = [w.id.val for w in plate.copyWells()]
    print "WellIds", wellIds

    data1 = WellColumn('Well', '', wellIds)
    data2 = StringColumn('TestColumn', '', 64, ["foobar"])
    data = [data1, data2]
    table.addData(data)
    table.close()

    orig_file = table.getOriginalFile()
    fileAnn = FileAnnotationI()
    fileAnn.ns = rstring('openmicroscopy.org/omero/bulk_annotations')
    fileAnn.setFile(OriginalFileI(orig_file.id.val, False))
    fileAnn = conn.getUpdateService().saveAndReturnObject(fileAnn)
    link = PlateAnnotationLinkI()
    link.setParent(PlateI(plate.id.val, False))
    link.setChild(FileAnnotationI(fileAnn.id.val, False))
    update_service.saveAndReturnObject(link)
    return plate, wellIds
コード例 #43
0
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()
コード例 #44
0
def run(username, password, plate_id, host, port):
    """Run the script."""
    # Create connection to training server
    conn = BlitzGateway(username, password, host=host, port=port)
    conn.connect()

    # Create connection to IDR server
    # NB: conn.connect() not working on IDR. Do it like this
    idr_client = omero.client(host="idr.openmicroscopy.org", port=4064)
    idr_client.createSession('public', 'public')
    idr_conn = BlitzGateway(client_obj=idr_client)

    # The plate we want to copy from IDR
    idr_plate = idr_conn.getObject("Plate", plate_id)
    plate_name = idr_plate.getName()

    update_service = conn.getUpdateService()
    plate = PlateI()
    plate.name = rstring(plate_name)
    plate = update_service.saveAndReturnObject(plate)

    for idr_well in idr_plate.listChildren():
        print("Well", idr_well.id, 'row', idr_well.row, 'col', idr_well.column)
        # For each Well, get image and clone locally...
        new_imgs = []
        for idr_wellsample in idr_well.listChildren():
            idr_image = idr_wellsample.getImage()

            print("Image", idr_image.id)
            image = copy_image(conn, idr_image)
            new_imgs.append(image)
        # link to Plate...
        add_images_to_plate(update_service, plate, new_imgs,
                            idr_well.row, idr_well.column)

    conn.close()
    idr_conn.close()
コード例 #45
0
ファイル: test_gateway.py プロジェクト: olatarkowska/omero-py
    def test_plate(self):
        """Tests label methods for Plate and Well."""
        name = u'plate_∞'
        cols = 4
        rows = 3
        obj = PlateI()
        obj.name = rstring(name)

        plate = MockConnection(obj).getObject("Plate", 1)
        assert plate.getName() == name.encode('utf8')
        plate._gridSize = {'rows': rows, 'columns': cols}
        assert plate.getColumnLabels() == [c for c in range(1, cols + 1)]
        assert plate.getRowLabels() == ['A', 'B', 'C']

        well_obj = WellI()
        well_obj.column = rint(1)
        well_obj.row = rint(2)

        class MockWell(WellWrapper):
            def getParent(self):
                return plate

        well = MockWell(None, well_obj)
        assert well.getWellPos() == "C2"
コード例 #46
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)
コード例 #47
0
def plate_wells_with_no_acq_date(itest, well_grid_factory, update_service,
                                 conn):
    """
    Creates a plate with a single well containing an image with no acquisition
    date set. Returns the plate and the time from the creation event in a map.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Simple grid: one well with one image
    [well] = well_grid_factory({(0, 0): 1})
    plate.addWell(well)
    well.copyWellSamples()[0].image.acquisitionDate = None
    plate = update_service.saveAndReturnObject(plate)
    image = plate.copyWells()[0].copyWellSamples()[0].image
    creation_date = image.details.creationEvent.time
    return {'plate': plate, 'creation_date': creation_date.val / 1000}
コード例 #48
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)
コード例 #49
0
    def update_table(self, columns):
        """Updates the OmeroTables instance backing our results."""
        # Create a new OMERO table to store our measurement results
        sr = self.service_factory.sharedResources()
        name = self.get_name()
        self.table = sr.newTable(1, '/%s.r5' % name)
        if self.table is None:
            raise MeasurementError(
                "Unable to create table: %s" % name)

        # Retrieve the original file corresponding to the table for the
        # measurement, link it to the file annotation representing the
        # umbrella measurement run, link the annotation to the plate from
        # which it belongs and save the file annotation.
        table_original_file = self.table.getOriginalFile()
        table_original_file_id = table_original_file.id.val
        log.info("Created new table: %d" % table_original_file_id)
        unloaded_o_file = OriginalFileI(table_original_file_id, False)
        self.file_annotation.file = unloaded_o_file
        unloaded_plate = PlateI(self.analysis_ctx.plate_id, False)
        plate_annotation_link = PlateAnnotationLinkI()
        plate_annotation_link.parent = unloaded_plate
        plate_annotation_link.child = self.file_annotation
        plate_annotation_link = \
            self.update_service.saveAndReturnObject(plate_annotation_link)
        self.file_annotation = plate_annotation_link.child

        t0 = int(time.time() * 1000)
        self.table.initialize(columns)
        log.debug("Table init took %sms" % (int(time.time() * 1000) - t0))
        t0 = int(time.time() * 1000)
        column_report = dict()
        for column in columns:
            column_report[column.name] = len(column.values)
        log.debug("Column report: %r" % column_report)
        self.table.addData(columns)
        self.table.close()
        log.info("Table update took %sms" % (int(time.time() * 1000) - t0))
コード例 #50
0
def plate_well_table(itest, well_grid_factory, update_service, conn):
    """
    Returns a new OMERO Plate, linked Wells, linked WellSamples, and linked
    Images populated by an L{omeroweb.testlib.IWebTest} instance.
    """
    plate = PlateI()
    plate.name = rstring(itest.uuid())
    # Well A1 has one WellSample
    plate.addWell(well_grid_factory({(0, 0): 1})[0])
    plate = update_service.saveAndReturnObject(plate)

    col1 = WellColumn('Well', '', [])
    col2 = StringColumn('TestColumn', '', 64, [])

    columns = [col1, col2]
    tablename = "plate_well_table_test:%s" % str(random())
    table = conn.c.sf.sharedResources().newTable(1, tablename)
    table.initialize(columns)

    wellIds = [w.id.val for w in plate.copyWells()]
    print("WellIds", wellIds)

    data1 = WellColumn('Well', '', wellIds)
    data2 = StringColumn('TestColumn', '', 64, ["foobar"])
    data = [data1, data2]
    table.addData(data)

    orig_file = table.getOriginalFile()
    table.close()

    fileAnn = FileAnnotationI()
    fileAnn.ns = rstring('openmicroscopy.org/omero/bulk_annotations')
    fileAnn.setFile(OriginalFileI(orig_file.id.val, False))
    fileAnn = conn.getUpdateService().saveAndReturnObject(fileAnn)
    link = PlateAnnotationLinkI()
    link.setParent(PlateI(plate.id.val, False))
    link.setChild(FileAnnotationI(fileAnn.id.val, False))
    update_service.saveAndReturnObject(link)
    return plate, wellIds
コード例 #51
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
コード例 #52
0
ファイル: conftest.py プロジェクト: knabar/omero-marshal
def screen_with_plates(screen):
    for plate_id in range(5, 7):
        o = PlateI()
        o.id = rlong(plate_id)
        o.name = rstring('plate_name_%d' % plate_id)
        o.description = rstring('plate_description_%d' % plate_id)
        o.columnNamingConvention = rstring('number')
        o.rowNamingConvention = rstring('letter')
        o.columns = rint(12)
        o.rows = rint(8)
        o.defaultSample = rint(0)
        o.externalIdentifier = rstring('external_identifier_%d' % plate_id)
        o.status = rstring('status_%d' % plate_id)
        o.wellOriginX = LengthI(0.1, UnitsLength.REFERENCEFRAME)
        o.wellOriginY = LengthI(1.1, UnitsLength.REFERENCEFRAME)
        screen.linkPlate(o)
        for well_id in range(7, 9):
            well = WellI()
            well.id = rlong(well_id)
            well.column = rint(2)
            well.row = rint(1)
            well.externalDescription = \
                rstring('external_description_%d' % well_id)
            well.externalIdentifier = \
                rstring('external_identifier_%d' % well_id)
            well.type = rstring('the_type')
            well.alpha = rint(0)
            well.red = rint(255)
            well.green = rint(0)
            well.blue = rint(0)
            well.status = rstring('the_status')
            o.addWell(well)
            plateacquisition = PlateAcquisitionI()
            plateacquisition.id = rlong(well_id)
            plateacquisition.name = rstring(
                'plateacquisition_name_%d' % well_id)
            plateacquisition.description = rstring(
                'plateacquisition_description_%d' % well_id)
            plateacquisition.maximumFieldCount = rint(1)
            plateacquisition.startTime = rtime(1L)
            plateacquisition.endTime = rtime(2L)
            for wellsample_id in range(9, 11):
                wellsample = WellSampleI()
                wellsample.setPlateAcquisition(plateacquisition)
                wellsample.id = rlong(wellsample_id)
                wellsample.posX = LengthI(1.0, UnitsLength.REFERENCEFRAME)
                wellsample.posY = LengthI(2.0, UnitsLength.REFERENCEFRAME)
                wellsample.timepoint = rtime(1L)
                wellsample.image = create_image(1L)
                well.addWellSample(wellsample)

    return screen
コード例 #53
0
def screen_with_plates(screen):
    for plate_id in range(5, 7):
        o = PlateI()
        o.id = rlong(plate_id)
        o.name = rstring("plate_name_%d" % plate_id)
        o.description = rstring("plate_description_%d" % plate_id)
        o.columnNamingConvention = rstring("number")
        o.rowNamingConvention = rstring("letter")
        o.columns = rint(12)
        o.rows = rint(8)
        o.defaultSample = rint(0)
        o.externalIdentifier = rstring("external_identifier_%d" % plate_id)
        o.status = rstring("status_%d" % plate_id)
        o.wellOriginX = LengthI(0.1, UnitsLength.REFERENCEFRAME)
        o.wellOriginY = LengthI(1.1, UnitsLength.REFERENCEFRAME)
        screen.linkPlate(o)
    return screen