Skip to content

Commit

Permalink
fix: write out .sample_data in dragen-to-bam-qc (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Jan 24, 2024
1 parent 8f762e5 commit d153896
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/cli/__snapshots__/test_tools.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

'''
# ---
# name: test_dragen_to_bam_qc.1
'''
case_id set_id bam_stats
. . {"""sample""": {"""summary""": {"""mean coverage""": 35.44, """total target size""": 39036020}, """min_cov_target""": {"""0""": 100.0, """1""": 99.0, """3""": 98.77, """10""": 98.18, """15""": 97.59, """20""": 95.41, """50""": 0.88, """100""": 0.05, """500""": 0.03, """1000""": 0.03, """1500""": 0.03}, """bamstats""": {"""sequences""": 1055691016, """reads duplicated""": 65335430, """insert size average""": 488.03, """insert size standard deviation""": 115.27}}, """sample2""": {"""summary""": {"""mean coverage""": 35.44, """total target size""": 39036020}, """min_cov_target""": {"""0""": 100.0, """1""": 99.0, """3""": 98.77, """10""": 98.18, """15""": 97.59, """20""": 95.41, """50""": 0.88, """100""": 0.05, """500""": 0.03, """1000""": 0.03, """1500""": 0.03}, """bamstats""": {"""sequences""": 1055691016, """reads duplicated""": 65335430, """insert size average""": 488.03, """insert size standard deviation""": 115.27}}}

'''
# ---
# name: test_load_bam_qc
BamQc(sample_data={'sample': BamQcData(summary={'mean coverage': 35.44, 'total target size': 39036020}, min_cov_target={0: 100.0, 1: 99.0, 3: 98.77, 10: 98.18, 15: 97.59, 20: 95.41, 50: 0.88, 100: 0.05, 500: 0.03, 1000: 0.03, 1500: 0.03}, bamstats={'sequences': 1055691016, 'reads duplicated': 65335430, 'insert size average': 488.03, 'insert size standard deviation': 115.27}), 'sample2': BamQcData(summary={'mean coverage': 35.44, 'total target size': 39036020}, min_cov_target={0: 100.0, 1: 99.0, 3: 98.77, 10: 98.18, 15: 97.59, 20: 95.41, 50: 0.88, 100: 0.05, 500: 0.03, 1000: 0.03, 1500: 0.03}, bamstats={'sequences': 1055691016, 'reads duplicated': 65335430, 'insert size average': 488.03, 'insert size standard deviation': 115.27})})
# ---
3 changes: 3 additions & 0 deletions tests/cli/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ def test_dragen_to_bam_qc(

assert result.exit_code == 0, result.output
assert result.output == snapshot

with open(f"{tmpdir}/OUT.tsv", "rt") as f:
assert f.read() == snapshot
3 changes: 2 additions & 1 deletion varfish_cli/cli/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import csv
import fnmatch
import gzip
import json
from typing import Annotated, Dict, List

from logzero import logger
Expand Down Expand Up @@ -211,7 +212,7 @@ def dragen_to_bam_qc(
else:
output_file = open(output_file, "wt")
with output_file:
json_str = bam_qc.model_dump_json().replace('"', '"""')
json_str = json.dumps(bam_qc.model_dump(mode="json")["sample_data"]).replace('"', '"""')
print(f"case_id\tset_id\tbam_stats\n.\t.\t{json_str}", file=output_file)
logger.debug("... done writing output file.")

Expand Down

0 comments on commit d153896

Please sign in to comment.