From cd11a9575f7a6b6610e705e1532b40498d4f312c Mon Sep 17 00:00:00 2001 From: barillac <barillac> Date: Fri, 12 Dec 2014 10:40:40 +0000 Subject: [PATCH] new sample types + dynamic properties added SVN: 33036 --- .../petermigration/1/as/definitions.py | 31 +++++--- .../1/as/initialize-master-data.py | 74 +++++++++++++++++-- .../1/compatibility/adenosine_count.py | 1 + .../1/compatibility/cytosine_count.py | 1 + .../petermigration/1/compatibility/gc.py | 9 +++ .../1/compatibility/guanosine_count.py | 1 + .../petermigration/1/compatibility/length.py | 9 +++ .../1/compatibility/nucleotide_count.py | 9 +++ .../1/compatibility/thymidine_count.py | 1 + .../petermigration/1/compatibility/tm.py | 9 +++ .../drop-boxes/petermigration/migration.py | 44 ++++++++++- 11 files changed, 168 insertions(+), 21 deletions(-) create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/adenosine_count.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/cytosine_count.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/gc.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/guanosine_count.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/length.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/nucleotide_count.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/thymidine_count.py create mode 100644 plasmid/source/core-plugins/petermigration/1/compatibility/tm.py diff --git a/plasmid/source/core-plugins/petermigration/1/as/definitions.py b/plasmid/source/core-plugins/petermigration/1/as/definitions.py index 220f739068a..2499678ad13 100644 --- a/plasmid/source/core-plugins/petermigration/1/as/definitions.py +++ b/plasmid/source/core-plugins/petermigration/1/as/definitions.py @@ -16,6 +16,14 @@ def getPropertyDefinitionByCode(definition, code): # Scripts # commentsScriptName = "COMMENTS"; +adenosineScriptName = "ADENOSINE_COUNT" +cytosineScriptName= "CYTOSINE_COUNT" +gcScriptName= "GC" +guanosineScriptName= "GUANOSINE_COUNT" +lengthScriptName= "SEQUENCE_LENGTH" +nucelotideScriptName= "ONUCLEOTIDE_COUNT" +thymidineScriptName= "THYMIDINE_COUNT" +tmScriptName= "TM" # # Storage @@ -90,7 +98,6 @@ antibodyDefinition = [ ["FROZEN", "General", "frozen", DataType.TIMESTAMP, None, "", None, None, False] ]; - cellDefinition = [ ["CO2", "General", "%CO2", DataType.CONTROLLEDVOCABULARY, "CO2", "", None, None, False], ["ATCC_NUM", "General", "ATCC No.", DataType.VARCHAR, None, "", None, None, False], @@ -207,7 +214,7 @@ strainDefinition = [ ]; oligoDefinition = [ - #["ADENOSINE", "General", "adenosine", DataType.XML, None, "", adenineScriptName], + ["ADENOSINE", "Calculated fields", "adenosine", DataType.INTEGER, None, "", adenosineScriptName, None, False], ["AMOUNT", "General", "amount", DataType.REAL, None, "", None, None, False], ["BARCODE", "General", "barcode", DataType.VARCHAR, None, "", None, None, False], ["BARCODE_LABEL", "General", "barcode label", DataType.VARCHAR, None, "", None, None, False], @@ -215,19 +222,19 @@ oligoDefinition = [ ["CONCENTRATION", "General", "concentration", DataType.REAL, None, "", None, None, False], ["CONCENTRATION_UNIT", "General", "concentration unit", DataType.CONTROLLEDVOCABULARY, "CONC_UNITS", "", None, None, False], ["CREATION_DATE", "General", "creation date", DataType.TIMESTAMP, None, "", None, None, False], - # ["CYTOSINE", "General", "cytosine", DataType.XML, None, "", cytosineScriptName], + ["CYTOSINE", "Calculated fields", "cytosine", DataType.INTEGER, None, "", cytosineScriptName, None, False], ["DATE", "General", "date", DataType.VARCHAR, None, "", None, None, False], ["FROZEN", "General", "frozen", DataType.TIMESTAMP, None, "", None, None, False], - #["GC", "General", "gc", DataType.XML, None, "", gcScriptName], + ["GC", "Calculated fields", "gc", DataType.REAL, None, "", gcScriptName, None, False], ["GENE_LOCUS", "General", "gene locus", DataType.VARCHAR, None, "", None, None, False], ["GRADE", "General", "grade", DataType.CONTROLLEDVOCABULARY, "OLIGO_GRADE", "", None, None, False], - #["GUANOSINE", "General", "guanosine", DataType.XML, None, "", guanosineScriptName], + ["GUANOSINE", "Calculated fields", "guanosine", DataType.INTEGER, None, "", guanosineScriptName, None, False], ["COMMENTS", "General", "Info", DataType.VARCHAR, None, "", None, None, False], ["INVESTIGATOR", "General", "investigator", DataType.CONTROLLEDVOCABULARY, "ALL_LAB_MEMBERS", "", None, None, False], - #["LENGTH", "General", "length", DataType.XML, None, "", lengthScriptName], - ["MODIFICATION_DATE", "General", "modification date", DataType.TIMESTAMP, None, "", None, None, False], - ["MODIFIED_BY", "General", "modified by", DataType.CONTROLLEDVOCABULARY, "ALL_LAB_MEMBERS", "", None, None, False], - #["O_NUCLEOTIDE", "General", "O nucleotide", DataType.XML, None, "", nucelotideScriptName], + ["LENGTH", "Calculated fields", "length", DataType.INTEGER, None, "", lengthScriptName, None, False], + ["MODIFICATION_DATE", "General", "modification date", DataType.TIMESTAMP, None, "", None, None, False], + ["MODIFIED_BY", "General", "modified by", DataType.CONTROLLEDVOCABULARY, "ALL_LAB_MEMBERS", "", None, None, False], + ["O_NUCLEOTIDE", "Calculated fields", "O nucleotide", DataType.INTEGER, None, "", nucelotideScriptName, None, False], ["OD", "General", "od", DataType.INTEGER, None, "", None, None, False], ["NAME", "General", "oligo ID", DataType.INTEGER, None, "", None, None, False], ["OLIGO_ID_NR", "General", "oligo_id_nr", DataType.VARCHAR, None, "", None, None, False], @@ -240,8 +247,8 @@ oligoDefinition = [ ["RESTRICTION_SITE", "General", "restriction site", DataType.CONTROLLEDVOCABULARY, "RESTRICTION", "", None, None, False], ["SEQUENCE", "General", "sequence", DataType.VARCHAR, None, "", None, None, False], ["SERIAL_NUMBER", "General", "serial number", DataType.VARCHAR, None, "", None, None, False], - #["THYMIDINE", "General", "thymidine", DataType.XML, None, "", thymidineScriptName], - #["TM", "General", "tm", DataType.XML, None, "", tmScriptName], + ["THYMIDINE", "Calculated fields", "thymidine", DataType.INTEGER, None, "", thymidineScriptName, None, False], + ["TM", "Calculated fields", "tm", DataType.REAL, None, "", tmScriptName, None, False], ["USAGE", "General", "usage", DataType.CONTROLLEDVOCABULARY, "OLIGO_USAGE", "", None, None, False] ]; @@ -334,7 +341,7 @@ siRNADefinition = [ ["OFF_TARGET_EFFECTS", "General", "Off target effects", DataType.VARCHAR, None, "", None, None, False], ["INFO", "General", "Info", DataType.VARCHAR, None, "", None, None, False], ["SPECIFIC_SPLICE_VARIANT", "General", "Specific splice variant", DataType.VARCHAR, None, "", None, None, False], - ["TRANSFECTION_AGENT", "General", "Transfection agent", DataType.VARCHAR, None, "", None, None, False], + ["TRANSFECTION_AGENT", "General", "Transfection agent", DataType.CONTROLLEDVOCABULARY, "TRANSFECTION_AGENT", "", None, None, False], ["PUBLISHED", "General", "Published", DataType.VARCHAR, None, "", None, None, False], ["LIBRARY", "General", "Library", DataType.VARCHAR, None, "", None, None, False], ["CHARACTERIZED_BY_COMPANY", "General", "Characterized by company", DataType.VARCHAR, None, "", None, None, False], diff --git a/plasmid/source/core-plugins/petermigration/1/as/initialize-master-data.py b/plasmid/source/core-plugins/petermigration/1/as/initialize-master-data.py index ebe35d1e62e..8227260d1e9 100644 --- a/plasmid/source/core-plugins/petermigration/1/as/initialize-master-data.py +++ b/plasmid/source/core-plugins/petermigration/1/as/initialize-master-data.py @@ -17,8 +17,8 @@ ## ## Configuration ## -PATH_TO_MANAGE_PROPERTIES_SCRIPTS = "/Users/juanf/Documents/workspace/openbis/source/core-plugins/petermigration/1/compatibility/"; -#PATH_TO_MANAGE_PROPERTIES_SCRIPTS = "/Users/barillac/openbis-peter/servers/core-plugins/petermigration/1/compatibility/"; +#PATH_TO_MANAGE_PROPERTIES_SCRIPTS = "/Users/juanf/Documents/workspace/openbis/source/core-plugins/petermigration/1/compatibility/"; +PATH_TO_MANAGE_PROPERTIES_SCRIPTS = "/Users/barillac/openbis-peter/servers/core-plugins/petermigration/1/compatibility/"; # MasterDataRegistrationTransaction Class import definitions @@ -133,7 +133,7 @@ def createScript(path, name, description, scriptType, entityType): return script; ## -## Manage properties scripts +## Managed properties scripts ## commentsScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "comments.py", definitions.commentsScriptName, @@ -141,6 +141,57 @@ commentsScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "comments.py", "MANAGED_PROPERTY", "SAMPLE"); +## +## Dynamic properties scripts +## +adenosineScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "adenosine_count.py", + definitions.adenosineScriptName, + "Count number of adenosine in sequence", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +cytosineScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "cytosine_count.py", + definitions.cytosineScriptName, + "Count number of cytosine in sequence", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +gcScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "gc.py", + definitions.gcScriptName, + "(guanosine+cytosine)*100/length", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +guanosineScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "guanosine_count.py", + definitions.guanosineScriptName, + "Count number of guanosine in sequence", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +lengthScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "length.py", + definitions.lengthScriptName, + "Count total length of sequence (A+C+T+G+O_nucleotide)", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +nucelotideScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "nucleotide_count.py", + definitions.nucelotideScriptName, + "Count number of r,y,m,k,s,w,h,b,d,x,N in sequence", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +thymidineScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "thymidine_count.py", + definitions.thymidineScriptName, + "Count number of thymidine in sequence", + "DYNAMIC_PROPERTY", + "SAMPLE"); + +tmScript = createScript(PATH_TO_MANAGE_PROPERTIES_SCRIPTS + "tm.py", + definitions.tmScriptName, + "68.3 + (0.41 * gc) - (600/length)", + "DYNAMIC_PROPERTY", + "SAMPLE"); + ## ## Vocabulary Types ## @@ -150,13 +201,26 @@ for vocabularyCode, vocabularyValues in definitionsVoc.vocacbularyDefinitions.it ## ## Experiment Types ## -createExperimentTypeWithProperties("ANTIBODY", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); createExperimentTypeWithProperties("DEFAULT_EXPERIMENT", "Default Experiment", definitions.experimentDefinition); - +createExperimentTypeWithProperties("ANTIBODY", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("CELL", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("STRAIN", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("PLASMID", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("CHEMICAL", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("SIRNA", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); +createExperimentTypeWithProperties("OLIGO", "BOX TO HOLD SAMPLES OF THIS TYPE FOR ORGANIZATIONAL PURPOSES", []); ## ## Sample Types ## createSampleTypeWithProperties("ANTIBODY", "", definitions.antibodyDefinition); +createSampleTypeWithProperties("CELL", "", definitions.cellDefinition); +createSampleTypeWithProperties("STRAIN", "", definitions.strainDefinition); +createSampleTypeWithProperties("PLASMID", "", definitions.plasmidDefinition); +createSampleTypeWithProperties("CHEMICAL", "", definitions.chemicalDefinition); +createSampleTypeWithProperties("SIRNA", "", definitions.siRNADefinition); +createSampleTypeWithProperties("OLIGO", "", definitions.oligoDefinition); + + addStorageGroups(definitions.numberOfStorageGroups, "ANTIBODY"); diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/adenosine_count.py b/plasmid/source/core-plugins/petermigration/1/compatibility/adenosine_count.py new file mode 100644 index 00000000000..58363afbe1c --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/adenosine_count.py @@ -0,0 +1 @@ +entity.propertyValue('SEQUENCE').count('A')+entity.propertyValue('SEQUENCE').count('a') \ No newline at end of file diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/cytosine_count.py b/plasmid/source/core-plugins/petermigration/1/compatibility/cytosine_count.py new file mode 100644 index 00000000000..faed851214f --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/cytosine_count.py @@ -0,0 +1 @@ +entity.propertyValue('SEQUENCE').count('C')+entity.propertyValue('SEQUENCE').count('c') \ No newline at end of file diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/gc.py b/plasmid/source/core-plugins/petermigration/1/compatibility/gc.py new file mode 100644 index 00000000000..5067337f62e --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/gc.py @@ -0,0 +1,9 @@ +import re + +def calculate_Onuc(): + result = (len(re.findall("G|g|C|c", entity.propertyValue('SEQUENCE'))) * 100)/len(re.findall("A|a|C|c|G|g|T|t|R|r|Y|y|M|m|K|k|S|s|W|w|H|h|b|B|D|d|X|x|n|N", entity.propertyValue('SEQUENCE'))) + + return result + +def calculate(): + return calculate_Onuc() diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/guanosine_count.py b/plasmid/source/core-plugins/petermigration/1/compatibility/guanosine_count.py new file mode 100644 index 00000000000..913b9db58cc --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/guanosine_count.py @@ -0,0 +1 @@ +entity.propertyValue('SEQUENCE').count('G')+entity.propertyValue('SEQUENCE').count('g') \ No newline at end of file diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/length.py b/plasmid/source/core-plugins/petermigration/1/compatibility/length.py new file mode 100644 index 00000000000..13aedef6fbb --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/length.py @@ -0,0 +1,9 @@ +import re + +def calculate_Onuc(): + result = len(re.findall("A|a|C|c|G|g|T|t|R|r|Y|y|M|m|K|k|S|s|W|w|H|h|b|B|D|d|X|x|n|N", entity.propertyValue('SEQUENCE'))) + + return result + +def calculate(): + return calculate_Onuc() diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/nucleotide_count.py b/plasmid/source/core-plugins/petermigration/1/compatibility/nucleotide_count.py new file mode 100644 index 00000000000..e7630820e04 --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/nucleotide_count.py @@ -0,0 +1,9 @@ +import re + +def calculate_Onuc(): + result = len(re.findall("R|r|Y|y|M|m|K|k|S|s|W|w|H|h|b|B|D|d|X|x|n|N", entity.propertyValue('SEQUENCE'))) + + return result + +def calculate(): + return calculate_Onuc() diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/thymidine_count.py b/plasmid/source/core-plugins/petermigration/1/compatibility/thymidine_count.py new file mode 100644 index 00000000000..9d9db9385a9 --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/thymidine_count.py @@ -0,0 +1 @@ +entity.propertyValue('SEQUENCE').count('T')+entity.propertyValue('SEQUENCE').count('t') \ No newline at end of file diff --git a/plasmid/source/core-plugins/petermigration/1/compatibility/tm.py b/plasmid/source/core-plugins/petermigration/1/compatibility/tm.py new file mode 100644 index 00000000000..a841d384a32 --- /dev/null +++ b/plasmid/source/core-plugins/petermigration/1/compatibility/tm.py @@ -0,0 +1,9 @@ +import re + +def calculate_Onuc(): + result =68.3+ (0.41* float(len(re.findall("G|g|C|c", entity.propertyValue('SEQUENCE'))) * 100)/float(len(re.findall("A|a|C|c|G|g|T|t|R|r|Y|y|M|m|K|k|S|s|W|w|H|h|b|B|D|d|X|x|n|N", entity.propertyValue('SEQUENCE'))))) -(600/float(len(re.findall("A|a|C|c|G|g|T|t|R|r|Y|y|M|m|K|k|S|s|W|w|H|h|b|B|D|d|X|x|n|N", entity.propertyValue('SEQUENCE'))))) + + return result + +def calculate(): + return calculate_Onuc() diff --git a/plasmid/source/core-plugins/petermigration/1/dss/drop-boxes/petermigration/migration.py b/plasmid/source/core-plugins/petermigration/1/dss/drop-boxes/petermigration/migration.py index 2e0335b67a4..2a7969b7f4c 100644 --- a/plasmid/source/core-plugins/petermigration/1/dss/drop-boxes/petermigration/migration.py +++ b/plasmid/source/core-plugins/petermigration/1/dss/drop-boxes/petermigration/migration.py @@ -427,6 +427,41 @@ class PlasmidOpenBISDTO(OpenBISDTO): else : return False +class OligoAdaptor(FileMakerEntityAdaptor): + + def init(self): + self.selectQuery = "SELECT * FROM \"boxit oligos\"" + self.definition = definitions.oligoDefinition + FileMakerEntityAdaptor.init(self) + + def addEntity(self, values): + self.entities.append(OligoOpenBISDTO(values, self.definition)) + +class OligoOpenBISDTO(OpenBISDTO): + def write(self, tr): + code = self.values["OLIGO_ID_NR"] + if code is not None: + sample = getSampleForUpdate("/INVENTORY/"+code,"OLIGO", tr) + setEntityProperties(tr, self.definition, sample, self.values); + + def getIdentifier(self, tr): + code = self.values["OLIGO_ID_NR"] + return code + + def isInOpenBIS(self, tr): + antibodyID2Antibody[self.values["NAME"]] = self.values + code = self.values["OLIGO_ID_NR"] + if code is not None: + sample = getSampleForUpdate("/INVENTORY/"+ code, None, tr) + if sample is not None: + lastModificationData = self.values["MODIFICATION_DATE"].strip() + lastModificationData = str(datetime.strptime(lastModificationData, "%Y-%m-%d"))[:10] + lastModificationOpenBIS = sample.getPropertyValue("MODIFICATION_DATE")[:10] + return lastModificationOpenBIS == lastModificationData + else : + return False + + class ChemicalAdaptor(FileMakerEntityAdaptor): def init(self): @@ -472,17 +507,17 @@ class SirnaAdaptor(FileMakerEntityAdaptor): class SirnaOpenBISDTO(OpenBISDTO): def write(self, tr): - code = self.values["SIRNA_OLIGONUMBER"] + code = "SI_" + self.values["SIRNA_OLIGONUMBER"] if code is not None: sample = getSampleForUpdate("/INVENTORY/"+code,"SIRNA", tr) setEntityProperties(tr, self.definition, sample, self.values); def getIdentifier(self, tr): - code = self.values["SIRNA_OLIGONUMBER"] + code = "SI_" +self.values["SIRNA_OLIGONUMBER"] return code def isInOpenBIS(self, tr): - code = self.values["SIRNA_OLIGONUMBER"] + code = "SI_" + self.values["SIRNA_OLIGONUMBER"] if code is not None: sample = getSampleForUpdate("/INVENTORY/"+ code, None, tr) if sample is not None: @@ -560,8 +595,9 @@ fmPassServer = "ibcimsb2014" #CellAdaptor(fmConnString, fmUser, fmPass, "BOXIT_cells_Peter"), #PlasmidAdaptor(fmConnString, fmUser, fmPass, "BOXIT_plasmids_Peter"), #StrainAdaptor(fmConnString, fmUser, fmPass, "BOXIT_strains_Peter"), + #SirnaAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"), #ChemicalAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"),] -adaptors = [SirnaAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"), +adaptors = [OligoAdaptor(fmConnString, fmUser, fmPass, "BOXIT_oligos_Peter"), DocumentsAdaptor(fmConnString, fmUser, fmPass, "BOXIT_documents_Peter")] def createDataHierarchy(tr): -- GitLab