From 0edf4d8d6700495424c4910e0c5047693d015b63 Mon Sep 17 00:00:00 2001 From: jakubmajercik Date: Thu, 27 Jun 2024 11:20:58 +0200 Subject: [PATCH] tests extended --- src/seqtk/seqtk_sample/test.sh | 45 ++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/seqtk/seqtk_sample/test.sh b/src/seqtk/seqtk_sample/test.sh index d8594724..f9d942eb 100644 --- a/src/seqtk/seqtk_sample/test.sh +++ b/src/seqtk/seqtk_sample/test.sh @@ -11,7 +11,7 @@ meta_resources_dir="src/seqtk/seqtk_sample" mkdir seqtk_sample_se cd seqtk_sample_se -echo "> Run seqtk_sample on SE with fastq" +echo "> Run seqtk_sample on fastq SE" "$meta_executable" \ --input "$meta_resources_dir/test_data/reads/a.fastq" \ --seed 42 \ @@ -24,14 +24,12 @@ if [ ! -f "sampled.fastq" ]; then exit 1 fi -cat sampled.fastq - ######################################################################################### cd .. -mkdir seqtk_sample_pe -cd seqtk_sample_pe +mkdir seqtk_sample_pe_number +cd seqtk_sample_pe_number -echo ">> Run seqtk_sample on PE with fastq.gz" +echo ">> Run seqtk_sample on fastq.gz PE with number of reads" "$meta_executable" \ --input "$meta_resources_dir/test_data/reads/a.1.fastq.gz" \ --seed 42 \ @@ -56,4 +54,37 @@ headers1=$(grep '^@' sampled_1.fastq | sed -e's/ 1$//' | sort) headers2=$(grep '^@' sampled_2.fastq | sed -e 's/ 2$//' | sort) # Compare headers -diff <(echo "$headers1") <(echo "$headers2") || echo "Mismatch detected" && exit 1 +diff <(echo "$headers1") <(echo "$headers2") || { echo "Mismatch detected"; exit 1; } + +######################################################################################### +cd .. +mkdir seqtk_sample_pe_fraction +cd seqtk_sample_pe_fraction + +echo ">> Run seqtk_sample on fastq.gz PE with fraction of reads" +"$meta_executable" \ + --input "$meta_resources_dir/test_data/reads/a.1.fastq.gz" \ + --seed 42 \ + --fraction_number 0.5 \ + --output "sampled_1.fastq" + +"$meta_executable" \ + --input "$meta_resources_dir/test_data/reads/a.2.fastq.gz" \ + --seed 42 \ + --fraction_number 0.5 \ + --output "sampled_2.fastq" + +echo ">> Check if output exists" +if [ ! -f "sampled_1.fastq" ] || [ ! -f "sampled_2.fastq" ]; then + echo ">> One or both output files do not exist" + exit 1 +fi + +echo ">> Compare reads" +# Extract headers +headers1=$(grep '^@' sampled_1.fastq | sed -e's/ 1$//' | sort) +headers2=$(grep '^@' sampled_2.fastq | sed -e 's/ 2$//' | sort) + +# Compare headers +diff <(echo "$headers1") <(echo "$headers2") || { echo "Mismatch detected"; exit 1; } +