Skip to content

Commit ae5cdf8

Browse files
committed
- Added file_pos function for vcflib progress bar
- Added #pragma once - Updated htslib to latest
1 parent 6c5860e commit ae5cdf8

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

htslib

Submodule htslib updated 97 files

tabix.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#pragma once
2+
13
#include <string>
24
#include <stdlib.h>
35
#include <sys/stat.h>
@@ -24,6 +26,30 @@ class Tabix {
2426
bool has_jumped;
2527
vector<string>::iterator current_chrom;
2628

29+
/* uncompressed file pos
30+
off_t hts_utell1(htsFile *fp)
31+
{
32+
if (fp->is_bgzf) {
33+
return bgzf_htell(fp->fp.bgzf);
34+
}
35+
else
36+
return htell(fp->fp.hfile);
37+
}
38+
*/
39+
40+
// Get file position in compressed file - really on disk
41+
off_t bgzf_htell1(BGZF *fp) {
42+
if (fp->mt) {
43+
return -1; // skip if multithreading
44+
//pthread_mutex_lock(&fp->mt->job_pool_m);
45+
//off_t pos = fp->block_address + fp->block_clength;
46+
//pthread_mutex_unlock(&fp->mt->job_pool_m);
47+
//return pos;
48+
} else {
49+
return htell(fp->fp);
50+
}
51+
}
52+
2753
public:
2854
string filename;
2955
vector<string> chroms;
@@ -37,5 +63,6 @@ class Tabix {
3763
bool setRegion(string& region);
3864
bool getNextLine(string& line);
3965
bool getNextLineKS();
40-
66+
// Specialised function gets actual file position when using bgzf
67+
long file_pos() { return bgzf_htell1(fn->fp.bgzf); };
4168
};

0 commit comments

Comments
 (0)