Skip to content

Commit

Permalink
Merge branch 'smalton/DOR-756-cherry-pick-demux-segfault' into 'relea…
Browse files Browse the repository at this point in the history
…se-v0.7'

DOR-756: Cherry pick demux segfault fix to 0.7 branch

See merge request machine-learning/dorado!1072
  • Loading branch information
malton-ont committed Jun 12, 2024
2 parents c670201 + 8a41fc8 commit 3621800
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ test:macos:x64:
BATCH: 0
MODEL_SPEED: hac
MODEL_VERSION: v4.2.0
timeout: 1h 30m

# Test that you can run dorado in a clean cuda 20.04 environment
test_archive:linux:x86:20.04_nvidia:
Expand Down
19 changes: 14 additions & 5 deletions dorado/demux/AdapterDetector.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "AdapterDetector.h"

#include "parse_custom_sequences.h"
#include "utils/alignment_utils.h"
#include "utils/parse_custom_kit.h"
#include "utils/sequence_utils.h"
#include "utils/types.h"
Expand All @@ -27,7 +26,7 @@ const int PRIMER_TRIM_LENGTH = 150;
EdlibAlignConfig init_edlib_config_for_adapters() {
EdlibAlignConfig placement_config = edlibDefaultAlignConfig();
placement_config.mode = EDLIB_MODE_HW;
placement_config.task = EDLIB_TASK_PATH;
placement_config.task = EDLIB_TASK_LOC;
// Currently none of our adapters or primers have Ns, but we should support them.
static const EdlibEqualityPair additionalEqualities[4] = {
{'N', 'A'}, {'N', 'T'}, {'N', 'C'}, {'N', 'G'}};
Expand Down Expand Up @@ -122,8 +121,13 @@ const std::vector<AdapterDetector::Query>& AdapterDetector::get_primer_sequences
static SingleEndResult copy_results(const EdlibAlignResult& source,
const std::string& name,
size_t length) {
SingleEndResult dest;
SingleEndResult dest{};
dest.name = name;

if (source.status != EDLIB_STATUS_OK || !source.startLocations || !source.endLocations) {
return dest;
}

dest.score = 1.0f - float(source.editDistance) / length;
dest.position = {source.startLocations[0], source.endLocations[0]};
return dest;
Expand Down Expand Up @@ -219,8 +223,13 @@ AdapterScoreResult AdapterDetector::detect(const std::string& seq,
}
}
}
result.front = front_results[best_front];
result.rear = rear_results[best_rear];

if (best_front != -1) {
result.front = front_results[best_front];
}
if (best_rear != -1) {
result.rear = rear_results[best_rear];
}
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions dorado/demux/Trimmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ std::pair<int, int> Trimmer::determine_trim_interval(const BarcodeScoreResult& r
// window.
if (trim_interval.second <= trim_interval.first) {
if (res.use_top) {
return {res.top_barcode_pos.second, seqlen};
trim_interval = {res.top_barcode_pos.second, seqlen};
} else {
return {0, res.bottom_barcode_pos.first};
trim_interval = {0, res.bottom_barcode_pos.first};
}
}
} else {
Expand Down
Binary file added tests/data/pod5/degenerate/overtrim.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/overtrim.pod5 -b ${batch} --skip-model-compatibility-check --kit-name EXP-NBD196 > $output_dir/error_condition.fq

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

Expand Down

0 comments on commit 3621800

Please sign in to comment.