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 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 3d10906..0a69c96 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" @@ -13,11 +16,11 @@ 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_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..." - 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 @@ -39,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 @@ -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 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