Skip to content

Commit

Permalink
changed default comment formatting to one space after //
Browse files Browse the repository at this point in the history
  • Loading branch information
muellan committed Mar 11, 2024
1 parent bfbdda5 commit 54790ef
Show file tree
Hide file tree
Showing 43 changed files with 358 additions and 355 deletions.
30 changes: 15 additions & 15 deletions src/alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,43 +195,43 @@ align_semi_global(const QuerySequence& query,
typename SubjectSequence::value_type>::value,
"query and subject value type must be identical");

//datatypes from scoring scheme
// datatypes from scoring scheme
using value_t = typename QuerySequence::value_type;
using index_t = typename QuerySequence::size_type;
using score_t = typename ScoringScheme::score_type;
using predc_t = typename ScoringScheme::predecessor;

//get lengths from sequence containers
// get lengths from sequence containers
const index_t len_q = query.size();
const index_t len_s = subject.size();

//quadratic memory solution for relaxing and backtracking
// quadratic memory solution for relaxing and backtracking
std::vector<score_t> score((len_q+1)*(len_s+1), 0);
std::vector<predc_t> predc((len_q+1)*(len_s+1), predc_t(0));

for (index_t q = 1; q < len_q+1; q++) {

//cache the query at position q
// cache the query at position q
const auto vquery = query[q-1];

for (index_t s = 1; s < len_s+1; s++) {
//cache the subject at position s
// cache the subject at position s
auto vsubject = subject[s-1];
//cache diagonal, above and left entry of score matrix
// cache diagonal, above and left entry of score matrix
score_t diag = score[(q-1)*(len_s+1)+(s-1)];
score_t above = score[(q-1)*(len_s+1)+(s-0)];
score_t left = score[(q-0)*(len_s+1)+(s-1)];

//relax ingoing edges
// relax ingoing edges
auto argmax = scoring.relax(diag, above, left, vsubject, vquery);

//update current node
// update current node
score[q*(len_s+1)+s] = argmax.score;
predc[q*(len_s+1)+s] = argmax.predc;
}
}

//searching the best score
// searching the best score
auto bsf_q = len_q;
auto bsfS = len_s;
auto bsf_v = score[len_q*(len_s+1)+len_s];
Expand All @@ -254,26 +254,26 @@ align_semi_global(const QuerySequence& query,
}
}

//construct the alignment
// construct the alignment
auto res = alignment<score_t,value_t>{};
res.score = bsf_v;

if (mode == alignment_mode::backtrace) {
auto pred = predc[bsf_q*(len_s+1)+bsfS];
//backtracing predecessor information
// backtracing predecessor information
do {
//caution, encode changes the values of bsf_q and bsfS
// caution, encode changes the values of bsf_q and bsfS
auto symbol = scoring.encode(bsf_q, bsfS, pred, query, subject);

//write down the aligment
// write down the aligment
res.query.push_back(std::get<0>(symbol));
res.subject.push_back(std::get<1>(symbol));

//update pred
// update pred
pred = predc[bsf_q*(len_s+1)+bsfS];
} while (bool(pred));

//reverse the alignment
// reverse the alignment
std::reverse(res.query.begin(), res.query.end());
std::reverse(res.subject.begin(), res.subject.end());
}
Expand Down
22 changes: 11 additions & 11 deletions src/building.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void rank_targets_with_mapping_file(taxonomy_cache& taxonomy,
}

bool showProgress = showInfo && fsize > 100000000;
//accession2taxid files have 40-450M lines
//update progress indicator every 1M lines
// accession2taxid files have 40-450M lines
// update progress indicator every 1M lines
size_t step = 0;
size_t statStep = 1UL << 20;
if (showProgress) show_progress_indicator(cout, 0);
Expand All @@ -94,21 +94,21 @@ void rank_targets_with_mapping_file(taxonomy_cache& taxonomy,
std::uint64_t taxid;
string gi;

//skip header
// skip header
getline(is, acc);
acc.clear();

while (is >> acc >> accver >> taxid >> gi) {
//target in database?
//accession.version is the default
// target in database?
// accession.version is the default
const taxon* tax = taxonomy.taxon_with_name(accver);

if (!tax) {
tax = taxonomy.taxon_with_similar_name(acc);
if (!tax) tax = taxonomy.taxon_with_name(gi);
}

//if in database then set parent
// if in database then set parent
if (tax) {
auto i = targetTaxa.find(tax);
if (i != targetTaxa.end()) {
Expand Down Expand Up @@ -218,16 +218,16 @@ taxon_id find_taxon_id(
if (name2tax.empty()) return taxonomy::none_id();
if (name.empty()) return taxonomy::none_id();

//try to find exact match
// try to find exact match
auto i = name2tax.find(name);
if (i != name2tax.end()) return i->second;

//find nearest match
// find nearest match
i = name2tax.upper_bound(name);
if (i == name2tax.end()) return taxonomy::none_id();

//if nearest match contains 'name' as prefix -> good enough
//e.g. accession vs. accession.version
// if nearest match contains 'name' as prefix -> good enough
// e.g. accession vs. accession.version
if (i->first.compare(0,name.size(),name) != 0) return taxonomy::none_id();
return i->second;
}
Expand Down Expand Up @@ -490,7 +490,7 @@ void post_process_features(database& db, const build_options& opt)
if (dbconf.removeOverpopulatedFeatures) {
auto old = db.feature_count();
auto maxlpf = db.max_locations_per_feature() - 1;
if (maxlpf > 0) { //always keep buckets with size 1
if (maxlpf > 0) { // always keep buckets with size 1
if (notSilent) {
cout << "\nRemoving features with more than "
<< maxlpf << " locations... " << flush;
Expand Down
30 changes: 15 additions & 15 deletions src/candidate_generation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ void for_all_contiguous_window_ranges(
{
using hit_count = match_candidate::count_type;

//list empty?
// list empty?
if (fst == end) return;

//first entry in list
// first entry in list
hit_count hits = 1;
match_candidate curBest;
curBest.tax = nullptr;
Expand All @@ -69,32 +69,32 @@ void for_all_contiguous_window_ranges(
auto lst = fst;
++lst;

//rest of list: check hits per query sequence
// rest of list: check hits per query sequence
while (lst != end) {
//look for neighboring windows with the highest total hit count
//as long as we are in the same target and the windows are in a
//contiguous range
// look for neighboring windows with the highest total hit count
// as long as we are in the same target and the windows are in a
// contiguous range
if (lst->tgt == curBest.tgt) {
//add new hits to the right
// add new hits to the right
hits++;
//subtract hits to the left that fall out of range
// subtract hits to the left that fall out of range
while (fst != lst &&
(lst->win - fst->win) >= numWindows)
{
hits--;
//move left side of range
// move left side of range
++fst;
}
//track best of the local sub-ranges
// track best of the local sub-ranges
if (hits > curBest.hits) {
curBest.hits = hits;
curBest.pos.beg = fst->win;
curBest.pos.end = lst->win;
}
}
else { //end of current target
else { // end of current target
if (!consume(curBest)) return;
//reset to new target
// reset to new target
fst = lst;
hits = 1;
curBest.tax = nullptr;
Expand Down Expand Up @@ -204,21 +204,21 @@ class best_distinct_matches_in_contiguous_window_ranges
top_.resize(rules.maxCandidates);
}
}
//above sequence level, taxa can occur more than once
// above sequence level, taxa can occur more than once
else {
auto i = std::find_if (top_.begin(), top_.end(),
[&] (const match_candidate& c) {
return c.tax == cand.tax;
});

if (i != top_.end()) {
//taxon already in list, update, if more hits
// taxon already in list, update, if more hits
if (cand.hits > i->hits) {
*i = cand;
std::sort(top_.begin(), i+1, greater);
}
}
//taxon not in list yet
// taxon not in list yet
else {
auto j = std::upper_bound(top_.begin(), top_.end(), cand, greater);

Expand Down
6 changes: 3 additions & 3 deletions src/candidate_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ struct candidate_generation_rules
{
constexpr candidate_generation_rules() noexcept = default;

//maximum length of contiguous window range
// maximum length of contiguous window range
window_id maxWindowsInRange = 3;

//maximum number of candidates to be generated
// maximum number of candidates to be generated
std::size_t maxCandidates = std::numeric_limits<std::size_t>::max();

//list only the best candidate of a taxon on rank
// list only the best candidate of a taxon on rank
taxon_rank mergeBelow = taxon_rank::Sequence;
};

Expand Down
14 changes: 7 additions & 7 deletions src/chunk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class chunk_allocator
using value_type = T;

chunk_allocator():
minChunkSize_(128*1024*1024/sizeof(T)), //128 MiB
minChunkSize_(128*1024*1024/sizeof(T)), // 128 MiB
freeSize_(0),
chunks_{}
{}
Expand Down Expand Up @@ -144,8 +144,8 @@ class chunk_allocator
T* allocate(std::size_t n)
{
// std::lock_guard<std::mutex> lock(mutables_);
//at the moment chunks will only be used,
//if they have been reserved explicitly
// at the moment chunks will only be used,
// if they have been reserved explicitly
if (n <= freeSize_) {
for (auto& c : chunks_) {
auto p = c.next_buffer(n);
Expand All @@ -155,11 +155,11 @@ class chunk_allocator
}
}
}
//make new chunk
// make new chunk
// chunks_.emplace_back(std::max(minChunkSize_,n));
// auto p = chunks_.back().next_buffer(n);
// if (p) return p;
//fallback
// fallback
try {
auto p = new T[n];
return p;
Expand All @@ -172,7 +172,7 @@ class chunk_allocator
{
// std::lock_guard<std::mutex> lock(mutables_);

//at the moment occupied chunk buffers are not given back
// at the moment occupied chunk buffers are not given back
auto it = std::find_if (begin(chunks_), end(chunks_),
[p](const chunk& c){ return c.owns(p); });

Expand All @@ -183,7 +183,7 @@ class chunk_allocator

chunk_allocator
select_on_container_copy_construction() const {
//don't propagate
// don't propagate
return chunk_allocator{};
}

Expand Down
Loading

0 comments on commit 54790ef

Please sign in to comment.