diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c37dfb6..eaf223c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,12 @@ +# Include shared CI include: - project: "epi2melabs/ci-templates" file: "wf-containers.yaml" -.run: &run | - ${NEXTFLOWRUN} -w ${OUTPUT}/workspace --out_dir ${OUTPUT} \ - --fastq test_data +variables: + # Workflow inputs given to nextflow. + # The workflow should define `--out_dir`, the CI template sets this. + # Only common file inputs and option values need to be given here + # (not things such as -profile) + NF_WORKFLOW_OPTS: "--fastq test_data" -conda-run: - extends: .conda-run - script: - - *run - -docker-run: - extends: .docker-run - script: - - *run - - touch ${CI_PROJECT_DIR}/success diff --git a/bin/read_lengths.py b/bin/read_lengths.py index eac7a46..aec06ca 100755 --- a/bin/read_lengths.py +++ b/bin/read_lengths.py @@ -1,13 +1,17 @@ #!/usr/bin/env python +"""Create a simple summary of a fastq file.""" + import argparse import glob import itertools import os -import pysam + import numpy as np +import pysam def mean_qual(quals): + """Calculate mean quality of a read.""" qual = np.fromiter( (ord(x) - 33 for x in quals), dtype=int, count=len(quals)) @@ -16,9 +20,12 @@ def mean_qual(quals): def main(): + """Run entry point.""" parser = argparse.ArgumentParser() - parser.add_argument("directory", help="Directory containing .fastq(.gz) files") - parser.add_argument("output", help="Output file") + parser.add_argument( + "directory", help="Directory containing .fastq(.gz) files") + parser.add_argument( + "output", help="Output file") args = parser.parse_args() fastqs = glob.glob(os.path.join(args.directory, "*.fastq*")) diff --git a/bin/report.py b/bin/report.py index bc355b4..14fae2a 100755 --- a/bin/report.py +++ b/bin/report.py @@ -1,16 +1,16 @@ #!/usr/bin/env python +"""Create workflow report.""" import argparse -import glob + +from aplanat import annot, hist, report +from bokeh.layouts import gridplot import numpy as np import pandas as pd -from bokeh.layouts import gridplot, layout -import aplanat -from aplanat import annot, hist, report - def read_files(summaries): + """Combine a list of files into a single dataframe.""" dfs = list() for fname in sorted(summaries): dfs.append(pd.read_csv(fname, sep="\t")) @@ -18,6 +18,7 @@ def read_files(summaries): def main(): + """Run the entry point.""" parser = argparse.ArgumentParser() parser.add_argument("report", help="Report output file") parser.add_argument("summaries", nargs='+', help="Read summary file.") @@ -25,7 +26,8 @@ def main(): report_doc = report.HTMLReport( "Workflow Template Sequencing report", - "Results generated through the wf-template nextflow workflow by Oxford Nanopore Technologies") + ("Results generated through the wf-template nextflow " + "workflow by Oxford Nanopore Technologies")) report_doc.markdown(''' ### Read Quality control @@ -33,8 +35,6 @@ This section displays basic QC metrics indicating read data quality. ''') np_blue = '#0084A9' - np_dark_grey = '#455560' - np_light_blue = '#90C6E7' # read length summary seq_summary = read_files(args.summaries) @@ -72,11 +72,13 @@ This section displays basic QC metrics indicating read data quality. report_doc.markdown(''' ### About -**Oxford Nanopore Technologies products are not intended for use for health assessment -or to diagnose, treat, mitigate, cure or prevent any disease or condition.** +**Oxford Nanopore Technologies products are not intended for use for health +assessment or to diagnose, treat, mitigate, cure or prevent any disease or +condition.** -This report was produced using the [epi2me-labs/wf-template](https://github.com/epi2me-labs/wf-template). -The workflow can be run using `nextflow epi2me-labs/wf-template --help` +This report was produced using the +[epi2me-labs/wf-template](https://github.com/epi2me-labs/wf-template). The +workflow can be run using `nextflow epi2me-labs/wf-template --help` --- ''') @@ -84,5 +86,6 @@ The workflow can be run using `nextflow epi2me-labs/wf-template --help` # write report report_doc.write(args.report) + if __name__ == "__main__": main()