def __init__(self, runfolder, parser_configurations, *args, **kwargs): """ Create a DemuxSummaryParser instance for the specified runfolder :param runfolder: path to the runfolder to parse :param parser_configurations: dict containing any extra configuration required by the parser under class name key """ super().__init__(*args, **kwargs) self.runfolder = runfolder # NOTE: This parser will use the same config entry a the StatsJsonParser in order # to not break backward compatibility. And it feel unnecessary to add this # value to the config twice. /JD 2018-09-14 self.parser_conf = parser_configurations.get("StatsJsonParser") if not self.parser_conf: raise ConfigurationError("The configuration must contain parser_configurations " "key with subkey StatsJsonParser. E.g: \n" "parser_configurations:\n" "\tStatsJsonParser:\n" "\t\tbcl2fastq_output_path: Data/Intensities/BaseCalls") self._bcl2fastq_output_path = self.parser_conf.get("bcl2fastq_output_path") if not self._bcl2fastq_output_path: raise ConfigurationError("The configuration must contain the key bcl2fastq_output_path, specifying " "where the bcl2fastq output is, relative to the runfolder root.") self._nbr_of_lanes = RunfolderReader.get_nbr_of_lanes(self.runfolder) self._validate_demux_summary_files_exist(self.runfolder, self._bcl2fastq_output_path)
def custom_configuration_validation(self): try: value = self.qc_config[self.ALLOW_MISSING_ERROR_RATE] except KeyError as e: raise ConfigurationError( "Did not find key '{}' in configuration for ErrorRate handler". format(e.args[0])) if not isinstance(value, bool): raise ConfigurationError( "Only True/False are allowed as values for 'allow_missing_error_rate' in the " "ErrorRate handler config. Value was: {}".format(value))
def validate_configuration(self): """ This overrides the normal configuration which looks for warning/error. :return: None :raises: ConfigurationError if the configuration for the handler was not valid. """ try: self.qc_config['significance_threshold'] except KeyError: raise ConfigurationError("The {} handler expects 'significance_threshold' to be set. " "Perhaps it is missing from the configuration " "file?".format(self.__class__.__name__))
def __init__(self, runfolder, parser_configurations, *args, **kwargs): """ Create a StatsJsonParser instance for the specified runfolder :param runfolder: path to the runfolder to parse :param parser_configurations: dict containing any extra configuration required by the parser under class name key """ super().__init__(*args, **kwargs) self.parser_conf = parser_configurations.get(self.__class__.__name__) if not self.parser_conf: raise ConfigurationError( "The configuration must contain parser_configurations " "key with subkey StatsJsonParser. E.g: \n" "parser_configurations:\n" "\tStatsJsonParser:\n" "\t\tbcl2fastq_output_path: Data/Intensities/BaseCalls") bcl2fastq_output_path = self.parser_conf.get("bcl2fastq_output_path") if not bcl2fastq_output_path: raise ConfigurationError( "The configuration must contain the key bcl2fastq_output_path, specifying " "where the bcl2fastq output is, relative to the runfolder root." ) self.file_path = os.path.join(runfolder, bcl2fastq_output_path, "Stats", "Stats.json") if not os.path.exists(self.file_path): log.error( "Could not identify a Stats.json file at: {}. This file is " "created by bcl2fastq, please ensure that you have run " "bcl2fastq on this runfolder before running checkqc." "If this file is not located under <RUNFOLDER>/Data/Intensities/BaseCalls/Stats/Stats.json " "which is the default option for bcl2fastq, you can specify where the 'Stats' directory is " "located by changing the 'bcl2fastq_output_path' in the 'StatsJsonParser' part of the " "checkqc configuration file.".format(self.file_path)) raise StatsJsonNotFound( "Could not find a Stats.json file at: {}".format( self.file_path))
def validate_configuration(self): """ This method will validate the configuration which has been passed to the QCHandler. This should be called by the class making use of this instance. It will not be called automatically e.g. at object creation. :returns: None :raises: ConfigurationError if there is a problem with the configuration """ try: self.qc_config[self.ERROR] self.qc_config[self.WARNING] except KeyError as e: raise ConfigurationError( "Configuration expects key: {}. Perhaps it is missing?".format( e.args[0])) self.custom_configuration_validation()