Skip to content

Commit

Permalink
update single orientation json
Browse files Browse the repository at this point in the history
  • Loading branch information
balajtimate committed Oct 2, 2024
1 parent fbb90f4 commit 6ef13f6
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions htsinfer/get_read_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6ef13f6

Please sign in to comment.