def configure_and_run(self): """ Configures and runs the application. It will set the exit status of the object in accordance with if any fatal qc errors were found or not. :returns: The reports of the application as a dict """ try: config = ConfigFactory.from_config_path(self._config_file) parser_configurations = config.get("parser_configurations", None) run_type_recognizer = RunTypeRecognizer(config=config, runfolder=self._runfolder) instrument_and_reagent_version = run_type_recognizer.instrument_and_reagent_version( ) # TODO For now assume symmetric read lengths both_read_lengths = run_type_recognizer.read_length() read_length = int(both_read_lengths.split("-")[0]) handler_config = config.get_handler_configs( instrument_and_reagent_version, read_length) run_type_summary = RunTypeSummarizer.summarize( instrument_and_reagent_version, both_read_lengths, handler_config) qc_engine = QCEngine(runfolder=self._runfolder, parser_configurations=parser_configurations, handler_config=handler_config) reports = qc_engine.run() reports["run_summary"] = run_type_summary self.exit_status = qc_engine.exit_status return reports except CheckQCException as e: log.error(e) self.exit_status = 1
def configure_and_run(self): """ Configures and runs the application. It will set the exit status of the object in accordance with if any fatal qc errors were found or not. :returns: The reports of the application as a dict """ config = ConfigFactory.from_config_path(self._config_file) parser_configurations = config.get("parser_configurations", None) if not Path(self._runfolder).is_dir(): raise RunfolderNotFoundError( "Could not find runfolder: {}. Are you " "sure the path is correct?".format(self._runfolder)) run_type_recognizer = RunTypeRecognizer(runfolder=self._runfolder) instrument_and_reagent_version = run_type_recognizer.instrument_and_reagent_version( ) # TODO For now assume symmetric read lengths both_read_lengths = run_type_recognizer.read_length() read_length = int(both_read_lengths.split("-")[0]) handler_config = config.get_handler_configs( instrument_and_reagent_version, read_length) run_type_summary = RunTypeSummarizer.summarize( instrument_and_reagent_version, both_read_lengths, handler_config) qc_engine = QCEngine(runfolder=self._runfolder, parser_configurations=parser_configurations, handler_config=handler_config) reports = qc_engine.run() reports["run_summary"] = run_type_summary self.exit_status = qc_engine.exit_status return reports
class TestRunTypeRecognizerFromFolder(TestCase): def setUp(self): self.runtype_recognizer = RunTypeRecognizer(runfolder=os.path.join(os.path.dirname(__file__), "resources", "Rapid")) def test_instrument_type(self): expected = "hiseq2500" actual = self.runtype_recognizer.instrument_type() self.assertEqual(expected, actual.name()) def test_read_length(self): expected = "51" actual = self.runtype_recognizer.read_length() self.assertEqual(expected, actual) def test_run_mode(self): expected = "hiseq2500_rapidrun_v2" actual = self.runtype_recognizer.instrument_and_reagent_version() self.assertEqual(expected, actual)
return checkqc_config_dict if __name__ == "__main__": parser = argparse.ArgumentParser( description="Converts CheckQC tresholds to MultiQC conditional format") parser.add_argument("--runfolder", type=str, required=True, help="Path to runfolder") parser.add_argument("--config", type=str, help="Path to checkQC config") args = parser.parse_args() runfolder = args.runfolder config = args.config run_type_recognizer = RunTypeRecognizer(runfolder) config = ConfigFactory.from_config_path(config) instrument_and_reagent_version = ( run_type_recognizer.instrument_and_reagent_version()) both_read_lengths = run_type_recognizer.read_length() read_length = int(both_read_lengths.split("-")[0]) checkqc_config = config.get_handler_configs(instrument_and_reagent_version, read_length) checkqc_config_dict = convert_to_dict(checkqc_config) multiqc_config = convert_to_multiqc_config(checkqc_config_dict) with open("qc_thresholds.yaml", "w") as outfile: yaml.dump(multiqc_config, outfile)
def _create_runtype_recognizer(self, instrument_name): with mock.patch.object(RunfolderReader, 'read_run_info_xml', return_value={"RunInfo": {"Run": {"Instrument": instrument_name}}}), \ mock.patch.object(RunfolderReader, 'read_run_parameters_xml', return_value=None): return RunTypeRecognizer(runfolder='foo')
def setUp(self): self.runtype_recognizer = RunTypeRecognizer(runfolder=os.path.join(os.path.dirname(__file__), "resources", "Rapid"))