LRez  v2.1
Classes | Macros | Functions
gzIndex.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <iostream>
#include <fstream>
Include dependency graph for gzIndex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  point
 
struct  access
 

Macros

#define local   static
 
#define SPAN   1048576L /* desired distance between access points */
 
#define WINSIZE   32768U /* sliding window size */
 
#define CHUNK   16384 /* file input buffer size */
 

Functions

void freeGzIndex (struct access *index)
 
void serializeGzIndex (struct access *index, string outputFile)
 
struct accessdeserializeGzIndex (struct access *index, string inputFile)
 
int buildGzIndex (string gzFile, off_t span, struct access **built)
 
int buildGzIndex_Stream (FILE *in, off_t span, struct access **built)
 
int extract (string gzFile, struct access *index, off_t offset, unsigned char *buf, int len)
 
int extract_Stream (FILE *in, struct access *index, off_t offset, unsigned char *buf, int len)
 
string extractFastqReadFromOffset (FILE *in, struct access *index, off_t offset)
 

Macro Definition Documentation

◆ CHUNK

#define CHUNK   16384 /* file input buffer size */

Definition at line 73 of file gzIndex.h.

◆ local

#define local   static

Definition at line 69 of file gzIndex.h.

◆ SPAN

#define SPAN   1048576L /* desired distance between access points */

Definition at line 71 of file gzIndex.h.

◆ WINSIZE

#define WINSIZE   32768U /* sliding window size */

Definition at line 72 of file gzIndex.h.

Function Documentation

◆ buildGzIndex()

int buildGzIndex ( string  gzFile,
off_t  span,
struct access **  built 
)

Index a given gzip file.

Parameters
gzFilegzip file to build the index for
spanbuild access points every span bits of uncompressed output
builtstructure where to store the index
Exceptions
ios_base::failurethrown if gzFile could not be open
Returns
the number of access points on success (>=1), Z_MEM_ERROR for out of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file read error. On success, *built points to the resulting index.

◆ buildGzIndex_Stream()

int buildGzIndex_Stream ( FILE *  in,
off_t  span,
struct access **  built 
)

Index a given gzip file.

Parameters
FILEopen on the desired gzip file to build the index for
spanbuild access points every span bits of uncompressed output
builtstructure where to store the index
Returns
the number of access points on success (>=1), Z_MEM_ERROR for out of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file read error. On success, *built points to the resulting index.

◆ deserializeGzIndex()

struct access* deserializeGzIndex ( struct access index,
string  inputFile 
)

Deserialize a gzip index from a file.

Parameters
indexindex to fill
inputFilefile where the index is stored
Exceptions
ios_base::failurethrown if inputFile could not be open
Returns
the index populated with the contents of the file

◆ extract()

int extract ( string  gzFile,
struct access index,
off_t  offset,
unsigned char *  buf,
int  len 
)

Extract data starting from a given offset off the uncompressed file, using the index.

Parameters
gzFilegzip to extract data from
indexthe index of the gzip file
offsetoffset to start extracting data from
bufbuffer where to store the extracted data
lennumber of bytes to extract
Exceptions
ios_base::failurethrown if gzFile could not be open
Returns
bytes read or negative for error (Z_DATA_ERROR or Z_MEM_ERROR)

◆ extract_Stream()

int extract_Stream ( FILE *  in,
struct access index,
off_t  offset,
unsigned char *  buf,
int  len 
)

Extract data starting from a given offset off the uncompressed file, using the index.

Parameters
inFILE open on the desired gzip file
indexthe index of the gzip file
offsetoffset to start extracting data from
bufbuffer where to store the extracted data
lennumber of bytes to extract
Returns
bytes read or negative for error (Z_DATA_ERROR or Z_MEM_ERROR)

◆ extractFastqReadFromOffset()

string extractFastqReadFromOffset ( FILE *  in,
struct access index,
off_t  offset 
)

Extract the fastq format read at the specified offset.

Parameters
inFILE open on the desired gzip file
indexthe index of the gzip file
offsetoffset off the read to extract
Returns
the extracted read in fastq format

◆ freeGzIndex()

void freeGzIndex ( struct access index)

Deallocate an index built by build_index()

Parameters
indexindex to deallocate

◆ serializeGzIndex()

void serializeGzIndex ( struct access index,
string  outputFile 
)

Serialize the gzip index into a file.

Parameters
indexindex to serialize
outputFilefile where to store the index
Exceptions
ios_base::failurethrown if outputFile could not be open