NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions
synced_bcf_reader.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include "htslib/synced_bcf_reader.h"
#include "htslib/kseq.h"
#include "htslib/khash_str2int.h"

Go to the source code of this file.

Classes

struct  region1_t
 
struct  _region_t
 

Macros

#define MAX_CSI_COOR   0x7fffffff
 

Typedefs

typedef struct _region_t region_t
 

Functions

int bcf_sr_set_regions (bcf_srs_t *readers, const char *regions, int is_file)
 
int bcf_sr_set_targets (bcf_srs_t *readers, const char *targets, int is_file, int alleles)
 
int bcf_sr_add_reader (bcf_srs_t *files, const char *fname)
 
bcf_srs_tbcf_sr_init (void)
 
void bcf_sr_destroy (bcf_srs_t *files)
 
void bcf_sr_remove_reader (bcf_srs_t *files, int i)
 
void debug_buffer (FILE *fp, bcf_sr_t *reader)
 
void debug_buffers (FILE *fp, bcf_srs_t *files)
 
int _reader_next_line (bcf_srs_t *files)
 
int bcf_sr_next_line (bcf_srs_t *files)
 
int bcf_sr_seek (bcf_srs_t *readers, const char *seq, int pos)
 
int bcf_sr_set_samples (bcf_srs_t *files, const char *fname, int is_file)
 
bcf_sr_regions_tbcf_sr_regions_init (const char *regions, int is_file, int ichr, int ifrom, int ito)
 
void bcf_sr_regions_destroy (bcf_sr_regions_t *reg)
 
int bcf_sr_regions_seek (bcf_sr_regions_t *reg, const char *seq)
 
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 *reg)
 

Macro Definition Documentation

#define MAX_CSI_COOR   0x7fffffff

Definition at line 12 of file synced_bcf_reader.c.

Typedef Documentation

typedef struct _region_t region_t

Function Documentation

int _reader_next_line ( bcf_srs_t files)

Definition at line 540 of file synced_bcf_reader.c.

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.

Definition at line 83 of file synced_bcf_reader.c.

void bcf_sr_destroy ( bcf_srs_t readers)

Destroy bcf_srs_t struct

Definition at line 198 of file synced_bcf_reader.c.

bcf_srs_t* bcf_sr_init ( void  )

Init bcf_srs_t struct

Definition at line 178 of file synced_bcf_reader.c.

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.

Definition at line 609 of file synced_bcf_reader.c.

void bcf_sr_regions_destroy ( bcf_sr_regions_t reg)

Definition at line 976 of file synced_bcf_reader.c.

void bcf_sr_regions_flush ( bcf_sr_regions_t reg)

Definition at line 1179 of file synced_bcf_reader.c.

bcf_sr_regions_t* bcf_sr_regions_init ( const char *  regions,
int  is_file,
int  ichr,
int  ifrom,
int  ito 
)

Definition at line 909 of file synced_bcf_reader.c.

int bcf_sr_regions_next ( bcf_sr_regions_t reg)

Definition at line 1017 of file synced_bcf_reader.c.

int bcf_sr_regions_overlap ( bcf_sr_regions_t reg,
const char *  seq,
int  start,
int  end 
)

Definition at line 1151 of file synced_bcf_reader.c.

int bcf_sr_regions_seek ( bcf_sr_regions_t reg,
const char *  seq 
)

Definition at line 1001 of file synced_bcf_reader.c.

void bcf_sr_remove_reader ( bcf_srs_t files,
int  i 
)

Definition at line 213 of file synced_bcf_reader.c.

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

Definition at line 646 of file synced_bcf_reader.c.

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

Definition at line 60 of file synced_bcf_reader.c.

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.

Definition at line 664 of file synced_bcf_reader.c.

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.

Definition at line 74 of file synced_bcf_reader.c.

void debug_buffer ( FILE *  fp,
bcf_sr_t reader 
)

Definition at line 272 of file synced_bcf_reader.c.

void debug_buffers ( FILE *  fp,
bcf_srs_t files 
)

Definition at line 285 of file synced_bcf_reader.c.