Skip to content

Commit

Permalink
feat: add read orient paired json output
Browse files Browse the repository at this point in the history
  • Loading branch information
balajtimate committed Oct 3, 2024
1 parent 6ef13f6 commit 0bcc152
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions htsinfer/get_read_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,61 @@ def process_paired( # pylint: disable=R0912,R0915
orientation.file_1 = StatesOrientation.unstranded
orientation.file_2 = StatesOrientation.unstranded

# write log messages and return result
orient_df_1 = pd.DataFrame([{
'Number of mapped reads': reads,
'Fraction ISF': fractions_all_states.get(
StatesOrientationRelationship.inward_stranded_forward
),
'Fraction ISR': fractions_all_states.get(
StatesOrientationRelationship.inward_stranded_reverse
),
'Orientation': getattr(orientation.file_1, 'value', None),
'Relationship': getattr(orientation.relationship, 'value', None)
}])
orient_df_2 = pd.DataFrame([{
'Number of mapped reads': reads,
'Fraction ISF': fractions_all_states.get(
StatesOrientationRelationship.inward_stranded_forward
),
'Fraction ISR': fractions_all_states.get(
StatesOrientationRelationship.inward_stranded_reverse
),
'Orientation': getattr(orientation.file_2, 'value', None),
'Relationship': getattr(orientation.relationship, 'value', None)
}])
LOGGER.debug(
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.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(
f"Required number of mapped read pairs: {self.min_mapped_reads}"
f"Orientation relationship: {orient_df_1.iloc[0, 4]}"
)
LOGGER.debug(f"Number of reads mapped: {reads}")
LOGGER.debug(f"Fraction of states: {fractions_all_states}")
LOGGER.debug(f"Orientation: {orientation}")
filename_1 = (
Path(self.out_dir) / f"read_orientation_{self.paths[0].name}.json"
)
LOGGER.debug(f"Writing results to file: {filename_1}")
orient_df_1.to_json(
filename_1,
orient='split',
index=False,
indent=True,
)
filename_2 = (
Path(self.out_dir) / f"read_orientation_"
f"{getattr(self.paths[1], 'name')}.json"
)
LOGGER.debug(f"Writing results to file: {filename_2}")
orient_df_2.to_json(
filename_2,
orient='split',
index=False,
indent=True,
)

return orientation

@staticmethod
Expand Down

0 comments on commit 0bcc152

Please sign in to comment.