Skip to content
Snippets Groups Projects
Commit 10f341ef authored by juanf's avatar juanf
Browse files

SSDM-1285 : ELN - Peter Lab Migration

SVN: 33044
parent 3bd1fc7c
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,7 @@ def setEntityProperties(tr, definition, entity, properties): ...@@ -61,7 +61,7 @@ def setEntityProperties(tr, definition, entity, properties):
vocabulary.addTerm(term) vocabulary.addTerm(term)
#Uses new vocabulary term #Uses new vocabulary term
propertyValue = codeToUse propertyValue = codeToUse
print repr(entity.getCode() + ", CREATED FOR VOCABULARY: " + propertyDefinition[4] + ", FOUND VALUE: " + labelToUse + ", NEW TERM WITH CODE: " + codeToUse) #print repr(entity.getCode() + ", CREATED FOR VOCABULARY: " + propertyDefinition[4] + ", FOUND VALUE: " + labelToUse + ", NEW TERM WITH CODE: " + codeToUse)
if propertyDefinition is not None: #Sometimes special fields are added for other purposes, these should not be set if propertyDefinition is not None: #Sometimes special fields are added for other purposes, these should not be set
entity.setPropertyValue(propertyCode, propertyValue) entity.setPropertyValue(propertyCode, propertyValue)
...@@ -203,30 +203,32 @@ class FMPeterBoxAdaptor(FileMakerEntityAdaptor): ...@@ -203,30 +203,32 @@ class FMPeterBoxAdaptor(FileMakerEntityAdaptor):
entityCodeFieldName = None entityCodeFieldName = None
def init(self): def init(self):
print "Reading boxes for: " + self.__class__.__name__
emptyBox = 0 emptyBox = 0
boxes = {} boxes = {}
EntityAdaptor.init(self) EntityAdaptor.init(self)
preparedStatement = self.connection.prepareStatement(self.selectBoxQuery) preparedStatement = self.connection.prepareStatement(self.selectBoxQuery)
result = preparedStatement.executeQuery() result = preparedStatement.executeQuery()
while result.next(): while result.next():
entityId = unicode(entityIdFieldName) entityId = unicode(result.getString(self.entityIdFieldName))
if entityId is not None: if entityId is not None:
if entityId in sampleID2Sample: if entityId in sampleID2Sample:
antibodyNumber = sampleID2Sample[entityId][entityCodeFieldName] antibodyNumber = sampleID2Sample[entityId][self.entityCodeFieldName]
values = {} if antibodyNumber is not None:
values["STORAGE_NAME"] = result.getString("location") values = {}
values["STORAGE_ROW"] = None values["STORAGE_NAME"] = result.getString("location")
values["STORAGE_COLUMN"] = None values["STORAGE_ROW"] = None
values["STORAGE_BOX_NAME"] = result.getString("box label") values["STORAGE_COLUMN"] = None
values["STORAGE_USER"] = result.getString("frozen by") values["STORAGE_BOX_NAME"] = result.getString("box label")
values["STORAGE_BOX_POSITION"] = result.getString("position") values["STORAGE_USER"] = result.getString("frozen by")
values["STORAGE_BOX_POSITION"] = result.getString("position")
allboxes = []
if antibodyNumber in boxes: allBoxes = []
allboxes = boxes[antibodyNumber] if antibodyNumber in boxes:
else: allBoxes = boxes[antibodyNumber]
boxes[antibodyNumber] = allboxes else:
allboxes.append(values) boxes[antibodyNumber] = allBoxes
allBoxes.append(values)
else: else:
#The antibody is not there. What the *#%$& #The antibody is not there. What the *#%$&
emptyBox += 1 emptyBox += 1
...@@ -236,17 +238,14 @@ class FMPeterBoxAdaptor(FileMakerEntityAdaptor): ...@@ -236,17 +238,14 @@ class FMPeterBoxAdaptor(FileMakerEntityAdaptor):
print "Not found: " + str(emptyBox) print "Not found: " + str(emptyBox)
for antibodyCode, allAntibodyBoxes in boxes.iteritems(): for entiyCode, allBoxes in boxes.iteritems():
self.addEntity({ self.addEntity({
"ANTIBODY_ID_NR" : antibodyCode, "*CODE" : entiyCode,
"*BOXESLIST" : allAntibodyBoxes "*BOXESLIST" : allBoxes
}) })
result.close() result.close()
preparedStatement.close() preparedStatement.close()
def addEntity(self, values):
self.entities.append(AntibodyBoxOpenBISDTO(values, self.definition))
## ##
## Antibodies ## Antibodies
...@@ -269,53 +268,10 @@ class AntibodyOpenBISDTO(FMPeterOpenBISDTO): ...@@ -269,53 +268,10 @@ class AntibodyOpenBISDTO(FMPeterOpenBISDTO):
def getIdentifier(self, tr): def getIdentifier(self, tr):
return self.values["ANTIBODY_ID_NR"] return self.values["ANTIBODY_ID_NR"]
class AntibodyBoxAdaptor(FileMakerEntityAdaptor): class AntibodyBoxAdaptor(FMPeterBoxAdaptor):
selectBoxQuery = "SELECT * FROM \"antibody boxes\""
def init(self): entityIdFieldName = "antibody ID"
emptyAntibodyBox = 0 entityCodeFieldName = "ANTIBODY_ID_NR"
antibodyBoxes = {}
self.selectQuery = "SELECT * FROM \"antibody boxes\""
EntityAdaptor.init(self)
preparedStatement = self.connection.prepareStatement(self.selectQuery)
result = preparedStatement.executeQuery()
while result.next():
antibodyID = unicode(result.getString("antibody ID"))
if antibodyID is not None:
if antibodyID in sampleID2Sample:
antibodyNumber = sampleID2Sample[antibodyID]["ANTIBODY_ID_NR"]
values = {}
values["STORAGE_NAME"] = result.getString("location")
values["STORAGE_ROW"] = None
values["STORAGE_COLUMN"] = None
values["STORAGE_BOX_NAME"] = result.getString("box label")
values["STORAGE_USER"] = result.getString("frozen by")
values["STORAGE_BOX_POSITION"] = result.getString("position")
allboxes = []
if antibodyNumber in antibodyBoxes:
allboxes = antibodyBoxes[antibodyNumber]
else:
antibodyBoxes[antibodyNumber] = allboxes
allboxes.append(values)
else:
#The antibody is not there. What the *#%$&
emptyAntibodyBox += 1
else:
#The antibody is not there. What the *#%$&
emptyAntibodyBox += 1
print "Antibody not found: " + str(emptyAntibodyBox)
for antibodyCode, allAntibodyBoxes in antibodyBoxes.iteritems():
self.addEntity({
"ANTIBODY_ID_NR" : antibodyCode,
"*BOXESLIST" : allAntibodyBoxes
})
result.close()
preparedStatement.close()
def addEntity(self, values): def addEntity(self, values):
self.entities.append(AntibodyBoxOpenBISDTO(values, self.definition)) self.entities.append(AntibodyBoxOpenBISDTO(values, self.definition))
...@@ -323,7 +279,7 @@ class AntibodyBoxAdaptor(FileMakerEntityAdaptor): ...@@ -323,7 +279,7 @@ class AntibodyBoxAdaptor(FileMakerEntityAdaptor):
class AntibodyBoxOpenBISDTO(OpenBISDTO): class AntibodyBoxOpenBISDTO(OpenBISDTO):
def write(self, tr): def write(self, tr):
sample = getSampleForUpdate("/INVENTORY/"+self.values["ANTIBODY_ID_NR"], None, tr) sample = getSampleForUpdate("/INVENTORY/"+self.values["*CODE"], None, tr)
#Delete old boxes #Delete old boxes
for boxNum in range(1, definitions.numberOfStorageGroups+1): for boxNum in range(1, definitions.numberOfStorageGroups+1):
for propertyCode in definitions.stogageGroupPropertyCodes: for propertyCode in definitions.stogageGroupPropertyCodes:
...@@ -353,7 +309,7 @@ class AntibodyBoxOpenBISDTO(OpenBISDTO): ...@@ -353,7 +309,7 @@ class AntibodyBoxOpenBISDTO(OpenBISDTO):
sample.setPropertyValue(propertyCode + "_" + str(boxNum), propertyValue) sample.setPropertyValue(propertyCode + "_" + str(boxNum), propertyValue)
def isBoxPressent(self, boxSignature, tr): def isBoxPressent(self, boxSignature, tr):
sample = getSampleForUpdate("/INVENTORY/"+self.values["ANTIBODY_ID_NR"], None, tr) sample = getSampleForUpdate("/INVENTORY/"+self.values["*CODE"], None, tr)
if sample is not None: if sample is not None:
for boxNum in range(1, definitions.numberOfStorageGroups+1): for boxNum in range(1, definitions.numberOfStorageGroups+1):
storedSignature = ""; storedSignature = "";
...@@ -592,14 +548,14 @@ fmConnStringServer = "jdbc:filemaker://fm.ethz.ch/" ...@@ -592,14 +548,14 @@ fmConnStringServer = "jdbc:filemaker://fm.ethz.ch/"
fmUserServer= "sistemp" fmUserServer= "sistemp"
fmPassServer = "ibcimsb2014" fmPassServer = "ibcimsb2014"
#adaptors = [#AntibodyAdaptor(fmConnString, fmUser, fmPass, "BOXIT_antibodies_Peter"), adaptors = [AntibodyAdaptor(fmConnString, fmUser, fmPass, "BOXIT_antibodies_Peter"),
#AntibodyBoxAdaptor(fmConnString, fmUser, fmPass, "BOXIT_antibody_boxes_Peter"), AntibodyBoxAdaptor(fmConnString, fmUser, fmPass, "BOXIT_antibody_boxes_Peter"),
#CellAdaptor(fmConnString, fmUser, fmPass, "BOXIT_cells_Peter"), #CellAdaptor(fmConnString, fmUser, fmPass, "BOXIT_cells_Peter"),
#PlasmidAdaptor(fmConnString, fmUser, fmPass, "BOXIT_plasmids_Peter"), #PlasmidAdaptor(fmConnString, fmUser, fmPass, "BOXIT_plasmids_Peter"),
#StrainAdaptor(fmConnString, fmUser, fmPass, "BOXIT_strains_Peter"), #StrainAdaptor(fmConnString, fmUser, fmPass, "BOXIT_strains_Peter"),
#SirnaAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"), #SirnaAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"),
#ChemicalAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"),] #ChemicalAdaptor(fmConnString, fmUser, fmPass, "BOXIT_Main_Menu_Peter"),
adaptors = [OligoAdaptor(fmConnString, fmUser, fmPass, "BOXIT_oligos_Peter"), #OligoAdaptor(fmConnString, fmUser, fmPass, "BOXIT_oligos_Peter"),
DocumentsAdaptor(fmConnString, fmUser, fmPass, "BOXIT_documents_Peter")] DocumentsAdaptor(fmConnString, fmUser, fmPass, "BOXIT_documents_Peter")]
def createDataHierarchy(tr): def createDataHierarchy(tr):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment