Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages from vg haplotypes #4121

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/kff-cpp-api
Submodule kff-cpp-api updated 3 files
+1 −0 .gitignore
+2 −2 CMakeLists.txt
+5 −1 kff_io.cpp
2 changes: 1 addition & 1 deletion src/kff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ParallelKFFReader {
typedef gbwtgraph::Key64::value_type kmer_type;

/// Creates a new reader for the given file. Throws `std::runtime_error` if the
/// sanity checks fail.
/// file cannot be opened or the sanity checks fail.
ParallelKFFReader(const std::string& filename);

/// Reads the next `n` kmers and counts from the file. This can be called safely
Expand Down
31 changes: 24 additions & 7 deletions src/subcommand/haplotypes_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ int main_haplotypes(int argc, char** argv) {
if (config.verbosity >= Haplotypes::verbosity_basic) {
std::cerr << "Loading haplotype information from " << config.haplotype_input << std::endl;
}
sdsl::simple_sds::load_from(haplotypes, config.haplotype_input);
try {
sdsl::simple_sds::load_from(haplotypes, config.haplotype_input);
} catch (const std::runtime_error& e) {
std::cerr << "error: [vg haplotypes] " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
}

// Save haplotype information if necessary.
Expand Down Expand Up @@ -518,7 +523,7 @@ void preprocess_graph(const gbwtgraph::GBZ& gbz, Haplotypes& haplotypes, Haploty
haplotypes = partitioner.partition_haplotypes(config.partitioner_parameters);
}
catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
std::cerr << "error: [vg haplotypes] " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
if (config.verbosity >= Haplotypes::verbosity_basic) {
Expand All @@ -544,7 +549,13 @@ void validate_subgraph(const gbwtgraph::GBWTGraph& graph, const gbwtgraph::GBWTG
void sample_haplotypes(const gbwtgraph::GBZ& gbz, const Haplotypes& haplotypes, const HaplotypesConfig& config) {
omp_set_num_threads(threads_to_jobs(config.threads));
Recombinator recombinator(gbz, config.verbosity);
gbwt::GBWT merged = recombinator.generate_haplotypes(haplotypes, config.kmer_input, config.recombinator_parameters);
gbwt::GBWT merged;
try {
merged = recombinator.generate_haplotypes(haplotypes, config.kmer_input, config.recombinator_parameters);
} catch (const std::runtime_error& e) {
std::cerr << "error: [vg haplotypes] " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
omp_set_num_threads(config.threads); // Restore the number of threads.

// Build and serialize GBWTGraph.
Expand Down Expand Up @@ -860,10 +871,16 @@ void extract_haplotypes(const gbwtgraph::GBZ& gbz, const Haplotypes& haplotypes,
}

Recombinator recombinator(gbz, config.verbosity);
auto result = recombinator.extract_sequences(
haplotypes, config.kmer_input,
config.chain_id, config.subchain_id, config.recombinator_parameters
);
std::vector<Recombinator::LocalHaplotype> result;
try {
result = recombinator.extract_sequences(
haplotypes, config.kmer_input,
config.chain_id, config.subchain_id, config.recombinator_parameters
);
} catch (const std::runtime_error& e) {
std::cerr << "error: [vg haplotypes] " << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
if (config.verbosity >= Haplotypes::verbosity_detailed) {
std::cerr << "Found " << result.size() << " haplotypes" << std::endl;
}
Expand Down
Loading