diff --git a/src/bedtools/bedtools_genomecov/test.sh b/src/bedtools/bedtools_genomecov/test.sh index b2253600..89d53061 100644 --- a/src/bedtools/bedtools_genomecov/test.sh +++ b/src/bedtools/bedtools_genomecov/test.sh @@ -30,16 +30,20 @@ assert_identical_content() { # Create directories for tests echo "Creating Test Data..." -mkdir -p test_data +TMPDIR=$(mktemp -d "$meta_temp_dir/XXXXXX") +function clean_up { + [[ -d "$TMPDIR" ]] && rm -r "$TMPDIR" +} +trap clean_up EXIT # Create and populate input files -printf "chr1\t248956422\nchr2\t198295559\nchr3\t242193529\n" > "test_data/genome.txt" -printf "chr2\t128\t228\tmy_read/1\t37\t+\nchr2\t428\t528\tmy_read/2\t37\t-\n" > "test_data/example.bed" -printf "chr2\t128\t228\tmy_read/1\t60\t+\t128\t228\t255,0,0\t1\t100\t0\nchr2\t428\t528\tmy_read/2\t60\t-\t428\t528\t255,0,0\t1\t100\t0\n" > "test_data/example.bed12" -printf "chr2\t100\t103\n" > "test_data/example_dz.bed" +printf "chr1\t248956422\nchr2\t198295559\nchr3\t242193529\n" > "$TMPDIR/genome.txt" +printf "chr2\t128\t228\tmy_read/1\t37\t+\nchr2\t428\t528\tmy_read/2\t37\t-\n" > "$TMPDIR/example.bed" +printf "chr2\t128\t228\tmy_read/1\t60\t+\t128\t228\t255,0,0\t1\t100\t0\nchr2\t428\t528\tmy_read/2\t60\t-\t428\t528\t255,0,0\t1\t100\t0\n" > "$TMPDIR/example.bed12" +printf "chr2\t100\t103\n" > "$TMPDIR/example_dz.bed" # expected outputs -cat > "test_data/expected_default.bed" < "$TMPDIR/expected_default.bed" < "test_data/expected_ibam.bed" < "$TMPDIR/expected_ibam.bed" < "test_data/expected_ibam_pc.bed" < "$TMPDIR/expected_ibam_pc.bed" < "test_data/expected_ibam_fs.bed" < "$TMPDIR/expected_ibam_fs.bed" < "test_data/expected_dz.bed" < "$TMPDIR/expected_dz.bed" < "test_data/expected_strand.bed" < "$TMPDIR/expected_strand.bed" < "test_data/expected_5.bed" < "$TMPDIR/expected_5.bed" < "test_data/expected_bg_scale.bed" < "$TMPDIR/expected_bg_scale.bed" < "test_data/expected_trackopts.bed" < "$TMPDIR/expected_trackopts.bed" < "test_data/expected_split.bed" < "$TMPDIR/expected_split.bed" < "test_data/expected_ignoreD_du.bed" < "$TMPDIR/expected_ignoreD_du.bed" < /dev/null echo "> Run bedtools_genomecov on BED file" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_default.bed" +assert_identical_content "output.bed" "../expected_default.bed" echo "- test1 succeeded -" -cd .. +popd > /dev/null # Test 2: ibam option -mkdir test2 -cd test2 +mkdir "$TMPDIR/test2" && pushd "$TMPDIR/test2" > /dev/null echo "> Run bedtools_genomecov on BAM file with -ibam" "$meta_executable" \ @@ -140,95 +142,90 @@ echo "> Run bedtools_genomecov on BAM file with -ibam" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_ibam.bed" +assert_identical_content "output.bed" "../expected_ibam.bed" echo "- test2 succeeded -" -cd .. +popd > /dev/null # Test 3: depth option -mkdir test3 -cd test3 +mkdir "$TMPDIR/test3" && pushd "$TMPDIR/test3" > /dev/null echo "> Run bedtools_genomecov on BED file with -dz" "$meta_executable" \ - --input "../test_data/example_dz.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example_dz.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --depth_zero # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_dz.bed" +assert_identical_content "output.bed" "../expected_dz.bed" echo "- test3 succeeded -" -cd .. +popd > /dev/null # Test 4: strand option -mkdir test4 -cd test4 +mkdir "$TMPDIR/test4" && pushd "$TMPDIR/test4" > /dev/null echo "> Run bedtools_genomecov on BED file with -strand" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --strand "-" \ # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_strand.bed" +assert_identical_content "output.bed" "../expected_strand.bed" echo "- test4 succeeded -" -cd .. +popd > /dev/null # Test 5: 5' end option -mkdir test5 -cd test5 +mkdir "$TMPDIR/test5" && pushd "$TMPDIR/test5" > /dev/null echo "> Run bedtools_genomecov on BED file with -5" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --five_prime \ # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_5.bed" +assert_identical_content "output.bed" "../expected_5.bed" echo "- test5 succeeded -" -cd .. +popd > /dev/null # Test 6: max option -mkdir test6 -cd test6 +mkdir "$TMPDIR/test6" && pushd "$TMPDIR/test6" > /dev/null echo "> Run bedtools_genomecov on BED file with -max" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --max 100 \ # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_default.bed" +assert_identical_content "output.bed" "../expected_default.bed" echo "- test6 succeeded -" -cd .. +popd > /dev/null # Test 7: bedgraph and scale option -mkdir test7 -cd test7 +mkdir "$TMPDIR/test7" && pushd "$TMPDIR/test7" > /dev/null echo "> Run bedtools_genomecov on BED file with -bg and -scale" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --bed_graph \ --scale 100 \ @@ -236,19 +233,18 @@ echo "> Run bedtools_genomecov on BED file with -bg and -scale" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_bg_scale.bed" +assert_identical_content "output.bed" "../expected_bg_scale.bed" echo "- test7 succeeded -" -cd .. +popd > /dev/null # Test 8: trackopts option -mkdir test8 -cd test8 +mkdir "$TMPDIR/test8" && pushd "$TMPDIR/test8" > /dev/null echo "> Run bedtools_genomecov on BED file with -bg and -trackopts" "$meta_executable" \ - --input "../test_data/example.bed" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed" \ + --genome "../genome.txt" \ --output "output.bed" \ --bed_graph \ --trackopts "name=example" \ @@ -256,14 +252,13 @@ echo "> Run bedtools_genomecov on BED file with -bg and -trackopts" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_trackopts.bed" +assert_identical_content "output.bed" "../expected_trackopts.bed" echo "- test8 succeeded -" -cd .. +popd > /dev/null # Test 9: ibam pc options -mkdir test9 -cd test9 +mkdir "$TMPDIR/test9" && pushd "$TMPDIR/test9" > /dev/null echo "> Run bedtools_genomecov on BAM file with -ibam, -pc" "$meta_executable" \ @@ -275,14 +270,13 @@ echo "> Run bedtools_genomecov on BAM file with -ibam, -pc" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_ibam_pc.bed" +assert_identical_content "output.bed" "../expected_ibam_pc.bed" echo "- test9 succeeded -" -cd .. +popd > /dev/null # Test 10: ibam fs options -mkdir test10 -cd test10 +mkdir "$TMPDIR/test10" && pushd "$TMPDIR/test10" > /dev/null echo "> Run bedtools_genomecov on BAM file with -ibam, -fs" "$meta_executable" \ @@ -293,33 +287,31 @@ echo "> Run bedtools_genomecov on BAM file with -ibam, -fs" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_ibam_fs.bed" +assert_identical_content "output.bed" "../expected_ibam_fs.bed" echo "- test10 succeeded -" -cd .. +popd > /dev/null # Test 11: split -mkdir test11 -cd test11 +mkdir "$TMPDIR/test11" && pushd "$TMPDIR/test11" > /dev/null echo "> Run bedtools_genomecov on BED12 file with -split" "$meta_executable" \ - --input "../test_data/example.bed12" \ - --genome "../test_data/genome.txt" \ + --input "../example.bed12" \ + --genome "../genome.txt" \ --output "output.bed" \ --split \ # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_split.bed" +assert_identical_content "output.bed" "../expected_split.bed" echo "- test11 succeeded -" -cd .. +popd > /dev/null # Test 12: ignore deletion and du -mkdir test12 -cd test12 +mkdir "$TMPDIR/test12" && pushd "$TMPDIR/test12" > /dev/null echo "> Run bedtools_genomecov on BAM file with -ignoreD and -du" "$meta_executable" \ @@ -331,10 +323,10 @@ echo "> Run bedtools_genomecov on BAM file with -ignoreD and -du" # checks assert_file_exists "output.bed" assert_file_not_empty "output.bed" -assert_identical_content "output.bed" "../test_data/expected_ignoreD_du.bed" +assert_identical_content "output.bed" "../expected_ignoreD_du.bed" echo "- test12 succeeded -" -cd .. +popd > /dev/null echo "---- All tests succeeded! ----" exit 0