#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include <iostream>
#include <fstream>
Go to the source code of this file.
|
| #define | local static |
| |
| #define | SPAN 1048576L /* desired distance between access points */ |
| |
| #define | WINSIZE 32768U /* sliding window size */ |
| |
| #define | CHUNK 16384 /* file input buffer size */ |
| |
|
| void | freeGzIndex (struct access *index) |
| |
| void | serializeGzIndex (struct access *index, string outputFile) |
| |
| struct access * | deserializeGzIndex (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) |
| |
◆ CHUNK
| #define CHUNK 16384 /* file input buffer size */ |
◆ local
◆ SPAN
| #define SPAN 1048576L /* desired distance between access points */ |
◆ WINSIZE
| #define WINSIZE 32768U /* sliding window size */ |
◆ buildGzIndex()
| int buildGzIndex |
( |
string |
gzFile, |
|
|
off_t |
span, |
|
|
struct access ** |
built |
|
) |
| |
Index a given gzip file.
- Parameters
-
| gzFile | gzip file to build the index for |
| span | build access points every span bits of uncompressed output |
| built | structure where to store the index |
- Exceptions
-
| ios_base::failure | thrown 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
-
| FILE | open on the desired gzip file to build the index for |
| span | build access points every span bits of uncompressed output |
| built | structure 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
-
| index | index to fill |
| inputFile | file where the index is stored |
- Exceptions
-
| ios_base::failure | thrown 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
-
| gzFile | gzip to extract data from |
| index | the index of the gzip file |
| offset | offset to start extracting data from |
| buf | buffer where to store the extracted data |
| len | number of bytes to extract |
- Exceptions
-
| ios_base::failure | thrown 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
-
| in | FILE open on the desired gzip file |
| index | the index of the gzip file |
| offset | offset to start extracting data from |
| buf | buffer where to store the extracted data |
| len | number 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
-
| in | FILE open on the desired gzip file |
| index | the index of the gzip file |
| offset | offset 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
-
◆ serializeGzIndex()
| void serializeGzIndex |
( |
struct access * |
index, |
|
|
string |
outputFile |
|
) |
| |
Serialize the gzip index into a file.
- Parameters
-
| index | index to serialize |
| outputFile | file where to store the index |
- Exceptions
-
| ios_base::failure | thrown if outputFile could not be open |