Skip to content

Commit

Permalink
refactor: update logging level (#171)
Browse files Browse the repository at this point in the history
* refactor: update logging levels

* revert rounding

* refactor: minor fixes to logging

---------

Co-authored-by: Alex Kanitz <[email protected]>
  • Loading branch information
balajtimate and uniqueg authored Oct 30, 2024
1 parent ef82690 commit 797abe8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
7 changes: 5 additions & 2 deletions htsinfer/get_library_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_",
Expand Down
5 changes: 3 additions & 2 deletions htsinfer/get_library_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions htsinfer/get_library_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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..."
)
Expand All @@ -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."
)

Expand Down
22 changes: 11 additions & 11 deletions htsinfer/get_read_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion htsinfer/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 797abe8

Please sign in to comment.