From f4e9d11b71aa72261d1e64007e3b2b3d4e22f306 Mon Sep 17 00:00:00 2001 From: Katherine Eaton Date: Mon, 21 Sep 2020 14:32:03 -0400 Subject: [PATCH] test new pipeline workflow after updating docs --- .github/workflows/pipeline.yaml | 68 +++++++++++++++++++++++++++++++++ .gitignore | 1 + workflow/Snakefile | 34 +++++++++++++++-- workflow/envs/iqtree.yaml | 5 +++ workflow/rules/phylogeny.smk | 8 +++- 5 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pipeline.yaml create mode 100644 workflow/envs/iqtree.yaml diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml new file mode 100644 index 000000000..14e2c952e --- /dev/null +++ b/.github/workflows/pipeline.yaml @@ -0,0 +1,68 @@ +#------------------------------------------------------------------------------# +name: Pipeline +#------------------------------------------------------------------------------# +# Global workflow environment variables +env: + CONDA_ENVS_PATH: "/home/runner/miniconda/envs:/usr/share/miniconda/envs" + CONDA_PKGS_DIRS: "/home/runner/miniconda/pkgs" +#------------------------------------------------------------------------------# +# Workflow conditions +on: + push: + branches: + - '*' + paths: + - '.github/workflows/pipeline.yaml' + - 'workflow/Snakefile' + - 'workflow/rules/*.smk' + - 'workflow/envs/*.yaml' + pull_request: + branches: + - '*' + release: + types: [published] +#------------------------------------------------------------------------------# +jobs: + #----------------------------------------------------------------------------# + # Install dependencies + install : + runs-on: ubuntu-latest + steps: + #------------------------------------------------------------------------# + # Checkout Repository + - name: checkout repo + uses: actions/checkout@v2 + #------------------------------------------------------------------------# + # Setup conda with mamba + - name: setup conda + uses: goanpeca/setup-miniconda@v1 + with: + auto-update-conda: true + mamba-version: "*" + channels: conda-forge + #------------------------------------------------------------------------# + # Restore (cache) conda environments + - name: cache default env + id: cache-default + uses: actions/cache@v2 + with: + path: /home/runner/miniconda/envs/default + key: snakemake-default-${{ runner.os }}-${{ hashFiles('workflow/envs/default.yaml') }} + # Check conda environments + - name: check cache + run: | + conda info --envs + # Create environment (if not cached) + - name: create default environment + if: steps.cache-default.outputs.cache-hit != 'true' + shell: bash -l {0} + run: + mamba env create -f workflow/envs/default.yaml + #------------------------------------------------------------------------# + # Test pipeline + - name: test pipeline + shell: bash -l {0} + run: + conda activate default; + snakemake all --use-conda --profile profiles/gh-actions; + conda deactivate; diff --git a/.gitignore b/.gitignore index 28bf39b73..ddaee5fec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ results/* test/* sra/* +workflow/logs/* diff --git a/workflow/Snakefile b/workflow/Snakefile index 35c112a85..42580ab22 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -44,6 +44,9 @@ report: "report/workflow.rst" # -----------------------------------------------------------------------------# rule all: + """ + The default pipeline target. + """ input: "results/iqtree/iqtree.treefile" @@ -57,9 +60,32 @@ rule help: """ run: for rule in workflow.rules: + print("-" * 80) print("rule: ", rule.name ) print(rule.docstring ) - if rule._input: print("input: ", rule._input) - if rule._output: print("output: ", rule._output) - if rule._params: print("params: ", rule._params) - print("") + # Rule Inputs + if rule._input: + print("\tinput:") + for in_file in rule.input: + print("\t\t" + in_file) + for in_file in rule.input.keys(): + print("\t\t" + in_file + ": " + str(rule.input[in_file])) + if rule._output: + print("\toutput:") + for out_file in rule.output: + print("\t\t" + out_file) + for out_file in rule.output.keys(): + print("\t\t" + out_file + ": " + str(rule.output[out_file])) + if rule._params: + print("\tparams:") + for param in rule.params.keys(): + print("\t\t" + param + ": " + str(rule.params[param])) + if rule.resources: + print("\tresources:") + for resource in rule.resources.keys(): + print("\t\t" + resource.strip("_") + ": " + str(rule.resources[resource])) + if rule.conda_env: + print("\t\tconda: ", rule.conda_env) + if rule._log: + print("\t\tlog: ", rule._log) + #print(rule.conda_env) diff --git a/workflow/envs/iqtree.yaml b/workflow/envs/iqtree.yaml new file mode 100644 index 000000000..b95d6090c --- /dev/null +++ b/workflow/envs/iqtree.yaml @@ -0,0 +1,5 @@ +channels: + - bioconda + - defaults +dependencies: + - iqtree=2.0.3 diff --git a/workflow/rules/phylogeny.smk b/workflow/rules/phylogeny.smk index 9bec42a97..573104df7 100644 --- a/workflow/rules/phylogeny.smk +++ b/workflow/rules/phylogeny.smk @@ -9,5 +9,9 @@ rule iqtree: snp_aln = "results/snippy_multi/snippy-core.full.aln" output: tree = "results/iqtree/iqtree.treefile" - run: - shell("touch {output.tree}") + threads: + workflow.cores, + conda: + os.path.join(envs_dir,"iqtree.yaml") + shell: + "touch {output.tree}"