Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2437,14 +2437,12 @@ int8_t* AlignerClient::parse_matrix(istream& matrix_stream) {
crash_unless(matrix != nullptr);
for (size_t i = 0; i < 16; i++) {
if (!matrix_stream.good()) {
std::cerr << "error: vg Aligner::parse_matrix requires a 4x4 whitespace separated integer matrix\n";
throw "";
throw std::domain_error("error: vg Aligner::parse_matrix requires a 4x4 whitespace separated integer matrix");
}
int score;
matrix_stream >> score;
if (score > 127 || score < -127) {
std::cerr << "error: vg Aligner::parse_matrix requires values in the range [-127,127]\n";
throw "";
throw std::domain_error("error: vg Aligner::parse_matrix requires values in the range [-127,127]");
}
matrix[i] = score;
}
Expand Down
2 changes: 1 addition & 1 deletion src/banded_global_aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ BandedGlobalAligner<IntType>::AltTracebackStack::Deflection::Deflection(const in
}

template <class IntType>
BandedGlobalAligner<IntType>::AltTracebackStack::Deflection::~Deflection() {
BandedGlobalAligner<IntType>::AltTracebackStack::Deflection::~Deflection() noexcept {
// nothing to do
}

Expand Down
2 changes: 1 addition & 1 deletion src/banded_global_aligner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace vg {
public:
Deflection(const int64_t from_node_id, const int64_t row_idx, const int64_t col_idx,
const int64_t to_node_id, const matrix_t to_matrix);
~Deflection();
~Deflection() noexcept;

/// Node ID where deflection occurs
const int64_t from_node_id;
Expand Down
6 changes: 5 additions & 1 deletion src/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ BenchmarkResult run_benchmark(const string& name, size_t iterations, const funct
test_samples.push_back(chrono::duration_cast<benchtime>(test_stop - test_start).count());
control_samples.push_back(chrono::duration_cast<benchtime>(control_stop - control_start).count());
}


if (iterations == 0) {
return to_return;
}

// Calculate the moments with magic numeric algorithms
// See <https://stackoverflow.com/a/7616783>

Expand Down
14 changes: 8 additions & 6 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,9 +2672,9 @@ int64_t TipAnchoredMaxDistance::operator()(const pos_t& pos_1, const pos_t& pos_
}

TargetValueSearch::TargetValueSearch(const HandleGraph& handle_graph,
DistanceHeuristic* upper_bound_heuristic,
DistanceHeuristic* lower_bound_heuristic) :
handle_graph(handle_graph), upper_bound_heuristic(upper_bound_heuristic), lower_bound_heuristic(lower_bound_heuristic) {
std::unique_ptr<DistanceHeuristic> upper_bound_heuristic,
std::unique_ptr<DistanceHeuristic> lower_bound_heuristic) :
handle_graph(handle_graph), upper_bound_heuristic(std::move(upper_bound_heuristic)), lower_bound_heuristic(std::move(lower_bound_heuristic)) {
// nothing else to do
}

Expand Down Expand Up @@ -3164,8 +3164,10 @@ int64_t TargetValueSearch::tv_path_length(const pos_t& pos_1, const pos_t& pos_2
}

TVSClusterer::TVSClusterer(const HandleGraph* handle_graph, SnarlDistanceIndex* distance_index) :
tvs(*handle_graph, new TipAnchoredMaxDistance(*distance_index), new SnarlMinDistance(*distance_index)) {

tvs(*handle_graph,
std::make_unique<TipAnchoredMaxDistance>(*distance_index),
std::make_unique<SnarlMinDistance>(*distance_index)) {

// nothing else to do
}

Expand Down Expand Up @@ -3819,7 +3821,7 @@ vector<pair<gcsa::node_type, size_t> > mem_node_start_positions(const HandleGrap
}
}
}
next = todo;
next = std::move(todo);
}
// ensure positions are sorted by remainder
std::sort(positions.begin(), positions.end(),
Expand Down
4 changes: 2 additions & 2 deletions src/cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ class TargetValueSearch {
public:
TargetValueSearch() = delete;
TargetValueSearch(const HandleGraph& handle_graph,
DistanceHeuristic* upper_bound_heuristic,
DistanceHeuristic* lower_bound_heuristic);
std::unique_ptr<DistanceHeuristic> upper_bound_heuristic,
std::unique_ptr<DistanceHeuristic> lower_bound_heuristic);
~TargetValueSearch() = default;

/// Does a path exist from pos_1 to pos_2 with length within the tolerance from the target value?
Expand Down
8 changes: 4 additions & 4 deletions src/dozeu_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ class XdropAligner : public DozeuInterface {
/// Copy assignment
XdropAligner& operator=(const XdropAligner& other);
/// Move constructor
XdropAligner(XdropAligner&& other);
XdropAligner(XdropAligner&& other) noexcept;
/// Move assignment
XdropAligner& operator=(XdropAligner&& other);
XdropAligner& operator=(XdropAligner&& other) noexcept;
};

/*
Expand Down Expand Up @@ -337,9 +337,9 @@ class QualAdjXdropAligner : public DozeuInterface {
/// Copy assignment
QualAdjXdropAligner& operator=(const QualAdjXdropAligner& other);
/// Move constructor
QualAdjXdropAligner(QualAdjXdropAligner&& other);
QualAdjXdropAligner(QualAdjXdropAligner&& other) noexcept;
/// Move assignment
QualAdjXdropAligner& operator=(QualAdjXdropAligner&& other);
QualAdjXdropAligner& operator=(QualAdjXdropAligner&& other) noexcept;
};

} // end of namespace vg
Expand Down
6 changes: 5 additions & 1 deletion src/explainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@
if (!explaining()) {
return;
}
write_connected_components();
try {
write_connected_components();
} catch (...) {

Check warning on line 302 in src/explainer.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Handle this exception or don't catch it at all.

See more on https://sonarcloud.io/project/issues?id=electricEpilith_vg&issues=AZ1SXPQT-tMJpjjASatU&open=AZ1SXPQT-tMJpjjASatU&pullRequest=5
// Cannot propagate exceptions from destructor
}
}

void DiagramExplainer::add_globals(const annotation_t& annotations) {
Expand Down
5 changes: 4 additions & 1 deletion src/gbwt_extender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,9 @@ struct WFANode {
// Points on the wavefronts are indexed by score, diagonal.
std::array<hash_map<WFAPoint::key_type, WFAPoint::value_type>, 3> wavefronts;

WFANode(WFANode&&) noexcept = default;
WFANode& operator=(WFANode&&) noexcept = default;

WFANode(const gbwtgraph::CachedGBWTGraph& graph, const gbwt::SearchState& state, pos_t target, std::uint32_t parent) :
parent(parent), target_offset(std::numeric_limits<std::uint32_t>::max()), dead_end(false)
{
Expand Down Expand Up @@ -1625,7 +1628,7 @@ class WFATree {
gbwt::SearchState state = this->graph.get_state(handle);
WFANode root(this->graph, state, this->to, 0);
root.update(WFANode::MATCHES, 0, 0, 0, offset(this->from) + 1);
this->nodes.push_back(root);
this->nodes.push_back(std::move(root));

// Determine score bound based on the error model and sequence length.
std::int32_t max_mismatches = error_model.mismatches.evaluate(sequence.length());
Expand Down
24 changes: 20 additions & 4 deletions src/hash_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ class hash_map : public google::dense_hash_map<K, V, wang_hash<K>>
class hash_map : public spp::sparse_hash_map<K, V, wang_hash<K>>
#endif
{
#ifdef USE_DENSE_HASH
public:
hash_map(hash_map&&) noexcept = default;
hash_map& operator=(hash_map&&) noexcept = default;
#ifdef USE_DENSE_HASH
hash_map() {
this->set_empty_key(-1);
}
#else
hash_map() = default;
#endif
};

Expand All @@ -163,11 +167,15 @@ class pair_hash_map : public google::dense_hash_map<K, V, wang_hash<K>>
class pair_hash_map : public spp::sparse_hash_map<K, V, wang_hash<K>>
#endif
{
#ifdef USE_DENSE_HASH
public:
pair_hash_map(pair_hash_map&&) noexcept = default;
pair_hash_map& operator=(pair_hash_map&&) noexcept = default;
#ifdef USE_DENSE_HASH
pair_hash_map() {
this->set_empty_key(K(-1, -1));
}
#else
pair_hash_map() = default;
#endif
};

Expand Down Expand Up @@ -196,11 +204,15 @@ class hash_set : public google::dense_hash_set<K, wang_hash<K>>
class hash_set : public spp::sparse_hash_set<K, wang_hash<K>>
#endif
{
#ifdef USE_DENSE_HASH
public:
hash_set(hash_set&&) noexcept = default;
hash_set& operator=(hash_set&&) noexcept = default;
#ifdef USE_DENSE_HASH
hash_set() {
this->set_empty_key(-1);
}
#else
hash_set() = default;
#endif
};

Expand All @@ -226,11 +238,15 @@ class pair_hash_set : public google::dense_hash_set<K, wang_hash<K>>
class pair_hash_set : public spp::sparse_hash_set<K, wang_hash<K>>
#endif
{
#ifdef USE_DENSE_HASH
public:
pair_hash_set(pair_hash_set&&) noexcept = default;
pair_hash_set& operator=(pair_hash_set&&) noexcept = default;
#ifdef USE_DENSE_HASH
pair_hash_set() {
this->set_empty_key(K(-1, -1));
}
#else
pair_hash_set() = default;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion src/hts_alignment_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ HTSWriter::~HTSWriter() {

for (size_t thread_number = 0; thread_number < sam_files.size(); thread_number++) {
// For each thread, find its samFile*
auto& sam_file = sam_files.at(thread_number);
auto& sam_file = sam_files[thread_number];

if (sam_file != nullptr) {
// Close out all the open samFile*s and flush their data before the
Expand Down
4 changes: 2 additions & 2 deletions src/index_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4832,7 +4832,7 @@ IndexRegistry::~IndexRegistry() {
}
}

IndexRegistry::IndexRegistry(IndexRegistry&& other) :
IndexRegistry::IndexRegistry(IndexRegistry&& other) noexcept :
index_registry(std::move(other.index_registry)),
recipe_registry(std::move(other.recipe_registry)),
registered_suffixes(std::move(other.registered_suffixes)),
Expand All @@ -4844,7 +4844,7 @@ IndexRegistry::IndexRegistry(IndexRegistry&& other) :
other.work_dir.clear();
}

IndexRegistry& IndexRegistry::operator=(IndexRegistry&& other) {
IndexRegistry& IndexRegistry::operator=(IndexRegistry&& other) noexcept {
index_registry = std::move(other.index_registry);
recipe_registry = std::move(other.recipe_registry);
registered_suffixes = std::move(other.registered_suffixes);
Expand Down
4 changes: 2 additions & 2 deletions src/index_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ class IndexRegistry {
IndexRegistry& operator=(const IndexRegistry& other) = delete;

// And we need to be moved carefully
IndexRegistry(IndexRegistry&& other);
IndexRegistry& operator=(IndexRegistry&& other);
IndexRegistry(IndexRegistry&& other) noexcept;
IndexRegistry& operator=(IndexRegistry&& other) noexcept;


/// Prefix for all saved outputs
Expand Down
4 changes: 2 additions & 2 deletions src/mem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class MaximalExactMatch {

MaximalExactMatch(void) = default; // Copy constructor
MaximalExactMatch(const MaximalExactMatch&) = default; // Copy constructor
MaximalExactMatch(MaximalExactMatch&&) = default; // Move constructor
MaximalExactMatch(MaximalExactMatch&&) noexcept = default; // Move constructor
MaximalExactMatch& operator=(const MaximalExactMatch&) & = default; // Copy assignment operator
MaximalExactMatch& operator=(MaximalExactMatch&&) & = default; // Move assignment operator
MaximalExactMatch& operator=(MaximalExactMatch&&) & noexcept = default; // Move assignment operator
//virtual ~MaximalExactMatch() { } // Destructor
};

Expand Down
4 changes: 2 additions & 2 deletions src/minimizer_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,8 +1590,8 @@ void MinimizerMapper::process_until_threshold_e(size_t items, const function<Sco
if (threshold != 0 && get_score(item_num) <= cutoff) {
// Item would fail the score threshold

bool escape = false;
if (unskipped < min_count || (escape = threshold_escape(item_num))) {
bool escape = threshold_escape(item_num);
if (unskipped < min_count || escape) {
// But we need it to make up the minimum number, or the item escapes the
// score threshold.

Expand Down
11 changes: 5 additions & 6 deletions src/multipath_alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace vg {
*this = other;
}

multipath_alignment_t::multipath_alignment_t(multipath_alignment_t&& other) {
multipath_alignment_t::multipath_alignment_t(multipath_alignment_t&& other) noexcept {
*this = std::move(other);
}

Expand Down Expand Up @@ -64,7 +64,7 @@ namespace vg {
return *this;
}

multipath_alignment_t& multipath_alignment_t::operator=(multipath_alignment_t&& other) {
multipath_alignment_t& multipath_alignment_t::operator=(multipath_alignment_t&& other) noexcept {
if (this != &other) {
_sequence = std::move(other._sequence);
_quality = std::move(other._quality);
Expand Down Expand Up @@ -2712,12 +2712,11 @@ namespace vg {
}

bool is_supplementary(const multipath_alignment_t& multipath_aln) {
if (!multipath_aln.has_annotation("supplementary")) {
auto [type, value] = multipath_aln.get_annotation("supplementary");
if (value == nullptr) {
return false;
}
else {
return *((bool*) multipath_aln.get_annotation("supplementary").second);
}
return *((bool*) value);
}

vector<tuple<int64_t, int64_t, int64_t, int64_t>>
Expand Down
4 changes: 2 additions & 2 deletions src/multipath_alignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ namespace vg {
public:
multipath_alignment_t();
multipath_alignment_t(const multipath_alignment_t& other);
multipath_alignment_t(multipath_alignment_t&& other);
multipath_alignment_t(multipath_alignment_t&& other) noexcept;
~multipath_alignment_t();
multipath_alignment_t& operator=(const multipath_alignment_t& other);
multipath_alignment_t& operator=(multipath_alignment_t&& other);
multipath_alignment_t& operator=(multipath_alignment_t&& other) noexcept;
inline const string& sequence() const;
inline string* mutable_sequence();
inline void set_sequence(const string& s);
Expand Down
2 changes: 2 additions & 0 deletions src/packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ size_t Packer::node_quality_vector_size(void) const {
}

pair<size_t, size_t> Packer::coverage_bin_offset(size_t i) const {
if (cov_bin_size == 0) return {0, i};
size_t bin = min((size_t)(i / cov_bin_size), (size_t)(coverage_dynamic.size() - 1));
// last bin can have different size so we don't use mod
size_t offset = i - bin * cov_bin_size;
Expand All @@ -693,6 +694,7 @@ pair<size_t, size_t> Packer::edge_coverage_bin_offset(size_t i) const {
}

pair<size_t, size_t> Packer::node_quality_bin_offset(size_t i) const {
if (node_qual_bin_size == 0) return {0, i};
size_t bin = min((size_t)(i / node_qual_bin_size), (size_t)(node_quality_dynamic.size() - 1));
// last bin can have different size so we don't use mod
size_t offset = i - bin * node_qual_bin_size;
Expand Down
4 changes: 2 additions & 2 deletions src/qual_adj_xdrop_aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ QualAdjXdropAligner& QualAdjXdropAligner::operator=(const QualAdjXdropAligner& o
return *this;
}

QualAdjXdropAligner::QualAdjXdropAligner(QualAdjXdropAligner&& other)
QualAdjXdropAligner::QualAdjXdropAligner(QualAdjXdropAligner&& other) noexcept
{
*this = other;
}

QualAdjXdropAligner& QualAdjXdropAligner::operator=(QualAdjXdropAligner&& other)
QualAdjXdropAligner& QualAdjXdropAligner::operator=(QualAdjXdropAligner&& other) noexcept
{
if (this != &other) {
if (dz) {
Expand Down
4 changes: 4 additions & 0 deletions src/recombinator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ class Haplotypes {
/// Sequence `i` contains kmer `j` if and only if `kmers_present[i * kmers.size() + j] == 1`.
sdsl::bit_vector kmers_present;

Subchain() = default;
Subchain(Subchain&&) noexcept = default;
Subchain& operator=(Subchain&&) noexcept = default;

/// Returns the start node as a GBWTGraph handle.
handle_t start_handle() const { return gbwtgraph::GBWTGraph::node_to_handle(this->start); }

Expand Down
4 changes: 2 additions & 2 deletions src/small_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SmallBitset {
this->copy(another);
}

SmallBitset(SmallBitset&& another) {
SmallBitset(SmallBitset&& another) noexcept {
this->move(another);
}

Expand All @@ -46,7 +46,7 @@ class SmallBitset {
return *this;
}

SmallBitset& operator=(SmallBitset&& another) {
SmallBitset& operator=(SmallBitset&& another) noexcept {
if (&another != this) {
this->clear();
this->move(another);
Expand Down
Loading