diff --git a/plasmid/source/core-plugins/newbrowser/1/as/initialize-master-data.py b/plasmid/source/core-plugins/newbrowser/1/as/initialize-master-data.py index 6364474ab586df106a7630c635d1f2e25e6a899a..343e596858ec69c18265d353ab5f489f88c3a956 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/initialize-master-data.py +++ b/plasmid/source/core-plugins/newbrowser/1/as/initialize-master-data.py @@ -20,12 +20,14 @@ import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.DataType as DataTyp ## ## Help Methods ## +vocabulariesCache = {}; propertiesCache = {}; tr = service.transaction() def createVocabularyWithTerms(vocabularyCode, terms): vocabulary = tr.createNewVocabulary(vocabularyCode); addTerms(vocabulary, terms); + vocabulariesCache[vocabularyCode] = vocabulary; def addTerms(vocabulary, terms): for term in terms: @@ -35,17 +37,30 @@ def addTermWithLabel(vocabulary, termCode, termLabel): newTerm = tr.createNewVocabularyTerm(termCode); newTerm.setLabel(termLabel); vocabulary.addTerm(newTerm); - + +def createSampleTypeWithProperties(sampleTypeCode, description, properties): + newSampleType = tr.getOrCreateNewSampleType(sampleTypeCode); + newSampleType.setDescription(description); + newSampleType.setAutoGeneratedCode(True); + newSampleType.setGeneratedCodePrefix(sampleTypeCode[:3]); + addProperties(newSampleType, properties); + +def createDataSetTypeWithProperties(dataSetCode, kind, description, properties): + newDataSet = tr.getOrCreateNewDataSetType(dataSetCode); + newDataSet.setDataSetKind(kind); + newDataSet.setDescription(description); + addProperties(newDataSet, properties); + def createExperimentTypeWithProperties(experimentTypeCode, description, properties): newExperiment = tr.getOrCreateNewExperimentType(experimentTypeCode); newExperiment.setDescription(description); addProperties(newExperiment, properties); - + def addProperties(entity, properties): for property in properties: - addProperty(entity, property[0], property[1], property[2], property[3], property[4]); - -def addProperty(entity, propertyCode, section, propertyLabel, dataType, propertyDescription): + addProperty(entity, property[0], property[1], property[2], property[3], property[4], property[5]); + +def addProperty(entity, propertyCode, section, propertyLabel, dataType, vocabularyCode, propertyDescription): property = None; if propertyCode in propertiesCache: @@ -55,6 +70,8 @@ def addProperty(entity, propertyCode, section, propertyLabel, dataType, property property.setDescription(propertyDescription); property.setLabel(propertyLabel); propertiesCache[propertyCode] = property; + if dataType == DataType.CONTROLLEDVOCABULARY: + property.setVocabulary(vocabulariesCache[vocabularyCode]); propertyAssignment = tr.assignPropertyType(entity, property); propertyAssignment.setSection(section); @@ -326,12 +343,20 @@ createVocabularyWithTerms("MACHINE", [ ["SRX_101A", "Konica Minolta SRX-101A"], ["LIGHT_CYCLER", "LightCycler 480"] ]); + ## -## Property Types +## DataSet Types ## -NOTES = tr.getOrCreateNewPropertyType("NOTES", DataType.MULTILINE_VARCHAR); -NOTES.setDescription("Notes regarding the dataset"); -NOTES.setLabel("Notes"); + +createDataSetTypeWithProperties("ELN_PREVIEW", "PHYSICAL", "ELN Preview image", []); + +createDataSetTypeWithProperties("SEQ_FILE", "PHYSICAL", "", [ + ["NOTES", "General information", "Notes", DataType.MULTILINE_VARCHAR, None, "Notes regarding the dataset"], +]); + +createDataSetTypeWithProperties("RAW_DATA", "PHYSICAL", "", [ + ["NOTES", "General information", "Notes", DataType.MULTILINE_VARCHAR, None, "Notes regarding the dataset"], +]); ## ## Experiment Types @@ -354,31 +379,32 @@ createExperimentTypeWithProperties("PCR_PROTOCOL", "BOX TO HOLD SAMPLES OF THIS createExperimentTypeWithProperties("WESTERN_BLOTTING_PROTOCOL", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); createExperimentTypeWithProperties("DEFAULT_EXPERIMENT", "Default Experiment", [ - ["NAME", "General", "Name", DataType.VARCHAR, "Name"], - ["EXPERIMENTAL_GOALS", "General", "Experimental goals", DataType.MULTILINE_VARCHAR, "Goal of the experiment"], - ["GRANT", "General", "Grant", DataType.VARCHAR, "grant name"], - ["START_DATE", "General", "Start Date", DataType.TIMESTAMP, "Start Date"], - ["END_DATE", "General", "End Date", DataType.TIMESTAMP, "End Date"], - ["EXPERIMENTAL_RESULTS", "General", "Experimental results", DataType.MULTILINE_VARCHAR, "Brief summary of the results obtained"] + ["NAME", "General", "Name", DataType.VARCHAR, None, "Name"], + ["EXPERIMENTAL_GOALS", "General", "Experimental goals", DataType.MULTILINE_VARCHAR, None, "Goal of the experiment"], + ["GRANT", "General", "Grant", DataType.VARCHAR, None, "grant name"], + ["START_DATE", "General", "Start Date", DataType.TIMESTAMP, None, "Start Date"], + ["END_DATE", "General", "End Date", DataType.TIMESTAMP, None, "End Date"], + ["EXPERIMENTAL_RESULTS","General", "Experimental results", DataType.MULTILINE_VARCHAR, None, "Brief summary of the results obtained"], + ["XMLCOMMENTS", "Comments","Comments List", DataType.XML, None, "Several comments can be added by different users"] ]); ## -## Dataset +## Sample Types ## -ELN_PREVIEW = tr.getOrCreateNewDataSetType("ELN_PREVIEW") -ELN_PREVIEW.setDescription("ELN Preview"); -ELN_PREVIEW.setDataSetKind("PHYSICAL"); -SEQ_FILE = tr.getOrCreateNewDataSetType("SEQ_FILE") -SEQ_FILE.setDescription(""); -SEQ_FILE.setDataSetKind("PHYSICAL"); - -SEQ_FILE_NOTES = tr.assignPropertyType(SEQ_FILE, NOTES); -SEQ_FILE_NOTES.setSection("General information"); - -RAW_DATA = tr.getOrCreateNewDataSetType("RAW_DATA") -RAW_DATA.setDescription(""); -RAW_DATA.setDataSetKind("PHYSICAL"); - -RAW_DATA_NOTES = tr.assignPropertyType(RAW_DATA, NOTES); -RAW_DATA_NOTES.setSection("General information"); \ No newline at end of file +createSampleTypeWithProperties("ANTIBODY", "", [ + ["NAME", "General", "Name", DataType.VARCHAR, None, "Name"], + ["HOST", "General", "Host", DataType.CONTROLLEDVOCABULARY, "HOST", "Host used to produce the antibody"], + ["FOR_WHAT", "General", "For what", DataType.MULTILINE_VARCHAR, None, "For what kind of experimental application/readout this sample is used in the lab"], + ["DETECTION", "General", "Detection", DataType.CONTROLLEDVOCABULARY, "DETECTION","Protein detection system (fill in this information only for secondary antibodies)"], + ["EPITOPE", "General", "Epitope", DataType.MULTILINE_VARCHAR, None, "Epitope of the antibody"], + ["CLONALITY", "General", "Clonality", DataType.CONTROLLEDVOCABULARY, "CLONALITY","Clonality of the antibody"], + ["ISOTYPE", "General", "Isotype", DataType.MULTILINE_VARCHAR, None, "Isotype of the antibody"], + ["SUPPLIER", "Supplier and storage", "Supplier", DataType.MULTILINE_VARCHAR, None, "Supplier of the product"], + ["ARTICLE_NUMBER", "Supplier and storage", "Art. Number", DataType.MULTILINE_VARCHAR, None, "Article number of the product"], + ["STORAGE", "Supplier and storage", "Storage", DataType.CONTROLLEDVOCABULARY, "STORAGE", "Storage conditions of the product"], + ["STOCK_CONCENTRATION", "Supplier and storage", "Stock concentration", DataType.VARCHAR, None, "Stock concentration of the solution where the product is kept in the lab"], + ["PUBLICATION", "Comments", "Publication", DataType.MULTILINE_VARCHAR, None, "Publication from where the information was first found OR technical sheet given by the manufacturer"], + ["NOTES", "Comments", "Notes", DataType.MULTILINE_VARCHAR, None, "Notes"], + ["XMLCOMMENTS", "Comments", "Comments List", DataType.XML, None, "Several comments can be added by different users"] +]);