Skip to content

Commit

Permalink
tests extended
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmajercik committed Jun 27, 2024
1 parent 2682d39 commit 0edf4d8
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/seqtk/seqtk_sample/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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; }

0 comments on commit 0edf4d8

Please sign in to comment.