Skip to content

Commit

Permalink
Merge branch 'DOR-736_short_read_crashfix' into 'master'
Browse files Browse the repository at this point in the history
DOR-736 Add handling for very short reads that are entirely trimmed by the ScalerNode

Closes DOR-736

See merge request machine-learning/dorado!1047
  • Loading branch information
MarkBicknellONT committed Jun 3, 2024
2 parents f9beb39 + 1d389d0 commit b531918
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dorado/read_pipeline/ScalerNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ 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 &&
size_t(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 +242,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 (size_t(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 b531918

Please sign in to comment.