Skip to content

Commit

Permalink
Merge pull request #155 from Clinical-Genomics/store-files (minor)
Browse files Browse the repository at this point in the history
Concatenated pangolin for nanopore
  • Loading branch information
henningonsbring authored Jul 22, 2022
2 parents 6311686 + 62684f0 commit 29de8cb
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 301 deletions.
15 changes: 3 additions & 12 deletions mutant/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from mutant import version, log, WD, TIMESTAMP
from mutant.modules.artic_illumina.start import RunSC2
from mutant.modules.artic_nanopore.parser import ParserNanopore
from mutant.modules.artic_nanopore.reformat import reformat_fastq_folder
from mutant.modules.artic_nanopore.report import ReportPrinterNanopore
from mutant.modules.generic_parser import get_json
Expand Down Expand Up @@ -100,20 +99,12 @@ def sarscov2(

if nanopore:
if config_case != "":
parser = ParserNanopore(
caseinfo=config_case,
)
result: dict = parser.collect_results(
resdir=os.path.abspath(resdir), barcode_to_sampleid=barcode_to_sampleid
)
variants: list = parser.collect_variants(
resdir=os.path.abspath(resdir), barcode_to_sampleid=barcode_to_sampleid
)
report_printer = ReportPrinterNanopore(
nanopore_report = ReportPrinterNanopore(
caseinfo=config_case,
indir=os.path.abspath(resdir),
barcode_to_sampleid=barcode_to_sampleid,
)
report_printer.create_all_nanopore_files(result=result, variants=variants)
nanopore_report.create_all_nanopore_files()

else:
# Report
Expand Down
31 changes: 6 additions & 25 deletions mutant/modules/artic_illumina/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import yaml
import json
from datetime import date
from pathlib import Path
from mutant.modules.generic_parser import (
get_sarscov2_config,
read_filelines,
Expand All @@ -21,6 +20,7 @@
get_artic_results,
get_results_paths,
)
from mutant.modules.generic_reporter import GenericReporter


class ReportSC2:
Expand All @@ -41,7 +41,11 @@ def __init__(self, caseinfo, indir, config_artic, fastq_dir, timestamp):
self.articdata = dict()

def create_all_files(self):
self.create_trailblazer_config()
generic_reporter = GenericReporter(
indir=self.indir,
nanopore=False,
)
generic_reporter.create_trailblazer_config()
self.load_lookup_dict()
self.create_concat_pangolin()
self.create_concat_pangolin_fohm()
Expand All @@ -55,29 +59,6 @@ def create_all_files(self):
self.create_jsonfile()
self.create_instrument_properties()

def get_finished_slurm_ids(self) -> list:
"""Get slurm IDs"""

trace_file_path = Path(self.indir, "pipeline_info", "execution_trace.txt")
slurm_id_list = []
with open(trace_file_path, "r") as trace_file_contents:
for line in trace_file_contents:
slurm_id = line.split()[2]
try:
slurm_id_list.append(int(slurm_id))
except Exception:
continue
return slurm_id_list

def create_trailblazer_config(self) -> None:
"""Create Trailblazer config file"""

trailblazer_config_path = Path(self.indir, "trailblazer_config.yaml")
finished_slurm_ids = self.get_finished_slurm_ids()
if not finished_slurm_ids:
return
with open(trailblazer_config_path, "w") as trailblazer_config_file:
yaml.dump(data={"jobs": finished_slurm_ids}, stream=trailblazer_config_file)

def load_lookup_dict(self):
"""Loads articdata with data from various sources. Atm, artic output and the case config input file"""
Expand Down
Loading

0 comments on commit 29de8cb

Please sign in to comment.