From 6ef13f6b97d24c244eed589ce22f38d60e6ba4e3 Mon Sep 17 00:00:00 2001 From: balajtimate Date: Wed, 2 Oct 2024 19:33:41 +0200 Subject: [PATCH] update single orientation json --- htsinfer/get_read_orientation.py | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htsinfer/get_read_orientation.py b/htsinfer/get_read_orientation.py index b4ffef2..01a0c9b 100644 --- a/htsinfer/get_read_orientation.py +++ b/htsinfer/get_read_orientation.py @@ -178,31 +178,31 @@ def process_single( else: orientation = StatesOrientation.unstranded - # write log messages and return result - LOGGER.debug( - f"Required number of mapped reads pairs: {self.min_mapped_reads}" - ) - LOGGER.debug(f"Number of reads mapped: {reads}") - LOGGER.debug( - f"Fraction of SF: {fractions_all_states.get(StatesOrientation.stranded_forward)}" - ) + orient_df = pd.DataFrame([{ + 'Number of mapped reads': reads, + 'Fraction SF': fractions[0].get( + StatesOrientation.stranded_forward + ), + 'Fraction SR': fractions[0].get( + StatesOrientation.stranded_reverse + ), + 'Orientation': orientation.value + }]) + LOGGER.debug( - f"Fraction of SR: {fractions_all_states.get(StatesOrientation.stranded_reverse)}" + f"Required number of mapped reads: {self.min_mapped_reads}" ) - LOGGER.debug(f"Orientation: {orientation.value}") + 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.debug(f"Orientation: {orient_df.iloc[0, 3]}") # write data frame (in JSON) to file filename = ( - Path(self.out_dir) / f"read_layout_{sam.name}.json" + Path(self.out_dir) / f"read_orientation_{self.paths[0].name}.json" ) LOGGER.debug(f"Writing results to file: {filename}") - orientation_df = pd.DataFrame([{ - 'Number of mapped reads': reads, - 'Fraction SF': fractions_all_states.get(StatesOrientation.stranded_forward), - 'Fraction SR': fractions_all_states.get(StatesOrientation.stranded_reverse), - 'Orientation': orientation.value - }]) - orientation_df.to_json( + orient_df.to_json( filename, orient='split', index=False,