Skip to content

Commit 5223a7f

Browse files
committed
clean slop
1 parent d326e02 commit 5223a7f

12 files changed

+59
-110
lines changed

src/gbwtgraph_helper.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,11 @@ void cache_payloads(
440440
std::cerr << "Caching payloads" << std::endl;
441441
}
442442

443-
const handlegraph::HandleGraph* graph_ptr = (const handlegraph::HandleGraph*) &gbz.graph;
444-
445443
gbz.graph.for_each_handle([&](const handle_t& handle) {
446444
nid_t node_id = gbz.graph.get_id(handle);
447445
ZipCode zipcode;
448446
pos_t pos = make_pos_t(node_id, false, 0);
449-
zipcode.fill_in_zipcode_from_pos(distance_index, pos, true, graph_ptr);
447+
zipcode.fill_in_zipcode_from_pos(distance_index, pos);
450448
payload_t payload = zipcode.get_payload_from_zip();
451449
if (payload == MIPayload::NO_CODE && oversized_zipcodes != nullptr) {
452450
// The zipcode is too large for the payload field.

src/minimizer_mapper.cpp

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,7 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
20482048

20492049
// Fill this in with the indexes of pairs of alignments we will output
20502050
// each alignment is stored as <fragment index, alignment index> into alignments
2051-
// fragment_index should be the same for both ends, unless one was rescued.
2052-
// Note that for a failed rescue, we still include the "pair" here that has one read unmapped.
2051+
// fragment_index should be the same for both ends, unless one was rescued
20532052
vector<std::array<read_alignment_index_t, 2>> paired_alignments;
20542053
paired_alignments.reserve(alignments.size());
20552054

@@ -2062,11 +2061,8 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
20622061
vector<std::array<vector<vector<size_t>>, 2>> alignment_groups(alignments.size());
20632062

20642063
// Grab all the scores in order for MAPQ computation.
2065-
// These correspond 1 to 1 with paired_alignments.
20662064
vector<double> paired_scores;
20672065
paired_scores.reserve(alignments.size());
2068-
// Record the fragment distances, which are 1 to 1 with paired_alignments
2069-
// and feed into MAPQ capping.
20702066
vector<int64_t> fragment_distances;
20712067
fragment_distances.reserve(alignments.size());
20722068

@@ -2206,6 +2202,7 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
22062202
unpaired_scores[r].reserve(unpaired_alignments.size());
22072203
}
22082204

2205+
22092206
array<vector<read_alignment_index_t>, 2> supplementaries;
22102207
if (!unpaired_alignments.empty()) {
22112208
//If we found some clusters that had no pair in a fragment cluster
@@ -2356,15 +2353,14 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
23562353
attempt_rescue(mapped_aln, rescued_aln, minimizers_by_read[1 - index.read], index.read == 0);
23572354

23582355
bool properly_paired = false;
2359-
int64_t fragment_dist;
23602356
double score;
23612357

23622358
if (rescued_aln.path().mapping_size() != 0) {
23632359
//If we actually found an alignment
23642360

23652361
// Compute the distance
2366-
fragment_dist = index.read == 0 ? distance_between(mapped_aln, rescued_aln)
2367-
: distance_between(rescued_aln, mapped_aln);
2362+
int64_t fragment_dist = index.read == 0 ? distance_between(mapped_aln, rescued_aln)
2363+
: distance_between(rescued_aln, mapped_aln);
23682364

23692365
// Use it to make a pair score
23702366
score = score_alignment_pair(mapped_aln, rescued_aln, fragment_dist);
@@ -2377,13 +2373,13 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
23772373
set_annotation(mapped_aln, "fragment_length", distance_to_annotation(fragment_dist));
23782374
set_annotation(rescued_aln, "fragment_length", distance_to_annotation(fragment_dist));
23792375

2376+
// Track it for the distribution
2377+
fragment_distances.emplace_back(fragment_dist);
23802378
} else {
23812379
// If there's no rescue result, the score of the pair is the score of the one actually-aligned read
23822380
score = mapped_aln.score();
2383-
// And the fragment distance is unreachable. But don't add an annotation for it.
2384-
fragment_dist = std::numeric_limits<int64_t>::max();
23852381
}
2386-
2382+
23872383
// Add the annotations that don't always need a fragment distance.
23882384
set_annotation(mapped_aln, "rescuer", true);
23892385
set_annotation(rescued_aln, "rescued", true);
@@ -2411,7 +2407,7 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
24112407
paired_alignments.back().at(r).check_for_read_in(r, alignments);
24122408
}
24132409
#endif
2414-
fragment_distances.emplace_back(fragment_dist);
2410+
24152411
paired_scores.emplace_back(score);
24162412
pair_types.push_back(index.read == 0 ? rescued_from_first : rescued_from_second);
24172413
better_cluster_count_by_pairs.emplace_back(better_cluster_count[mapped_index.fragment]);
@@ -2451,8 +2447,7 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
24512447
}
24522448

24532449
if (find_supplementaries) {
2454-
supplementaries = std::move(identify_supplementary_alignments(alignments, paired_alignments, paired_scores,
2455-
fragment_distances, pair_types, better_cluster_count_by_pairs,
2450+
supplementaries = std::move(identify_supplementary_alignments(alignments, paired_alignments, paired_scores, pair_types,
24562451
unpaired_alignments, attempted_rescue_from, funnels));
24572452
}
24582453
}
@@ -2463,16 +2458,6 @@ pair<vector<Alignment>, vector<Alignment>> MinimizerMapper::map_paired(Alignment
24632458
funnels[r].stage("winner");
24642459
}
24652460
}
2466-
2467-
// Make sure we haven't dropped any parts of our multi-vector per-pair
2468-
// alignment data records.
2469-
//
2470-
// TODO: Remove the possibility to get this wrong by making these all
2471-
// members of a struct.
2472-
crash_unless(paired_scores.size() == paired_alignments.size());
2473-
crash_unless(fragment_distances.size() == paired_alignments.size());
2474-
crash_unless(pair_types.size() == paired_alignments.size());
2475-
crash_unless(better_cluster_count_by_pairs.size() == paired_alignments.size());
24762461

24772462
// Fill this in with the alignments we will output.
24782463
std::array<vector<Alignment>, 2> mappings;
@@ -3565,9 +3550,7 @@ array<vector<MinimizerMapper::read_alignment_index_t>, 2>
35653550
MinimizerMapper::identify_supplementary_alignments(vector<std::array<vector<Alignment>, 2>>& alignments,
35663551
vector<std::array<read_alignment_index_t, 2>>& paired_alignments,
35673552
vector<double>& paired_scores,
3568-
vector<int64_t>& fragment_distances,
35693553
vector<MinimizerMapper::PairType>& pair_types,
3570-
vector<size_t>& better_cluster_count_by_pairs,
35713554
const vector<alignment_index_t>& unpaired_alignments,
35723555
const vector<bool>& attempted_rescue_from,
35733556
array<Funnel, 2>& funnels) const {
@@ -3718,9 +3701,7 @@ MinimizerMapper::identify_supplementary_alignments(vector<std::array<vector<Alig
37183701
// Shift into the front of the vector
37193702
paired_alignments[i - s] = paired_alignments[i];
37203703
paired_scores[i - s] = paired_scores[i];
3721-
fragment_distances[i - s] = fragment_distances[i];
37223704
pair_types[i - s] = pair_types[i];
3723-
better_cluster_count_by_pairs[i - s] = better_cluster_count_by_pairs[s];
37243705

37253706
}
37263707
}
@@ -3746,9 +3727,7 @@ MinimizerMapper::identify_supplementary_alignments(vector<std::array<vector<Alig
37463727

37473728
paired_alignments.resize(paired_alignments.size() - s);
37483729
paired_scores.resize(paired_alignments.size());
3749-
fragment_distances.resize(paired_alignments.size());
37503730
pair_types.resize(paired_alignments.size());
3751-
better_cluster_count_by_pairs.resize(paired_alignments.size());
37523731
}
37533732
else {
37543733
if (show_work) {

src/minimizer_mapper.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,7 @@ class MinimizerMapper : public AlignerClient {
993993
array<vector<read_alignment_index_t>, 2> identify_supplementary_alignments(vector<std::array<vector<Alignment>, 2>>& alignments,
994994
vector<std::array<read_alignment_index_t, 2>>& paired_alignments,
995995
vector<double>& paired_scores,
996-
vector<int64_t>& fragment_distances,
997996
vector<PairType>& pair_types,
998-
vector<size_t>& better_cluster_count_by_pairs,
999997
const vector<alignment_index_t>& unpaired_alignments,
1000998
const vector<bool>& attempted_rescue_from,
1001999
array<Funnel, 2>& funnels) const;

src/recombinator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,12 +1727,9 @@ gbwt::GBWT Recombinator::generate_haplotypes(const std::string& kff_file, const
17271727
std::vector<std::vector<gbwt::size_type>> reference_paths(this->haplotypes.jobs());
17281728
if (parameters.include_reference) {
17291729
for (size_t i = 0; i < this->gbz.graph.named_paths.size(); i++) {
1730-
gbwt::size_type path_id = this->gbz.graph.named_paths[i].id;
1731-
std::string path_name = gbwtgraph::compose_path_name(
1732-
this->gbz.index, path_id, this->gbz.graph.named_paths[i].sense);
17331730
size_t job_id = this->jobs_for_cached_paths[i];
17341731
if (job_id < this->haplotypes.jobs()) {
1735-
reference_paths[job_id].push_back(path_id);
1732+
reference_paths[job_id].push_back(this->gbz.graph.named_paths[i].id);
17361733
}
17371734
}
17381735
}

src/subcommand/depth_main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,14 @@ int main_depth(int argc, char** argv) {
227227
subrange_t subrange;
228228
string base_name = Paths::strip_subrange(path_name, &subrange);
229229
base_path_set.insert(base_name);
230-
// just take anything if no selection (excluding alt paths)
231-
bool use_it = !Paths::is_alt(path_name) &&
232-
path_prefixes.empty() && ref_paths_input_set.empty();
230+
// just take anything if no selection
231+
bool use_it = !Paths::is_alt(path_name) && path_prefixes.empty() && ref_paths_input_set.empty();
233232

234233
// then look in the input paths -p
235234
if (!use_it && ref_paths_input_set.count(base_name)) {
236235
use_it = true;
237236
}
238-
237+
239238
// then look in the prefixes
240239
for (size_t i = 0; i < path_prefixes.size() && !use_it; ++i) {
241240
if (path_name.substr(0, path_prefixes[i].length()) == path_prefixes[i]) {

src/subcommand/giraffe_main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,7 @@ void help_giraffe(char** argv, const BaseOptionGroup& parser, const std::map<std
688688
<< " in the GR tag as a cs-style difference string" << endl
689689
<< " -n, --discard discard all output alignments (for profiling)" << endl
690690
<< " --output-basename NAME write output to a GAM file with the given prefix" << endl
691-
<< " for each setting combination. Setting values for" << endl
692-
<< " many other options can be provided as ranges" << endl
693-
<< " in the format start[:end[:step]], with end"
694-
<< " being inclusive." << endl
691+
<< " for each setting combination" << endl
695692
<< " --report-name FILE write a TSV of output file and mapping speed" << endl
696693
<< " --show-work log how the mapper comes to its conclusions" << endl
697694
<< " about mapping locations (use one read at a time)" << endl;

src/subcommand/stats_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,7 @@ int main_stats(int argc, char** argv) {
11961196
}
11971197
vector<string> ref_path_names;
11981198
pp_graph->for_each_path_of_sample(snarl_sample, [&](path_handle_t path_handle) {
1199-
string path_name = graph->get_path_name(path_handle);
1200-
ref_path_names.push_back(path_name);
1199+
ref_path_names.push_back(graph->get_path_name(path_handle));
12011200
extra_node_weight[graph->get_id(graph->get_handle_of_step(graph->path_begin(path_handle)))] += EXTRA_WEIGHT;
12021201
extra_node_weight[graph->get_id(graph->get_handle_of_step(graph->path_back(path_handle)))] += EXTRA_WEIGHT;
12031202
});

src/subcommand/surject_main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using namespace vg;
3333
using namespace vg::subcommand;
3434

3535
void help_surject(char** argv) {
36-
cerr << "usage: " << argv[0] << " surject [options] <aln.gam> >[proj.gam]" << endl
36+
cerr << "usage: " << argv[0] << " surject [options] <aln.gam> >[proj.cram]" << endl
3737
<< "Transforms alignments to be relative to particular paths." << endl
3838
<< endl
3939
<< "options:" << endl
@@ -50,9 +50,9 @@ void help_surject(char** argv) {
5050
<< " overlapping paths instead of just primary" << endl
5151
<< " -G, --gaf-input input file is GAF instead of GAM" << endl
5252
<< " -m, --gamp-input input file is GAMP instead of GAM" << endl
53-
<< " -c, --cram-output write CRAM instead of GAM to stdout" << endl
54-
<< " -b, --bam-output write BAM instead of GAM to stdout" << endl
55-
<< " -s, --sam-output write SAM instead of GAM to stdout" << endl
53+
<< " -c, --cram-output write CRAM to stdout" << endl
54+
<< " -b, --bam-output write BAM to stdout" << endl
55+
<< " -s, --sam-output write SAM to stdout" << endl
5656
<< " -u, --supplementary divide into supplementary alignments as necessary" << endl
5757
<< " -l, --subpath-local let the multipath mapping surjection produce local" << endl
5858
<< " (rather than global) alignments" << endl

src/zip_code.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ using namespace std;
88
// Make sure that the default / empty payload exists as a value that can be pointed to.
99
constexpr std::pair<gbwtgraph::KmerEncoding::code_type, gbwtgraph::KmerEncoding::code_type> MIPayload::NO_CODE;
1010

11-
void ZipCode::fill_in_zipcode_from_pos(const SnarlDistanceIndex& distance_index, const pos_t& pos,
12-
bool fill_in_decoder, const handlegraph::HandleGraph* graph_ptr) {
11+
void ZipCode::fill_in_zipcode_from_pos(const SnarlDistanceIndex& distance_index, const pos_t& pos, bool fill_in_decoder) {
12+
1313
std::vector<net_handle_t> ancestors;
1414
net_handle_t current_handle = distance_index.get_node_net_handle(id(pos));
1515

@@ -121,7 +121,7 @@ void ZipCode::fill_in_zipcode_from_pos(const SnarlDistanceIndex& distance_index,
121121
}
122122
return;
123123
}
124-
} else if (distance_index.is_regular_snarl(current_ancestor, false, graph_ptr)) {
124+
} else if (distance_index.is_regular_snarl(current_ancestor)) {
125125
snarl_code_t snarl_code = get_regular_snarl_code(current_ancestor, ancestors[i-1], distance_index);
126126
zipcode.add_value(snarl_code.get_raw_code_type());
127127
zipcode.add_value(snarl_code.get_raw_prefix_sum_or_identifier());

src/zip_code.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ class ZipCode {
6868
public:
6969

7070
//Fill in an empty zipcode given a position
71-
void fill_in_zipcode_from_pos(const SnarlDistanceIndex& distance_index, const vg::pos_t& pos,
72-
bool fill_in_decoder = true, const handlegraph::HandleGraph* graph_ptr = nullptr);
71+
void fill_in_zipcode_from_pos(const SnarlDistanceIndex& distance_index, const vg::pos_t& pos, bool fill_in_decoder = true);
7372

7473
using code_type = gbwtgraph::KmerEncoding::code_type;
7574
typedef std::pair<code_type, code_type> payload_type;

0 commit comments

Comments
 (0)