Skip to content

Commit

Permalink
Add/snakemake flux (#25)
Browse files Browse the repository at this point in the history
* adding darshan

this likely should be added as a view that can be used on the fly,
but this container should be an OK start (and we can adjust as needed)

Signed-off-by: vsoch <vsoch@users.noreply.github.com>* wrong container tag
  • Loading branch information
vsoch committed Nov 12, 2023
1 parent 57d40d5 commit 8956873
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-matrices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
name: Build ${{ matrix.result.container_name }} ${{ matrix.arch[0] }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/setup-go@v3

- name: GHCR Login
Expand Down
34 changes: 34 additions & 0 deletions snakemake/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG tag=3.11
FROM python:${tag}

# docker build -t snakemake .
# command: snakemake --cores 1 --flux --jobs 1
# workdir: /workflow

RUN apt-get update
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && \
apt-get -y install \
git \
curl \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Wrappers to ensure we source the mamba environment!
RUN git clone --depth 1 https://github.com/snakemake/snakemake-tutorial-data /workflow
WORKDIR /workflow

# This wraps the existing entrypoint
COPY ./Snakefile ./
RUN mkdir ./scripts
COPY ./scripts/plot-quals.py ./scripts/plot-quals.py

# instead of altering the entrypoint to active the environment!
RUN pip install snakemake && \
pip install git+https://github.com/snakemake/snakemake-interface-common && \
pip install git+https://github.com/snakemake/snakemake-executor-plugin-flux && \
pip install git+https://github.com/snakemake/snakemake-interface-executor-plugins && \
pip install git+https://github.com/snakemake/snakemake-executor-flux

WORKDIR /code
15 changes: 15 additions & 0 deletions snakemake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Flux Snakemake Example

This is an example container where you can build (optional) and run
the [Snakemake tutorial workflow](https://snakemake.readthedocs.io/en/stable/tutorial/tutorial.html):

```bash
$ docker build -t snakemake .
```

or with a tag for the restful API:

```bash
$ docker build --no-cache --build-arg app="latest" -t snakemake .
```

56 changes: 56 additions & 0 deletions snakemake/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
SAMPLES = ["A", "B"]


rule all:
input:
"plots/quals.svg"


rule bwa_map:
input:
"data/genome.fa",
"data/samples/{sample}.fastq"
output:
"mapped_reads/{sample}.bam"
shell:
"bwa mem {input} | samtools view -Sb - > {output}"


rule samtools_sort:
input:
"mapped_reads/{sample}.bam"
output:
"sorted_reads/{sample}.bam"
shell:
"samtools sort -T sorted_reads/{wildcards.sample} "
"-O bam {input} > {output}"


rule samtools_index:
input:
"sorted_reads/{sample}.bam"
output:
"sorted_reads/{sample}.bam.bai"
shell:
"samtools index {input}"


rule bcftools_call:
input:
fa="data/genome.fa",
bam=expand("sorted_reads/{sample}.bam", sample=SAMPLES),
bai=expand("sorted_reads/{sample}.bam.bai", sample=SAMPLES)
output:
"calls/all.vcf"
shell:
"bcftools mpileup -f {input.fa} {input.bam} | "
"bcftools call -mv - > {output}"


rule plot_quals:
input:
"calls/all.vcf"
output:
"plots/quals.svg"
script:
"scripts/plot-quals.py"
9 changes: 9 additions & 0 deletions snakemake/scripts/plot-quals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from pysam import VariantFile

quals = [record.qual for record in VariantFile(snakemake.input[0])]
plt.hist(quals)

plt.savefig(snakemake.output[0])
6 changes: 6 additions & 0 deletions snakemake/uptodate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dockerbuild:
build_args:
tag:
key: python
versions:
- "3.11"

0 comments on commit 8956873

Please sign in to comment.