Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/zhanxw/seqminer
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanxw committed Nov 27, 2023
2 parents 75c93ea + f5b374c commit f050002
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/RangeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class RangeList{
positionPair(NULL){
chromSize = rc.getChromVector().size();
inChromRegionSize = getRegions(chromIndex)? getRegions(chromIndex)->size() : 0;
if (chromSize) {
if (chromSize && chromIndex < chromSize) {
chrom = &(rc.getChromVector()[chromIndex]);
positionPair = getRegions(chromIndex);
}
Expand All @@ -358,7 +358,7 @@ class RangeList{
this->inChromRangeIndex = 0;
chromSize = this->rangeCollection->getChromVector().size();
inChromRegionSize = getRegions(chromIndex)? getRegions(chromIndex)->size() : 0;
chrom = &(this->rangeCollection->getChromVector()[chromIndex]);
chrom = chromIndex < chromSize ? &(this->rangeCollection->getChromVector()[chromIndex]) : NULL;
positionPair = getRegions(chromIndex);
}
return (*this);
Expand Down
3 changes: 2 additions & 1 deletion src/SingleChromosomeBCFIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ int SingleChromosomeBCFIndex::createIndex() {
int64_t bgzf_offset_before_chrom = bgzf_tell(fp); // the offset to #CHROM
s.resize(l_text - before_chrom_size);
int64_t after_chrom_size = bgzf_read(fp, (void*) s.data(), l_text - before_chrom_size);
int32_t last_character = s[after_chrom_size - 1];
// load sample names
while (s.back() == '\n' || s.back() == '\0') {
s.resize(s.size() - 1);
}
stringTokenize(s, "\t", &bcfHeader.sample_names);
const int64_t num_sample = (int)bcfHeader.sample_names.size() - 9; // vcf header has 9 columns CHROM...FORMAT before actual sample names
Rprintf("sample size = %ld\n", num_sample);
Rprintf("last character is s[after_chrom_size-1] = %d\n", s[after_chrom_size - 1]); // should be 0, the null terminator character
Rprintf("last character is s[after_chrom_size-1] = %d\n", last_character); // should be 0, the null terminator character
// quality check
if (bgzf_offset_after_header != bgzf_tell(fp)) {
REprintf( "Messed up bgzf header\n");
Expand Down

0 comments on commit f050002

Please sign in to comment.