forked from samtools/htslib
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow repeated calls of bcf_sr_set_regions
and make repeated bcf_sr_seek()+next_line() calls consistent. Resolves samtools#1623 and samtools/bcftools#1918
- Loading branch information
Showing
2 changed files
with
15 additions
and
7 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/// @file htslib/synced_bcf_reader.h | ||
/// Stream through multiple VCF files. | ||
/* | ||
Copyright (C) 2012-2017, 2019-2021 Genome Research Ltd. | ||
Copyright (C) 2012-2017, 2019-2023 Genome Research Ltd. | ||
Author: Petr Danecek <[email protected]> | ||
|
@@ -306,8 +306,10 @@ int bcf_sr_set_samples(bcf_srs_t *readers, const char *samples, int is_file); | |
* Targets (but not regions) can be prefixed with "^" to request logical complement, | ||
* for example "^X,Y,MT" indicates that sequences X, Y and MT should be skipped. | ||
* | ||
* API note: bcf_sr_set_regions/bcf_sr_set_targets MUST be called before the | ||
* first call to bcf_sr_add_reader(). | ||
* API notes: | ||
* - bcf_sr_set_targets MUST be called before the first call to bcf_sr_add_reader() | ||
* - bcf_sr_set_regions AFTER readers where initialized will reposition the readers | ||
* and discard all previous regions. | ||
*/ | ||
HTSLIB_EXPORT | ||
int bcf_sr_set_targets(bcf_srs_t *readers, const char *targets, int is_file, int alleles); | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* synced_bcf_reader.c -- stream through multiple VCF files. | ||
Copyright (C) 2012-2021 Genome Research Ltd. | ||
Copyright (C) 2012-2023 Genome Research Ltd. | ||
Author: Petr Danecek <[email protected]> | ||
|
@@ -76,6 +76,7 @@ static bcf_sr_regions_t *_regions_init_string(const char *str); | |
static int _regions_match_alleles(bcf_sr_regions_t *reg, int als_idx, bcf1_t *rec); | ||
static void _regions_sort_and_merge(bcf_sr_regions_t *reg); | ||
static int _bcf_sr_regions_overlap(bcf_sr_regions_t *reg, const char *seq, hts_pos_t start, hts_pos_t end, int missed_reg_handler); | ||
static void bcf_sr_seek_start(bcf_srs_t *readers); | ||
|
||
char *bcf_sr_strerror(int errnum) | ||
{ | ||
|
@@ -187,8 +188,10 @@ int bcf_sr_set_regions(bcf_srs_t *readers, const char *regions, int is_file) | |
{ | ||
if ( readers->nreaders || readers->regions ) | ||
{ | ||
hts_log_error("Must call bcf_sr_set_regions() before bcf_sr_add_reader()"); | ||
return -1; | ||
if ( readers->regions ) bcf_sr_regions_destroy(readers->regions); | ||
readers->regions = bcf_sr_regions_init(regions,is_file,0,1,-2); | ||
bcf_sr_seek_start(readers); | ||
return 0; | ||
} | ||
|
||
readers->regions = bcf_sr_regions_init(regions,is_file,0,1,-2); | ||
|
@@ -676,7 +679,6 @@ static int _reader_fill_buffer(bcf_srs_t *files, bcf_sr_t *reader) | |
hts_log_error("This should never happen, just to keep clang compiler happy: %d",BCF_SR_AUX(files)->targets_overlap); | ||
exit(1); | ||
} | ||
|
||
if ( beg <= files->regions->prev_end || end < files->regions->start || beg > files->regions->end ) continue; | ||
} | ||
|
||
|
@@ -843,7 +845,11 @@ static void bcf_sr_seek_start(bcf_srs_t *readers) | |
for (i=0; i<reg->nseqs; i++) | ||
reg->regs[i].creg = -1; | ||
reg->iseq = 0; | ||
reg->start = -1; | ||
reg->end = -1; | ||
reg->prev_seq = -1; | ||
reg->prev_start = -1; | ||
reg->prev_end = -1; | ||
} | ||
|
||
|
||
|