From 797abe8465443a3e17d080b7ffd46a403fab2144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Balajti?= <51365402+balajtimate@users.noreply.github.com> Date: Wed, 30 Oct 2024 19:34:35 +0100 Subject: [PATCH] refactor: update logging level (#171) * refactor: update logging levels * revert rounding * refactor: minor fixes to logging --------- Co-authored-by: Alex Kanitz --- htsinfer/get_library_source.py | 7 +++++-- htsinfer/get_library_stats.py | 5 +++-- htsinfer/get_library_type.py | 18 +++++++++--------- htsinfer/get_read_orientation.py | 22 +++++++++++----------- htsinfer/mapping.py | 2 +- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/htsinfer/get_library_source.py b/htsinfer/get_library_source.py index 5fcf945..3ef7c4e 100644 --- a/htsinfer/get_library_source.py +++ b/htsinfer/get_library_source.py @@ -83,7 +83,10 @@ def evaluate(self) -> ResultsSource: self.transcripts_file ) source.file_1.short_name = src_name - + LOGGER.info( + f'Library source taxonomy ID: {self.tax_id}, ' + f'short name: {source.file_1.short_name}' + ) if self.paths[1] is not None: source.file_2.taxon_id = self.tax_id source.file_2.short_name = source.file_1.short_name @@ -211,7 +214,7 @@ def run_kallisto_quantification( Raises: KallistoProblem: Kallisto quantification failed. """ - LOGGER.debug(f"Running Kallisto quantification for: {fastq}") + LOGGER.info(f"Running Kallisto quantification for: {fastq}") with tempfile.TemporaryDirectory( prefix="kallisto_", diff --git a/htsinfer/get_library_stats.py b/htsinfer/get_library_stats.py index 6413586..718521c 100644 --- a/htsinfer/get_library_stats.py +++ b/htsinfer/get_library_stats.py @@ -60,8 +60,8 @@ def evaluate(self) -> ResultsStats: self.fastq_get_stats_read_length(fastq=self.paths[0]) ) # process file 2 - LOGGER.info(f"Obtaining statistics for file: {self.paths[1]}") if self.paths[1] is not None: + LOGGER.info(f"Obtaining statistics for file: {self.paths[1]}") (stats.file_2.read_length.min, stats.file_2.read_length.max, stats.file_2.read_length.mean, @@ -88,7 +88,8 @@ def fastq_get_stats_read_length(fastq: Path) -> Tuple[ FileProblem: Could not process FASTQ file. """ LOGGER.debug( - f"Extracting read length statistics in: {fastq}") + f"Extracting read length statistics in: {fastq}" + ) min_len: int = 1000000 max_len: int = 0 total_lengths: int = 0 diff --git a/htsinfer/get_library_type.py b/htsinfer/get_library_type.py index 8e4166b..4a2b0ff 100644 --- a/htsinfer/get_library_type.py +++ b/htsinfer/get_library_type.py @@ -135,7 +135,7 @@ def _evaluate_mate_relationship( self.library_source.file_1.short_name is not None or self.library_source.file_2.short_name is not None ): - LOGGER.debug("Determining mate relationship by alignment...") + LOGGER.info("Determining mate relationship by alignment...") self.mapping.library_type.relationship \ = StatesTypeRelationship.not_available self.mapping.library_source = self.library_source @@ -146,7 +146,7 @@ def _evaluate_mate_relationship( self.library_source.file_1.short_name is not None or self.library_source.file_2.short_name is not None ): - LOGGER.debug("Determining mate relationship by alignment...") + LOGGER.info("Determining mate relationship by alignment...") self.mapping.library_type.relationship \ = StatesTypeRelationship.not_available self.mapping.library_source = self.library_source @@ -155,7 +155,7 @@ def _evaluate_mate_relationship( self._align_mates() else: self.results.relationship = StatesTypeRelationship.not_available - LOGGER.debug( + LOGGER.info( "Sequence IDs and library source are not determined, " "mate relationship cannot be inferred." ) @@ -220,9 +220,9 @@ def _align_mates(self): aligned_mate1 = len(list(filter(None, mate1))) aligned_mate2 = len(list(filter(None, mate2))) - LOGGER.debug(f"Number of aligned reads file 1: {aligned_mate1}") - LOGGER.debug(f"Number of aligned reads file 2: {aligned_mate2}") - LOGGER.debug(f"Number of concordant reads: {concordant}") + LOGGER.info(f"Number of aligned reads file 1: {aligned_mate1}") + LOGGER.info(f"Number of aligned reads file 2: {aligned_mate2}") + LOGGER.info(f"Number of concordant reads: {concordant}") self._update_relationship_type( concordant, min(aligned_mate1, aligned_mate2) @@ -351,7 +351,7 @@ def evaluate(self) -> None: with open(self.path, encoding="utf-8") as _f: # type: ignore # Get sequence identifier format from first record - LOGGER.debug( + LOGGER.info( "Determining identifier and library type from first " "record..." ) @@ -375,13 +375,13 @@ def evaluate(self) -> None: raise FileProblem(f"File is empty: {self.path}") from exc if self.seq_id_format is not None: - LOGGER.debug( + LOGGER.info( "Sequence identifier format: " f"{self.seq_id_format.name}" ) else: self.result = StatesType.not_available - LOGGER.debug( + LOGGER.info( "Could not determine sequence identifier format." ) diff --git a/htsinfer/get_read_orientation.py b/htsinfer/get_read_orientation.py index d5bac0f..6904e39 100644 --- a/htsinfer/get_read_orientation.py +++ b/htsinfer/get_read_orientation.py @@ -81,7 +81,7 @@ def evaluate(self) -> ResultsOrientation: self.library_source.file_1.short_name is not None or self.library_source.file_2.short_name is not None ): - LOGGER.debug("Determining read relationship by alignment...") + LOGGER.info("Determining read relationship by alignment...") self.mapping.evaluate() return self.process_alignments(star_dirs=self.mapping.star_dirs) @@ -155,7 +155,7 @@ def process_single( f"Failed to open SAM file: '{sam}'" ) from exc - LOGGER.debug("Deciding read orientation...") + LOGGER.info("Deciding read orientation...") reads = len(states) fractions = [ self.get_frequencies(*state) for state in states.values() @@ -182,12 +182,12 @@ def process_single( reads, fractions_all_states, orientation, paired=False ) - LOGGER.debug( + LOGGER.info( f"Required number of mapped reads: {self.min_mapped_reads}" ) - LOGGER.debug(f"Number of mapped reads: {orient_df.iloc[0, 0]}") - LOGGER.debug(f"Fraction of SF: {orient_df.iloc[0, 1]}") - LOGGER.debug(f"Fraction of SR: {orient_df.iloc[0, 2]}") + LOGGER.info(f"Number of mapped reads: {orient_df.iloc[0, 0]}") + LOGGER.info(f"Fraction of SF: {orient_df.iloc[0, 1]}") + LOGGER.info(f"Fraction of SR: {orient_df.iloc[0, 2]}") LOGGER.debug(f"Orientation: {orient_df.iloc[0, 3]}") self.write_orientation_to_json(orient_df, self.paths[0].name) @@ -268,7 +268,7 @@ def process_paired( # pylint: disable=R0912,R0915 ) from exc # deciding read orientation - LOGGER.debug("Deciding read orientation...") + LOGGER.info("Deciding read orientation...") reads = len(states) fractions = [ self.get_frequencies(*state) for state in states.values() @@ -309,12 +309,12 @@ def process_paired( # pylint: disable=R0912,R0915 reads, fractions_all_states, orientation, paired=True, file_index=2 ) - LOGGER.debug( + LOGGER.info( f"Required number of mapped reads: {self.min_mapped_reads}" ) - LOGGER.debug(f"Number of mapped reads: {orient_df_1.iloc[0, 0]}") - LOGGER.debug(f"Fraction of ISF: {orient_df_1.iloc[0, 1]}") - LOGGER.debug(f"Fraction of ISR: {orient_df_1.iloc[0, 2]}") + LOGGER.info(f"Number of mapped reads: {orient_df_1.iloc[0, 0]}") + LOGGER.info(f"Fraction of ISF: {orient_df_1.iloc[0, 1]}") + LOGGER.info(f"Fraction of ISR: {orient_df_1.iloc[0, 2]}") LOGGER.debug(f"Orientation file 1: {orient_df_1.iloc[0, 3]}") LOGGER.debug(f"Orientation file 2: {orient_df_2.iloc[0, 3]}") LOGGER.debug( diff --git a/htsinfer/mapping.py b/htsinfer/mapping.py index 52780f3..e3b1893 100644 --- a/htsinfer/mapping.py +++ b/htsinfer/mapping.py @@ -355,7 +355,7 @@ def generate_star_alignments(commands: Dict[Path, List[str]]) -> None: Raises: StarProblem: Generating alignments failed. """ - LOGGER.debug("Aligning reads with STAR...") + LOGGER.info("Aligning reads with STAR...") # execute commands for out_dir, cmd in commands.items():