Merge branch 'updates' into 'dev'

Backport additions from wf-artic

See merge request epi2melabs/workflow-containers/workflow-template!2
This commit is contained in:
Chris Wright 2021-02-24 17:45:39 +00:00
commit d95ccc2e41
5 changed files with 103 additions and 38 deletions

View File

@ -24,11 +24,14 @@ conda-run:
- *install-nextflow
- *install-conda
script:
- ./nextflow run workflow.nf
- OUTPUT=${CI_PROJECT_NAME}
- ./nextflow run main.nf
-w ${OUTPUT}/workspace
-profile conda
--reads test_data/reads.fq.gz
--fastq test_data/reads.fq.gz
--out_dir ${OUTPUT}
only:
- branches
build-image:
@ -42,11 +45,12 @@ build-image:
- docker build --no-cache -t "${TAG}" -f Dockerfile . --build-arg BASEIMAGE=${BASEIMAGE}
# run letting nextflow orchestrate the containers
- docker tag "${TAG}" "${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:latest"
- OUTPUT="template-workflow"
- ./nextflow run workflow.nf
- OUTPUT=${CI_PROJECT_NAME}
- ./nextflow run main.nf
-w ${OUTPUT}/workspace
-profile standard
--reads test_data/reads.fq.gz
--wfversion latest
--fastq test_data/reads.fq.gz
--out_dir ${OUTPUT}
# push
- if [[ ${CI_COMMIT_BRANCH} == 'dev' ]]; then
@ -60,7 +64,7 @@ build-image:
artifacts:
paths:
# Add the output directory for the test
- "template-workflow"
- ${CI_PROJECT_NAME}
expire_in: 1 day
@ -94,9 +98,12 @@ release-hub:
script:
- echo ${DOCKERHUB_TOKEN} | docker login --username epi2melabs --password-stdin
- RELTAG="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}"
- LATEST="${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:latest"
- echo "Pushing ${RELTAG}"
- docker tag ${SHATAG} ${RELTAG}
- docker push ${RELTAG}
- docker tag ${SHATAG} ${LATEST}
- docker push ${LATEST}
# 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
git python3-all-dev git-lfs python3-venv
- 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
- git config --global user.email "research.git@nanoporetech.com"
- git config --global user.name "ontresearch"
- git config --global user.email "epi2melabs@nanoporetech.com"
- git config --global user.name "epi2melabs-bot"
script:
# Push master and tag to github
- git remote add ont ${CI_REPOSITORY_URL} || true
@ -127,7 +134,7 @@ push-github:
- source release_env/bin/activate
- pip install pip --upgrade
- 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:
- /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/
except:

View File

@ -14,7 +14,7 @@ alternative software isolation method to Docker.
The Docker container image can be built with the following command:
```bash
CONTAINER_TAG=ontresearch/template-workflow
CONTAINER_TAG=ontresearch/workflow-template
docker build \
-t ${CONTAINER_TAG} -f Dockerfile \
--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`:
```
OUTPUT=template-workflow
nextflow run workflow.nf \
OUTPUT=workflow-template
nextflow run main.nf \
-w ${OUTPUT}/workspace \
-profile standard \
--reads test_data/reads.fq.gz \
--fastq test_data/reads.fq.gz \
--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
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
OUTPUT=template-workflow
nextflow run workflow.nf \
OUTPUT=workflow-template
nextflow run main.nf \
-w ${OUTPUT}/workspace \
-profile conda \
--reads test_data/reads.fq.gz \
--fastq test_data/reads.fq.gz \
--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
params.help = ""
if(params.help) {
log.info ''
log.info '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 ''
def helpMessage(){
log.info """
Workflow template'
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"
"""
#!/usr/bin/env python
import pysam
with open("seqs.txt", 'w') as fh:
for rec in pysam.FastxFile("$reads"):
fh.write("{}\\t{}\\n".format(rec.name, len(rec.sequence)))
read_lengths.py $reads seqs.txt
sleep 60
"""
}
@ -78,7 +72,21 @@ workflow pipeline {
// entrypoint 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)
output(results)
}

View File

@ -10,6 +10,20 @@
// for further help editing this file.
params {
help = false
out_dir = "output"
wfversion = "v0.0.1"
}
executor {
$local {
cpus = 4
memory = "8 GB"
}
}
profiles {
// the "standard" profile is used implicitely by nextflow
// if no other profile is given on the CLI
@ -22,7 +36,7 @@ profiles {
}
process {
withLabel:pysam {
container = 'ontresearch/workflow-template:latest'
container = "ontresearch/workflow-template:${params.wfversion}"
}
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"
}