From 7a604f5b36527fe07a8627c107d00f8d7f40295b Mon Sep 17 00:00:00 2001 From: Alejandra Escobar Date: Thu, 18 Apr 2024 11:16:07 +0100 Subject: [PATCH] Dram fixes (#3) Fixes in dram and pangenome_db_builder script --- bin/pangenomeDB_builder_codon.py | 27 ++++++++------------------- modules/local/dram/distill.nf | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/bin/pangenomeDB_builder_codon.py b/bin/pangenomeDB_builder_codon.py index 812b396..5e50b64 100755 --- a/bin/pangenomeDB_builder_codon.py +++ b/bin/pangenomeDB_builder_codon.py @@ -51,7 +51,10 @@ def metadata_parser(catalogue_metadata): def accessory_writer(reps_clusters, loc_prefix): for rep in reps_clusters: if len(reps_clusters[rep]) > 1: - rep_prefix = rep[:-2] + if rep.endswith('.1'): + rep_prefix = rep[:-4] + else: + rep_prefix = rep[:-2] pan_loc = ( loc_prefix + "/species_catalogue/" @@ -85,7 +88,10 @@ def accessory_writer(reps_clusters, loc_prefix): def annot_writer(reps_clusters, loc_prefix, pfam_desc): for rep in reps_clusters: core_list, core_mgygs = [], [] - rep_prefix = rep[:-2] + if rep.endswith('.1'): + rep_prefix = rep[:-4] + else: + rep_prefix = rep[:-2] rep_loc = ( loc_prefix + "/species_catalogue/" + rep_prefix + "/" + rep + "/genome/" ) @@ -205,23 +211,6 @@ def gff_parser(gff_file): att_l = attr.split(";") gene_id = att_l[0].replace("ID=", "") gff_dict[gene_id] = [contig, start, end, strand] - """ - kegg_flag, pfam_flag = 0, 0 - for attribute in att_l: - att_key,att_val = attribute.split('=') - if att_key == 'KEGG': - ko = att_val.replace('ko:','') - kegg_flag = 1 - if att_key == 'Pfam': - pfam = att_val - pfam_flag = 1 - if kegg_flag == 0: - ko = '-' - if pfam_flag == 0: - pfam = '-' - gff_dict[gene_id].append(ko) - gff_dict[gene_id].append(pfam) - """ return gff_dict diff --git a/modules/local/dram/distill.nf b/modules/local/dram/distill.nf index f7a10e9..405d132 100644 --- a/modules/local/dram/distill.nf +++ b/modules/local/dram/distill.nf @@ -14,8 +14,8 @@ process DRAM_DISTILL { val(in_type) //species or community output: - tuple val(meta), path("*_dram*"), emit: destill_out - path "versions.yml" , emit: versions + tuple val(meta), path("*_dram*"), emit: destill_out, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -31,12 +31,16 @@ process DRAM_DISTILL { fi cat $dram_summary >> dram_input.txt - DRAM.py \\ - distill \\ - -i dram_input.txt \\ - -o dram_out - mv dram_out/product.html ${prefix}_${tool}_${in_type}_dram.html - mv dram_out/product.tsv ${prefix}_${tool}_${in_type}_dram.tsv + line_count=\$(wc -l dram_input.txt) + + if [[ \$line_count -gt 1 ]]; then + DRAM.py \\ + distill \\ + -i dram_input.txt \\ + -o dram_out + mv dram_out/product.html ${prefix}_${tool}_${in_type}_dram.html + mv dram_out/product.tsv ${prefix}_${tool}_${in_type}_dram.tsv + fi cat <<-END_VERSIONS > versions.yml "${task.process}":