Skip to content

Commit

Permalink
adding some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaspe committed Aug 6, 2024
1 parent 3f8a45f commit cdeb8e6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/bedtools/bedtools_groupby/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ argument_groups:
E.g., "-c 5,4,6 -o sum,mean,count" will give the sum of column 5,
the mean of column 4, and the count of column 6.
The order of output columns will match the ordering given in the command.
required: true
- name: --full
type: boolean_true
Expand Down
2 changes: 1 addition & 1 deletion src/bedtools/bedtools_groupby/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ bedtools groupby \
-i "$par_input" \
-g "$par_groupby" \
-c "$par_column" \
-o "$par_operation" \
${par_operation:+-o "$par_operation"} \
> "$par_output"

69 changes: 61 additions & 8 deletions src/bedtools/bedtools_groupby/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,81 @@ assert_identical_content() {
echo "Creating Test Data..."
mkdir -p test_data

# Create and populate featuresA.bed
# Create and populate example.bed
cat << EOF > test_data/example.bed
# Header
chr21 9719758 9729320 variant1 chr21 9719768 9721892 ALR/Alpha 1004 +
chr21 9719758 9729320 variant1 chr21 9721905 9725582 ALR/Alpha 1010 +
chr21 9719758 9729320 variant1 chr21 9725582 9725977 L1PA3 3288 +
chr21 9719758 9729320 variant1 chr21 9726021 9729309 ALR/Alpha 1051 +
chr21 9729310 9757478 variant2 chr21 9729320 9729809 L1PA3 3897 -
chr21 9729310 9757478 variant2 chr21 9729809 9730866 L1P1 8367 +
chr21 9729310 9757478 variant2 chr21 9730866 9734026 ALR/Alpha 1036 -
chr21 9729310 9757478 variant2 chr21 9734037 9757471 ALR/Alpha 1182 -
chr21 9795588 9796685 variant3 chr21 9795589 9795713 (GAATG)n 308 +
chr21 9795588 9796685 variant3 chr21 9795736 9795894 (GAATG)n 683 +
chr21 9795588 9796685 variant3 chr21 9795911 9796007 (GAATG)n 345 +
chr21 9795588 9796685 variant3 chr21 9796028 9796187 (GAATG)n 756 +
chr21 9795588 9796685 variant3 chr21 9796202 9796615 (GAATG)n 891 +
chr21 9795588 9796685 variant3 chr21 9796637 9796824 (GAATG)n 621 +
EOF

# Create and populate expected output files for different tests
cat << EOF > test_data/expected.bed
chr21 9719758 9729320 6353
chr21 9729310 9757478 14482
chr21 9795588 9796685 3604
EOF
cat << EOF > test_data/expected_max.bed
chr21 9719758 9729320 variant1 3288
chr21 9729310 9757478 variant2 8367
chr21 9795588 9796685 variant3 891
EOF

# Test 1: Default intersect
# Test 1: without operation option, default operation is sum
mkdir test1
cd test1

# echo "> Run bedtools_intersect on BED files with default intersect"
# "$meta_executable" \
# --input_a "../test_data/featuresA.bed" \
# --input_b "../test_data/featuresB.bed" \
# --output "output.bed"
echo "> Run bedtools groupby on BED file"
"$meta_executable" \
--input "../test_data/example.bed" \
--groupby "1,2,3" \
--column "9" \
--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" "../test_data/expected.bed"
echo "- test1 succeeded -"

cd ..

# Test 2: with operation option
mkdir test2
cd test2

echo "> Run bedtools groupby on BED file with max operation"
"$meta_executable" \
--input "../test_data/example.bed" \
--groupby "1-4" \
--column "9" \
--operation "max" \
--output "output.bed"

# checks
assert_file_exists "output.bed"
assert_file_not_empty "output.bed"
assert_identical_content "output.bed" "../test_data/expected_max.bed"
echo "- test2 succeeded -"

cd ..

# Test 3:






echo "---- All tests succeeded! ----"
Expand Down
15 changes: 15 additions & 0 deletions src/bedtools/bedtools_groupby/test_data/example.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Header
chr21 9719758 9729320 variant1 chr21 9719768 9721892 ALR/Alpha 1004 +
chr21 9719758 9729320 variant1 chr21 9721905 9725582 ALR/Alpha 1010 +
chr21 9719758 9729320 variant1 chr21 9725582 9725977 L1PA3 3288 +
chr21 9719758 9729320 variant1 chr21 9726021 9729309 ALR/Alpha 1051 +
chr21 9729310 9757478 variant2 chr21 9729320 9729809 L1PA3 3897 -
chr21 9729310 9757478 variant2 chr21 9729809 9730866 L1P1 8367 +
chr21 9729310 9757478 variant2 chr21 9730866 9734026 ALR/Alpha 1036 -
chr21 9729310 9757478 variant2 chr21 9734037 9757471 ALR/Alpha 1182 -
chr21 9795588 9796685 variant3 chr21 9795589 9795713 (GAATG)n 308 +
chr21 9795588 9796685 variant3 chr21 9795736 9795894 (GAATG)n 683 +
chr21 9795588 9796685 variant3 chr21 9795911 9796007 (GAATG)n 345 +
chr21 9795588 9796685 variant3 chr21 9796028 9796187 (GAATG)n 756 +
chr21 9795588 9796685 variant3 chr21 9796202 9796615 (GAATG)n 891 +
chr21 9795588 9796685 variant3 chr21 9796637 9796824 (GAATG)n 621 +
3 changes: 3 additions & 0 deletions src/bedtools/bedtools_groupby/test_data/expected.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chr21 9719758 9729320 6353
chr21 9729310 9757478 14482
chr21 9795588 9796685 3604

0 comments on commit cdeb8e6

Please sign in to comment.