From 569725a8aeafd0a908ce19c493fa894d2a0a9abe Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:07:18 -0800 Subject: [PATCH 1/6] add edge case test --- tests/integration_tests_run.sh | 2 +- .../scripts/no_edits_edge_case_test.sh | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/strandedness_tests/scripts/no_edits_edge_case_test.sh diff --git a/tests/integration_tests_run.sh b/tests/integration_tests_run.sh index 3d10906..40e1bd5 100755 --- a/tests/integration_tests_run.sh +++ b/tests/integration_tests_run.sh @@ -13,7 +13,7 @@ tests_folder="strandedness_tests/" echo "Bulk tests scripts" ls -lh $MARINE/tests/$tests_folder/scripts/ -for t in "F1R2_pair_test-single_end_mode_sailor" "F1R2_pair_test-single_end_mode" "F1R2_pair_test" "F2R1_end_second_in_pair_test" "same_pos_dif_reads_test" "tax1bp3_chr17_3665556_read_test" "pair_test" "unstranded_pair_test" +for t in "no_edits_edge_case" "F1R2_pair_test-single_end_mode_sailor" "F1R2_pair_test-single_end_mode" "F1R2_pair_test" "F2R1_end_second_in_pair_test" "same_pos_dif_reads_test" "tax1bp3_chr17_3665556_read_test" "pair_test" "unstranded_pair_test" do echo $t echo "Removing old files..." diff --git a/tests/strandedness_tests/scripts/no_edits_edge_case_test.sh b/tests/strandedness_tests/scripts/no_edits_edge_case_test.sh new file mode 100644 index 0000000..4b219c5 --- /dev/null +++ b/tests/strandedness_tests/scripts/no_edits_edge_case_test.sh @@ -0,0 +1,20 @@ +mypython=$1 + +$mypython $MARINE/marine.py \ +--bam_filepath \ +$MARINE/tests/strandedness_tests/bams/same_pos_dif_reads.bam \ +--annotation_bedfile_path \ +$MARINE/annotations/hg38_gencode.v35.annotation.genes.bed \ +--output_folder \ +$MARINE/tests/strandedness_tests/no_edits_edge_case_test \ +--min_dist_from_end \ +0 \ +--min_base_quality \ +50 \ +--cores \ +16 \ +--paired_end \ +--strandedness 2 \ +--contigs "chr17" \ +--num_intervals_per_contig 16 \ +--keep_intermediate_files \ No newline at end of file From 298f64db14c4b2d8fada3228373522d7728e5640 Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:13:38 -0800 Subject: [PATCH 2/6] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ce1f37..f1c7625 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: - name: Install Mamba run: | - conda install -c conda-forge mamba=1.5.11 -y + conda install -c conda-forge mamba=1.5.12 -y - name: Print conda folder contents run: | @@ -28,7 +28,7 @@ jobs: - name: Create Conda Environment run: | - /usr/share/miniconda/bin/mamba create -n marine_environment python=3.8.18 -y + /usr/share/miniconda/bin/mamba create -n marine_environment python=3.10 -y /usr/share/miniconda/bin/mamba env update -n marine_environment --file marine_environment2.yaml - name: Print marine_environment bin folder contents From 23567e578a7a56ecea35c3663ea43879e7ea7a80 Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:23:48 -0800 Subject: [PATCH 3/6] working failing test --- tests/integration_tests_run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests_run.sh b/tests/integration_tests_run.sh index 40e1bd5..705eaea 100755 --- a/tests/integration_tests_run.sh +++ b/tests/integration_tests_run.sh @@ -13,7 +13,7 @@ tests_folder="strandedness_tests/" echo "Bulk tests scripts" ls -lh $MARINE/tests/$tests_folder/scripts/ -for t in "no_edits_edge_case" "F1R2_pair_test-single_end_mode_sailor" "F1R2_pair_test-single_end_mode" "F1R2_pair_test" "F2R1_end_second_in_pair_test" "same_pos_dif_reads_test" "tax1bp3_chr17_3665556_read_test" "pair_test" "unstranded_pair_test" +for t in "no_edits_edge_case_test" "F1R2_pair_test-single_end_mode_sailor" "F1R2_pair_test-single_end_mode" "F1R2_pair_test" "F2R1_end_second_in_pair_test" "same_pos_dif_reads_test" "tax1bp3_chr17_3665556_read_test" "pair_test" "unstranded_pair_test" do echo $t echo "Removing old files..." From 931c9491ba59aa5436fa44d3ce7ee8120b327ed1 Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:37:27 -0800 Subject: [PATCH 4/6] Update integration_tests_run.sh #!/bin/bash set -e # Exit immediately if a command exits with a non-zero status --- tests/integration_tests_run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration_tests_run.sh b/tests/integration_tests_run.sh index 705eaea..52fc6d6 100755 --- a/tests/integration_tests_run.sh +++ b/tests/integration_tests_run.sh @@ -1,3 +1,6 @@ +#!/bin/bash +set -e # Exit immediately if a command exits with a non-zero status + mypython=$1 echo "Python is $mypython" @@ -53,4 +56,4 @@ $mypython $MARINE/tests/integration_tests_auto_check.py tests exitcode=$? echo "Exit code: $exitcode" -exit $exitcode \ No newline at end of file +exit $exitcode From 4f8af2800a6f3d936ead7c02581001f3a4979bb1 Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:44:30 -0800 Subject: [PATCH 5/6] Update integration_tests_run.sh Dont exit if rm fails --- tests/integration_tests_run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests_run.sh b/tests/integration_tests_run.sh index 52fc6d6..0a69c96 100755 --- a/tests/integration_tests_run.sh +++ b/tests/integration_tests_run.sh @@ -20,7 +20,7 @@ for t in "no_edits_edge_case_test" "F1R2_pair_test-single_end_mode_sailor" "F1R2 do echo $t echo "Removing old files..." - rm $MARINE/tests/$tests_folder$t/* -r + rm $MARINE/tests/$tests_folder$t/* -r || true echo "Running tests..." bash $MARINE/tests/$tests_folder/scripts/$t.sh $mypython @@ -42,7 +42,7 @@ for t in "only_5_cells_test" "only_5_cells_bulk_mode_test" "only_5_cells_all_cel do echo $t echo "Removing old files..." - rm $MARINE/tests/$tests_folder$t/* -r + rm $MARINE/tests/$tests_folder$t/* -r || true echo "Running tests..." bash $MARINE/tests/$tests_folder/scripts/$t.sh $mypython From d91c4a52ff98680ff28999d7485e321a3942bcb3 Mon Sep 17 00:00:00 2001 From: Eric Kofman Date: Mon, 3 Feb 2025 11:55:21 -0800 Subject: [PATCH 6/6] fix zero edits edge case --- src/utils.py | 4 +++- tests/integration_tests_auto_check.py | 7 ++++++- tests/integration_tests_run.sh | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils.py b/src/utils.py index 1a7346d..b3177ec 100644 --- a/src/utils.py +++ b/src/utils.py @@ -14,6 +14,7 @@ from multiprocessing import Pool import multiprocessing import time +import tracemalloc import anndata as ad import scanpy as sc from scipy.sparse import csr_matrix @@ -1439,7 +1440,8 @@ def get_edits_with_coverage_df(output_folder, # this will still be true even with no barcode specified, in which case the contig will be _no_barcode # Therefore: replace the contig with the part before the barcode - all_edit_info_unique_position_with_coverage_df['contig'] = all_edit_info_unique_position_with_coverage_df.apply(lambda row: row['contig'].replace('_{}'.format(row['barcode']), ''), axis=1) + if len(all_edit_info_unique_position_with_coverage_df) > 0: + all_edit_info_unique_position_with_coverage_df['contig'] = all_edit_info_unique_position_with_coverage_df.apply(lambda row: row['contig'].replace('_{}'.format(row['barcode']), ''), axis=1) return all_edit_info_unique_position_with_coverage_df diff --git a/tests/integration_tests_auto_check.py b/tests/integration_tests_auto_check.py index 7cb2dc8..444b7c6 100755 --- a/tests/integration_tests_auto_check.py +++ b/tests/integration_tests_auto_check.py @@ -8,7 +8,12 @@ test_name_to_expectations = { -"edge_case_test": { + "no_edits_edge_case_test": { + "folder": "strandedness_tests", + "total_edit_sites": 0, + "expectations": [] + }, + "edge_case_test": { "folder": "singlecell_tests", "total_edit_sites": 2, "expectations": [{ diff --git a/tests/integration_tests_run.sh b/tests/integration_tests_run.sh index 705eaea..3eb5284 100755 --- a/tests/integration_tests_run.sh +++ b/tests/integration_tests_run.sh @@ -1,3 +1,5 @@ +set -e + mypython=$1 echo "Python is $mypython"