diff --git a/bin/csv_adorn.py b/bin/csv_adorn.py index 2052082..f2ee795 100755 --- a/bin/csv_adorn.py +++ b/bin/csv_adorn.py @@ -12,8 +12,13 @@ def csv_adorn(path: str, header: str) -> None: """ print(f"id,{header}") with open(path) as f: + any_data = False for line in f: + any_data = True print(line.strip() + ",1") + if not any_data: + # this is a stupid hack, but the only way we found that does not break modularity + print("nothing,0") def main() -> None: diff --git a/bin/make_score_table.py b/bin/make_score_table.py index abbce80..c0f06b2 100755 --- a/bin/make_score_table.py +++ b/bin/make_score_table.py @@ -48,6 +48,9 @@ def main() -> None: # Print the data for i, row in enumerate(data): + # this if cleans up the stupid hack from csv_adorn + if scores[i] == 0: + continue print(row[0] + "," + id_formats[i] + "," + ",".join(row[1:]) + "," + str(scores[i])) diff --git a/bin/make_stats.py b/bin/make_stats.py index 7287024..17dc63a 100755 --- a/bin/make_stats.py +++ b/bin/make_stats.py @@ -24,11 +24,11 @@ def make_stats(score_table: str) -> None: # calculate stats n = len(scores) - mode = max(set(scores), key=scores.count) - mean = sum(scores) / n + mode = max(set(scores), key=scores.count) if scores else 0 + mean = sum(scores) / n if n else 0 goodness = mean / max_score - percent_max = sum(score == max_score for score in scores) / n - percent_privates = sum(score == 1 for score in scores) / n + percent_max = sum(score == max_score for score in scores) / n if n else 0 + percent_privates = sum(score == 1 for score in scores) / n if n else 0 # print stats as yaml print(f"n: {n}") diff --git a/bin/plot_orthologs.R b/bin/plot_orthologs.R index 85a82d4..2b3960e 100755 --- a/bin/plot_orthologs.R +++ b/bin/plot_orthologs.R @@ -49,6 +49,10 @@ empty_plots <- function(e) { } data <- tryCatch(read.csv(args[1], header = TRUE, stringsAsFactors = FALSE), error = empty_plots) +if (nrow(data) == 0) { + empty_plots() +} + # Melt the data keeping ID and score melted_data <- melt(data, id.vars = c("id", "id_format", "score"), variable.name = "method", value.name = "support") %>% filter(support == 1) %>% diff --git a/bin/score_hits.py b/bin/score_hits.py index c9a25fd..e8e409c 100755 --- a/bin/score_hits.py +++ b/bin/score_hits.py @@ -41,7 +41,7 @@ def filter_centroid(data) -> list: if sum([column[i] for column in columns]) > 1: for j in range(len(columns[i])): scores[i] += columns[i][j] - ratios = [scores[i] / sum(columns[i]) for i in range(len(columns))] + ratios = [scores[i] / sum(columns[i]) if sum(columns[i]) else 0 for i in range(len(columns))] # get index of highest ratio centroid = ratios.index(max(ratios)) diff --git a/conf/modules.config b/conf/modules.config index 6390dfe..614ed45 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -114,7 +114,7 @@ process { } withName: 'MERGE_HITS' { - ext.args = "-u NA" + ext.args = "-u 0 -k" ext.prefix = "aggregated_hits" publishDir = [ path: { "${params.outdir}/orthologs/hits" }, diff --git a/modules/local/fetch_eggnog_group_local.nf b/modules/local/fetch_eggnog_group_local.nf index baa6702..368fb58 100644 --- a/modules/local/fetch_eggnog_group_local.nf +++ b/modules/local/fetch_eggnog_group_local.nf @@ -2,11 +2,6 @@ process FETCH_EGGNOG_GROUP_LOCAL { tag "$meta.id" label 'process_single' - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : - 'biocontainers/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' }" - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : diff --git a/modules/local/fetch_oma_group_local.nf b/modules/local/fetch_oma_group_local.nf index 2ba3278..58f9581 100644 --- a/modules/local/fetch_oma_group_local.nf +++ b/modules/local/fetch_oma_group_local.nf @@ -2,11 +2,6 @@ process FETCH_OMA_GROUP_LOCAL { tag "$meta.id" label 'process_single' - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : - 'biocontainers/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' }" - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : diff --git a/modules/local/fetch_panther_group_local.nf b/modules/local/fetch_panther_group_local.nf index f823666..4512bf0 100644 --- a/modules/local/fetch_panther_group_local.nf +++ b/modules/local/fetch_panther_group_local.nf @@ -2,11 +2,6 @@ process FETCH_PANTHER_GROUP_LOCAL { tag "$meta.id" label 'process_single' - conda "conda-forge::python=3.10.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/python:3.10' : - 'biocontainers/python:3.10' }" - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : diff --git a/modules/local/filter_fasta.nf b/modules/local/filter_fasta.nf index 35d7181..4d68ef7 100644 --- a/modules/local/filter_fasta.nf +++ b/modules/local/filter_fasta.nf @@ -2,11 +2,6 @@ process FILTER_FASTA { tag "$meta.id" label 'process_single' - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' : - 'biocontainers/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' }" - conda "conda-forge::python=3.11.0 conda-forge::biopython=1.83.0 conda-forge::requests=2.31.0" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/mulled-v2-bc54124b36864a4af42a9db48b90a404b5869e7e:5258b8e5ba20587b7cbf3e942e973af5045a1e59-0' :