-
Notifications
You must be signed in to change notification settings - Fork 444
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
Allow repeated calls of bcf_sr_set_regions #1624
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; | ||
} | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.