Skip to content

Commit

Permalink
DOR-736 Add test for handling very short reads that are entirely trim…
Browse files Browse the repository at this point in the history
…med by the ScalerNode and fix the crash they cause.
  • Loading branch information
MarkBicknellONT committed Jun 3, 2024
1 parent f9beb39 commit 03d94f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dorado/read_pipeline/ScalerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void ScalerNode::input_thread_fn() {
int trim_start = 0;
if (is_rna_model) {
trim_start = determine_rna_adapter_pos(*read, m_model_type);
if (m_trim_rna_adapter) {
if (m_trim_rna_adapter && trim_start < read->read_common.get_raw_data_samples()) {
read->read_common.raw_data =
read->read_common.raw_data.index({Slice(trim_start, at::indexing::None)});
read->read_common.rna_adapter_end_signal_pos = 0;
Expand Down Expand Up @@ -241,8 +241,12 @@ void ScalerNode::input_thread_fn() {
utils::DEFAULT_TRIM_MIN_ELEMENTS);
}

read->read_common.raw_data =
read->read_common.raw_data.index({Slice(trim_start, at::indexing::None)});
if (trim_start < read->read_common.get_raw_data_samples()) {
read->read_common.raw_data =
read->read_common.raw_data.index({Slice(trim_start, at::indexing::None)});
} else {
trim_start = 0;
}
}

read->read_common.num_trimmed_samples = trim_start;
Expand Down
Binary file added tests/data/pod5/degenerate/trimming_bomb.pod5
Binary file not shown.
3 changes: 3 additions & 0 deletions tests/test_simple_basecaller_execution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ if $dorado_bin basecaller $model_5k_v43 $data_dir/duplex/pod5 --modified-bases 5
fi
set -e

# Check that dorado handles degenerate reads without crashing
$dorado_bin basecaller $model_5k_v43 $data_dir/pod5/degenerate --skip-model-compatibility-check > $output_dir/error_condition.fq

echo dorado summary test stage
$dorado_bin summary $output_dir/calls.bam

Expand Down

0 comments on commit 03d94f3

Please sign in to comment.