Commit be72b712 authored by bow's avatar bow
Browse files

Update summary script

parent ea202861
...@@ -176,14 +176,23 @@ def post_process(cs): ...@@ -176,14 +176,23 @@ def post_process(cs):
return cs return cs
def parse_idm(fh):
def add_variant_plots(idm_fh, var_plot_dir): idms = []
idms = set([]) for lineno, line in enumerate(fh):
for lineno, line in enumerate(idm_fh):
if lineno == 0: if lineno == 0:
continue continue
_, gsym, _ = line.strip().split("\t") gid, gsym, raw_tids = line.strip().split("\t")
assert gsym not in idms, gsym tids = raw_tids.split(",")
idms.append({"gene_id": gid, "gene_symbol": gsym,
"transcript_ids": tids})
return idms
def add_variant_plots(idm, var_plot_dir):
idms = set([])
for item in idm:
gsym = item["gene_symbol"]
assert gsym not in idms, item
idms.add(gsym) idms.add(gsym)
plots = [] plots = []
...@@ -224,11 +233,13 @@ def main(id_mappings_path, var_plot_dir, ...@@ -224,11 +233,13 @@ def main(id_mappings_path, var_plot_dir,
insert_stats_path, exon_cov_stats_path, vep_stats_path, insert_stats_path, exon_cov_stats_path, vep_stats_path,
run_name, sample_name, pipeline_version): run_name, sample_name, pipeline_version):
"""Helper script for combining multiple stats files into one JSON.""" """Helper script for combining multiple stats files into one JSON."""
idm = parse_idm(id_mappings_path)
combined = { combined = {
"metadata": { "metadata": {
"pipeline_version": pipeline_version, "pipeline_version": pipeline_version,
"run_name": run_name, "run_name": run_name,
"sample_name": sample_name, "sample_name": sample_name,
"genes_of_interest": idm,
}, },
"stats": { "stats": {
"seq": process_seq_stats(seq_stats_path), "seq": process_seq_stats(seq_stats_path),
...@@ -238,10 +249,12 @@ def main(id_mappings_path, var_plot_dir, ...@@ -238,10 +249,12 @@ def main(id_mappings_path, var_plot_dir,
"ins": process_insert_stats(insert_stats_path), "ins": process_insert_stats(insert_stats_path),
"var": process_var_stats(vep_stats_path), "var": process_var_stats(vep_stats_path),
}, },
"snv_indels": {"plots": []}, "results": {
"var": {"plots": []},
},
} }
combined["snv_indels"]["plots"].extend( combined["results"]["var"]["plots"].extend(
add_variant_plots(id_mappings_path, var_plot_dir)) add_variant_plots(idm, var_plot_dir))
combined["stats"] = post_process(combined["stats"]) combined["stats"] = post_process(combined["stats"])
print(json.dumps(combined, separators=(",", ":"), sort_keys=True)) print(json.dumps(combined, separators=(",", ":"), sort_keys=True))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment