diff --git a/src/DAJIN2/core/preprocess/midsv_caller.py b/src/DAJIN2/core/preprocess/midsv_caller.py index 6198684..1bf7753 100644 --- a/src/DAJIN2/core/preprocess/midsv_caller.py +++ b/src/DAJIN2/core/preprocess/midsv_caller.py @@ -215,8 +215,8 @@ def generate_midsv(ARGS, is_control: bool = False, is_insertion: bool = False) - path_splice = Path(ARGS.tempdir, name, "sam", f"splice_{allele}.sam") path_output_midsv = Path(ARGS.tempdir, name, "midsv", f"{allele}.json") - sam_ont = sam_handler.remove_overlapped_reads(list(midsv.read_sam(path_ont))) - sam_splice = sam_handler.remove_overlapped_reads(list(midsv.read_sam(path_splice))) + sam_ont = sam_handler.remove_overlapped_reads(list(sam_handler.read_sam(path_ont))) + sam_splice = sam_handler.remove_overlapped_reads(list(sam_handler.read_sam(path_splice))) qname_of_map_ont = extract_qname_of_map_ont(sam_ont, sam_splice) sam_of_map_ont = filter_sam_by_preset(sam_ont, qname_of_map_ont, preset="map-ont") sam_of_splice = filter_sam_by_preset(sam_splice, qname_of_map_ont, preset="splice") diff --git a/src/DAJIN2/utils/sam_handler.py b/src/DAJIN2/utils/sam_handler.py index c0b9b74..4668a8d 100644 --- a/src/DAJIN2/utils/sam_handler.py +++ b/src/DAJIN2/utils/sam_handler.py @@ -1,6 +1,9 @@ from __future__ import annotations import re + +from pathlib import Path +from typing import Generator from itertools import groupby from DAJIN2.utils.dna_handler import revcomp @@ -22,6 +25,17 @@ def is_mapped(s: list[str]) -> bool: return not s[0].startswith("@") and s[9] != "*" +########################################################### +# Read sam +########################################################### + + +def read_sam(path_of_sam: str | Path) -> Generator[list]: + with open(path_of_sam) as f: + for line in f: + yield line.strip().split("\t") + + ########################################################### # remove_overlapped_reads ###########################################################