Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Enumerations | Functions
synced_bcf_reader.h File Reference
#include "hts.h"
#include "vcf.h"
#include "tbx.h"

Go to the source code of this file.

Classes

struct  _bcf_sr_regions_t
 
struct  bcf_sr_t
 
struct  bcf_srs_t
 

Macros

#define COLLAPSE_NONE   0
 
#define COLLAPSE_SNPS   1
 
#define COLLAPSE_INDELS   2
 
#define COLLAPSE_ANY   4
 
#define COLLAPSE_SOME   8
 
#define COLLAPSE_BOTH   (COLLAPSE_SNPS|COLLAPSE_INDELS)
 
#define bcf_sr_has_line(readers, i)   (readers)->has_line[i]
 
#define bcf_sr_get_line(_readers, i)   ((_readers)->has_line[i] ? ((_readers)->readers[i].buffer[0]) : NULL)
 
#define bcf_sr_region_done(_readers, i)   (!(_readers)->has_line[i] && !(_readers)->readers[i].nbuffer ? 1 : 0)
 
#define bcf_sr_get_header(_readers, i)   (_readers)->readers[i].header
 
#define bcf_sr_get_reader(_readers, i)   &((_readers)->readers[i])
 

Typedefs

typedef struct _bcf_sr_regions_t bcf_sr_regions_t
 

Enumerations

enum  bcf_sr_error {
  open_failed, not_bgzf, idx_load_failed, file_type_error,
  api_usage_error, header_error
}
 

Functions

bcf_srs_tbcf_sr_init (void)
 
void bcf_sr_destroy (bcf_srs_t *readers)
 
char * bcf_sr_strerror (int errnum)
 
int bcf_sr_add_reader (bcf_srs_t *readers, const char *fname)
 
void bcf_sr_remove_reader (bcf_srs_t *files, int i)
 
int bcf_sr_next_line (bcf_srs_t *readers)
 
int bcf_sr_seek (bcf_srs_t *readers, const char *seq, int pos)
 
int bcf_sr_set_samples (bcf_srs_t *readers, const char *samples, int is_file)
 
int bcf_sr_set_targets (bcf_srs_t *readers, const char *targets, int is_file, int alleles)
 
int bcf_sr_set_regions (bcf_srs_t *readers, const char *regions, int is_file)
 
bcf_sr_regions_tbcf_sr_regions_init (const char *regions, int is_file, int chr, int from, int to)
 
void bcf_sr_regions_destroy (bcf_sr_regions_t *regions)
 
int bcf_sr_regions_seek (bcf_sr_regions_t *regions, const char *chr)
 
int bcf_sr_regions_next (bcf_sr_regions_t *reg)
 
int bcf_sr_regions_overlap (bcf_sr_regions_t *reg, const char *seq, int start, int end)
 
void bcf_sr_regions_flush (bcf_sr_regions_t *regs)
 

Macro Definition Documentation

#define bcf_sr_get_header (   _readers,
 
)    (_readers)->readers[i].header
#define bcf_sr_get_line (   _readers,
 
)    ((_readers)->has_line[i] ? ((_readers)->readers[i].buffer[0]) : NULL)
#define bcf_sr_get_reader (   _readers,
 
)    &((_readers)->readers[i])
#define bcf_sr_has_line (   readers,
 
)    (readers)->has_line[i]
#define bcf_sr_region_done (   _readers,
 
)    (!(_readers)->has_line[i] && !(_readers)->readers[i].nbuffer ? 1 : 0)
#define COLLAPSE_ANY   4
#define COLLAPSE_BOTH   (COLLAPSE_SNPS|COLLAPSE_INDELS)
#define COLLAPSE_INDELS   2
#define COLLAPSE_NONE   0
#define COLLAPSE_SNPS   1
#define COLLAPSE_SOME   8

Typedef Documentation

Enumeration Type Documentation

Enumerator
open_failed 
not_bgzf 
idx_load_failed 
file_type_error 
api_usage_error 
header_error 

Function Documentation

int bcf_sr_add_reader ( bcf_srs_t readers,
const char *  fname 
)

bcf_sr_add_reader() - open new reader : holder of the open readers : the VCF file

Returns 1 if the call succeeded, or 0 on error.

See also the bcf_srs_t data structure for parameters controlling the reader's logic.

void bcf_sr_destroy ( bcf_srs_t readers)

Destroy bcf_srs_t struct

bcf_srs_t* bcf_sr_init ( void  )

Init bcf_srs_t struct

int bcf_sr_next_line ( bcf_srs_t readers)

bcf_sr_next_line() - the iterator : holder of the open readers

Returns the number of readers which have the current line (bcf_sr_t.buffer[0]) set at this position. Use the bcf_sr_has_line macro to determine which of the readers are set.

void bcf_sr_regions_destroy ( bcf_sr_regions_t regions)
void bcf_sr_regions_flush ( bcf_sr_regions_t regs)
bcf_sr_regions_t* bcf_sr_regions_init ( const char *  regions,
int  is_file,
int  chr,
int  from,
int  to 
)
int bcf_sr_regions_next ( bcf_sr_regions_t reg)
int bcf_sr_regions_overlap ( bcf_sr_regions_t reg,
const char *  seq,
int  start,
int  end 
)
int bcf_sr_regions_seek ( bcf_sr_regions_t regions,
const char *  chr 
)
void bcf_sr_remove_reader ( bcf_srs_t files,
int  i 
)
int bcf_sr_seek ( bcf_srs_t readers,
const char *  seq,
int  pos 
)

bcf_sr_seek() - set all readers to selected position : sequence name; NULL to seek to start : 0-based coordinate

int bcf_sr_set_regions ( bcf_srs_t readers,
const char *  regions,
int  is_file 
)
int bcf_sr_set_samples ( bcf_srs_t readers,
const char *  samples,
int  is_file 
)

bcf_sr_set_samples() - sets active samples : holder of the open readers : this can be one of: file name with one sample per line; or column-separated list of samples; or '-' for a list of samples shared by all files. If first character is the exclamation mark, all but the listed samples are included. : 0: list of samples; 1: file with sample names

Returns 1 if the call succeeded, or 0 on error.

int bcf_sr_set_targets ( bcf_srs_t readers,
const char *  targets,
int  is_file,
int  alleles 
)

bcf_sr_set_targets(), bcf_sr_set_regions() - init targets/regions : holder of the open readers : list of regions, one-based and inclusive. : 0: targets is a comma-separated list of regions (chr,chr:from-to) 1: targets is a tabix indexed file with a list of regions (<chr,pos> or <chr,from,to>)

Returns 0 if the call succeeded, or -1 on error.

Both functions behave the same way, unlisted positions will be skipped by bcf_sr_next_line(). However, there is an important difference: regions use index to jump to desired positions while targets streams the whole files and merely skip unlisted positions.

Moreover, bcf_sr_set_targets() accepts an optional parameter $alleles which is intepreted as a 1-based column index in the tab-delimited file where alleles are listed. This in principle enables to perform the COLLAPSE_* logic also with tab-delimited files. However, the current implementation considers the alleles merely as a suggestion for prioritizing one of possibly duplicate VCF lines. It is up to the caller to examine targets->als if perfect match is sought after. Note that the duplicate positions in targets file are currently not supported. 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.

char* bcf_sr_strerror ( int  errnum)