From 0990cd65b90fdc7b3590024cc480c313f3aa4332 Mon Sep 17 00:00:00 2001 From: Ziad Al Bkhetan Date: Fri, 4 Oct 2024 15:00:53 +1000 Subject: [PATCH] model names in lower case --- bin/generate_report.py | 24 ++++++++++++------------ main.nf | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/generate_report.py b/bin/generate_report.py index dd980ba4..1058c4bf 100755 --- a/bin/generate_report.py +++ b/bin/generate_report.py @@ -294,7 +294,7 @@ def pdb_to_lddt(pdb_files, generate_tsv): parser.add_argument("--html_template", dest="html_template") parser.add_argument("--version", action="version", version=f"{version}") parser.set_defaults(output_dir="") -parser.set_defaults(in_type="ESMFOLD") +parser.set_defaults(in_type="esmfold") parser.set_defaults(name="") args = parser.parse_args() @@ -316,26 +316,26 @@ def pdb_to_lddt(pdb_files, generate_tsv): io.save(ref_structure_path) aligned_structures[0] = ref_structure_path -alphafold_template = open(args.html_template, "r").read() -alphafold_template = alphafold_template.replace("*sample_name*", args.name) -alphafold_template = alphafold_template.replace("*prog_name*", args.in_type) +proteinfold_template = open(args.html_template, "r").read() +proteinfold_template = proteinfold_template.replace("*sample_name*", args.name) +proteinfold_template = proteinfold_template.replace("*prog_name*", args.in_type) args_pdb_array_js = ",\n".join([f'"{model}"' for model in structures]) -alphafold_template = re.sub( +proteinfold_template = re.sub( r"const MODELS = \[.*?\];", # Match the existing MODELS array in HTML template f"const MODELS = [\n {args_pdb_array_js}\n];", # Replace with the new array - alphafold_template, + proteinfold_template, flags=re.DOTALL, ) averages_js_array = f"const LDDT_AVERAGES = {lddt_averages};" -alphafold_template = alphafold_template.replace( +proteinfold_template = proteinfold_template.replace( "const LDDT_AVERAGES = [];", averages_js_array ) i = 0 for structure in aligned_structures: - alphafold_template = alphafold_template.replace( + proteinfold_template = proteinfold_template.replace( f"*_data_ranked_{i}.pdb*", open(structure, "r").read().replace("\n", "\\n") ) i += 1 @@ -347,22 +347,22 @@ def pdb_to_lddt(pdb_files, generate_tsv): else f"{args.output_dir}/{args.name + ('_' if args.name else '')}seq_coverage.png" ) with open(image_path, "rb") as in_file: - alphafold_template = alphafold_template.replace( + proteinfold_template = proteinfold_template.replace( "seq_coverage.png", f"data:image/png;base64,{base64.b64encode(in_file.read()).decode('utf-8')}", ) else: pattern = r'
.*?(.*?)*?
\s*' - alphafold_template = re.sub(pattern, "", alphafold_template, flags=re.DOTALL) + proteinfold_template = re.sub(pattern, "", proteinfold_template, flags=re.DOTALL) with open( f"{args.output_dir}/{args.name + ('_' if args.name else '')}coverage_LDDT.html", "r", ) as in_file: lddt_html = in_file.read() - alphafold_template = alphafold_template.replace( + proteinfold_template = proteinfold_template.replace( '
', lddt_html ) with open(f"{args.output_dir}/{args.name}_{args.in_type.lower()}_report.html", "w") as out_file: - out_file.write(alphafold_template) + out_file.write(proteinfold_template) diff --git a/main.nf b/main.nf index e7e0778c..f670b354 100644 --- a/main.nf +++ b/main.nf @@ -117,7 +117,7 @@ workflow NFCORE_PROTEINFOLD { ch_multiqc = ALPHAFOLD2.out.multiqc_report ch_versions = ch_versions.mix(ALPHAFOLD2.out.versions) ch_report_input = ch_report_input.mix( - ALPHAFOLD2.out.pdb.join(ALPHAFOLD2.out.msa).map{it[0]["model"] = "ALPHAFOLD2"; it} + ALPHAFOLD2.out.pdb.join(ALPHAFOLD2.out.msa).map{it[0]["model"] = "alphafold2"; it} ) } @@ -191,7 +191,7 @@ workflow NFCORE_PROTEINFOLD { ch_multiqc = ESMFOLD.out.multiqc_report ch_versions = ch_versions.mix(ESMFOLD.out.versions) ch_report_input = ch_report_input.mix( - ESMFOLD.out.pdb.combine(Channel.fromPath("$projectDir/assets/NO_FILE")).map{it[0]["model"] = "ESMFOLD"; it} + ESMFOLD.out.pdb.combine(Channel.fromPath("$projectDir/assets/NO_FILE")).map{it[0]["model"] = "esmfold"; it} ) } //