Skip to content

Commit a24df70

Browse files
committed
[MISC] read_layouts_file
1 parent 8ae25d6 commit a24df70

4 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/util/display_layout/general.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,16 @@ int execute(config const & cfg)
186186

187187
// https://godbolt.org/z/PeKnxzjn1
188188
#if defined(__clang__)
189-
auto tuple = chopper::layout::read_layout_file(layout_file);
189+
auto tuple = chopper::layout::read_layouts_file(layout_file);
190190
// https://godbolt.org/z/WoWf55KPb
191191
auto filenames = std::move(std::get<0>(tuple));
192192
auto chopper_config = std::move(std::get<1>(tuple));
193-
auto hibf_layout = std::move(std::get<2>(tuple));
193+
auto hibf_layouts = std::move(std::get<2>(tuple));
194194
#else
195-
auto [filenames, chopper_config, hibf_layouts] = chopper::layout::read_layouts_file(layout_file);
195+
auto [filenames, chopper_config, hibf_layouts] = chopper::layout::read_layouts_file(layouts_file);
196196
#endif
197+
198+
auto const & hibf_layout = hibf_layouts[0];
197199
auto const & hibf_config = chopper_config.hibf_config;
198200

199201
layout_file.close();
@@ -223,7 +225,7 @@ int execute(config const & cfg)
223225
// If the index is the same, sort by file sizes (happens for merged bins).
224226
// Using the smallest file to initialise the shared k-mers later will be less work.
225227
std::ranges::sort(
226-
hibf_layouts[0].user_bins,
228+
hibf_layout[0].user_bins,
227229
[&filesizes](seqan::hibf::layout::layout::user_bin const & lhs,
228230
seqan::hibf::layout::layout::user_bin const & rhs)
229231
{
@@ -232,7 +234,7 @@ int execute(config const & cfg)
232234
return first_idx < second_idx || (first_idx == second_idx && filesizes[lhs.idx] < filesizes[rhs.idx]);
233235
});
234236

235-
size_t const total_ub_count = hibf_layouts[0].user_bins.size();
237+
size_t const total_ub_count = hibf_layout[0].user_bins.size();
236238
progress_bar progress{total_ub_count};
237239

238240
// Create chunks containing user bin indices for one technical bin.
@@ -249,8 +251,8 @@ int execute(config const & cfg)
249251
// Two user bins belong to the same chunk if they are in the same technical bin.
250252
auto predicate = [&](size_t const lhs, size_t const rhs)
251253
{
252-
auto const & lhs_ub = hibf_layouts[0].user_bins[lhs];
253-
auto const & rhs_ub = hibf_layouts[0].user_bins[rhs];
254+
auto const & lhs_ub = hibf_layout[0].user_bins[lhs];
255+
auto const & rhs_ub = hibf_layout[0].user_bins[rhs];
254256
// The top-level technical bin index for the current user bin.
255257
// user_bin.previous_TB_indices.size() == 0: true for split bins, false for merged bins
256258
// user_bin.storage_TB_id: technical bin index on the lowest level
@@ -289,7 +291,7 @@ int execute(config const & cfg)
289291

290292
for (size_t const ub_index : chunk)
291293
{
292-
auto const & user_bin = hibf_layouts[0].user_bins[ub_index];
294+
auto const & user_bin = hibf_layout[0].user_bins[ub_index];
293295
current_kmers.clear();
294296

295297
// We don't need to keep the current_kmers if there are no shared k-mers to merge them with.
@@ -325,7 +327,7 @@ int execute(config const & cfg)
325327
}
326328

327329
// Into how many techincal bins is the user bin split? Always 1 for merged bins.
328-
size_t const split_count{is_merged ? 1u : hibf_layouts[0].user_bins[chunk[0]].number_of_technical_bins};
330+
size_t const split_count{is_merged ? 1u : hibf_layout[0].user_bins[chunk[0]].number_of_technical_bins};
329331
size_t const avg_kmer_count = (current_kmer_set.size() + split_count - 1u) / split_count;
330332
size_t const sketch_estimate = (sketch.estimate() + split_count - 1u) / split_count;
331333

src/util/display_layout/sizes.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ void execute_general_stats(config const & cfg)
284284

285285
// https://godbolt.org/z/PeKnxzjn1
286286
#if defined(__clang__)
287-
auto tuple = chopper::layout::read_layout_file(layout_file);
287+
auto tuple = chopper::layout::read_layouts_file(layout_file);
288288
// https://godbolt.org/z/WoWf55KPb
289289
auto filenames = std::move(std::get<0>(tuple));
290290
auto chopper_config = std::move(std::get<1>(tuple));
@@ -293,6 +293,8 @@ void execute_general_stats(config const & cfg)
293293
auto [filenames, chopper_config, hibf_layouts] = chopper::layout::read_layouts_file(layout_file);
294294
#endif
295295

296+
auto const & hibf_layout = hibf_layouts[0];
297+
296298
// Prepare configs
297299
chopper_config.hibf_config.threads = cfg.threads;
298300
auto input_lambda = [&filenames, &chopper_config](size_t const user_bin_id, seqan::hibf::insert_iterator it)
@@ -311,9 +313,9 @@ void execute_general_stats(config const & cfg)
311313
auto const & hibf_config = chopper_config.hibf_config;
312314

313315
// Prepare stats
314-
assert(hibf_layouts.size() > 0);
315-
size_t part = (hibf_layouts.size() == 1) ? 0 : 1;
316-
for (auto const & hibf_layout : hibf_layouts)
316+
assert(hibf_layout.size() > 0);
317+
size_t part = (hibf_layout.size() == 1) ? 0 : 1;
318+
for (auto const & hibf_layout : hibf_layout)
317319
{
318320
size_t const number_of_ibfs = hibf_layout.max_bins.size() + 1u;
319321
std::vector<ibf_stats> stats(number_of_ibfs);

test/api/config_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ TEST(config_test, read_from_with_more_meta)
149149
}
150150

151151
// Easier to do in the config_test because of existing helper functions
152-
TEST(input, read_layout_file)
152+
TEST(input, read_layouts_file)
153153
{
154154
std::string config_string{"@CHOPPER_USER_BINS\n"
155155
"@0 file1.fa\n"
@@ -169,7 +169,9 @@ TEST(input, read_layout_file)
169169

170170
std::stringstream ss{config_string};
171171

172-
auto [filenames, config, layout] = chopper::layout::read_layout_file(ss);
172+
auto [filenames, config, layouts] = chopper::layout::read_layouts_file(ss);
173+
174+
auto const & layout = layouts[0];
173175

174176
std::vector<std::vector<std::string>> const expected_filenames{{"file1.fa"},
175177
{"file2.fa"},

test/api/layout/input_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ TEST(layout_test, read_single_layout)
7171
5 1;2;3;4;22 1;1;1;1;21
7272
)layout_file"};
7373

74-
auto [filenames, chopper_config, layouts] = chopper::layout::read_layout_file(ss);
74+
auto [filenames, chopper_config, layouts] = chopper::layout::read_layouts_file(ss);
7575

7676
auto const & layout = layouts[0];
7777

0 commit comments

Comments
 (0)