def __init__(self, stageLayout, graphPaneObj, progressPaneObj, ratioWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. ratioWidget : QWidget The parent widget for this object. Used mainly for displaying error boxes. project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.ratioWidget = ratioWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We import the stage information from a json file if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/ratioStageInfo.json') infoFile = infoFile.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/ratioStageInfo.json" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Ratio Calculation", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QGridLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane self.internal_standardOption = QComboBox() self.internal_standardOption.addItem(" ") self.standardLabel = QLabel(self.stageInfo["standard_label"]) self.optionsGrid.addWidget(self.standardLabel, 0, 0) self.optionsGrid.addWidget(self.internal_standardOption, 0, 1) self.internal_standardOption.activated.connect(self.internal_standardClicked) self.internal_standardOption.setToolTip(self.stageInfo["standard_description"]) self.standardLabel.setToolTip(self.stageInfo["standard_description"]) self.standardLabel.setMaximumWidth(150) self.optionsGrid.setColumnStretch(2,1) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the apply button for the right-most section of the Controls Pane. self.applyButton = QPushButton("APPLY") self.applyButton.clicked.connect(self.pressedApplyButton) self.stageControls.addApplyButton(self.applyButton) self.applyButton.setEnabled(False) #log self.logger = logging.getLogger(__name__) self.logger.info('ratio initialised')
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, importStageWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. importStageWidget : QWidget A reference to this stage's widget in order to manage popup windows project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.logger = logging.getLogger(__name__) self.logger.info('Initialised import stage!') self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.importStageWidget = importStageWidget self.fileLocation = "" self.project = project self.importListener = None self.guideDomain = links[0] self.reportIssue = links[1] # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We capture the default parameters for this stage's function call self.defaultParams = self.stageControls.getDefaultParameters( inspect.signature(la.analyse)) # We import the stage information from a json file and set the default data folder if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/importStageInfo.json') infoFile = infoFile.replace('\\', '/') self.defaultDataFolder = os.path.join( os.path.dirname(sys.executable), "./data/") self.defaultDataFolder = self.defaultDataFolder.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/importStageInfo.json" self.defaultDataFolder = "./data/" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Import Data", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QGridLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane self.findDataButton = QPushButton(self.stageInfo["find_data_label"]) self.findDataButton.setMaximumWidth(100) self.findDataButton.clicked.connect(self.findDataButtonClicked) self.optionsGrid.addWidget(self.findDataButton, 0, 0) self.findDataButton.setToolTip(self.stageInfo["find_data_description"]) self.fileLocationLine = QLineEdit(self.defaultDataFolder) self.optionsGrid.addWidget(self.fileLocationLine, 0, 1) self.fileLocationLine.setReadOnly(True) self.fileLocationLine.setToolTip( self.stageInfo["find_data_description"]) self.configOption = QComboBox() # The configOption values are added based on the read_latoolscfg values for key in dict(la.config.read_latoolscfg()[1]): self.configOption.addItem(key) # The config option self.config_label = QLabel(self.stageInfo["config_label"]) self.optionsGrid.addWidget(self.config_label, 1, 0) self.optionsGrid.addWidget(self.configOption, 1, 1) self.configOption.setToolTip(self.stageInfo["config_description"]) self.config_label.setToolTip(self.stageInfo["config_description"]) # The SRM identifier option self.srm_identifierLabel = QLabel(self.stageInfo["srm_label"]) self.srm_identifierOption = QLineEdit( self.defaultParams['srm_identifier']) self.optionsGrid.addWidget(self.srm_identifierLabel, 2, 0) self.optionsGrid.addWidget(self.srm_identifierOption, 2, 1) self.srm_identifierOption.setToolTip(self.stageInfo["srm_description"]) self.srm_identifierLabel.setToolTip(self.stageInfo["srm_description"]) # The file extension option self.file_extensionLabel = QLabel( self.stageInfo["file_extension_label"]) self.file_extensionOption = QLineEdit(self.defaultParams['extension']) self.optionsGrid.addWidget(self.file_extensionLabel, 3, 0) self.optionsGrid.addWidget(self.file_extensionOption, 3, 1) self.file_extensionOption.setToolTip( self.stageInfo["file_extension_description"]) self.file_extensionLabel.setToolTip( self.stageInfo["file_extension_description"]) # We create a button for the converter window self.converterButton = QPushButton("Data converter") self.converterButton.clicked.connect(self.converterPressed) self.stageControls.addDefaultButton(self.converterButton) # We create a button to open the Make a New Configuration popup window self.makeConfigButton = QPushButton("Make configuration") self.makeConfigButton.clicked.connect(self.makeConfig) self.stageControls.addDefaultButton(self.makeConfigButton) # We create a reset to default button self.defaultButton = QPushButton("Defaults") self.defaultButton.clicked.connect(self.defaultButtonPress) self.stageControls.addDefaultButton(self.defaultButton) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the button for the right-most section of the Controls Pane. self.applyButton = QPushButton("APPLY") self.applyButton.clicked.connect(self.pressedApplyButton) self.stageControls.addApplyButton(self.applyButton)
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, autorangeWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. autorangeWidget : QWidget The parent widget for this object. Used mainly for displaying error boxes. project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.autorangeWidget = autorangeWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We capture the default parameters for this stage's function call self.defaultParams = self.stageControls.getDefaultParameters( inspect.signature(la.analyse.autorange)) # We import the stage information from a json file if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/autorangeStageInfo.json') infoFile = infoFile.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/autorangeStageInfo.json" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Autorange", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QGridLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane self.analyteBox = QComboBox() self.analyteLabel = QLabel(self.stageInfo["analyte_label"]) self.analyteBox.addItem("total_counts") self.optionsGrid.addWidget(self.analyteLabel, 0, 0) self.optionsGrid.addWidget(self.analyteBox, 0, 1) self.analyteBox.setToolTip(self.stageInfo["analyte_description"]) self.analyteLabel.setToolTip(self.stageInfo["analyte_description"]) self.gwinLabel = QLabel(self.stageInfo["gwin_label"]) self.gwinEdit = QLineEdit(self.defaultParams['gwin']) self.optionsGrid.addWidget(self.gwinLabel, 1, 0) self.optionsGrid.addWidget(self.gwinEdit, 1, 1) self.gwinEdit.setToolTip(self.stageInfo["gwin_description"]) self.gwinLabel.setToolTip(self.stageInfo["gwin_description"]) self.swinLabel = QLabel(self.stageInfo["swin_label"]) self.swinEdit = QLineEdit(self.defaultParams['swin']) self.optionsGrid.addWidget(self.swinLabel, 2, 0) self.optionsGrid.addWidget(self.swinEdit, 2, 1) self.swinEdit.setToolTip(self.stageInfo["swin_description"]) self.swinLabel.setToolTip(self.stageInfo["swin_description"]) self.winLabel = QLabel(self.stageInfo["win_label"]) self.winEdit = QLineEdit(self.defaultParams['win']) self.optionsGrid.addWidget(self.winLabel, 3, 0) self.optionsGrid.addWidget(self.winEdit, 3, 1) self.winEdit.setToolTip(self.stageInfo["win_description"]) self.winLabel.setToolTip(self.stageInfo["win_description"]) self.on_multLabel = QLabel(self.stageInfo["on_mult_label"]) self.on_multEdit1 = QLineEdit("1.0") self.on_multEdit2 = QLineEdit("1.5") self.optionsGrid.addWidget(self.on_multLabel, 0, 2) self.optionsGrid.addWidget(self.on_multEdit1, 0, 3) self.optionsGrid.addWidget(self.on_multEdit2, 0, 4) self.on_multEdit1.setToolTip(self.stageInfo["on_mult_description"]) self.on_multEdit2.setToolTip(self.stageInfo["on_mult_description"]) self.on_multLabel.setToolTip(self.stageInfo["on_mult_description"]) self.off_multLabel = QLabel(self.stageInfo["off_mult_label"]) self.off_multEdit1 = QLineEdit("1.5") self.off_multEdit2 = QLineEdit("1.0") self.optionsGrid.addWidget(self.off_multLabel, 1, 2) self.optionsGrid.addWidget(self.off_multEdit1, 1, 3) self.optionsGrid.addWidget(self.off_multEdit2, 1, 4) self.off_multEdit1.setToolTip(self.stageInfo["off_mult_description"]) self.off_multEdit2.setToolTip(self.stageInfo["off_mult_description"]) self.off_multLabel.setToolTip(self.stageInfo["off_mult_description"]) # self.nbinLabel = QLabel(self.stageInfo["nbin_label"]) # self.nbinEdit = QLineEdit(self.defaultParams.get('nbin', "10")) # self.optionsGrid.addWidget(self.nbinLabel, 2, 2) # self.optionsGrid.addWidget(self.nbinEdit, 2, 3, 1, 2) # self.nbinEdit.setToolTip(self.stageInfo["nbin_description"]) # self.nbinLabel.setToolTip(self.stageInfo["nbin_description"]) self.logTransformCheck = QCheckBox( self.stageInfo["log_transform_label"]) self.logTransformCheck.setChecked( self.defaultParams['transform'] == 'True') self.optionsGrid.addWidget(self.logTransformCheck, 2, 2, 1, 2) self.logTransformCheck.setToolTip( self.stageInfo["log_transform_description"]) # We create a reset to default button self.defaultButton = QPushButton("Defaults") self.defaultButton.clicked.connect(self.defaultButtonPress) self.stageControls.addDefaultButton(self.defaultButton) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the button for the right-most section of the Controls Pane. self.applyButton = QPushButton("APPLY") self.applyButton.clicked.connect(self.pressedApplyButton) self.stageControls.addApplyButton(self.applyButton) # Initializing the logger self.logger = logging.getLogger(__name__) #Validators self.gwinEdit.setValidator(QIntValidator()) self.swinEdit.setValidator(QIntValidator()) self.winEdit.setValidator(QIntValidator()) self.on_multEdit1.setValidator(QDoubleValidator()) self.off_multEdit1.setValidator(QDoubleValidator())
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, calibrationWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. calibrationWidget : QWidget The parent widget for this object. Used mainly for displaying error boxes. project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.calibrationWidget = calibrationWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] self.imported_srms = False # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) self.srmfile = None self.srmList = [] self.autoApplyButton = False # We capture the default parameters for this stage's function call self.defaultParams = self.stageControls.getDefaultParameters(inspect.signature(la.analyse.calibrate)) # We import the stage information from a json file if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/calibrationStageInfo.json') infoFile = infoFile.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/calibrationStageInfo.json" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Calibration", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsHBox = QHBoxLayout(self.stageControls.getOptionsWidget()) # We create a panel on the left for options self.optionsLeftWidget = QWidget() self.optionsLeft = QGridLayout(self.optionsLeftWidget) self.optionsHBox.addWidget(self.optionsLeftWidget) # We create an area to hold the SRM list self.analytesWidget = QWidget() self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setWidgetResizable(True) self.scroll.setMinimumWidth(70) self.innerWidget = QWidget() self.innerWidget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.optionsRight = QVBoxLayout(self.innerWidget) self.optionsHBox.addWidget(self.scroll) self.analytesWidget.scroll = self.scroll self.scroll.setWidget(self.innerWidget) # We define the stage options and add them to the Controls Pane self.drift_correctOption = QCheckBox(self.stageInfo["drift_correct_label"]) self.drift_correctOption.setChecked(self.defaultParams['drift_correct'] == 'True') self.optionsLeft.addWidget(self.drift_correctOption, 0, 0, 1, 2) self.drift_correctOption.setToolTip(self.stageInfo["drift_correct_description"]) self.optionsRight.addWidget(QLabel("<span style=\"color:#779999; font-weight:bold\">" + self.stageInfo["standard_label"] + "</span>")) #self.zero_interceptOption = QCheckBox(self.stageInfo["zero_intercept_label"]) #self.zero_interceptOption.setChecked(self.defaultParams['zero_intercept'] == 'True') #self.optionsLeft.addWidget(self.zero_interceptOption, 1, 0) #self.zero_interceptOption.setToolTip(self.stageInfo["zero_intercept_description"]) self.n_minLabel = QLabel(self.stageInfo["n_min_label"]) self.n_minOption = QLineEdit(self.defaultParams['n_min']) self.optionsLeft.addWidget(self.n_minLabel, 2, 0) self.optionsLeft.addWidget(self.n_minOption, 2, 1) self.n_minOption.setToolTip(self.stageInfo["n_min_description"]) self.n_minLabel.setToolTip(self.stageInfo["n_min_description"]) self.reloadButton = QPushButton("View SRM table") self.reloadButton.clicked.connect(self.pressedReloadButton) self.stageControls.addApplyButton(self.reloadButton) self.reloadButton.setToolTip(self.stageInfo["srm_button_description"]) # We create the buttons for the top of the right-most section of the Controls Pane. self.defaultButton = QPushButton("Defaults") self.defaultButton.clicked.connect(self.defaultButtonPress) self.stageControls.addDefaultButton(self.defaultButton) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the buttons for the bottom of the right-most section of the Controls Pane. self.calcButton = QPushButton("Calculate calibration") self.calcButton.clicked.connect(self.pressedCalculateButton) #self.stageControls.addApplyButton(self.calcButton) self.popupButton = QPushButton("Plot in popup") self.popupButton.clicked.connect(self.pressedPopupButton) self.stageControls.addApplyButton(self.popupButton) self.popupButton.setEnabled(False) self.applyButton = QPushButton("Apply calibration") self.applyButton.clicked.connect(self.pressedApplyButton) self.stageControls.addApplyButton(self.applyButton) # self.applyButton.setEnabled(False) #Logger self.logger = logging.getLogger(__name__) self.logger.info('initialised calibration') #Validation self.n_minOption.setValidator(QIntValidator())
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, despikingWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. despikingWidget : QWidget The parent widget for this object. Used mainly for displaying error boxes. project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.despikingWidget = despikingWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We capture the default parameters for this stage's function call self.defaultParams = self.stageControls.getDefaultParameters( inspect.signature(la.analyse.despike)) # We import the stage information from a json file if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/despikeStageInfo.json') infoFile = infoFile.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/despikeStageInfo.json" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Data De-spiking", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QHBoxLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane # We make two despiking option areas, called pane1 and pane2 # We create the first pane of options self.pane1VWidget = QWidget() self.pane1VLayout = QVBoxLayout(self.pane1VWidget) self.exponentialLabel = QLabel(self.stageInfo["despike_1"]) self.pane1VLayout.addWidget(self.exponentialLabel) self.pane1Frame = QFrame() self.pane1Frame.setFrameShape(QFrame.StyledPanel) self.pane1Frame.setFrameShadow(QFrame.Raised) self.pane1Layout = QGridLayout(self.pane1Frame) self.pane1VLayout.addWidget(self.pane1Frame) self.pane1VLayout.addStretch(1) self.optionsGrid.addWidget(self.pane1VWidget) # We add the exp decay option self.pane1expdecayOption = QCheckBox(self.stageInfo["exp_decay_label"]) self.pane1expdecayOption.setChecked( self.defaultParams['expdecay_despiker'] == 'True') self.pane1Layout.addWidget(self.pane1expdecayOption, 0, 0, 1, 0) self.pane1expdecayOption.setToolTip( self.stageInfo["exp_decay_description"]) # We add the exponent option self.pane1ExponentLabel = QLabel(self.stageInfo["exponent_label"]) self.pane1Exponent = QLineEdit(self.defaultParams['exponent']) self.pane1Layout.addWidget(self.pane1ExponentLabel, 1, 0) self.pane1Layout.addWidget(self.pane1Exponent, 1, 1) self.pane1Exponent.setToolTip(self.stageInfo["exponent_description"]) self.pane1ExponentLabel.setToolTip( self.stageInfo["exponent_description"]) self.pane1Exponent.setPlaceholderText("auto") #self.pane1Maxiter = QLineEdit(self.defaultParams('maxiter')) #self.pane1Layout.addWidget(QLabel("maxiter"), 2, 0) #self.pane1Layout.addWidget(self.pane1Maxiter, 2, 1) # Second pane self.pane2VWidget = QWidget() self.pane2VLayout = QVBoxLayout(self.pane2VWidget) self.noiseLabel = QLabel(self.stageInfo["despike_2"]) self.pane2VLayout.addWidget(self.noiseLabel) self.pane2Frame = QFrame() self.pane2Frame.setFrameShape(QFrame.StyledPanel) self.pane2Frame.setFrameShadow(QFrame.Raised) self.pane2Layout = QGridLayout(self.pane2Frame) self.pane2VLayout.addWidget(self.pane2Frame) self.pane2VLayout.addStretch(1) self.optionsGrid.addWidget(self.pane2VWidget) # We create the noise option self.pane2NoiseOption = QCheckBox(self.stageInfo["noise_label"]) self.pane2NoiseOption.setChecked( self.defaultParams['noise_despiker'] == 'True') self.pane2Layout.addWidget(self.pane2NoiseOption, 0, 0, 1, 0) self.pane2NoiseOption.setToolTip(self.stageInfo["noise_description"]) # We create the win option self.winLabel = QLabel(self.stageInfo["win_label"]) self.pane2win = QLineEdit(self.defaultParams['win']) self.pane2Layout.addWidget(self.winLabel, 1, 0) self.pane2Layout.addWidget(self.pane2win, 1, 1) self.pane2win.setToolTip(self.stageInfo["win_description"]) self.winLabel.setToolTip(self.stageInfo["win_description"]) # We create the nlim option self.nlimLabel = QLabel(self.stageInfo["nlim_label"]) self.pane2nlim = QLineEdit(self.defaultParams['nlim']) #nlim self.pane2Layout.addWidget(self.nlimLabel, 2, 0) self.pane2Layout.addWidget(self.pane2nlim, 2, 1) self.pane2nlim.setToolTip(self.stageInfo["nlim_description"]) self.nlimLabel.setToolTip(self.stageInfo["nlim_description"]) # We create the maxiter option self.maxiterLabel = QLabel(self.stageInfo["maxiter_label"]) self.pane2Maxiter = QLineEdit(self.defaultParams['maxiter']) self.pane2Layout.addWidget(self.maxiterLabel, 3, 0) self.pane2Layout.addWidget(self.pane2Maxiter, 3, 1) self.pane2Maxiter.setToolTip(self.stageInfo["maxiter_description"]) self.maxiterLabel.setToolTip(self.stageInfo["maxiter_description"]) # We create a reset to default button self.defaultButton = QPushButton("Defaults") self.defaultButton.clicked.connect(self.defaultButtonPress) self.stageControls.addDefaultButton(self.defaultButton) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the button for the right-most section of the Controls Pane. self.applyButton = QPushButton("APPLY") self.applyButton.clicked.connect(self.pressedApplyButton) self.stageControls.addApplyButton(self.applyButton) self.pane1Exponent.setValidator(QDoubleValidator()) self.pane2win.setValidator(QDoubleValidator()) self.pane2nlim.setValidator(QDoubleValidator()) self.pane2Maxiter.setValidator(QIntValidator()) self.logger = logging.getLogger(__name__) self.logger.info('Initialised despiking stage')
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, exportStageWidget, project, links, mainWindow): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. exportStageWidget : QWidget A reference to this stage's widget in order to manage popup windows project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.logger = logging.getLogger(__name__) self.logger.info('Initialised import stage!') self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.exportStageWidget = exportStageWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] # Updated on import with the default location to export data to self.defaultDataFolder = "" self.statsExportCount = 1 # Updated with each completed focus stage self.focus_stages = [] self.focusSet = set() self.mainWindow = mainWindow # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We import the stage information from a json file and set the default data folder if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/exportStageInfo.json') infoFile = infoFile.replace('\\', '/') #self.defaultDataFolder = os.path.join(os.path.dirname(sys.executable), "./data/") #self.defaultDataFolder = self.defaultDataFolder.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/exportStageInfo.json" #self.defaultDataFolder = "./data/" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() self.stageControls.setDescription(self.stageInfo["stage_label"], self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QGridLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane # A combobox for the type of export #self.typeLabel = QLabel(self.stageInfo["type_label"]) self.typeCombo = QComboBox() #self.optionsGrid.addWidget(self.typeLabel, 0, 0) self.optionsGrid.addWidget(self.typeCombo, 0, 0, 1, 2) # We add the full export type option. The other will be added after the background removal stage. self.typeCombo.addItem("Full export") # Set the tooltips #self.typeLabel.setToolTip(self.stageInfo["type_description"]) self.typeCombo.setToolTip(self.stageInfo["type_description"]) # Connect a function for the type combobox self.typeCombo.activated.connect(self.typeChange) # A button to find the export folder's filepath self.locationButton = QPushButton(self.stageInfo["location_label"]) self.locationButton.setMaximumWidth(100) self.locationButton.clicked.connect(self.locationButtonClicked) self.optionsGrid.addWidget(self.locationButton, 0, 2) self.locationButton.setToolTip(self.stageInfo["location_description"]) # A line to display the currently selected folder path self.fileLocationLine = QLineEdit(self.defaultDataFolder) self.optionsGrid.addWidget(self.fileLocationLine, 0, 3) self.fileLocationLine.setReadOnly(True) self.fileLocationLine.setToolTip( self.stageInfo["location_description"]) # A pane for the export_traces option self.pane1Frame = QFrame() self.pane1Frame.setFrameShape(QFrame.StyledPanel) self.pane1Frame.setFrameShadow(QFrame.Raised) self.pane1Layout = QGridLayout(self.pane1Frame) self.optionsGrid.addWidget(self.pane1Frame, 1, 1, 2, 3) self.analysisLabel = QLabel( "<span style=\"color:#779999; font-weight:bold\">" + self.stageInfo["focus_label"] + "</span>") self.pane1Layout.addWidget(self.analysisLabel, 0, 0) self.analysisLabel.setToolTip(self.stageInfo["focus_description"]) self.updateFocus("rawdata") # A pane for the Sample statistics option self.pane2Frame = QFrame() self.pane2Frame.setFrameShape(QFrame.StyledPanel) self.pane2Frame.setFrameShadow(QFrame.Raised) self.pane2Layout = QGridLayout(self.pane2Frame) #self.optionsGrid.addWidget(self.pane2Frame, 1, 1, 2, 3) # Analytes combo self.analyteBoxes = [] self.analytesWidget = QWidget() self.analytesLabel = QLabel( "<span style=\"color:#779999; font-weight:bold\">Analytes</span>") self.optionsGrid.addWidget(self.analytesLabel, 1, 0) self.scroll = QScrollArea() self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setWidgetResizable(True) self.scroll.setMinimumWidth(70) self.innerWidget = QWidget() self.innerWidget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.analyteLayout = QVBoxLayout(self.innerWidget) self.optionsGrid.addWidget(self.scroll, 2, 0) self.innerWidget.setToolTip(self.stageInfo["analyte_description"]) self.analytesWidget.scroll = self.scroll self.scroll.setWidget(self.innerWidget) # Focus stage #self.focusSet.add("rawdata") # A combobox for the focus stage #self.focusLabel = QLabel(self.stageInfo["focus_label"]) #self.focusCombo = QComboBox() #self.pane1Layout.addWidget(self.focusLabel, 1, 0) #self.pane1Layout.addWidget(self.focusCombo, 1, 1) #self.focusCombo.addItem("rawdata") # Set the tooltips #self.focusLabel.setToolTip(self.stageInfo["focus_description"]) #self.focusCombo.setToolTip(self.stageInfo["focus_description"]) # To Filt label for Full export #self.filtExport = QCheckBox(self.stageInfo["filt_label"]) #self.filtExport.setToolTip(self.stageInfo["filt_description"]) #self.pane1Layout.addWidget(self.filtExport, 2, 0, 1, 2) self.pane1Layout.setColumnStretch(2, 1) self.optionsGrid.setColumnStretch(3, 1) self.optionsGrid.setRowStretch(2, 1) # Stats list area self.statsTypes = [ "mean", "std", "se", "H15_mean", "H15_std", "H15_se" ] # Stats Pane self.statsBoxes = [] self.statsWidget = QWidget() self.statsLabel = QLabel( "<span style=\"color:#779999; font-weight:bold\">" + self.stageInfo["stats_label"] + "</span>") self.pane2Layout.addWidget(self.statsLabel, 0, 0) self.statsLabel.setToolTip(self.stageInfo["stats_description"]) self.statsScroll = QScrollArea() self.statsScroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.statsScroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.statsScroll.setWidgetResizable(True) self.statsScroll.setMinimumWidth(70) self.statsInnerWidget = QWidget() self.statsInnerWidget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.statsLayout = QVBoxLayout(self.statsInnerWidget) self.pane2Layout.addWidget(self.statsScroll, 1, 0, 2, 1) self.statsWidget.scroll = self.statsScroll self.statsScroll.setWidget(self.statsInnerWidget) # Set the tooltips self.statsInnerWidget.setToolTip(self.stageInfo["stats_description"]) # Create the stats checkboxes for s in self.statsTypes: self.statsBoxes.append(QCheckBox(s)) self.statsLayout.addWidget(self.statsBoxes[-1]) # We turn on the stats functions that are used in the default call self.statsBoxes[0].setChecked(True) self.statsBoxes[1].setChecked(True) # To Filt label for Sample statistics self.filtStats = QCheckBox(self.stageInfo["filt_label"]) self.filtStats.setToolTip(self.stageInfo["filt_description"]) self.pane2Layout.addWidget(self.filtStats, 1, 1) self.pane2Layout.setColumnStretch(3, 1) self.pane2Layout.setRowStretch(3, 1) # We create a button to export the error logs to a zip folder in the LAtools directory self.exportLogsButton = QPushButton("Export error logs") self.exportLogsButton.clicked.connect(self.mainWindow.zipLogs) self.exportLogsButton.setToolTip( "<qt/>Saves your error log files to \"Logs.zip\" in the LAtools directory. <br>" + "You can also do this at any time via the File menu.") self.stageControls.addDefaultButton(self.exportLogsButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the export button for the right-most section of the Controls Pane. self.exportButton = QPushButton("Export") self.exportButton.clicked.connect(self.pressedExportButton) self.stageControls.addApplyButton(self.exportButton) # Initialise logging self.logger = logging.getLogger(__name__)
def __init__(self, stageLayout, graphPaneObj, progressPaneObj, backgroundWidget, project, links): """ Initialising creates and customises a Controls Pane for this stage. Parameters ---------- stageLayout : QVBoxLayout The layout for the entire stage screen, that the Controls Pane will be added to. graphPaneObj : GraphPane A reference to the Graph Pane that will sit at the bottom of the stage screen and display updates t the graph, produced by the processing defined in the stage. progressPaneObj : ProgressPane A reference to the Progress Pane so that the right button can be enabled by completing the stage. backgroundWidget : QWidget The parent widget for this object. Used mainly for displaying error boxes. project : RunningProject A reference to the project object which contains all of the information unique to this project, including the latools analyse object that the stages will update. links : (str, str, str) links[0] = The User guide website domain links[1] = The web link for reporting an issue links[2] = The tooltip for the report issue button """ self.graphPaneObj = graphPaneObj self.progressPaneObj = progressPaneObj self.backgroundWidget = backgroundWidget self.project = project self.guideDomain = links[0] self.reportIssue = links[1] # We create a controls pane object which covers the general aspects of the stage's controls pane self.stageControls = controlsPane.ControlsPane(stageLayout) # We capture the default parameters for this stage's function call self.defaultWeightParams = self.stageControls.getDefaultParameters( inspect.signature(la.analyse.bkg_calc_weightedmean)) self.defaultInterParams = self.stageControls.getDefaultParameters( inspect.signature(la.analyse.bkg_calc_interp1d)) # We import the stage information from a json file if getattr(sys, 'frozen', False): # If the program is running as a bundle, then get the relative directory infoFile = os.path.join(os.path.dirname(sys.executable), 'information/backgroundStageInfo.json') infoFile = infoFile.replace('\\', '/') else: # Otherwise the program is running in a normal python environment infoFile = "information/backgroundStageInfo.json" with open(infoFile, "r") as read_file: self.stageInfo = json.load(read_file) read_file.close() # We set the title and description for the stage self.stageControls.setDescription("Background Correction", self.stageInfo["stage_description"]) # The space for the stage options is provided by the Controls Pane. self.optionsGrid = QGridLayout(self.stageControls.getOptionsWidget()) # We define the stage options and add them to the Controls Pane self.methodOption = QComboBox() self.methodOption.addItem(self.stageInfo["bkg_method_1_label"]) self.methodOption.addItem(self.stageInfo["bkg_method_2_label"]) # When methodOption is changed, it calls methodUpdate self.methodOption.activated.connect(self.methodUpdate) self.optionsGrid.addWidget(QLabel(self.stageInfo["bkg_method_label"]), 0, 0) self.optionsGrid.addWidget(self.methodOption, 0, 1) # Set up a layout that will only be displayed when bkg_calc_weightedmean is selected self.methodWidget1 = QWidget() self.methodLayout1 = QGridLayout(self.methodWidget1) self.weight_fwhmLabel = QLabel(self.stageInfo["weight_fwhm_label"]) self.weight_fwhmOption = QLineEdit( self.defaultWeightParams['weight_fwhm']) self.methodLayout1.addWidget(self.weight_fwhmLabel, 0, 0) self.methodLayout1.addWidget(self.weight_fwhmOption, 0, 1) self.weight_fwhmOption.setToolTip( self.stageInfo["weight_fwhm_description"]) self.weight_fwhmLabel.setToolTip( self.stageInfo["weight_fwhm_description"]) self.weight_fwhmOption.setPlaceholderText("auto") self.n_minLabel = QLabel(self.stageInfo["n_min_label"]) self.n_minOption = QLineEdit(self.defaultWeightParams['n_min']) self.methodLayout1.addWidget(self.n_minLabel, 0, 2) self.methodLayout1.addWidget(self.n_minOption, 0, 3) self.n_minOption.setToolTip(self.stageInfo["n_min_description"]) self.n_minLabel.setToolTip(self.stageInfo["n_min_description"]) self.n_maxLabel = QLabel(self.stageInfo["n_max_label"]) self.n_maxOption = QLineEdit(self.defaultWeightParams['n_max']) self.methodLayout1.addWidget(self.n_maxLabel, 0, 4) self.methodLayout1.addWidget(self.n_maxOption, 0, 5) self.n_maxOption.setToolTip(self.stageInfo["n_max_description"]) self.n_maxLabel.setToolTip(self.stageInfo["n_max_description"]) # Apply the bkg_calc_weightedmean options as default self.currentlyMethod1 = True self.optionsGrid.addWidget(self.methodWidget1, 1, 0, 1, 2) # Set up a layout for when "bkg_calc_interp1d" is selected self.methodWidget2 = QWidget() self.methodLayout2 = QGridLayout(self.methodWidget2) self.kind_label = QLabel(self.stageInfo["kind_label"]) self.kindOption = QLineEdit(self.defaultInterParams['kind']) self.methodLayout2.addWidget(self.kind_label, 0, 0) self.methodLayout2.addWidget(self.kindOption, 0, 1) self.kindOption.setToolTip(self.stageInfo["kind_description"]) self.kind_label.setToolTip(self.stageInfo["kind_description"]) self.n_min2Label = QLabel(self.stageInfo["n_min_label"]) self.n_minOption2 = QLineEdit(self.defaultInterParams['n_min']) self.methodLayout2.addWidget(self.n_min2Label, 0, 2) self.methodLayout2.addWidget(self.n_minOption2, 0, 3) self.n_minOption2.setToolTip(self.stageInfo["n_min_description"]) self.n_min2Label.setToolTip(self.stageInfo["n_min_description"]) self.n_max2Label = QLabel(self.stageInfo["n_max_label"]) self.n_maxOption2 = QLineEdit(self.defaultInterParams['n_max']) self.methodLayout2.addWidget(self.n_max2Label, 0, 4) self.methodLayout2.addWidget(self.n_maxOption2, 0, 5) self.n_maxOption2.setToolTip(self.stageInfo["n_max_description"]) self.n_max2Label.setToolTip(self.stageInfo["n_max_description"]) # Add the universal options self.cstepLabel = QLabel(self.stageInfo["cstep_label"]) self.cstepOption = QLineEdit(self.defaultWeightParams['cstep']) self.optionsGrid.addWidget(self.cstepLabel, 2, 0) self.optionsGrid.addWidget(self.cstepOption, 2, 1, 1, 1) self.cstepOption.setToolTip(self.stageInfo["cstep_description"]) self.cstepLabel.setToolTip(self.stageInfo["cstep_description"]) self.cstepOption.setPlaceholderText("auto") self.bkg_filterOption = QCheckBox(self.stageInfo["bkg_filter_label"]) self.optionsGrid.addWidget(self.bkg_filterOption, 3, 0) self.bkg_filterOption.setChecked( self.defaultWeightParams['bkg_filter'] == 'True') self.bkg_filterOption.setToolTip( self.stageInfo["bkg_filter_description"]) # We set up a click function for the checkbox self.bkg_filterOption.stateChanged.connect(self.bkgUpdate) # Set up a layout that will only be displayed when bkg_filter is checked self.bkgWidget = QWidget() self.bkgLayout = QGridLayout(self.bkgWidget) self.f_winOption = QLineEdit(self.defaultWeightParams['f_win']) self.f_winLabel = QLabel(self.stageInfo["f_win_label"]) self.bkgLayout.addWidget(self.f_winLabel, 0, 0) self.bkgLayout.addWidget(self.f_winOption, 0, 1) self.f_winOption.setToolTip(self.stageInfo["f_win_description"]) self.f_winLabel.setToolTip(self.stageInfo["f_win_description"]) self.f_n_limOption = QLineEdit(self.defaultWeightParams['f_n_lim']) self.f_n_limLabel = QLabel(self.stageInfo["f_n_lim_label"]) self.bkgLayout.addWidget(self.f_n_limLabel, 0, 2) self.bkgLayout.addWidget(self.f_n_limOption, 0, 3) self.f_n_limOption.setToolTip(self.stageInfo["f_n_lim_description"]) self.f_n_limLabel.setToolTip(self.stageInfo["f_n_lim_description"]) self.optionsGrid.addWidget(self.bkgWidget, 3, 1) self.f_winOption.setEnabled(False) self.f_n_limOption.setEnabled(False) # We create a reset to default button self.defaultButton = QPushButton("Defaults") self.defaultButton.clicked.connect(self.defaultButtonPress) self.stageControls.addDefaultButton(self.defaultButton) # We create a button to link to the user guide self.guideButton = QPushButton("User guide") self.guideButton.clicked.connect(self.userGuide) self.stageControls.addDefaultButton(self.guideButton) # We create a button to link to the form for reporting an issue self.reportButton = QPushButton("Report an issue") self.reportButton.clicked.connect(self.reportButtonClick) self.stageControls.addDefaultButton(self.reportButton) self.reportButton.setToolTip(links[2]) # We create the buttons for the right-most section of the Controls Pane. self.calcButton = QPushButton("Calculate background") self.calcButton.clicked.connect(self.pressedCalcButton) self.stageControls.addApplyButton(self.calcButton) self.popupButton = QPushButton("Plot in popup") self.popupButton.clicked.connect(self.pressedPopupButton) self.stageControls.addApplyButton(self.popupButton) self.popupButton.setEnabled(False) self.subtractButton = QPushButton("Subtract background") self.subtractButton.clicked.connect(self.pressedSubtractButton) self.stageControls.addApplyButton(self.subtractButton) self.subtractButton.setEnabled(False) self.subtractButton.setToolTip( self.stageInfo["subtract_button_description"]) #Logging self.logger = logging.getLogger(__name__) self.logger.info('Background initialised') #Validation self.weight_fwhmOption.setValidator(QDoubleValidator()) self.n_minOption.setValidator(QIntValidator()) self.n_maxOption.setValidator(QIntValidator()) self.cstepOption.setValidator(QDoubleValidator()) self.f_winOption.setValidator(QIntValidator()) self.f_n_limOption.setValidator(QIntValidator()) self.kindOption.setValidator(QIntValidator()) self.n_minOption2.setValidator(QIntValidator()) self.n_maxOption2.setValidator(QIntValidator())