Skip to content

Commit

Permalink
Metaphlan4 update: add --index (#3604)
Browse files Browse the repository at this point in the history
* Add --index to metaphlan

* correct --input_type
  • Loading branch information
LilyAnderssonLee authored Jul 6, 2023
1 parent c5b528d commit 31ec447
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/nf-core/metaphlan/metaphlan/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ process METAPHLAN_METAPHLAN {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def input_type = ("$input".endsWith(".fastq.gz") || "$input".endsWith(".fq.gz")) ? "--input_type fastq" : ("$input".contains(".fasta")) ? "--input_type fasta" : ("$input".endsWith(".bowtie2out.txt")) ? "--input_type bowtie2out" : "--input_type sam"
def input_type = "$input" =~ /.*\.(fastq|fq)/ ? "--input_type fastq" : "$input" =~ /.*\.(fasta|fna|fa)/ ? "--input_type fasta" : "$input".endsWith(".bowtie2out.txt") ? "--input_type bowtie2out" : "--input_type sam"
def input_data = ("$input_type".contains("fastq")) && !meta.single_end ? "${input[0]},${input[1]}" : "$input"
def bowtie2_out = "$input_type" == "--input_type bowtie2out" || "$input_type" == "--input_type sam" ? '' : "--bowtie2out ${prefix}.bowtie2out.txt"

"""
BT2_DB=`find -L "${metaphlan_db_latest}" -name "*rev.1.bt2l" -exec dirname {} \\;`
BT2_DB_INDEX=`find -L ${metaphlan_db_latest} -name "*.rev.1.bt2l" | sed 's/\\.rev.1.bt2l\$//' | sed 's/.*\\///'`
metaphlan \\
--nproc $task.cpus \\
Expand All @@ -37,6 +38,7 @@ process METAPHLAN_METAPHLAN {
$args \\
$bowtie2_out \\
--bowtie2db \$BT2_DB \\
--index \$BT2_DB_INDEX \\
--biom ${prefix}.biom \\
--output_file ${prefix}_profile.txt
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/nf-core/metaphlan/metaphlan/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ workflow test_metaphlan_sam {
db = [ [], file('https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/delete_me/metaphlan4_database.tar.gz', checkIfExists: true) ]

UNTAR ( db )
SAMTOOLS_VIEW ( input, [] ,[])
SAMTOOLS_VIEW ( input, [[],[]], [])
METAPHLAN_METAPHLAN ( SAMTOOLS_VIEW.out.sam, UNTAR.out.untar.map{ it[1] } )
}

0 comments on commit 31ec447

Please sign in to comment.