Skip to content

Commit

Permalink
feat: Add index file loading to Sketch constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ekg committed Oct 12, 2024
1 parent 6fe2be0 commit f11f911
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/map/include/winSketch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,34 @@ namespace skch
*/
Sketch(skch::Parameters p,
SequenceIdManager& idMgr,
const std::vector<std::string>& targets = {})
const std::vector<std::string>& targets = {},
const std::string& indexFilename = "")
: param(std::move(p)),
idManager(idMgr)
{
initialize(targets);
if (!indexFilename.empty()) {
loadIndex(indexFilename);
} else {
initialize(targets);
}
}

void loadIndex(const std::string& indexFilename) {
std::ifstream inStream(indexFilename, std::ios::binary);
if (!inStream) {
std::cerr << "Error: Unable to open index file: " << indexFilename << std::endl;
exit(1);
}
readParameters(inStream);
readSketchBinary(inStream);
readPosListBinary(inStream);
readFreqKmersBinary(inStream);
inStream.close();
isInitialized = true;
std::cerr << "[mashmap::skch::Sketch] Sketch loaded from index file: " << indexFilename << std::endl;
}

public:
void initialize(const std::vector<std::string>& targets = {}) {
std::cerr << "[mashmap::skch::Sketch] Initializing Sketch..." << std::endl;

Expand Down

0 comments on commit f11f911

Please sign in to comment.