NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
hts.c File Reference
#include <zlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include "htslib/bgzf.h"
#include "htslib/hts.h"
#include "cram/cram.h"
#include "htslib/hfile.h"
#include "version.h"
#include "htslib/kseq.h"
#include "htslib/khash.h"
#include "htslib/ksort.h"

Go to the source code of this file.

Classes

struct  bins_t
 
struct  __hts_idx_t
 

Macros

#define KS_BGZF   1
 
#define HTS_MIN_MARKER_DIST   0x10000
 
#define META_BIN(idx)   ((idx)->n_bins + 1)
 
#define pair64_lt(a, b)   ((a).u < (b).u)
 

Functions

const char * hts_version ()
 
htsFilehts_open (const char *fn, const char *mode)
 
int hts_close (htsFile *fp)
 
int hts_set_threads (htsFile *fp, int n)
 
int hts_set_fai_filename (htsFile *fp, const char *fn_aux)
 
BGZFhts_get_bgzfp (htsFile *fp)
 
int hts_useek (htsFile *fp, long uoffset, int where)
 
long hts_utell (htsFile *fp)
 
int hts_getline (htsFile *fp, int delimiter, kstring_t *str)
 
char ** hts_readlist (const char *string, int is_file, int *_n)
 
char ** hts_readlines (const char *fn, int *_n)
 
int hts_file_type (const char *fname)
 
typedef khash_t (bin)
 
hts_idx_thts_idx_init (int n, int fmt, uint64_t offset0, int min_shift, int n_lvls)
 
void hts_idx_finish (hts_idx_t *idx, uint64_t final_offset)
 
int hts_idx_push (hts_idx_t *idx, int tid, int beg, int end, uint64_t offset, int is_mapped)
 
void hts_idx_destroy (hts_idx_t *idx)
 
void hts_idx_save (const hts_idx_t *idx, const char *fn, int fmt)
 
hts_idx_thts_idx_load_local (const char *fn, int fmt)
 
void hts_idx_set_meta (hts_idx_t *idx, int l_meta, uint8_t *meta, int is_copy)
 
uint8_thts_idx_get_meta (hts_idx_t *idx, int *l_meta)
 
const char ** hts_idx_seqnames (const hts_idx_t *idx, int *n, hts_id2name_f getid, void *hdr)
 
int hts_idx_get_stat (const hts_idx_t *idx, int tid, uint64_t *mapped, uint64_t *unmapped)
 
uint64_t hts_idx_get_n_no_coor (const hts_idx_t *idx)
 
hts_itr_thts_itr_query (const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec)
 
void hts_itr_destroy (hts_itr_t *iter)
 
const char * hts_parse_reg (const char *s, int *beg, int *end)
 
hts_itr_thts_itr_querys (const hts_idx_t *idx, const char *reg, hts_name2id_f getid, void *hdr, hts_itr_query_func *itr_query, hts_readrec_func *readrec)
 
int hts_itr_next (BGZF *fp, hts_itr_t *iter, void *r, void *data)
 
char * hts_idx_getfn (const char *fn, const char *ext)
 
hts_idx_thts_idx_load (const char *fn, int fmt)
 

Variables

int hts_verbose = 3
 
const unsigned char seq_nt16_table [256]
 
const char seq_nt16_str [] = "=ACMGRSVTWYHKDBN"
 
 lidx_t
 

Macro Definition Documentation

#define HTS_MIN_MARKER_DIST   0x10000

Definition at line 430 of file hts.c.

#define KS_BGZF   1

Definition at line 16 of file hts.c.

#define META_BIN (   idx)    ((idx)->n_bins + 1)

Definition at line 434 of file hts.c.

#define pair64_lt (   a,
 
)    ((a).u < (b).u)

Definition at line 436 of file hts.c.

Function Documentation

int hts_close ( htsFile fp)

Close a file handle, flushing buffered data for output streams

Parameters
fpThe file handle to be closed
Returns
0 for success, or negative if an error occurred.

Definition at line 194 of file hts.c.

int hts_file_type ( const char *  fname)

Definition at line 396 of file hts.c.

BGZF* hts_get_bgzfp ( htsFile fp)

Definition at line 259 of file hts.c.

int hts_getline ( htsFile fp,
int  delimiter,
kstring_t str 
)

Definition at line 285 of file hts.c.

void hts_idx_destroy ( hts_idx_t idx)

Definition at line 698 of file hts.c.

void hts_idx_finish ( hts_idx_t idx,
uint64_t  final_offset 
)

Definition at line 619 of file hts.c.

uint8_t* hts_idx_get_meta ( hts_idx_t idx,
int *  l_meta 
)

Definition at line 981 of file hts.c.

uint64_t hts_idx_get_n_no_coor ( const hts_idx_t idx)

Definition at line 1026 of file hts.c.

int hts_idx_get_stat ( const hts_idx_t idx,
int  tid,
uint64_t mapped,
uint64_t unmapped 
)

Definition at line 1007 of file hts.c.

char* hts_idx_getfn ( const char *  fn,
const char *  ext 
)

Definition at line 1294 of file hts.c.

hts_idx_t* hts_idx_init ( int  n,
int  fmt,
uint64_t  offset0,
int  min_shift,
int  n_lvls 
)

Definition at line 513 of file hts.c.

hts_idx_t* hts_idx_load ( const char *  fn,
int  fmt 
)

Definition at line 1316 of file hts.c.

hts_idx_t* hts_idx_load_local ( const char *  fn,
int  fmt 
)

Definition at line 893 of file hts.c.

int hts_idx_push ( hts_idx_t idx,
int  tid,
int  beg,
int  end,
uint64_t  offset,
int  is_mapped 
)

Definition at line 635 of file hts.c.

void hts_idx_save ( const hts_idx_t idx,
const char *  fn,
int  fmt 
)

Definition at line 804 of file hts.c.

const char** hts_idx_seqnames ( const hts_idx_t idx,
int *  n,
hts_id2name_f  getid,
void *  hdr 
)

Definition at line 987 of file hts.c.

void hts_idx_set_meta ( hts_idx_t idx,
int  l_meta,
uint8_t meta,
int  is_copy 
)

Definition at line 971 of file hts.c.

void hts_itr_destroy ( hts_itr_t iter)

Definition at line 1166 of file hts.c.

int hts_itr_next ( BGZF fp,
hts_itr_t iter,
void *  r,
void *  data 
)

Definition at line 1220 of file hts.c.

hts_itr_t* hts_itr_query ( const hts_idx_t idx,
int  tid,
int  beg,
int  end,
hts_readrec_func readrec 
)

Definition at line 1053 of file hts.c.

hts_itr_t* hts_itr_querys ( const hts_idx_t idx,
const char *  reg,
hts_name2id_f  getid,
void *  hdr,
hts_itr_query_func itr_query,
hts_readrec_func readrec 
)

Definition at line 1202 of file hts.c.

htsFile* hts_open ( const char *  fn,
const char *  mode 
)

Definition at line 100 of file hts.c.

const char* hts_parse_reg ( const char *  s,
int *  beg,
int *  end 
)

Definition at line 1171 of file hts.c.

char** hts_readlines ( const char *  fn,
int *  _n 
)

Definition at line 347 of file hts.c.

char** hts_readlist ( const char *  fn,
int  is_file,
int *  _n 
)

Parse comma-separated list or read list from a file

Parameters
listFile name or comma-separated list
is_file
_nSize of the output array (number of items read)
Returns
NULL on failure or pointer to newly allocated array of strings

Definition at line 293 of file hts.c.

int hts_set_fai_filename ( htsFile fp,
const char *  fn_aux 
)

Set .fai filename for a file opened for reading

Returns
0 for success, negative on failure Called before *_hdr_read(), this provides the name of a .fai file used to provide a reference list if the htsFile contains no headers.

Definition at line 245 of file hts.c.

int hts_set_threads ( htsFile fp,
int  n 
)

Create extra threads to aid compress/decompression for this file

Parameters
fpThe file handle
nThe number of worker threads to create
Returns
0 for success, or negative if an error occurred. THIS THREADING API IS LIKELY TO CHANGE IN FUTURE.

Definition at line 236 of file hts.c.

int hts_useek ( htsFile fp,
long  uoffset,
int  where 
)

Definition at line 266 of file hts.c.

long hts_utell ( htsFile fp)

Definition at line 277 of file hts.c.

const char* hts_version ( void  )

Get the htslib version number

Returns
For released versions, a string like "N.N[.N]"; or git describe output if using a library built within a Git repository.

Definition at line 29 of file hts.c.

typedef khash_t ( bin  )

Definition at line 449 of file hts.c.

Variable Documentation

int hts_verbose = 3

Definition at line 27 of file hts.c.

lidx_t

Definition at line 454 of file hts.c.

const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"

Table for converting a 4-bit encoded nucleotide to a letter.

Definition at line 54 of file hts.c.

const unsigned char seq_nt16_table[256]
Initial value:
= {
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
1, 2, 4, 8, 15,15,15,15, 15,15,15,15, 15, 0 ,15,15,
15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15,
15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15,
15, 1,14, 2, 13,15,15, 4, 11,15,15,12, 15, 3,15,15,
15,15, 5, 6, 8,15, 7, 9, 15,10,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15
}

Table for converting a nucleotide character to the 4-bit encoding.

Definition at line 34 of file hts.c.