diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..62726d1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: blast ci +on: [push] + +jobs: + build: + name: blast ci + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + java_version: ['17'] + nextflow_version: ['23.10'] + + steps: + - name: Environment + run: env | sort + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: true + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: ${{ matrix.java_version }} + architecture: x64 + + - name: Setup Nextflow ${{ matrix.nextflow_version }} + uses: nf-core/setup-nextflow@b9f764e8ba5c76b712ace14ecbfcef0e40ae2dd8 # v1 + with: + version: "${{ matrix.nextflow_version }}" + + - name: Tests + run: | + nextflow run . -profile docker + env: + NXF_ANSI_LOG: false diff --git a/.gitignore b/.gitignore index 5964400..aa173da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .git -work .nextflow* -git push -u origin master \ No newline at end of file +work diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9c87d7f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -sudo: required -jdk: openjdk11 -services: -- docker -install: -- sudo apt-get -qq update -- sudo apt-get -qq -y install graphviz realpath -- curl -fsSL get.nextflow.io | bash -- docker pull nextflow/examples -script: -- ./nextflow run main.nf -with-docker diff --git a/README.md b/README.md index 75d55f6..60a8b94 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,24 @@ -# Blast example +# Blast example -A basic Blast pipeline using Nextflow +A basic Blast pipeline using Nextflow. -[![Build Status](https://travis-ci.org/nextflow-io/blast-example.svg?branch=master)](https://travis-ci.org/nextflow-io/blast-example) +[![nextflow](https://img.shields.io/badge/nextflow-%E2%89%A523.10-brightgreen.svg)](http://nextflow.io) -## Get started +## Get started -Install Nextflow +Install Nextflow - curl https://get.nextflow.io | bash +```bash +curl https://get.nextflow.io | bash +``` -Run the script +Run the pipeline: - nextflow run blast-example -with-docker +```bash +nextflow run blast-example -profile docker +``` -## Dependencies +## Dependencies -* Java 11 or later -* Docker 1.10 or later +* Java 17 or later +* Docker diff --git a/main.nf b/main.nf index 31d19fb..e4ccfeb 100644 --- a/main.nf +++ b/main.nf @@ -20,43 +20,41 @@ * You should have received a copy of the GNU General Public License * along with Nextflow. If not, see . */ - + /* - * Defines the pipeline inputs parameters (giving a default value for each for them) - * Each of the following parameters can be specified as command line options + * Defines the pipeline parameters (with a default value for each one) + * Each parameter can be specified on the command line (e.g. `--query query.fa`) */ -params.query = "$baseDir/data/sample.fa" -params.db = "$baseDir/blast-db/pdb/tiny" +params.query = "$projectDir/data/sample.fa" +params.db = "$projectDir/blast-db/pdb/tiny" params.out = "result.txt" -params.chunkSize = 100 - -db_name = file(params.db).name -db_dir = file(params.db).parent +params.chunkSize = 100 workflow { + db_dir = file(params.db).parent + db_name = file(params.db).name + /* * Create a channel emitting the given query fasta file(s). * Split the file into chunks containing as many sequences as defined by the parameter 'chunkSize'. * Finally, assign the resulting channel to the variable 'ch_fasta' */ - Channel - .fromPath(params.query) - .splitFasta(by: params.chunkSize, file:true) - .set { ch_fasta } + ch_fasta = channel.fromPath(params.query) + .splitFasta(by: params.chunkSize, file: true) /* * Execute a BLAST job for each chunk emitted by the 'ch_fasta' channel * and emit the resulting BLAST matches. */ - ch_hits = blast(ch_fasta, db_dir) + ch_hits = blast(ch_fasta, db_dir, db_name) /* * Each time a file emitted by the 'blast' process, an extract job is executed, * producing a file containing the matching sequences. */ - ch_sequences = extract(ch_hits, db_dir) + ch_sequences = extract(ch_hits, db_dir, db_name) /* * Collect all the sequences files into a single file @@ -71,13 +69,15 @@ workflow { process blast { input: path 'query.fa' - path db + path db_dir + val db_name output: path 'top_hits' + script: """ - blastp -db $db/$db_name -query query.fa -outfmt 6 > blast_result + blastp -db $db_dir/$db_name -query query.fa -outfmt 6 > blast_result cat blast_result | head -n 10 | cut -f 2 > top_hits """ } @@ -86,12 +86,14 @@ process blast { process extract { input: path 'top_hits' - path db + path db_dir + val db_name output: path 'sequences' + script: """ - blastdbcmd -db $db/$db_name -entry_batch top_hits | head -n 10 > sequences + blastdbcmd -db $db_dir/$db_name -entry_batch top_hits | head -n 10 > sequences """ } diff --git a/nextflow.config b/nextflow.config index 68819e5..8336bb7 100644 --- a/nextflow.config +++ b/nextflow.config @@ -1,7 +1,13 @@ manifest { - nextflowVersion = '>= 22.04.0' + nextflowVersion = '>= 23.10.0' } process { container = 'nextflow/examples' -} \ No newline at end of file +} + +profiles { + docker { + docker.enabled = true + } +}