Skip to content

Commit

Permalink
Merge branch 'mm2-v2.27' into 'master'
Browse files Browse the repository at this point in the history
upgrade to minimap2-2.27 (r1193)

See merge request machine-learning/dorado!885
  • Loading branch information
tijyojwad committed Mar 20, 2024
2 parents c0075a0 + 944b54b commit 9b49ae5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dorado/3rdparty/ont-minimap2
9 changes: 6 additions & 3 deletions dorado/alignment/Minimap2Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ bool Minimap2Index::initialise(Minimap2Options options) {
m_mapping_options = std::make_optional<mm_mapopt_t>();

mm_set_opt(0, &m_index_options.value(), &m_mapping_options.value());
// Setting options to map-ont default till relevant args are exposed.
mm_set_opt("map-ont", &m_index_options.value(), &m_mapping_options.value());
if (mm_set_opt(options.mm2_preset.c_str(), &m_index_options.value(),
&m_mapping_options.value()) != 0) {
spdlog::error("Cannot set mm2 options with preset: {}", options.mm2_preset);
return false;
}

set_index_options(options);
set_mapping_options(options);
Expand Down Expand Up @@ -180,4 +183,4 @@ const mm_mapopt_t& Minimap2Index::mapping_options() const {

const Minimap2Options& Minimap2Index::get_options() const { return m_options; }

} // namespace dorado::alignment
} // namespace dorado::alignment
16 changes: 9 additions & 7 deletions dorado/alignment/Minimap2Options.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cstdint>
#include <string>
#include <tuple>

namespace dorado::alignment {
Expand All @@ -9,11 +10,12 @@ struct Minimap2IndexOptions {
short kmer_size;
short window_size;
uint64_t index_batch_size;
std::string mm2_preset;
};

inline bool operator<(const Minimap2IndexOptions& l, const Minimap2IndexOptions& r) {
return std::tie(l.kmer_size, l.window_size, l.index_batch_size) <
std::tie(r.kmer_size, r.window_size, r.index_batch_size);
return std::tie(l.kmer_size, l.window_size, l.index_batch_size, l.mm2_preset) <
std::tie(r.kmer_size, r.window_size, r.index_batch_size, r.mm2_preset);
}

inline bool operator>(const Minimap2IndexOptions& l, const Minimap2IndexOptions& r) {
Expand All @@ -29,8 +31,8 @@ inline bool operator>=(const Minimap2IndexOptions& l, const Minimap2IndexOptions
}

inline bool operator==(const Minimap2IndexOptions& l, const Minimap2IndexOptions& r) {
return std::tie(l.kmer_size, l.window_size, l.index_batch_size) ==
std::tie(r.kmer_size, r.window_size, r.index_batch_size);
return std::tie(l.kmer_size, l.window_size, l.index_batch_size, l.mm2_preset) ==
std::tie(r.kmer_size, r.window_size, r.index_batch_size, r.mm2_preset);
}

inline bool operator!=(const Minimap2IndexOptions& l, const Minimap2IndexOptions& r) {
Expand Down Expand Up @@ -87,7 +89,7 @@ inline bool operator==(const Minimap2Options& l, const Minimap2Options& r) {

inline bool operator!=(const Minimap2Options& l, const Minimap2Options& r) { return !(l == r); }

static constexpr Minimap2Options dflt_options{{15, 10, 16000000000ull},
{5, 500, 20000, false, false, true},
false};
static const Minimap2Options dflt_options{{15, 10, 16000000000ull, "lr:hq"},
{5, 500, 20000, false, false, true},
false};
} // namespace dorado::alignment
7 changes: 7 additions & 0 deletions dorado/cli/cli_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ void add_minimap2_arguments(ArgParser& parser, const Options& dflt) {
"specified as NUM,[NUM]")
.default_value(to_size(dflt.bandwidth) + "," + to_size(dflt.bandwidth_long));

// Setting options to lr:hq which is appropriate for high quality nanopore reads.
parser.visible.add_argument("--mm2-preset")
.help("minimap2 preset for indexing and mapping. Alias for the -x "
"option in minimap2.")
.default_value(dflt.mm2_preset);

parser.hidden.add_argument("--secondary-seq")
.help("minimap2 output seq/qual for secondary and supplementary alignments")
.default_value(false)
Expand Down Expand Up @@ -251,6 +257,7 @@ Options process_minimap2_arguments(const ArgParser& parser, const Options& dflt)
throw std::runtime_error("Wrong number of arguments for option '-r'.");
}
res.soft_clipping = parser.visible.get<bool>("Y");
res.mm2_preset = parser.visible.get<std::string>("mm2-preset");
res.secondary_seq = parser.hidden.get<bool>("secondary-seq");
res.print_aln_seq = parser.hidden.get<bool>("print-aln-seq");
return res;
Expand Down

0 comments on commit 9b49ae5

Please sign in to comment.