Пример #1
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)
Пример #2
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)
Пример #3
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)
    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
Пример #5
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)
Пример #6
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)
        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
Пример #7
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)
Пример #8
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)
Пример #9
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)
        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
def run():
    """
    """
    dataTypes = [rstring("Plate")]

    client = scripts.client(
        "Manage_Plate_Acquisitions.py",
        "Add or remove PlateAcquisition(s) in a given Plate",

        scripts.String("Data_Type", optional=False, grouping="1",
                       description="The data type you want to work with.",
                       values=dataTypes,
                       default="Plate"),

        scripts.List("IDs", optional=False, grouping="2",
                     description="List of Plate IDs").ofType(rlong(0)),

        scripts.String("Mode", optional=False, grouping="3",
                       description="Select if you want to add or "
                                   "remove PlateAcquisitions",
                       values=[rstring("Add"), rstring("Remove")],
                       default="Add"),

        version="0.2",
        authors=["Niko Klaric"],
        institutions=["Glencoe Software Inc."],
        contact="*****@*****.**",
    )

    try:
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        connection = BlitzGateway(client_obj=client)
        updateService = connection.getUpdateService()
        queryService = connection.getQueryService()

        processedMessages = []

        for plateId in scriptParams["IDs"]:
            plateObj = connection.getObject("Plate", plateId)
            if plateObj is None:
                client.setOutput(
                    "Message",
                    rstring("ERROR: No Plate with ID %s" % plateId))
                return

            if scriptParams["Mode"] == "Add":
                plateAcquisitionObj = PlateAcquisitionI()
                plateAcquisitionObj.setPlate(PlateI(plateObj.getId(), False))

                wellGrid = plateObj.getWellGrid()
                for axis in wellGrid:
                    for wellObj in axis:
                        wellSampleList = wellObj.copyWellSamples()
                        plateAcquisitionObj.addAllWellSampleSet(wellSampleList)

                plateAcquisitionObj = updateService.saveAndReturnObject(
                    plateAcquisitionObj)
                plateAcquisitionId = plateAcquisitionObj.getId()._val

                processedMessages.append(
                    "Linked new PlateAcquisition with ID %d"
                    " to Plate with ID %d." % (plateAcquisitionId, plateId))
            else:
                params = ParametersI()
                params.addId(plateId)

                queryString = """
                    FROM PlateAcquisition AS pa
                    LEFT JOIN FETCH pa.wellSample
                    LEFT OUTER JOIN FETCH pa.annotationLinks
                        WHERE pa.plate.id = :id
                    """
                plateAcquisitionList = queryService.findAllByQuery(
                    queryString, params, connection.SERVICE_OPTS)
                if plateAcquisitionList:
                    updateList = []

                    for plate_acquisition in plateAcquisitionList:
                        for well_sample in plate_acquisition.copyWellSample():
                            well_sample.setPlateAcquisition(None)
                            updateList.append(well_sample)

                        updateService.saveArray(updateList)

                        plate_acquisition.clearWellSample()
                        plate_acquisition.clearAnnotationLinks()

                        plate_acquisition = updateService.saveAndReturnObject(
                            plate_acquisition)
                        updateService.deleteObject(plate_acquisition)

                processedMessages.append(
                    "%d PlateAcquisition(s) removed from Plate with ID %d." %
                    (len(plateAcquisitionList), plateId))

        client.setOutput("Message", rstring("No errors. %s" %
                         " ".join(processedMessages)))
    finally:
        client.closeSession()
Пример #11
0
def run():
    """
    """
    dataTypes = [rstring("Plate")]

    client = scripts.client(
        "Manage_Plate_Acquisitions.py",
        "Add or remove PlateAcquisition(s) in a given Plate",
        scripts.String("Data_Type",
                       optional=False,
                       grouping="1",
                       description="The data type you want to work with.",
                       values=dataTypes,
                       default="Plate"),
        scripts.List("IDs",
                     optional=False,
                     grouping="2",
                     description="List of Plate IDs").ofType(rlong(0)),
        scripts.String("Mode",
                       optional=False,
                       grouping="3",
                       description="Select if you want to add or "
                       "remove PlateAcquisitions",
                       values=[rstring("Add"),
                               rstring("Remove")],
                       default="Add"),
        version="0.2",
        authors=["Niko Klaric"],
        institutions=["Glencoe Software Inc."],
        contact="*****@*****.**",
    )

    try:
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        connection = BlitzGateway(client_obj=client)
        updateService = connection.getUpdateService()
        queryService = connection.getQueryService()

        processedMessages = []

        for plateId in scriptParams["IDs"]:
            plateObj = connection.getObject("Plate", plateId)
            if plateObj is None:
                client.setOutput(
                    "Message", rstring("ERROR: No Plate with ID %s" % plateId))
                return

            if scriptParams["Mode"] == "Add":
                plateAcquisitionObj = PlateAcquisitionI()
                plateAcquisitionObj.setPlate(PlateI(plateObj.getId(), False))

                wellGrid = plateObj.getWellGrid()
                for axis in wellGrid:
                    for wellObj in axis:
                        wellSampleList = wellObj.copyWellSamples()
                        plateAcquisitionObj.addAllWellSampleSet(wellSampleList)

                plateAcquisitionObj = updateService.saveAndReturnObject(
                    plateAcquisitionObj)
                plateAcquisitionId = plateAcquisitionObj.getId()._val

                processedMessages.append(
                    "Linked new PlateAcquisition with ID %d"
                    " to Plate with ID %d." % (plateAcquisitionId, plateId))
            else:
                params = ParametersI()
                params.addId(plateId)

                queryString = """
                    FROM PlateAcquisition AS pa
                    LEFT JOIN FETCH pa.wellSample
                    LEFT OUTER JOIN FETCH pa.annotationLinks
                        WHERE pa.plate.id = :id
                    """
                plateAcquisitionList = queryService.findAllByQuery(
                    queryString, params, connection.SERVICE_OPTS)
                if plateAcquisitionList:
                    updateList = []

                    for plate_acquisition in plateAcquisitionList:
                        for well_sample in plate_acquisition.copyWellSample():
                            well_sample.setPlateAcquisition(None)
                            updateList.append(well_sample)

                        updateService.saveArray(updateList)

                        plate_acquisition.clearWellSample()
                        plate_acquisition.clearAnnotationLinks()

                        plate_acquisition = updateService.saveAndReturnObject(
                            plate_acquisition)
                        updateService.deleteObject(plate_acquisition)

                processedMessages.append(
                    "%d PlateAcquisition(s) removed from Plate with ID %d." %
                    (len(plateAcquisitionList), plateId))

        client.setOutput(
            "Message", rstring("No errors. %s" % " ".join(processedMessages)))
    finally:
        client.closeSession()