Last active
May 19, 2022 16:28
-
-
Save lindenb/6e610870e93835fdb4c4cb448016552c to your computer and use it in GitHub Desktop.
https://www.biostars.org/p/9523782/ blast biostar nextflow fasta sequence align
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nextflow.enable.dsl=2 | |
/* full path to query directory */ | |
params.qdir="/DIR1" | |
/* full path to target/database directory */ | |
params.tdir="/DIR2" | |
workflow { | |
dir_ch = Channel.of(["query",params.qdir],["target",params.tdir]) | |
fasta_ch = findFasta(dir_ch).splitCsv(header: false,sep:'\t',strip:true) | |
query_ch = fasta_ch.filter{T->T[0].equals("query")}.map{T->T[1]} | |
target_ch = fasta_ch.filter{T->T[0].equals("target")}.map{T->T[1]} | |
blast_ch = blastIt(query_ch.combine(target_ch)) | |
zipIt(blast_ch.collect()) | |
} | |
process findFasta { | |
tag "${type} in ${dir}" | |
input: | |
tuple val(type),val(dir) | |
output: | |
path("paths.txt") | |
script: | |
""" | |
test -d "${dir}" | |
find "${dir}" -type f -name "*.fa" -o -name "*.fasta" |\ | |
sed 's/^/${type}\t/' > paths.txt | |
test -s paths.txt | |
""" | |
} | |
process blastIt { | |
tag "${query} / ${target}" | |
input: | |
tuple val(query),val(target) | |
output: | |
path("out.blast") | |
script: | |
""" | |
blastp -query "${query}" -db ${target} -out out.blast | |
""" | |
} | |
process zipIt { | |
input: | |
val(L) | |
output: | |
path("blast.zip") | |
script: | |
""" | |
zip -9 blast.zip ${L.join(" ")} | |
""" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment