Skip to content

Commit

Permalink
Allow multiple for adapters/fasta and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tverbeiren committed Feb 16, 2024
1 parent 99b4f01 commit c864e5e
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/cutadapt/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ functionality:
arguments:
- name: --adapter_fasta
type: file
multiple: true
description: |
Fasta file containing sequences of an adapter ligated to the 3' end (paired data:
of the first read). The adapter and subsequent bases are
Expand Down
86 changes: 74 additions & 12 deletions src/cutadapt/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,82 @@ fi
# - paired and single-end
# - string and fasta
###########################################################

multi_adapter=""
for adapter in `echo $par_adapter | tr ':' ' '`; do
multi_adapter="$multi_adapter --adapter $adapter"
done

multi_adapter_fasta=""
for adapter_fasta in `echo $par_adapter_fasta | tr ':' ' '`; do
multi_adapter_fasta="$multi_adapter_fasta --adapter file:$adapter_fasta"
done

multi_adapter_r2=""
for adapter_r2 in `echo $par_adapter_r2 | tr ':' ' '`; do
multi_adapter_r2="$multi_adapter_r2 --adapter_r2 $adapter_r2"
done

multi_adapter_fasta_r2=""
for adapter_fasta_r2 in `echo $par_adapter_fasta_r2 | tr ':' ' '`; do
multi_adapter_fasta_r2="$multi_adapter_fasta_r2 --adapter file:$adapter_fasta_r2"
done

multi_front=""
for front in `echo $par_front | tr ':' ' '`; do
multi_front="$multi_front --front $front"
done

multi_front_fasta=""
for front_fasta in `echo $par_front_fasta | tr ':' ' '`; do
multi_front_fasta="$multi_front_fasta --front file:$front_fasta"
done

multi_front_r2=""
for front_r2 in `echo $par_front_r2 | tr ':' ' '`; do
multi_front_r2="$multi_front_r2 --front_r2 $front_r2"
done

multi_front_fasta_r2=""
for front_fasta_r2 in `echo $par_front_fasta_r2 | tr ':' ' '`; do
multi_front_fasta_r2="$multi_front_fasta_r2 --front file:$front_fasta_r2"
done

multi_anywhere=""
for anywhere in `echo $par_anywhere | tr ':' ' '`; do
multi_anywhere="$multi_anywhere --anywhere $anywhere"
done

multi_anywhere_fasta=""
for anywhere_fasta in `echo $par_anywhere_fasta | tr ':' ' '`; do
multi_anywhere_fasta="$multi_anywhere_fasta --anywhere file:$anywhere_fasta"
done

multi_anywhere_r2=""
for anywhere_r2 in `echo $par_anywhere_r2 | tr ':' ' '`; do
multi_anywhere_r2="$multi_anywhere_r2 --anywhere_r2 $anywhere_r2"
done

multi_anywhere_fasta_r2=""
for anywhere_fasta_r2 in `echo $par_anywhere_fasta_r2 | tr ':' ' '`; do
multi_anywhere_fasta_r2="$multi_anywhere_fasta_r2 --anywhere file:$anywhere_fasta_r2"
done

echo ">> Parsing arguments dealing with adapters"
adapter_args=$(echo \
${par_adapter:+--adapter "${par_adapter}"} \
${par_adapter_fasta:+--adapter "file:${par_adapter_fasta}"} \
${par_front:+--front "${par_front}"} \
${par_front_fasta:+--front "file:${par_front_fasta}"} \
${par_anywhere:+--anywhere "${par_anywhere}"} \
${par_anywhere_fasta:+--anywhere "file:${par_anywhere_fasta}"} \
${par_adapter_r2:+--adapter_r2 "${par_adapter_r2}"} \
${par_adapter_r2_fasta:+--adapter_r2 "file:${par_adapter_r2_fasta}"} \
${par_front_r2:+--front_r2 "${par_front_r2}"} \
${par_front_r2_fasta:+--front_r2 "file:${par_front_r2_fasta}"} \
${par_anywhere_r2:+--anywhere_r2 "${par_anywhere_r2}"} \
${par_anywhere_r2_fasta:+--anywhere_r2 "file:${par_anywhere_r2_fasta}"}
${par_adapter:+${multi_adapter}} \
${par_adapter_fasta:+${multi_adapter_fasta}} \
${par_front:+${multi_front}} \
${par_front_fasta:+${multi_front_fasta}} \
${par_anywhere:+${multi_anywhere}} \
${par_anywhere_fasta:+${multi_anywhere_fasta}} \
${par_adapter_r2:+${multi_adapter_r2}} \
${par_adapter_fasta_r2:+${multi_adapter_fasta_r2}} \
${par_front_r2:+${multi_front_r2}} \
${par_front_fasta_r2:+${multi_front_fasta_r2}} \
${par_anywhere_r2:+${multi_anywhere_r2}} \
${par_anywhere_fasta_r2:+${multi_anywhere_fasta_r2}} \
)
echo "Arguments to cutadapt:"
echo "$adapter_args"
Expand Down
33 changes: 33 additions & 0 deletions src/cutadapt/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,44 @@ echo ">> Check if output is empty"

rm -r output-dir

echo "> Run with a combination of inputs"

echo ">adapter1" > adapters1.fasta
echo "AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC" >> adapters1.fasta

echo ">adapter1" > adapters2.fasta
echo "TGATCGGAAGAGCACACGTCTGAACTCCAGTCAC" >> adapters2.fasta

"$meta_executable" \
--report minimal \
--output output-dir \
--adapter AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC \
--adapter GGATCGGAAGAGCACACGTCTGAACTCCAGTCAC \
--adapter_fasta adapters1.fasta \
--adapter_fasta adapters2.fasta \
--input $dir_in/se/a.fastq \
--quality_cutoff 20 \
--json

echo ">> Checking output"
[ ! -f "output-dir/report.txt" ] && echo "report.txt does not exist" && exit 1
[ ! -f "output-dir/report.json" ] && echo "report.json does not exist" && exit 1
[ ! -f "output-dir/1_R1_001.fastq" ] && echo "1_R1_001.fastq does not exist" && exit 1
[ ! -f "output-dir/unknown_R1_001.fastq" ] && echo "1_R1_001.fastq does not exist" && exit 1

echo ">> Check if output is empty"
[ -s "output-dir/1_R1_001.fastq" ] && echo "1_R1_001.fastq should be empty" && exit 1
[ ! -s "output-dir/unknown_R1_001.fastq" ] && echo "unkown_R1_001.fastq is empty" && exit 1

rm -r output-dir
rm adapters?.fasta

echo "> Run cutadapt on paired-end data"
"$meta_executable" \
--report minimal \
--output output-dir \
--adapter AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC \
--adapter AGATCGGAAGAGCACACGTCTGAACTCCAGTCAB \
--input $dir_in/pe/a.1.fastq \
--input_r2 $dir_in/pe/a.2.fastq \
--quality_cutoff 20 \
Expand Down
1 change: 1 addition & 0 deletions src/cutadapt/test_data/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ cp -r /tmp/snakemake-wrappers/bio/cutadapt/se/test/reads/* src/cutadapt/test_dat
cp -r /tmp/snakemake-wrappers/bio/cutadapt/pe/test/reads/* src/cutadapt/test_data/pe

rm -rf /tmp/snakemake-wrappers

0 comments on commit c864e5e

Please sign in to comment.