ALG
ALG

Reputation: 212

Include command screen output in GNU Parallel log report

I have one script calling another multiple times with GNU Parallel. Here is the important part of my parallelization code:

export PTH_data={my input path}
export WDIR={my output path}
export idsuffix=\.'[1-2]'
export R1=${idsuffix/\[1-2\]/1}
export R2=${idsuffix/\[1-2\]/2}
export raw_extns='.fastq.gz'

## IDs is a txt file with one column containing the sample names.
inputFile=$(cat $PTH_data/IDs.txt | awk '{ print $1 }')

parallel "./bin/scr/MOTHUR_run.sh {1} > logs/parallel_{1}.log" ::: $inputFile 

And here the called MOTHUR_run.sh script:

#!/bin/bash

echo -e "MOTHUR pipeline for 16S analysis.
Analyzing sample "$(awk '/'$1'/{ print NR; }' $PTH_data/TotalIDs.txt)" of "$(< $PTH_data/TotalIDs.txt wc -l)".
Input files (FW & RV): 
- $1$R1$raw_extns 
- $1$R2$raw_extns"

echo -e "\n>>> TRIMMING ACTIVATED\n"
module load jdk/8u181
java -jar ./Trimmomatic-0.36/trimmomatic-0.36.jar PE -phred33 $WDIR/$1$R1.fastq $WDIR/$1$R2.fastq \
$WDIR/$1$R1'_paired.fastq' $WDIR/$1$R1'_unpaired.fastq.gz' $WDIR/$1$R2'_paired.fastq' $WDIR/$1$R2'_unpaired.fastq.gz' \
LEADING:3 TRAILING:3 SLIDINGWINDOW:20:30 MINLEN:220
ffile="$WDIR/"$1$R1"_paired"
rfile="$WDIR/"$1$R2"_paired"
module unload jdk/8u181
echo -e "\n>>> TRIMMING FINISHED\n"

module load intel/2018.5.274 mothur/1.40.5 vsearch/2.9.1

mothur "#summary.seqs(fasta=$(echo $ffile.trim.contigs.fasta))"

(And more code...)

I want to include the trimmomatic screen output inside the parallel log file, in the same order of execution. The echo parts work correctly, and mothur commands also include their screen output automatically inside the log file.

Any ideas?

Upvotes: 1

Views: 70

Answers (0)

Related Questions