Skip to content

Commit

Permalink
Handle resume ingestion for annotation VCFs (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
gspowley authored Dec 21, 2023
1 parent 128d736 commit eeb71ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion libtiledbvcf/src/vcf/vcf_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ bcf_hdr_t* VCFUtils::hdr_read_header(const std::string& path) {
std::vector<std::string> VCFUtils::get_sample_name_from_vcf(
const std::string& path) {
SafeBCFHdr hdr(hdr_read_header(path), bcf_hdr_destroy);
return hdr_get_samples(hdr.get());
auto samples = hdr_get_samples(hdr.get());
// If there are no samples, add an empty string to the list
// to indicate this is a sampleless VCF.
if (samples.empty()) {
samples.push_back("");
}
return samples;
}

std::vector<std::string> VCFUtils::hdr_get_samples(bcf_hdr_t* hdr) {
Expand Down
8 changes: 4 additions & 4 deletions libtiledbvcf/src/write/writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ std::pair<uint64_t, uint64_t> Writer::ingest_samples_v4(
if (params.resume_sample_partial_ingestion &&
!existing_sample_contig_fragments.empty()) {
const std::string first_sample_name =
VCFUtils::get_sample_name_from_vcf(samples.front().sample_uri)[0];
VCFUtils::get_sample_name_from_vcf(samples.front().sample_uri).at(0);
const std::string last_sample_name =
VCFUtils::get_sample_name_from_vcf(samples.back().sample_uri)[0];
VCFUtils::get_sample_name_from_vcf(samples.back().sample_uri).at(0);

LOG_INFO("Resume: checking for regions to skip");
LOG_DEBUG("Resume: regions before resume check = {}", regions_v4.size());
Expand All @@ -787,7 +787,7 @@ std::pair<uint64_t, uint64_t> Writer::ingest_samples_v4(
bool skip = false;

LOG_DEBUG(
"Resume: Checking sample_range=({}, {}) contig={}",
"Resume: Checking sample_range=('{}', '{}') contig={}",
first_sample_name,
last_sample_name,
contig);
Expand All @@ -803,7 +803,7 @@ std::pair<uint64_t, uint64_t> Writer::ingest_samples_v4(
{first_sample_name, last_sample_name});

LOG_DEBUG(
"Resume: found fragments with sample_range=({}, {})",
"Resume: found fragments with sample_range=('{}', '{}')",
first_sample_name,
last_sample_name);
// Loop over contigs for the sample range
Expand Down

0 comments on commit eeb71ef

Please sign in to comment.