コード例 #1
0
def addFeaturesToPuvspr2File(setupObject, addAbundDict):
    for puID in addAbundDict:
        puAddAbundDict = addAbundDict[puID]
        try:
            puAbundDict = setupObject.abundPUKeyDict[puID]
        except KeyError:
            puAbundDict = {}
        for featID in puAddAbundDict:
            puAbundDict[featID] = puAddAbundDict[featID]
        setupObject.abundPUKeyDict[puID] = puAbundDict

    cluz_setup.makePuvspr2DatFile(setupObject)
コード例 #2
0
ファイル: cluz_dialog1.py プロジェクト: AnotherBobSmith/CLUZ
    def convertCSVToAbundTable(self, setupObject):
        layerFactorCheck = True
        convFactorCheck = True

        unitIDFieldName = self.idfieldComboBox.currentText()
        csvFilePath = self.csvFileLineEdit.text()
        if csvFilePath == "":
            self.close()
            QMessageBox.critical(None, "No file specified", "Please specify a csv file to import.")
            layerFactorCheck = False
        elif os.path.isfile(csvFilePath) == False:
            self.close()
            QMessageBox.critical(None, "Incorrect format", "The specified csv file does not exist.")
            layerFactorCheck = False
        else:
            pass

        if layerFactorCheck == True:
            convFactor = 1 # Default value
            if self.userRadioButton.isChecked():
                try:
                    convFactor = float(self.convLineEdit.text())
                    if convFactor <= 0:
                        self.close()
                        QMessageBox.critical(None, "Incorrect conversion value", "The conversion value must be a number greater than 0.")
                        convFactorCheck = False

                except:
                    self.close()
                    QMessageBox.critical(None, "Incorrect conversion value", "The conversion value must be a number greater than 0.")
                    convFactorCheck = False

        if layerFactorCheck == True and convFactorCheck == True:
            addAbundDict, featIDList, warningStatus = cluz_functions1.makeCsvAddAbundDict(setupObject, csvFilePath, unitIDFieldName, convFactor)
            if warningStatus == "ExistingFeatures":
                self.close()
                QMessageBox.critical(None, "Duplicate features", "The feature ID values in the table duplicate some of those in the abundance table. This process will terminate.")
            elif warningStatus == "HeaderWithNoID":
                self.close()
                QMessageBox.critical(None, "Missing ID code", "One of the fields containing abundance data in the specified table does not contain any numerical characters and so does not specify the feature ID. This process will terminate.")
            else:
                setupObject.abundPUKeyDict = cluz_functions1.addAbundDictToAbundPUKeyDict(setupObject, addAbundDict)
                cluz_setup.makePuvspr2DatFile(setupObject)
                cluz_setup.makeSporderDatFile(setupObject)

                cluz_functions1.addFeaturesToTargetCsvFile(setupObject, addAbundDict, featIDList)
                setupObject.targetDict = cluz_setup.makeTargetDict(setupObject)

                self.close()
コード例 #3
0
    def convertCSVToAbundTable(self, setupObject):
        layerFactorCheck = True
        convFactorCheck = True

        unitIDFieldName = self.idfieldComboBox.currentText()
        csvFilePath = self.csvFileLineEdit.text()
        if csvFilePath == "":
            self.close()
            QMessageBox.critical(None, "No file specified",
                                 "Please specify a csv file to import.")
            layerFactorCheck = False
        elif os.path.isfile(csvFilePath) == False:
            self.close()
            QMessageBox.critical(None, "Incorrect format",
                                 "The specified csv file does not exist.")
            layerFactorCheck = False
        else:
            pass

        if layerFactorCheck == True:
            convFactor = 1  # Default value
            if self.userRadioButton.isChecked():
                try:
                    convFactor = float(self.convLineEdit.text())
                    if convFactor <= 0:
                        self.close()
                        QMessageBox.critical(
                            None, "Incorrect conversion value",
                            "The conversion value must be a number greater than 0."
                        )
                        convFactorCheck = False

                except:
                    self.close()
                    QMessageBox.critical(
                        None, "Incorrect conversion value",
                        "The conversion value must be a number greater than 0."
                    )
                    convFactorCheck = False

        if layerFactorCheck == True and convFactorCheck == True:
            addAbundDict, featIDList, warningStatus = cluz_functions1.makeCsvAddAbundDict(
                setupObject, csvFilePath, unitIDFieldName, convFactor)
            if warningStatus == "ExistingFeatures":
                self.close()
                QMessageBox.critical(
                    None, "Duplicate features",
                    "The feature ID values in the table duplicate some of those in the abundance table. This process will terminate."
                )
            elif warningStatus == "HeaderWithNoID":
                self.close()
                QMessageBox.critical(
                    None, "Missing ID code",
                    "One of the fields containing abundance data in the specified table does not contain any numerical characters and so does not specify the feature ID. This process will terminate."
                )
            else:
                setupObject.abundPUKeyDict = cluz_functions1.addAbundDictToAbundPUKeyDict(
                    setupObject, addAbundDict)
                cluz_setup.makePuvspr2DatFile(setupObject)
                cluz_setup.makeSporderDatFile(setupObject)

                cluz_functions1.addFeaturesToTargetCsvFile(
                    setupObject, addAbundDict, featIDList)
                setupObject.targetDict = cluz_setup.makeTargetDict(setupObject)

                self.close()