From 2d349a925d67d2218db0c473b796d78d212d333b Mon Sep 17 00:00:00 2001 From: ziadbkh Date: Sun, 12 May 2024 21:21:58 +1000 Subject: [PATCH] add figs to report --- assets/alphafold_template.html | 16 ++++++++-------- assets/generat_plots_2.py | 11 +++++++++++ tower.yml | 2 -- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/assets/alphafold_template.html b/assets/alphafold_template.html index 32be8829..8477b6f5 100755 --- a/assets/alphafold_template.html +++ b/assets/alphafold_template.html @@ -414,9 +414,9 @@

Download

- - - + + +
@@ -475,11 +475,11 @@

Download

] const LDDT_IMGS = [ - "*sample_name_here*_coverage_LDDT_0.png", - "*sample_name_here*_coverage_LDDT_1.png", - "*sample_name_here*_coverage_LDDT_2.png", - "*sample_name_here*_coverage_LDDT_3.png", - "*sample_name_here*_coverage_LDDT_4.png" + "coverage_LDDT_0.png", + "coverage_LDDT_1.png", + "coverage_LDDT_2.png", + "coverage_LDDT_3.png", + "coverage_LDDT_4.png" ] const REPRESENTATIONS = [ diff --git a/assets/generat_plots_2.py b/assets/generat_plots_2.py index c0948dd6..3b2ac1d8 100644 --- a/assets/generat_plots_2.py +++ b/assets/generat_plots_2.py @@ -4,6 +4,7 @@ from matplotlib import pyplot as plt import argparse from collections import OrderedDict +import base64 def generate_output_images(msa_path, plddt_paths, name, out_dir): msa = [] @@ -123,10 +124,20 @@ def generate_output_images(msa_path, plddt_paths, name, out_dir): alphfold_template = open(args.html_template, "r").read() alphfold_template = alphfold_template.replace(f"*sample_name_here*", args.name) + i = 0 for structure in structures: alphfold_template = alphfold_template.replace(f"*_data_ranked_{i}.pdb*", open(structure, "r").read().replace("\n", "\\n")) i += 1 +with open(f"{args.output_dir}/{args.name + ('_' if args.name else '')}seq_coverage.png", "rb") as in_file: + alphfold_template = alphfold_template.replace(f"seq_coverage.png", f"data:image/png;base64,{base64.b64encode(in_file.read()).decode('utf-8')}") + +for i in range(0, 5): + with open(f"{args.output_dir}/{args.name + ('_' if args.name else '')}coverage_LDDT_{i}.png", "rb") as in_file: + alphfold_template = alphfold_template.replace(f"coverage_LDDT_{i}.png", f"data:image/png;base64,{base64.b64encode(in_file.read()).decode('utf-8')}") + + + with open(f"{args.output_dir}/{args.name}_alphafold.html", "w") as out_file: out_file.write(alphfold_template) diff --git a/tower.yml b/tower.yml index 16a92fd3..c0b95ad4 100755 --- a/tower.yml +++ b/tower.yml @@ -5,5 +5,3 @@ reports: display: "Auto-created samplesheet with collated metadata and FASTQ paths" "*_alphafold.html": display: "Predected structures" - "*.png": - display: "Plots" \ No newline at end of file