generated from seqan/app-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from eseiler/misc/upgrade_index
[MISC] Add raptor upgrade
- Loading branch information
Showing
19 changed files
with
323 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <raptor/argument_parsing/shared.hpp> | ||
|
||
namespace raptor | ||
{ | ||
|
||
void init_upgrade_parser(seqan3::argument_parser & parser, upgrade_arguments & arguments); | ||
void run_upgrade(seqan3::argument_parser & parser); | ||
|
||
} // namespace raptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <raptor/shared.hpp> | ||
|
||
namespace raptor | ||
{ | ||
|
||
void raptor_upgrade(upgrade_arguments const & arguments); | ||
|
||
} // namespace raptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <raptor/argument_parsing/shared.hpp> | ||
#include <raptor/build/store_index.hpp> | ||
|
||
namespace raptor | ||
{ | ||
|
||
template <bool compressed> | ||
void upgrade_index(upgrade_arguments const & arguments) | ||
{ | ||
constexpr seqan3::data_layout layout = compressed ? seqan3::data_layout::compressed : seqan3::data_layout::uncompressed; | ||
seqan3::interleaved_bloom_filter<layout> original_ibf{}; | ||
|
||
if (arguments.parts == 1u) | ||
{ | ||
std::ifstream is{arguments.in_file, std::ios::binary}; | ||
cereal::BinaryInputArchive iarchive{is}; | ||
iarchive(original_ibf); | ||
store_index(arguments.out_file, original_ibf, arguments); | ||
} | ||
else | ||
{ | ||
for (size_t part : std::views::iota(0u, arguments.parts)) | ||
{ | ||
std::filesystem::path in_file{arguments.in_file}; | ||
in_file += "_" + std::to_string(part); | ||
|
||
std::ifstream is{in_file, std::ios::binary}; | ||
cereal::BinaryInputArchive iarchive{is}; | ||
iarchive(original_ibf); | ||
|
||
std::filesystem::path out_file{arguments.out_file}; | ||
out_file += "_" + std::to_string(part); | ||
store_index(out_file, original_ibf, arguments); | ||
} | ||
} | ||
} | ||
|
||
} // namespace raptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include <raptor/argument_parsing/upgrade.hpp> | ||
#include <raptor/upgrade/upgrade.hpp> | ||
|
||
namespace raptor | ||
{ | ||
|
||
void init_upgrade_parser(seqan3::argument_parser & parser, upgrade_arguments & arguments) | ||
{ | ||
init_shared_meta(parser); | ||
parser.add_option(arguments.bin_file, | ||
'\0', | ||
"bins", | ||
"File containing one file per line per bin.", | ||
seqan3::option_spec::required, | ||
seqan3::input_file_validator{}); | ||
parser.add_option(arguments.in_file, | ||
'\0', | ||
"input", | ||
"The index to upgrade. Parts: Without suffix _0", | ||
seqan3::option_spec::required); | ||
parser.add_option(arguments.out_file, | ||
'\0', | ||
"output", | ||
"Path to new index.", | ||
seqan3::option_spec::required, | ||
seqan3::output_file_validator{}); | ||
parser.add_option(arguments.window_size, | ||
'\0', | ||
"window", | ||
"The original window size.", | ||
seqan3::option_spec::required, | ||
positive_integer_validator{}); | ||
parser.add_option(arguments.kmer_size, | ||
'\0', | ||
"kmer", | ||
"The original kmer size.", | ||
seqan3::option_spec::required, | ||
seqan3::arithmetic_range_validator{1, 32}); | ||
parser.add_option(arguments.parts, | ||
'\0', | ||
"parts", | ||
"Original index consisted of this many parts.", | ||
seqan3::option_spec::standard, | ||
power_of_two_validator{}); | ||
parser.add_flag(arguments.compressed, | ||
'\0', | ||
"compressed", | ||
"Original IBF was compressed."); | ||
} | ||
|
||
void run_upgrade(seqan3::argument_parser & parser) | ||
{ | ||
upgrade_arguments arguments{}; | ||
init_upgrade_parser(parser, arguments); | ||
try_parsing(parser); | ||
|
||
// ========================================== | ||
// Various checks. | ||
// ========================================== | ||
|
||
if (arguments.parts == 1) | ||
{ | ||
seqan3::input_file_validator{}(arguments.in_file); | ||
} | ||
else | ||
{ | ||
seqan3::input_file_validator validator{}; | ||
for (size_t part{0}; part < arguments.parts; ++part) | ||
{ | ||
validator(arguments.in_file.string() + std::string{"_"} + std::to_string(part)); | ||
} | ||
} | ||
|
||
// ========================================== | ||
// Process bin_path | ||
// ========================================== | ||
std::ifstream istrm{arguments.bin_file}; | ||
std::string line; | ||
auto sequence_file_validator{bin_validator{}.sequence_file_validator}; | ||
|
||
while (std::getline(istrm, line)) | ||
{ | ||
if (!line.empty()) | ||
{ | ||
sequence_file_validator(line); | ||
arguments.bin_path.emplace_back(std::vector<std::string>{line}); | ||
} | ||
} | ||
|
||
// ========================================== | ||
// Dispatch | ||
// ========================================== | ||
raptor_upgrade(arguments); | ||
}; | ||
|
||
} // namespace raptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <raptor/upgrade/upgrade.hpp> | ||
#include <raptor/upgrade/upgrade_index.hpp> | ||
|
||
namespace raptor | ||
{ | ||
|
||
void raptor_upgrade(upgrade_arguments const & arguments) | ||
{ | ||
if (arguments.compressed) | ||
upgrade_index<true>(arguments); | ||
else | ||
upgrade_index<false>(arguments); | ||
return; | ||
} | ||
|
||
} // namespace raptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.