Skip to content

Commit

Permalink
decrease code duplication by separating optional outputs from paired/…
Browse files Browse the repository at this point in the history
…unpaired output arguments
  • Loading branch information
rcannood committed Feb 22, 2024
1 parent 986a090 commit 6b76604
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/cutadapt/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ par_fasta='false'
par_info_file='false'
## VIASH END

# TODO: change this?
if [ -z $par_output ]; then
par_output=.
else
Expand Down Expand Up @@ -169,15 +170,29 @@ echo "Arguments to cutadapt:"
echo $filter_args
echo

# Output arguments
# We write the output to a directory rather than
# individual files.
# Optional output arguments
###########################################################
echo ">> Output arguments"
echo ">> Optional arguments"
[[ "$par_json" == "false" ]] && unset par_json
[[ "$par_fasta" == "false" ]] && unset par_fasta
[[ "$par_info_file" == "false" ]] && unset par_info_file

optional_output_args=$(echo \
${par_report:+--report "${par_report}"} \
${par_json:+--json "${par_output}/report.json"} \
${par_fasta:+--fasta} \
${par_info_file:+--info-file "$par_output/info.txt"} \
)

echo "Arguments to cutadapt:"
echo $optional_output_args
echo

# Output arguments
# We write the output to a directory rather than
# individual files.
###########################################################

if [[ -z $par_fasta ]]; then
ext="fastq"
else
Expand All @@ -186,22 +201,15 @@ fi

if [ $mode = "se" ]; then
output_args=$(echo \
${par_report:+--report "${par_report}"} \
${par_json:+--json "${par_output}/report.json"} \
--output "$par_output/{name}_001.$ext" \
${par_fasta:+--fasta} \
${par_info_file:+--info-file} \
)
else
output_args=$(echo \
${par_report:+--report "${par_report}"} \
${par_json:+--json "${par_output}/report.json"} \
--output "$par_output/{name}_R1_001.$ext" \
--paired-output "$par_output/{name}_R2_001.$ext" \
${par_fasta:+--fasta} \
${par_info_file:+--info-file} \
)
fi

echo "Arguments to cutadapt:"
echo $output_args
echo
Expand All @@ -221,6 +229,7 @@ cli=$(echo \
$input_args \
$mod_args \
$filter_args \
$optional_output_args \
$output_args \
--cores $par_cpus
)
Expand Down

0 comments on commit 6b76604

Please sign in to comment.