Ejemplo n.º 1
0
	def updateContainerSize(self, contID, contSize):
		
		db = self.db
		cursor = self.cursor	# for easy access
		
		ltHandler = LocationTypeHandler(db, cursor)
		
		contSizeID = ltHandler.containerSizeToID(contSize)
		
		cursor.execute("UPDATE Container_tbl SET contTypeID=" + `contSizeID` + " WHERE containerID=" + `contID` + " AND status='ACTIVE'")
	def deleteContainerType(self, form):
		
		db = self.__db
		cursor = self.__cursor
		hostname = self.__hostname
	
		ltHandler = LocationTypeHandler(db, cursor)
		
		#print "Content-type:text/html"
		#print
		#print `form`
		
		contTypeID = form.getvalue("containerType")
		#print contTypeID
		
		ltHandler.deleteContainerType(contTypeID)
		utils.redirect(hostname + "Location.php?View=6&Sub=4&Del=1")
    def deleteContainerType(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        ltHandler = LocationTypeHandler(db, cursor)

        #print "Content-type:text/html"
        #print
        #print `form`

        contTypeID = form.getvalue("containerType")
        #print contTypeID

        ltHandler.deleteContainerType(contTypeID)
        utils.redirect(hostname + "Location.php?View=6&Sub=4&Del=1")
Ejemplo n.º 4
0
	def updateContainerType(self, contID, contType):
		
		db = self.db
		cursor = self.cursor	# for easy access
	
		ltHandler = LocationTypeHandler(db, cursor)
		
		contTypeID = ltHandler.containerTypeToID(contType)

		# container number needs to be updated too, since the container was moved into a new group
		contNum = self.findNextContainerNumberInGroup(contTypeID)
		cursor.execute("UPDATE Container_tbl SET contGroupCount=" + `contNum` + " WHERE containerID=" + `contID` + " AND status='ACTIVE'")

		# AND container-type specific properties need to be changed too
		self.updateContainerProperties(contID, contType)
		
		# Finally change container type
		cursor.execute("UPDATE Container_tbl SET contGroupID=" + `contTypeID` + " WHERE containerID=" + `contID` + " AND status='ACTIVE'")
Ejemplo n.º 5
0
	def updateContainerInfo(self, contID, contType, contSize, contName, contDesc, contLab, storage_type, storage_name, storage_address, cont_shelf, cont_rack, cont_row, cont_col):
		
		db = self.db
		cursor = self.cursor	# for easy access
		
		ltHandler = LocationTypeHandler(db, cursor)
		
		contTypeID = ltHandler.containerTypeToID(contType)
		contSizeID = ltHandler.containerSizeToID(contSize)
		
		# Compare old container properties to new values and only update those that have actually changed
		oldContType = self.findContainerType(contID)
		oldContSize = self.findContainerSize(contID)
		oldContName = self.findContainerName(contID)
		oldContDesc = self.findContainerDescription(contID)
		oldLabID = self.findContainerLabID(contID)
		oldBarcode = self.findContainerBarcode(contID)
		

		# Update barcode IFF container type, lab or size were changed!!!!
		if oldBarcode == '' or oldContType != contType or oldContSize != contSize or oldLabID != contLab:

			# only in this case recompute barcode
			contNum = self.findNextContainerBarcodeNumber(contTypeID, contSizeID, contLab)
			
			newBarcode = self.generateBarcode(contTypeID, contSizeID, contNum, contLab)
			self.updateContainerBarcode(contID, newBarcode)
		
		# Update the rest of the container properties if old and new values differ:
		if contType != oldContType:
			self.updateContainerType(contID, contType)
		
		if contSize != oldContSize:
			self.updateContainerSize(contID, contSize)
		
		if contName != oldContName:
			self.updateContainerName(contID, contName)
	
		if contDesc != oldContDesc:
			self.updateContainerDescription(contID, contDesc)
		
		if contLab != oldLabID:
			self.updateContainerLab(contID, contLab)
    def updateContainerType(self, form):
        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        ltHandler = LocationTypeHandler(db, cursor)

        contTypeID = form.getvalue("containerType")

        contName = ""
        contDesc = ""

        #print "Content-type:text/html"
        #print
        #print `form`

        contTypeID = int(form.getvalue("containerType"))

        contGroupName = form.getvalue("cont_group_name_field")
        contGroupCode = form.getvalue("cont_cont_code_field")

        if form.has_key("cont_cont_isolateActive_radio"):
            if form.getvalue("cont_cont_isolateActive_radio").upper() == 'YES':
                isoActive = form.getvalue(
                    "cont_cont_isolateActive_radio").upper()
                #print isoActive
            else:
                isoActive = "NO"
        else:
            isoActive = ltHandler.findIsolateActive(contTypeID)

        newContTypeFeatures = form.getlist("container_features")

        reagentTypes = form.getlist("reagent_types")  # feb. 9/10

        #print `reagentTypes`

        ltHandler.updateContainerType(contTypeID, contGroupName, contGroupCode,
                                      isoActive, newContTypeFeatures,
                                      reagentTypes)

        utils.redirect(hostname + "Location.php?View=6&Sub=4&contTypeID=" +
                       ` contTypeID `)
Ejemplo n.º 7
0
	def generateBarcode(self, cTypeID, cSizeID, contNum, cLab):
		
		db = self.db
		cursor = self.cursor	# for easy access
		
		# Get the lab code that corresponds to lab ID
		lHandler = LabHandler(db, cursor)
		labCode = lHandler.findLabCode(cLab)
		
		ltHandler = LocationTypeHandler(db, cursor)
		
		# Find the container size
		contSize = ltHandler.findNumContainerSamples(cSizeID)
		
		# Find the container group code
		contTypeCode = ltHandler.findContainerTypeCode(cTypeID)

		# Produce a string barcode
		barcode = labCode + `contSize` + contTypeCode + `contNum`
		
		return barcode
	def updateContainerType(self, form):
		db = self.__db
		cursor = self.__cursor
		hostname = self.__hostname
	
		ltHandler = LocationTypeHandler(db, cursor)
		
		contTypeID = form.getvalue("containerType")
		
		contName = ""
		contDesc = ""
		
		#print "Content-type:text/html"
		#print
		#print `form`
		
		contTypeID = int(form.getvalue("containerType"))
		
		contGroupName = form.getvalue("cont_group_name_field")
		contGroupCode = form.getvalue("cont_cont_code_field")
		
		if form.has_key("cont_cont_isolateActive_radio"):
			if form.getvalue("cont_cont_isolateActive_radio").upper() == 'YES':
				isoActive = form.getvalue("cont_cont_isolateActive_radio").upper()
				#print isoActive
			else:
				isoActive = "NO"
		else:
			isoActive = ltHandler.findIsolateActive(contTypeID)
			
		newContTypeFeatures = form.getlist("container_features")
		
		reagentTypes = form.getlist("reagent_types")	# feb. 9/10
		
		#print `reagentTypes`

		ltHandler.updateContainerType(contTypeID, contGroupName, contGroupCode, isoActive, newContTypeFeatures, reagentTypes)
		
		utils.redirect(hostname + "Location.php?View=6&Sub=4&contTypeID=" + `contTypeID`)
Ejemplo n.º 9
0
	def insertContainer(self, contTypeID, cSize, cName, cDesc, cLab, storage_type, storage_name, storage_address, cont_shelf, cont_rack, cont_row, cont_col):
		
		db = self.db
		cursor = self.cursor	# for easy access
		
		ltHandler = LocationTypeHandler(db, cursor)
		
		# find 'container type' and 'container size' foreign keys
		#contTypeID = ltHandler.containerTypeToID(cType)
		cType = ltHandler.findContainerTypeName(contTypeID)
		contSizeID = ltHandler.containerSizeToID(cSize)
		
		# find the next available number in this container group to assign to the new container
		contNum = self.findNextContainerNumberInGroup(contTypeID)
		
		# check if this is an isolate active container
		isoActive = ltHandler.isIsoActive(contTypeID)

		# generate barcode
		bcNum = self.findNextContainerBarcodeNumber(contTypeID, contSizeID, cLab)
		barcode = self.generateBarcode(contTypeID, contSizeID, bcNum, cLab)
		
		cursor.execute("INSERT INTO Container_tbl(contGroupID, contTypeID, contGroupCount, name, container_desc, labID, barcode, location, locationName, address, shelf, rack, row_number, col_number) VALUES(" + `contTypeID` + ", " + `contSizeID` + ", " + `contNum` + ", " + `cName` + ", " + `cDesc` + ", " + `cLab` + ", " + `barcode` + ", " + `storage_type` + ", " + `storage_name` + ", " + `storage_address` + ", " + `cont_shelf` + ", " + `cont_rack` + ", " + `cont_row` + ", " + `cont_col` + ")")
		
		newContID = int(db.insert_id())
		
		# Store container-specific properties
		nRows = ltHandler.findNumRows(contSizeID)
		nCols = ltHandler.findNumCols(contSizeID)
		
		container = Container(cType, cSize, nRows, nCols, cName, cLab, cDesc)
		
		#props = container.getContainerProperties()
		props = ltHandler.findContainerTypeProperties(contTypeID)
		
		#print "Content-type:text/html"
		#print
		#print storage_type
		
		#print `props`
		self.insertContainerProperties(newContID, props)
		
		return newContID
    def addContainerType(self, form):

        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        ltHandler = LocationTypeHandler(db, cursor)

        # some form values may be blank, so initialize as empty
        contName = ""
        contDesc = ""

        #print "Content-type:text/html"
        #print
        #print `form`

        contGroupName = form.getvalue("cont_group_name_field")
        contGroupCode = form.getvalue("cont_cont_code_field")

        if form.has_key("cont_cont_isolateActive_radio"):
            if form.getvalue("cont_cont_isolateActive_radio").upper() == 'YES':
                isoActive = form.getvalue(
                    "cont_cont_isolateActive_radio").upper()
            else:
                isoActive = "NO"

        newContTypeFeatures = form.getlist("container_features")
        #print `newContTypeFeatures`
        newContTypeID = ltHandler.insertContainerType(contGroupName, isoActive,
                                                      contGroupCode)

        ltHandler.addContainerTypeFeatures(newContTypeID, newContTypeFeatures)

        reagentTypes = form.getlist("cont_cont_group_selection")  # feb. 16/10
        #print `reagentTypes`
        ltHandler.updateContainerReagentTypes(newContTypeID, reagentTypes)

        utils.redirect(hostname + "Location.php?View=6&Sub=4&contTypeID=" +
                       ` newContTypeID `)
	def addContainerType(self, form):
		
		db = self.__db
		cursor = self.__cursor
		hostname = self.__hostname
	
		ltHandler = LocationTypeHandler(db, cursor)
		
		# some form values may be blank, so initialize as empty
		contName = ""
		contDesc = ""
		
		#print "Content-type:text/html"
		#print
		#print `form`
		
		contGroupName = form.getvalue("cont_group_name_field")
		contGroupCode = form.getvalue("cont_cont_code_field")
		
		if form.has_key("cont_cont_isolateActive_radio"):
			if form.getvalue("cont_cont_isolateActive_radio").upper() == 'YES':
				isoActive = form.getvalue("cont_cont_isolateActive_radio").upper()
			else:
				isoActive = "NO"
		
		newContTypeFeatures = form.getlist("container_features")
		#print `newContTypeFeatures`
		newContTypeID = ltHandler.insertContainerType(contGroupName, isoActive, contGroupCode)
		
		ltHandler.addContainerTypeFeatures(newContTypeID, newContTypeFeatures)
		
		reagentTypes = form.getlist("cont_cont_group_selection")	# feb. 16/10
		#print `reagentTypes`
		ltHandler.updateContainerReagentTypes(newContTypeID, reagentTypes)
		
		utils.redirect(hostname + "Location.php?View=6&Sub=4&contTypeID=" + `newContTypeID`)
Ejemplo n.º 12
0
    def exportPlate(self, form):
        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LocationHandler(db, cursor)
        ltHandler = LocationTypeHandler(db, cursor)
        rHandler = ReagentHandler(db, cursor)

        prepPropMapper = PrepPropertyMapper(db, cursor)
        cTypeMapper = ContainerTypeMapper(db, cursor)

        prepProp_Name_ID_Map = prepPropMapper.mapPrepPropNameToID()
        prepProp_ID_Name_Map = prepPropMapper.mapPrepPropIDToName()

        contType_Name_ID_Map = cTypeMapper.mapContainerTypeNameToID()

        contID = int(form.getvalue("contID"))
        contName = lHandler.findContainerName(contID)
        contArray = contName.split(" ")
        fname = string.join(contArray, "_") + ".csv"

        wells = lHandler.findContainerWells(contID)
        content = ""

        # debug
        #print "Content-type:text/html"
        #print

        contType = lHandler.findContainerType(contID)
        contTypeID = contType_Name_ID_Map[contType]
        contProps = ltHandler.findContainerTypeProperties(
            contTypeID)  # array of names

        iso_active = ltHandler.isIsoActive(contTypeID)

        if iso_active == 'YES':
            isoActive = True
        else:
            isoActive = False

        #print `contProps`

        # Header
        if isoActive:
            content = "Well,OpenFreezer ID,Selected Isolate,Flag,Reference,Comments,"
        else:
            content = "Well,OpenFreezer ID,Flag,Reference,Comments,"

        contPropIDs_sorted = []

        for cPropName in contProps:
            cPropID = prepProp_Name_ID_Map[cPropName]
            contPropIDs_sorted.append(cPropID)

        contPropIDs_sorted.sort()

        for cPropID in contPropIDs_sorted:
            cPropName = prepProp_ID_Name_Map[cPropID]
            content += cPropName + ','

        content += '\n'

        numRows = lHandler.getNumRows(contID)
        numCols = lHandler.getNumCols(contID)

        plate = {}

        for well in wells:
            wellRowNum = well.getWellRowNumber()
            #print wellRowNum

            if plate.has_key(wellRowNum):
                plate[wellRowNum].append(well)
            else:
                tmp_ar = []
                tmp_ar.append(well)
                plate[wellRowNum] = tmp_ar

        plate.keys().sort()

        for rowNum in range(1, numRows + 1):
            if plate.has_key(rowNum):
                wellRow = plate[rowNum]
                wellRowNum = rowNum
                wellRowLetter = Well.convertRowNumberToChar(wellRowNum)

                wellRow.sort()

                #print "ROW " + `rowNum`

                for colNum in range(1, numCols + 1):
                    for well in wellRow:
                        wellID = well.getWellID()
                        #print wellID
                        wellCol = well.getWellColumn()

                        if wellCol == colNum:

                            #print "COLUMN " + `wellCol`

                            wellCoords = wellRowLetter + ":" + ` wellCol `

                            # get prep, reference, comments, flag
                            prepID = lHandler.findPrepIDInWell(wellID)
                            #print prepID
                            prepRef = lHandler.findPrepReference(prepID)
                            #print prepRef

                            if not prepRef:
                                prepRef = ""

                            prepComms = lHandler.findPrepComments(prepID)
                            #print prepComms

                            if not prepComms:
                                prepComms = ""

                            prepFlag = lHandler.findPrepFlag(prepID)
                            #print prepFlag

                            # get isolate number, selected isolate
                            isoID = lHandler.findPrepIsolateID(prepID)
                            isoNum = lHandler.findIsolateNumber(isoID)
                            isoSelected = lHandler.isSelectedIsolate(isoID)

                            # get prep property values
                            prepPropValues = lHandler.findAllPrepProperties(
                                prepID)

                            # find the LIMS ID of the reagent stored in this well
                            expID = lHandler.findExperimentIDByIsolate(isoID)
                            rID = lHandler.findReagentIDByExperiment(expID)
                            limsID = rHandler.convertDatabaseToReagentID(rID)

                            # Output: Well , Reagent-isolate , Selected , Flag , Reference , Comments , Attributes [name1 , name2 , name3....]
                            if isoActive:
                                content += wellCoords + ',' + limsID + "-" + ` isoNum ` + ',' + isoSelected + ',' + prepFlag + ',' + prepRef + ',' + prepComms + ","
                            else:
                                content += wellCoords + ',' + limsID + ',' + prepFlag + ',' + prepRef + ',' + prepComms + ","

                            prepPropIDs_sorted = {}

                            prepProps = {}

                            for pProp in prepPropValues:
                                pName = pProp.getPropName()
                                pVal = pProp.getPropValue()
                                prepProps[pName] = pVal

                            prepProps.keys().sort(
                            )  # might not be necessary but still

                            for cPropID in contPropIDs_sorted:
                                cPropName = prepProp_ID_Name_Map[cPropID]

                                if prepProps.has_key(cPropName):
                                    pVal = prepProps[cPropName]
                                    content += pVal + ','
                                else:
                                    content += ','

                            content += '\n'

        print "Content-type: application/octet-stream"
        print "Content-Disposition: attachment; name=" + fname
        print

        print content