From 4b9baae58c37fead6816b3f72056d093c280f1ce Mon Sep 17 00:00:00 2001 From: WardDeb Date: Tue, 13 Aug 2024 13:40:36 +0200 Subject: [PATCH] make graphviz with an import exception, otherwise the ascii file is written to file. --- .github/condaBuildCI.yml | 5 +++-- .github/snakePipesEnvCI.yml | 3 +-- .github/workflows/conda-build.yml | 1 - conda-recipe/meta.yaml | 4 ++-- snakePipes/common_functions.py | 14 ++++++++++---- snakePipes/workflows/ATACseq/ATACseq.py | 2 +- snakePipes/workflows/ChIPseq/ChIPseq.py | 2 +- snakePipes/workflows/DNAmapping/DNAmapping.py | 2 +- snakePipes/workflows/HiC/HiC.py | 2 +- snakePipes/workflows/WGBS/WGBS.py | 2 +- .../workflows/createIndices/createIndices.py | 2 +- snakePipes/workflows/mRNAseq/mRNAseq.py | 2 +- snakePipes/workflows/ncRNAseq/ncRNAseq.py | 2 +- .../workflows/preprocessing/preprocessing.py | 2 +- snakePipes/workflows/scRNAseq/scRNAseq.py | 2 +- 15 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/condaBuildCI.yml b/.github/condaBuildCI.yml index 053031248..97edcb8a6 100644 --- a/.github/condaBuildCI.yml +++ b/.github/condaBuildCI.yml @@ -2,8 +2,9 @@ name: condaBuild_CI channels: - uibcdf - conda-forge - - defaults - bioconda dependencies: + - python=3.11 - anaconda-client - - conda-build \ No newline at end of file + - conda-build + - conda-verify \ No newline at end of file diff --git a/.github/snakePipesEnvCI.yml b/.github/snakePipesEnvCI.yml index 0d51d7ac1..c7410d0d5 100644 --- a/.github/snakePipesEnvCI.yml +++ b/.github/snakePipesEnvCI.yml @@ -1,4 +1,3 @@ name: snakePipes_CI dependencies: - - python >= 3.11 - - graphviz + - python >= 3.11 \ No newline at end of file diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index d24b6033f..60761a855 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -9,7 +9,6 @@ jobs: - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.11 environment-file: .github/condaBuildCI.yml auto-update-conda: false auto-activate-base: false diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index e54e97dc4..77afba14c 100755 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -10,18 +10,18 @@ source: build: number: 0 noarch: python - script: python -m pip install --no-deps --ignore-installed . + script: pip install . requirements: host: - python >=3 - pip + - seaborn run: - python >=3.11 - snakemake >=8 - snakemake-executor-plugin-cluster-generic >=1.0.9 - pandas - - graphviz - thefuzz - pyyaml >=5.1 diff --git a/snakePipes/common_functions.py b/snakePipes/common_functions.py index 19333fb65..2aac12ec3 100644 --- a/snakePipes/common_functions.py +++ b/snakePipes/common_functions.py @@ -14,7 +14,6 @@ import smtplib from email.message import EmailMessage from importlib.metadata import version -import graphviz def set_env_yamls(): """ @@ -687,10 +686,17 @@ def plot_DAG(args, snakemake_cmd, calling_script, defaults): # Read DOT data from stdout dot = DAGproc.stdout.read() - # Use graphviz to render DAG - graph = graphviz.Source(dot) + # Use graphviz to render DAG, if it is available + # conda graphviz doesn't provide the python bindings, the pip graphviz does, but has no executable. + # If graphviz is not available, write out the ASCII as file. output_file = os.path.join(args.outdir, f"{workflow_name}_pipeline") - graph.render(output_file, format='png') + try: + import graphviz + graph = graphviz.Source(dot) + graph.render(output_file, format='png') + except ModuleNotFoundError: + with open(output_file + 'DAG.txt', 'w') as f: + f.write(dot) def print_DAG(args, snakemake_cmd, callingScript, defaults): diff --git a/snakePipes/workflows/ATACseq/ATACseq.py b/snakePipes/workflows/ATACseq/ATACseq.py index 32e5790cf..1b67cff80 100755 --- a/snakePipes/workflows/ATACseq/ATACseq.py +++ b/snakePipes/workflows/ATACseq/ATACseq.py @@ -121,7 +121,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/ChIPseq/ChIPseq.py b/snakePipes/workflows/ChIPseq/ChIPseq.py index b4e474389..8772754b3 100755 --- a/snakePipes/workflows/ChIPseq/ChIPseq.py +++ b/snakePipes/workflows/ChIPseq/ChIPseq.py @@ -189,7 +189,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/DNAmapping/DNAmapping.py b/snakePipes/workflows/DNAmapping/DNAmapping.py index a994b608f..09419c81f 100755 --- a/snakePipes/workflows/DNAmapping/DNAmapping.py +++ b/snakePipes/workflows/DNAmapping/DNAmapping.py @@ -156,7 +156,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/HiC/HiC.py b/snakePipes/workflows/HiC/HiC.py index 03d5f825f..bf67d607e 100755 --- a/snakePipes/workflows/HiC/HiC.py +++ b/snakePipes/workflows/HiC/HiC.py @@ -187,7 +187,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) # CreateDAG - cf.print_DAG(args, snakemake_cmd, __file__, defaults) + cf.plot_DAG(args, snakemake_cmd, __file__, defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/WGBS/WGBS.py b/snakePipes/workflows/WGBS/WGBS.py index 651a7ec6b..08010b0f8 100755 --- a/snakePipes/workflows/WGBS/WGBS.py +++ b/snakePipes/workflows/WGBS/WGBS.py @@ -180,7 +180,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/createIndices/createIndices.py b/snakePipes/workflows/createIndices/createIndices.py index 90373b6d6..f9ef8212e 100755 --- a/snakePipes/workflows/createIndices/createIndices.py +++ b/snakePipes/workflows/createIndices/createIndices.py @@ -125,7 +125,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/mRNAseq/mRNAseq.py b/snakePipes/workflows/mRNAseq/mRNAseq.py index a70e11c72..fe3392351 100755 --- a/snakePipes/workflows/mRNAseq/mRNAseq.py +++ b/snakePipes/workflows/mRNAseq/mRNAseq.py @@ -196,4 +196,4 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) diff --git a/snakePipes/workflows/ncRNAseq/ncRNAseq.py b/snakePipes/workflows/ncRNAseq/ncRNAseq.py index 4413fbf8b..925f7af83 100755 --- a/snakePipes/workflows/ncRNAseq/ncRNAseq.py +++ b/snakePipes/workflows/ncRNAseq/ncRNAseq.py @@ -121,7 +121,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/preprocessing/preprocessing.py b/snakePipes/workflows/preprocessing/preprocessing.py index ad95a65b2..96fdee3f3 100755 --- a/snakePipes/workflows/preprocessing/preprocessing.py +++ b/snakePipes/workflows/preprocessing/preprocessing.py @@ -137,7 +137,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__": diff --git a/snakePipes/workflows/scRNAseq/scRNAseq.py b/snakePipes/workflows/scRNAseq/scRNAseq.py index 6f632c598..d1f63b6a4 100755 --- a/snakePipes/workflows/scRNAseq/scRNAseq.py +++ b/snakePipes/workflows/scRNAseq/scRNAseq.py @@ -150,7 +150,7 @@ def main(): cf.runAndCleanup(args, snakemake_cmd, logfile_name) #CreateDAG - cf.print_DAG(args,snakemake_cmd, __file__,defaults) + cf.plot_DAG(args,snakemake_cmd, __file__,defaults) if __name__ == "__main__":