Skip to content

Commit

Permalink
better fix for COMBINE-lab/simpleaf#99
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Aug 11, 2023
1 parent 9f134b4 commit f948511
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
23 changes: 20 additions & 3 deletions include/query/streaming_query_canonical_parsing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,21 @@ struct streaming_query_canonical_parsing {
inline void start() { m_start = true; }

inline void reset_state() {
// reset all of the relevant state
m_minimizer_not_found = false;
m_prev_query_offset = std::numeric_limits<int32_t>::lowest();
start();
m_curr_minimizer = constants::invalid_uint64;
m_prev_minimizer = constants::invalid_uint64;
m_kmer = constants::invalid_uint64;
start();

m_string_iterator.at(0);
m_begin = 0;
m_end = 0;
m_pos_in_window = 0;
m_window_size = 0;

m_reverse = false;
m_prev_query_offset = std::numeric_limits<int32_t>::lowest();
}

lookup_result get_contig_pos(const uint64_t km, const uint64_t km_rc,
Expand Down Expand Up @@ -110,11 +119,18 @@ struct streaming_query_canonical_parsing {
lookup_advanced();
} else if (same_minimizer()) {
if (minimizer_found()) {
// NOTE: Technically, I don't believe this additional check
// that we are attempting to extend from a prior search that did
// not result in a hit (i.e. m_res.kmer_id != constants::invalid_uint64)
// is necessary. However, until we can convince oursleves of this reliably
// @jermp, I am going to keep it. If and when we are convinced of this
// we can replace it with the simpler line below.
// if (extends()) {
if ( (m_res.kmer_id != constants::invalid_uint64) and extends() ) {
extend();
} else {
lookup_advanced();
}
}
}
} else {
m_minimizer_not_found = false;
Expand Down Expand Up @@ -288,6 +304,7 @@ struct streaming_query_canonical_parsing {
}
return false;
}

if (m_pos_in_window == m_window_size) return false;
if (m_kmer == m_string_iterator.read(2 * m_k)) {
++m_num_extensions;
Expand Down
24 changes: 13 additions & 11 deletions include/reference_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@ class reference_index {

bool is_member = (qres.kmer_id != sshash::constants::invalid_uint64);

//if (is_member && (qres.contig_id == invalid_u32)) {
// std::cerr << "qres.contig_id = " << qres.contig_id << ", but qres.kmerid = " << qres.kmer_id << "\n";
// std::cerr << "== ANSWER\n";
// std::cerr << "seq = " << kmit.seq() << "\n";
// std::cerr << "read position = " << kmit->second << "\n";
// std::cerr << "kmer_id " << qres.kmer_id << '\n';
// std::cerr << "kmer_id_in_contig " << qres.kmer_id_in_contig << '\n';
// std::cerr << "kmer_orientation " << qres.kmer_orientation << '\n';
// std::cerr << "contig_id " << qres.contig_id << '\n';
// std::cerr << "contig_size " << qres.contig_size << '\n';
//}
/*
if (is_member && (qres.contig_id == invalid_u32)) {
std::cerr << "qres.contig_id = " << qres.contig_id << ", but qres.kmerid = " << qres.kmer_id << "\n";
std::cerr << "== ANSWER\n";
std::cerr << "seq = " << kmit.seq() << "\n";
std::cerr << "read position = " << kmit->second << "\n";
std::cerr << "kmer_id " << qres.kmer_id << '\n';
std::cerr << "kmer_id_in_contig " << qres.kmer_id_in_contig << '\n';
std::cerr << "kmer_orientation " << qres.kmer_orientation << '\n';
std::cerr << "contig_id " << qres.contig_id << '\n';
std::cerr << "contig_size " << qres.contig_size << '\n';
}
*/

if (is_member) {
const auto k = m_dict.k();
Expand Down

0 comments on commit f948511

Please sign in to comment.