Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
work
.nextflow*
git push -u origin master
work
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
40 changes: 21 additions & 19 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,41 @@
* You should have received a copy of the GNU General Public License
* along with Nextflow. If not, see <http://www.gnu.org/licenses/>.
*/


/*
* 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
Expand All @@ -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
"""
}
Expand All @@ -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
"""
}
10 changes: 8 additions & 2 deletions nextflow.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
manifest {
nextflowVersion = '>= 22.04.0'
nextflowVersion = '>= 23.10.0'
}

process {
container = 'nextflow/examples'
}
}

profiles {
docker {
docker.enabled = true
}
}
Loading