NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions
faidx.h File Reference

Go to the source code of this file.

Typedefs

typedef struct __faidx_t faidx_t
 

Functions

int fai_build (const char *fn)
 
void fai_destroy (faidx_t *fai)
 
faidx_tfai_load (const char *fn)
 
char * fai_fetch (const faidx_t *fai, const char *reg, int *len)
 
int faidx_fetch_nseq (const faidx_t *fai)
 
char * faidx_fetch_seq (const faidx_t *fai, const char *c_name, int p_beg_i, int p_end_i, int *len)
 

Typedef Documentation

typedef struct __faidx_t faidx_t

Definition at line 49 of file faidx.h.

Function Documentation

int fai_build ( const char *  fn)

Build index for a FASTA or bgzip-compressed FASTA file.

Parameters
fnFASTA file name
Returns
0 on success; or -1 on failure File "fn.fai" will be generated.

Definition at line 174 of file faidx.c.

void fai_destroy ( faidx_t fai)

Distroy a faidx_t struct.

Parameters
faiPointer to the struct to be destroyed

Definition at line 164 of file faidx.c.

char* fai_fetch ( const faidx_t fai,
const char *  reg,
int *  len 
)

Fetch the sequence in a region.

Parameters
faiPointer to the faidx_t struct
regRegion in the format "chr2:20,000-30,000"
lenLength of the region; -2 if seq not present, -1 general error
Returns
Pointer to the sequence; null on failure

The returned sequence is allocated by malloc family and should be destroyed by end users by calling free() on it.

Definition at line 300 of file faidx.c.

faidx_t* fai_load ( const char *  fn)

Load index from "fn.fai".

Parameters
fnFile name of the FASTA file

Definition at line 246 of file faidx.c.

int faidx_fetch_nseq ( const faidx_t fai)

Fetch the number of sequences.

Parameters
faiPointer to the faidx_t struct
Returns
The number of sequences

Definition at line 376 of file faidx.c.

char* faidx_fetch_seq ( const faidx_t fai,
const char *  c_name,
int  p_beg_i,
int  p_end_i,
int *  len 
)

Fetch the sequence in a region.

Parameters
faiPointer to the faidx_t struct
c_nameRegion name
p_beg_iBeginning position number (zero-based)
p_end_iEnd position number (zero-based)
lenLength of the region; -2 if c_name not present, -1 general error
Returns
Pointer to the sequence; null on failure

The returned sequence is allocated by malloc family and should be destroyed by end users by calling free() on it.

Definition at line 381 of file faidx.c.