Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /usr/bin/env python
from commonImageDropbox import IBrain2ImageDataSetConfig
from commonDropbox import AcquiredDatasetMetadataParser
""" Plate geometry which will be used. Other possible value: 96_WELLS_8X12 """
PLATE_GEOMETRY = "384_WELLS_16X24"
""" sample type code of the plate, needed if a new sample is registered automatically """
PLATE_TYPE_CODE = "PLATE"
SIRNA_EXP_TYPE = "SIRNA_HCS"
PLATE_GEOMETRY_PROPERTY_CODE = "$PLATE_GEOMETRY"
def createPlateWithExperimentIfNeeded(transaction, assayParser, plate, space):
project = assayParser.get(assayParser.EXPERIMENTER_PROPERTY)
experiment = assayParser.get(assayParser.ASSAY_ID_PROPERTY)
experimentDesc = assayParser.get(assayParser.ASSAY_DESC_PROPERTY)
experimentType = assayParser.get(assayParser.ASSAY_TYPE_PROPERTY)
sampleIdentifier = "/"+space+"/"+plate
plate = transaction.getSample(sampleIdentifier)
if plate == None:
expIdentifier = "/"+space+"/"+project+"/"+experiment
experiment = transaction.getExperiment(expIdentifier)
if experiment == None:
experiment = transaction.createNewExperiment(expIdentifier, SIRNA_EXP_TYPE)
openbisExpDesc = experimentDesc + "\ntype: "+experimentType
experiment.setPropertyValue("DESCRIPTION", openbisExpDesc)
plate = transaction.createNewSample(sampleIdentifier, PLATE_TYPE_CODE)
plate.setPropertyValue(PLATE_GEOMETRY_PROPERTY_CODE, PLATE_GEOMETRY)
plate.setExperiment(experiment)
"""
TODO:
-
"""
if incoming.isDirectory():
imageDataset = IBrain2ImageDataSetConfig()
imageDataset.setRawImageDatasetType()
metadataParser = AcquiredDatasetMetadataParser(incoming)
assayParser = AssayParser(incoming)
plate = metadataParser.getPlateCode()
space = assayParser.get(assayParser.LAB_LEADER_PROPERTY)
imageDataset.setPlate(space, plate)
imageDataset.setFileFormatType("TIFF")
imageDataset.setGenerateThumbnails(True)
imageDataset.setMaxThumbnailWidthAndHeight(imageDataset.THUMBANAIL_SIZE)
imageDataset.setRecognizedImageExtensions(["tif, tiff"])
imageDataset.setStoreChannelsOnExperimentLevel(False)
imageRegistrationDetails = factory.createImageRegistrationDetails(imageDataset, incoming)
for propertyCode, value in metadataParser.getPropertiesIter():
imageRegistrationDetails.setPropertyValue(propertyCode, value)
tr = service.transaction(incoming, factory)
createPlateWithExperimentIfNeeded(tr, assayParser, plate, space)
dataset = tr.createNewDataSet(imageRegistrationDetails)
imageDataSetFolder = tr.moveFile(incoming.getPath(), dataset)
imageDatasetCode = dataset.getDataSetCode()
IBRAIN2Utils().createSuccessStatus(metadataParser.getIBrain2DatasetId(), imageDatasetCode, incoming)
print "Registered dataset:", imageDatasetCode
# TODO: test this !!!
def rollback_transaction(service, transaction, algorithmRunner, throwable):
incoming = service.incomingDataSetFile
iBrain2DatasetId = AcquiredDatasetMetadataParser(incoming).getIBrain2DatasetId()
IBRAIN2Utils().createFailureStatus(iBrain2DatasetId, throwable.getMessage(), incoming)