Skip to content

Commit

Permalink
change output types of ont json parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl-Svard committed Mar 6, 2024
1 parent f806009 commit 9adf1e1
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions cg_lims/EPPs/files/ont_json_to_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import sys
from pathlib import Path
from typing import Dict, List, Optional
from typing import Dict, List

import click
from cg_lims import options
Expand Down Expand Up @@ -54,52 +54,62 @@ def parse_json(file_path: str) -> Dict:
return data


def get_n50(json_dict: Dict) -> Optional[str]:
def get_n50(json_dict: Dict) -> int:
""""""
try:
return json_dict["acquisitions"][3]["read_length_histogram"][-2]["plot"]["histogram_data"][
0
]["n50"]
return int(
json_dict["acquisitions"][3]["read_length_histogram"][-2]["plot"]["histogram_data"][0][
"n50"
]
)
except KeyError:
return None
return 0


def get_estimated_bases(json_dict: Dict) -> Optional[str]:
def get_estimated_bases(json_dict: Dict) -> int:
""""""
try:
return json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"estimated_selected_bases"
]
return int(
json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"estimated_selected_bases"
]
)
except KeyError:
return None
return 0


def get_passed_bases(json_dict: Dict) -> Optional[str]:
def get_passed_bases(json_dict: Dict) -> int:
""""""
try:
return json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"basecalled_pass_bases"
]
return int(
json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"basecalled_pass_bases"
]
)
except KeyError:
return None
return 0


def get_failed_bases(json_dict: Dict) -> Optional[str]:
def get_failed_bases(json_dict: Dict) -> int:
""""""
try:
return json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"basecalled_fail_bases"
]
return int(
json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"][
"basecalled_fail_bases"
]
)
except KeyError:
return None
return 0


def get_read_count(json_dict: Dict) -> Optional[str]:
def get_read_count(json_dict: Dict) -> int:
""""""
try:
return json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"]["read_count"]
return int(
json_dict["acquisitions"][3]["acquisition_run_info"]["yield_summary"]["read_count"]
)
except KeyError:
return None
return 0


def set_sequencing_qc(artifact: Artifact, json_dict: Dict) -> None:
Expand Down

0 comments on commit 9adf1e1

Please sign in to comment.