Skip to content

Commit

Permalink
make graphviz with an import exception, otherwise the ascii file is w…
Browse files Browse the repository at this point in the history
…ritten to file.
  • Loading branch information
WardDeb committed Aug 13, 2024
1 parent 200a5a1 commit 4b9baae
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 21 deletions.
5 changes: 3 additions & 2 deletions .github/condaBuildCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: condaBuild_CI
channels:
- uibcdf
- conda-forge
- defaults
- bioconda
dependencies:
- python=3.11
- anaconda-client
- conda-build
- conda-build
- conda-verify
3 changes: 1 addition & 2 deletions .github/snakePipesEnvCI.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
name: snakePipes_CI
dependencies:
- python >= 3.11
- graphviz
- python >= 3.11
1 change: 0 additions & 1 deletion .github/workflows/conda-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions snakePipes/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import smtplib
from email.message import EmailMessage
from importlib.metadata import version
import graphviz

def set_env_yamls():
"""
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/ATACseq/ATACseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/ChIPseq/ChIPseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/DNAmapping/DNAmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/HiC/HiC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/WGBS/WGBS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/createIndices/createIndices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/mRNAseq/mRNAseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion snakePipes/workflows/ncRNAseq/ncRNAseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion snakePipes/workflows/scRNAseq/scRNAseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 4b9baae

Please sign in to comment.