From ae4222c95be1001fdbad2d0a0d345c749741585e Mon Sep 17 00:00:00 2001 From: amizeranschi Date: Thu, 16 May 2024 09:39:43 +0300 Subject: [PATCH] Replace multiple ifs with a single for The loop checks if files exist before moving them to temp/ --- modules/nf-core/rgi/main/main.nf | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/modules/nf-core/rgi/main/main.nf b/modules/nf-core/rgi/main/main.nf index 6ac87f1311e..ba05358abb4 100644 --- a/modules/nf-core/rgi/main/main.nf +++ b/modules/nf-core/rgi/main/main.nf @@ -60,16 +60,7 @@ process RGI_MAIN { --input_sequence $fasta mkdir temp/ - mv *.xml *.fsa *.{nhr,nin,nsq} *.draft *.potentialGenes temp/ - - ## These files not always generated, so only move if they exist - ## Taken from https://stackoverflow.com/a/54655320 (RIP) by @TSJNachos117 - if [ "\$(ls -A | grep -i \\variant.json\\\$)" ] ; then mv *variant.json temp/ ; fi - if [ "\$(ls -A | grep -i \\rrna.json\\\$)" ] ; then mv *rrna.json temp/ ; fi - if [ "\$(ls -A | grep -i \\protein.json\\\$)" ] ; then mv *protein.json temp/ ; fi - if [ "\$(ls -A | grep -i \\predictedGenes.json\\\$)" ]; then mv *predictedGenes.json temp/; fi - if [ "\$(ls -A | grep -i \\overexpression.json\\\$)" ]; then mv *overexpression.json temp/; fi - if [ "\$(ls -A | grep -i \\homolog.json\\\$)" ] ; then mv *homolog.json temp/ ; fi + for FILE in *.xml *.fsa *.{nhr,nin,nsq} *.draft *.potentialGenes *{variant,rrna,protein,predictedGenes,overexpression,homolog}.json; do [[ -e \$FILE ]] && mv \$FILE temp/; done RGI_VERSION=\$(rgi main --version)