diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc50f82..3bc0dda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,11 +55,10 @@ jobs: sudo update-locale LANG=en_US.UTF-8 - name: Run pipeline with test data - # TODO nf-core: You can customise CI pipeline run tests as required - # For example: adding multiple test runs with different parameters - # Remember that you can parallelise this by using strategy.matrix - run: | - nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }} + uses: Wandalen/wretry.action@v1.0.11 + with: + command: nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }} + attempt_limit: 3 motus: name: Test mOTUs with workflow parameters @@ -79,14 +78,9 @@ jobs: uses: actions/checkout@v2 - name: Install Nextflow - env: - NXF_VER: ${{ matrix.NXF_VER }} - # Uncomment only if the edge release is more recent than the latest stable release - # See https://github.com/nextflow-io/nextflow/issues/2467 - # NXF_EDGE: ${{ matrix.NXF_EDGE }} - run: | - wget -qO- get.nextflow.io | bash - sudo mv nextflow /usr/local/bin/ + uses: nf-core/setup-nextflow@v1 + with: + version: "${{ matrix.NXF_VER }}" - name: Show current locale run: locale diff --git a/bin/check_samplesheet.py b/bin/check_samplesheet.py index 7d6c1a9..ca54ed9 100755 --- a/bin/check_samplesheet.py +++ b/bin/check_samplesheet.py @@ -6,10 +6,10 @@ import sys import errno import argparse + def parse_args(args=None): - Description = ( - "Reformat nf-core/taxprofiler samplesheet file and check its contents." - ) + Description = "Reformat nf-core/taxprofiler samplesheet file and check its contents." + Epilog = "Example usage: python check_samplesheet.py " parser = argparse.ArgumentParser(description=Description, epilog=Epilog) @@ -17,6 +17,7 @@ def parse_args(args=None): parser.add_argument("FILE_OUT", help="Output file.") return parser.parse_args(args) + def make_dir(path): if len(path) > 0: try: @@ -25,6 +26,7 @@ def make_dir(path): if exception.errno != errno.EEXIST: raise exception + def print_error(error, context="Line", context_str=""): error_str = "ERROR: Please check samplesheet -> {}".format(error) if context != "" and context_str != "": @@ -34,6 +36,7 @@ def print_error(error, context="Line", context_str=""): print(error_str) sys.exit(1) + def check_samplesheet(file_in, file_out): """ This function checks that the samplesheet follows the following structure: @@ -117,9 +120,7 @@ def check_samplesheet(file_in, file_out): num_cols = len([x for x in lspl if x]) if num_cols < MIN_COLS: print_error( - "Invalid number of populated columns (minimum = {})!".format( - MIN_COLS - ), + "Invalid number of populated columns (minimum = {})!".format(MIN_COLS), "Line", line, ) @@ -182,13 +183,9 @@ def check_samplesheet(file_in, file_out): ## Auto-detect paired-end/single-end if sample and fastq_1 and fastq_2: ## Paired-end short reads sample_info.extend(["0", fastq_1, fastq_2, fasta]) - elif ( - sample and fastq_1 and not fastq_2 - ): ## Single-end short/long fastq reads + elif sample and fastq_1 and not fastq_2: ## Single-end short/long fastq reads sample_info.extend(["1", fastq_1, fastq_2, fasta]) - elif ( - sample and fasta and not fastq_1 and not fastq_2 - ): ## Single-end long reads + elif sample and fasta and not fastq_1 and not fastq_2: ## Single-end long reads sample_info.extend(["1", fastq_1, fastq_2, fasta]) elif fasta and (fastq_1 or fastq_2): print_error( diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0d62beb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +# Config file for Python. Mostly used to configure linting of bin/check_samplesheet.py with Black. +# Should be kept the same as nf-core/tools to avoid fighting with template synchronisation. +[tool.black] +line-length = 120 +target_version = ["py37", "py38", "py39", "py310"] + +[tool.isort] +profile = "black" +known_first_party = ["nf_core"] +multi_line_output = 3