Backport additions from wf-artic

This commit is contained in:
Chris Wright 2021-02-24 17:45:39 +00:00
parent b876c635ec
commit 5c60ad6779
5 changed files with 103 additions and 38 deletions

View File

@ -24,11 +24,14 @@ conda-run:
- *install-nextflow - *install-nextflow
- *install-conda - *install-conda
script: script:
- ./nextflow run workflow.nf - OUTPUT=${CI_PROJECT_NAME}
- ./nextflow run main.nf
-w ${OUTPUT}/workspace -w ${OUTPUT}/workspace
-profile conda -profile conda
--reads test_data/reads.fq.gz --fastq test_data/reads.fq.gz
--out_dir ${OUTPUT} --out_dir ${OUTPUT}
only:
- branches
build-image: build-image:
@ -42,11 +45,12 @@ build-image:
- docker build --no-cache -t "${TAG}" -f Dockerfile . --build-arg BASEIMAGE=${BASEIMAGE} - docker build --no-cache -t "${TAG}" -f Dockerfile . --build-arg BASEIMAGE=${BASEIMAGE}
# run letting nextflow orchestrate the containers # run letting nextflow orchestrate the containers
- docker tag "${TAG}" "${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:latest" - docker tag "${TAG}" "${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:latest"
- OUTPUT="template-workflow" - OUTPUT=${CI_PROJECT_NAME}
- ./nextflow run workflow.nf - ./nextflow run main.nf
-w ${OUTPUT}/workspace -w ${OUTPUT}/workspace
-profile standard -profile standard
--reads test_data/reads.fq.gz --wfversion latest
--fastq test_data/reads.fq.gz
--out_dir ${OUTPUT} --out_dir ${OUTPUT}
# push # push
- if [[ ${CI_COMMIT_BRANCH} == 'dev' ]]; then - if [[ ${CI_COMMIT_BRANCH} == 'dev' ]]; then
@ -60,7 +64,7 @@ build-image:
artifacts: artifacts:
paths: paths:
# Add the output directory for the test # Add the output directory for the test
- "template-workflow" - ${CI_PROJECT_NAME}
expire_in: 1 day expire_in: 1 day
@ -94,9 +98,12 @@ release-hub:
script: script:
- echo ${DOCKERHUB_TOKEN} | docker login --username epi2melabs --password-stdin - echo ${DOCKERHUB_TOKEN} | docker login --username epi2melabs --password-stdin
- RELTAG="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}" - RELTAG="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}"
- LATEST="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:latest"
- echo "Pushing ${RELTAG}" - echo "Pushing ${RELTAG}"
- docker tag ${SHATAG} ${RELTAG} - docker tag ${SHATAG} ${RELTAG}
- docker push ${RELTAG} - docker push ${RELTAG}
- docker tag ${SHATAG} ${LATEST}
- docker push ${LATEST}
# Send all tags matching vX.Y.Z to github (code and release) # Send all tags matching vX.Y.Z to github (code and release)
@ -107,10 +114,10 @@ push-github:
- apt-get update -qq && apt-get install -y -qq - apt-get update -qq && apt-get install -y -qq
git python3-all-dev git-lfs python3-venv git python3-all-dev git-lfs python3-venv
- mkdir ~/.ssh/ - mkdir ~/.ssh/
- cp $RESEARCH_BOT_GH_KEY ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa - cp $LABS_BOT_GH_KEY ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n\tHostname ssh.github.com\n\tPort 443\n\n" > ~/.ssh/config - echo -e "Host github.com\n\tStrictHostKeyChecking no\n\tHostname ssh.github.com\n\tPort 443\n\n" > ~/.ssh/config
- git config --global user.email "research.git@nanoporetech.com" - git config --global user.email "epi2melabs@nanoporetech.com"
- git config --global user.name "ontresearch" - git config --global user.name "epi2melabs-bot"
script: script:
# Push master and tag to github # Push master and tag to github
- git remote add ont ${CI_REPOSITORY_URL} || true - git remote add ont ${CI_REPOSITORY_URL} || true
@ -127,7 +134,7 @@ push-github:
- source release_env/bin/activate - source release_env/bin/activate
- pip install pip --upgrade - pip install pip --upgrade
- pip install git+https://github.com/epi2me-labs/github_release.git - pip install git+https://github.com/epi2me-labs/github_release.git
- github_release ${CI_PROJECT_NAME} ${CI_COMMIT_TAG} CHANGELOG.md ${RESEARCH_BOT_GH_TOKEN} - github_release ${CI_PROJECT_NAME} ${CI_COMMIT_TAG} CHANGELOG.md ${LABS_BOT_GH_TOKEN}
only: only:
- /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/ - /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/
except: except:

View File

@ -14,7 +14,7 @@ alternative software isolation method to Docker.
The Docker container image can be built with the following command: The Docker container image can be built with the following command:
```bash ```bash
CONTAINER_TAG=ontresearch/template-workflow CONTAINER_TAG=ontresearch/workflow-template
docker build \ docker build \
-t ${CONTAINER_TAG} -f Dockerfile \ -t ${CONTAINER_TAG} -f Dockerfile \
--build-arg BASEIMAGE=ontresearch/base-workflow-image:v0.1.0 \ --build-arg BASEIMAGE=ontresearch/base-workflow-image:v0.1.0 \
@ -34,15 +34,15 @@ To run the workflow using Docker containers supply the `-profile standard`
argument to `nextflow run`: argument to `nextflow run`:
``` ```
OUTPUT=template-workflow OUTPUT=workflow-template
nextflow run workflow.nf \ nextflow run main.nf \
-w ${OUTPUT}/workspace \ -w ${OUTPUT}/workspace \
-profile standard \ -profile standard \
--reads test_data/reads.fq.gz \ --fastq test_data/reads.fq.gz \
--out_dir ${OUTPUT} --out_dir ${OUTPUT}
``` ```
The output of the pipeline will be found in `./template-workflow` for the above The output of the pipeline will be found in `./workflow-template` for the above
example. This directory contains the nextflow working directories alongside example. This directory contains the nextflow working directories alongside
the two primary outputs of the pipeline. the two primary outputs of the pipeline.
@ -53,11 +53,11 @@ To run the workflow backed by conda environments, simply provide the
``` ```
# run the pipeline with the test data # run the pipeline with the test data
OUTPUT=template-workflow OUTPUT=workflow-template
nextflow run workflow.nf \ nextflow run main.nf \
-w ${OUTPUT}/workspace \ -w ${OUTPUT}/workspace \
-profile conda \ -profile conda \
--reads test_data/reads.fq.gz \ --fastq test_data/reads.fq.gz \
--out_dir ${OUTPUT} --out_dir ${OUTPUT}
``` ```

18
bin/read_lengths.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
import argparse
import pysam
def main():
parser = argparse.ArgumentParser()
parser.add_argument('fasta')
parser.add_argument('output')
args = parser.parse_args()
with open(args.output, 'w') as fh:
for rec in pysam.FastxFile(args.fasta):
fh.write("{}\t{}\n".format(rec.name, len(rec.sequence)))
if __name__ == '__main__':
main()

View File

@ -12,21 +12,18 @@
nextflow.enable.dsl = 2 nextflow.enable.dsl = 2
params.help = ""
if(params.help) { def helpMessage(){
log.info '' log.info """
log.info 'Workflow template' Workflow template'
log.info ''
log.info 'Usage: '
log.info ' nextflow run workflow.nf [options]'
log.info ''
log.info 'Script Options: '
log.info ' --fastq FILE Path to FASTQ file'
log.info ' --out_dir DIR Path for output'
log.info ''
return Usage:
nextflow run epi2melabs/workflow-template [options]
Script Options:
--fastq FILE Path to FASTQ file (required)
--out_dir DIR Path for output (default: $params.out_dir)
"""
} }
@ -39,11 +36,8 @@ process readSeqs {
file "seqs.txt" file "seqs.txt"
""" """
#!/usr/bin/env python read_lengths.py $reads seqs.txt
import pysam sleep 60
with open("seqs.txt", 'w') as fh:
for rec in pysam.FastxFile("$reads"):
fh.write("{}\\t{}\\n".format(rec.name, len(rec.sequence)))
""" """
} }
@ -78,7 +72,21 @@ workflow pipeline {
// entrypoint workflow // entrypoint workflow
workflow { workflow {
reads = channel.fromPath(params.reads, checkIfExists:true)
if (params.help) {
helpMessage()
exit 1
}
if (!params.fastq) {
helpMessage()
println("")
println("`--fastq` is required")
exit 1
}
reads = channel.fromPath(params.fastq, checkIfExists:true)
results = pipeline(reads) results = pipeline(reads)
output(results) output(results)
} }

View File

@ -10,6 +10,20 @@
// for further help editing this file. // for further help editing this file.
params {
help = false
out_dir = "output"
wfversion = "v0.0.1"
}
executor {
$local {
cpus = 4
memory = "8 GB"
}
}
profiles { profiles {
// the "standard" profile is used implicitely by nextflow // the "standard" profile is used implicitely by nextflow
// if no other profile is given on the CLI // if no other profile is given on the CLI
@ -22,7 +36,7 @@ profiles {
} }
process { process {
withLabel:pysam { withLabel:pysam {
container = 'ontresearch/workflow-template:latest' container = "ontresearch/workflow-template:${params.wfversion}"
} }
shell = ['/bin/bash', '-euo', 'pipefail'] shell = ['/bin/bash', '-euo', 'pipefail']
} }
@ -45,3 +59,21 @@ profiles {
} }
} }
} }
timeline {
enabled = true
file = "${params.out_dir}/execution_timeline.html"
}
report {
enabled = true
file = "${params.out_dir}/execution_report.html"
}
trace {
enabled = true
file = "${params.out_dir}/execution_trace.txt"
}
dag {
enabled = true
file = "${params.out_dir}/pipeline_dag.svg"
}