NVBIO
|
Go to the source code of this file.
Macros | |
#define | ITF8_MACROS |
Functions | |
int | cram_load_reference (cram_fd *fd, char *fn) |
int | refs2id (refs_t *r, SAM_hdr *bfd) |
void | refs_free (refs_t *r) |
char * | cram_get_ref (cram_fd *fd, int id, int start, int end) |
void | cram_ref_incr (refs_t *r, int id) |
void | cram_ref_decr (refs_t *r, int id) |
cram_container * | cram_new_container (int nrec, int nslice) |
void | cram_free_container (cram_container *c) |
cram_container * | cram_read_container (cram_fd *fd) |
int | cram_write_container (cram_fd *fd, cram_container *h) |
int | cram_flush_container (cram_fd *fd, cram_container *c) |
int | cram_flush_container_mt (cram_fd *fd, cram_container *c) |
cram_block_compression_hdr * | cram_new_compression_header (void) |
void | cram_free_compression_header (cram_block_compression_hdr *hdr) |
void | cram_free_slice_header (cram_block_slice_hdr *hdr) |
void | cram_free_slice (cram_slice *s) |
cram_slice * | cram_new_slice (enum cram_content_type type, int nrecs) |
cram_slice * | cram_read_slice (cram_fd *fd) |
cram_file_def * | cram_read_file_def (cram_fd *fd) |
int | cram_write_file_def (cram_fd *fd, cram_file_def *def) |
void | cram_free_file_def (cram_file_def *def) |
SAM_hdr * | cram_read_SAM_hdr (cram_fd *fd) |
int | cram_write_SAM_hdr (cram_fd *fd, SAM_hdr *hdr) |
cram_fd * | cram_open (const char *filename, const char *mode) |
cram_fd * | cram_dopen (cram_FILE *fp, const char *filename, const char *mode) |
int | cram_close (cram_fd *fd) |
int | cram_seek (cram_fd *fd, off_t offset, int whence) |
int | cram_flush (cram_fd *fd) |
int | cram_eof (cram_fd *fd) |
int | cram_set_option (cram_fd *fd, enum cram_option opt,...) |
int | cram_set_voption (cram_fd *fd, enum cram_option opt, va_list args) |
int | cram_set_header (cram_fd *fd, SAM_hdr *hdr) |
#define | CRAM_KEY(a, b) (((a)<<8)|((b))) |
#define | itf8_get(c, v) (((uc)(c)[0]<0x80)?(*(v)=(uc)(c)[0],1):(((uc)(c)[0]<0xc0)?(*(v)=(((uc)(c)[0]<<8)|(uc)(c)[1])&0x3fff,2):(((uc)(c)[0]<0xe0)?(*(v)=(((uc)(c)[0]<<16)|((uc)(c)[1]<<8)|(uc)(c)[2])&0x1fffff,3):(((uc)(c)[0]<0xf0)?(*(v)=(((uc)(c)[0]<<24)|((uc)(c)[1]<<16)|((uc)(c)[2]<<8)|(uc)(c)[3])&0x0fffffff,4):(*(v)=(((uc)(c)[0]&0x0f)<<28)|((uc)(c)[1]<<20)|((uc)(c)[2]<<12)|((uc)(c)[3]<<4)|((uc)(c)[4]&0x0f),5))))) |
#define | itf8_put(c, v) ((!((v)&~0x7f))?((c)[0]=(v),1):(!((v)&~0x3fff))?((c)[0]=((v)>>8)|0x80,(c)[1]=(v)&0xff,2):(!((v)&~0x1fffff))?((c)[0]=((v)>>16)|0xc0,(c)[1]=((v)>>8)&0xff,(c)[2]=(v)&0xff,3):(!((v)&~0xfffffff))?((c)[0]=((v)>>24)|0xe0,(c)[1]=((v)>>16)&0xff,(c)[2]=((v)>>8)&0xff,(c)[3]=(v)&0xff,4):((c)[0]=0xf0|(((v)>>28)&0xff),(c)[1]=((v)>>20)&0xff,(c)[2]=((v)>>12)&0xff,(c)[3]=((v)>>4)&0xff,(c)[4]=(v)&0xf,5)) |
#define | itf8_size(v) ((!((v)&~0x7f))?1:(!((v)&~0x3fff))?2:(!((v)&~0x1fffff))?3:(!((v)&~0xfffffff))?4:5) |
int | itf8_decode (cram_fd *fd, int32_t *val) |
int | itf8_put_blk (cram_block *blk, int val) |
#define | BLOCK_SIZE(b) ((b)->byte) |
#define | BLOCK_DATA(b) ((b)->data) |
#define | BLOCK_END(b) (&(b)->data[(b)->byte]) |
#define | BLOCK_RESIZE(b, l) |
#define | BLOCK_GROW(b, l) BLOCK_RESIZE((b), BLOCK_SIZE((b)) + (l)) |
#define | BLOCK_APPEND(b, s, l) |
#define | BLOCK_APPEND_CHAR(b, c) |
#define | BLOCK_APPENDF_1(b, buf, fmt, a1) |
#define | BLOCK_APPENDF_2(b, buf, fmt, a1, a2) |
#define | BLOCK_UPLEN(b) (b)->comp_size = (b)->uncomp_size = BLOCK_SIZE((b)) |
cram_block * | cram_new_block (enum cram_content_type content_type, int content_id) |
cram_block * | cram_read_block (cram_fd *fd) |
int | cram_write_block (cram_fd *fd, cram_block *b) |
void | cram_free_block (cram_block *b) |
char * | zlib_mem_inflate (char *cdata, size_t csize, size_t *size) |
int | cram_uncompress_block (cram_block *b) |
int | cram_compress_block (cram_fd *fd, cram_block *b, cram_metrics *metrics, int level, int strat, int level2, int strat2) |
cram_metrics * | cram_new_metrics (void) |
char * | cram_block_method2str (enum cram_block_method m) |
char * | cram_content_type2str (enum cram_content_type t) |
Include cram.h instead.
This is an internal part of the CRAM system and is automatically included when you #include cram.h.
Implements the low level CRAM I/O primitives. This includes basic data types such as byte, int, ITF-8, maps, bitwise I/O, etc.
Definition in file cram_io.h.
#define BLOCK_APPEND | ( | b, | |
s, | |||
l | |||
) |
#define BLOCK_APPEND_CHAR | ( | b, | |
c | |||
) |
#define BLOCK_APPENDF_1 | ( | b, | |
buf, | |||
fmt, | |||
a1 | |||
) |
#define BLOCK_APPENDF_2 | ( | b, | |
buf, | |||
fmt, | |||
a1, | |||
a2 | |||
) |
#define BLOCK_GROW | ( | b, | |
l | |||
) | BLOCK_RESIZE((b), BLOCK_SIZE((b)) + (l)) |
#define BLOCK_RESIZE | ( | b, | |
l | |||
) |
#define BLOCK_UPLEN | ( | b) | (b)->comp_size = (b)->uncomp_size = BLOCK_SIZE((b)) |
#define CRAM_KEY | ( | a, | |
b | |||
) | (((a)<<8)|((b))) |
#define itf8_get | ( | c, | |
v | |||
) | (((uc)(c)[0]<0x80)?(*(v)=(uc)(c)[0],1):(((uc)(c)[0]<0xc0)?(*(v)=(((uc)(c)[0]<<8)|(uc)(c)[1])&0x3fff,2):(((uc)(c)[0]<0xe0)?(*(v)=(((uc)(c)[0]<<16)|((uc)(c)[1]<<8)|(uc)(c)[2])&0x1fffff,3):(((uc)(c)[0]<0xf0)?(*(v)=(((uc)(c)[0]<<24)|((uc)(c)[1]<<16)|((uc)(c)[2]<<8)|(uc)(c)[3])&0x0fffffff,4):(*(v)=(((uc)(c)[0]&0x0f)<<28)|((uc)(c)[1]<<20)|((uc)(c)[2]<<12)|((uc)(c)[3]<<4)|((uc)(c)[4]&0x0f),5))))) |
#define itf8_put | ( | c, | |
v | |||
) | ((!((v)&~0x7f))?((c)[0]=(v),1):(!((v)&~0x3fff))?((c)[0]=((v)>>8)|0x80,(c)[1]=(v)&0xff,2):(!((v)&~0x1fffff))?((c)[0]=((v)>>16)|0xc0,(c)[1]=((v)>>8)&0xff,(c)[2]=(v)&0xff,3):(!((v)&~0xfffffff))?((c)[0]=((v)>>24)|0xe0,(c)[1]=((v)>>16)&0xff,(c)[2]=((v)>>8)&0xff,(c)[3]=(v)&0xff,4):((c)[0]=0xf0|(((v)>>28)&0xff),(c)[1]=((v)>>20)&0xff,(c)[2]=((v)>>12)&0xff,(c)[3]=((v)>>4)&0xff,(c)[4]=(v)&0xf,5)) |
#define itf8_size | ( | v) | ((!((v)&~0x7f))?1:(!((v)&~0x3fff))?2:(!((v)&~0x1fffff))?3:(!((v)&~0xfffffff))?4:5) |
char* cram_block_method2str | ( | enum cram_block_method | m) |
int cram_close | ( | cram_fd * | fd) |
int cram_compress_block | ( | cram_fd * | fd, |
cram_block * | b, | ||
cram_metrics * | metrics, | ||
int | level, | ||
int | strat, | ||
int | level2, | ||
int | strat2 | ||
) |
Compresses a block.
Compresses a block using one of two different zlib strategies. If we only want one choice set strat2 to be -1.
The logic here is that sometimes Z_RLE does a better job than Z_FILTERED or Z_DEFAULT_STRATEGY on quality data. If so, we'd rather use it as it is significantly faster.
char* cram_content_type2str | ( | enum cram_content_type | t) |
Opens an existing stream for reading or writing.
cram_FILE is either htslib's hFILE or stdio's FILE, depending on how cram_structs.h has been configured.
int cram_eof | ( | cram_fd * | fd) |
int cram_flush_container | ( | cram_fd * | fd, |
cram_container * | c | ||
) |
int cram_flush_container_mt | ( | cram_fd * | fd, |
cram_container * | c | ||
) |
void cram_free_block | ( | cram_block * | b) |
void cram_free_compression_header | ( | cram_block_compression_hdr * | hdr) |
Frees a cram_block_compression_hdr
void cram_free_container | ( | cram_container * | c) |
void cram_free_file_def | ( | cram_file_def * | def) |
Frees a cram_file_def structure.
void cram_free_slice | ( | cram_slice * | s) |
void cram_free_slice_header | ( | cram_block_slice_hdr * | hdr) |
char* cram_get_ref | ( | cram_fd * | fd, |
int | id, | ||
int | start, | ||
int | end | ||
) |
Returns a portion of a reference sequence from start to end inclusive.
The returned pointer is owned by the cram_file fd and should not be freed by the caller. It is valid only until the next cram_get_ref is called with the same fd parameter (so is thread-safe if given multiple files).
To return the entire reference sequence, specify start as 1 and end as 0.
int cram_load_reference | ( | cram_fd * | fd, |
char * | fn | ||
) |
cram_block* cram_new_block | ( | enum cram_content_type | content_type, |
int | content_id | ||
) |
CRAM blocks - the dynamically growable data block. We have code to create, update, (un)compress and read/write.
These are derived from the deflate_interlaced.c blocks, but with the CRAM extension of content types and IDs.
Allocates a new cram_block structure with a specified content_type and id.
cram_block_compression_hdr* cram_new_compression_header | ( | void | ) |
cram_container* cram_new_container | ( | int | nrec, |
int | nslice | ||
) |
Containers
Creates a new container, specifying the maximum number of slices and records permitted.
cram_metrics* cram_new_metrics | ( | void | ) |
cram_slice* cram_new_slice | ( | enum cram_content_type | type, |
int | nrecs | ||
) |
Creates a new empty slice in memory, for subsequent writing to disk.
cram_block* cram_read_block | ( | cram_fd * | fd) |
Reads a block from a cram file.
cram_container* cram_read_container | ( | cram_fd * | fd) |
Reads a container header.
cram_file_def* cram_read_file_def | ( | cram_fd * | fd) |
cram_slice* cram_read_slice | ( | cram_fd * | fd) |
Loads an entire slice.
FIXME: In 1.0 the native unit of slices within CRAM is broken as slices contain references to objects in other slices. To work around this while keeping the slice oriented outer loop we read all slices and stitch them together into a fake large slice instead.
int cram_set_option | ( | cram_fd * | fd, |
enum cram_option | opt, | ||
... | |||
) |
Sets options on the cram_fd.
See CRAM_OPT_* definitions in cram_structs.h. Use this immediately after opening.
int cram_set_voption | ( | cram_fd * | fd, |
enum cram_option | opt, | ||
va_list | args | ||
) |
Sets options on the cram_fd.
See CRAM_OPT_* definitions in cram_structs.h. Use this immediately after opening.
int cram_uncompress_block | ( | cram_block * | b) |
int cram_write_block | ( | cram_fd * | fd, |
cram_block * | b | ||
) |
int cram_write_container | ( | cram_fd * | fd, |
cram_container * | h | ||
) |
int cram_write_file_def | ( | cram_fd * | fd, |
cram_file_def * | def | ||
) |
Writes a cram_file_def structure to cram_fd.
int itf8_put_blk | ( | cram_block * | blk, |
int | val | ||
) |