NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Typedefs
kseq.h File Reference
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  __kstring_t
 

Macros

#define KS_SEP_SPACE   0
 
#define KS_SEP_TAB   1
 
#define KS_SEP_LINE   2
 
#define KS_SEP_MAX   2
 
#define __KS_TYPE(type_t)
 
#define ks_eof(ks)   ((ks)->is_eof && (ks)->begin >= (ks)->end)
 
#define ks_rewind(ks)   ((ks)->is_eof = (ks)->begin = (ks)->end = 0)
 
#define __KS_BASIC(SCOPE, type_t, __bufsize)
 
#define __KS_INLINED(__read)
 
#define KSTRING_T   kstring_t
 
#define kroundup32(x)   (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
 
#define __KS_GETUNTIL(SCOPE, __read)
 
#define KSTREAM_INIT2(SCOPE, type_t, __read, __bufsize)
 
#define KSTREAM_INIT(type_t, __read, __bufsize)   KSTREAM_INIT2(static, type_t, __read, __bufsize)
 
#define KSTREAM_DECLARE(type_t, __read)
 
#define kseq_rewind(ks)   ((ks)->last_char = (ks)->f->is_eof = (ks)->f->begin = (ks)->f->end = 0)
 
#define __KSEQ_BASIC(SCOPE, type_t)
 
#define __KSEQ_READ(SCOPE)
 
#define __KSEQ_TYPE(type_t)
 
#define KSEQ_INIT2(SCOPE, type_t, __read)
 
#define KSEQ_INIT(type_t, __read)   KSEQ_INIT2(static, type_t, __read)
 
#define KSEQ_DECLARE(type_t)
 

Typedefs

typedef struct __kstring_t kstring_t
 

Macro Definition Documentation

#define __KS_BASIC (   SCOPE,
  type_t,
  __bufsize 
)
Value:
SCOPE kstream_t *ks_init(type_t f) \
{ \
kstream_t *ks = (kstream_t*)calloc(1, sizeof(kstream_t)); \
ks->f = f; ks->bufsize = __bufsize; \
ks->buf = (unsigned char*)malloc(__bufsize); \
return ks; \
} \
SCOPE void ks_destroy(kstream_t *ks) \
{ \
if (!ks) return; \
free(ks->buf); \
free(ks); \
}

Definition at line 52 of file kseq.h.

#define __KS_GETUNTIL (   SCOPE,
  __read 
)

Definition at line 95 of file kseq.h.

#define __KS_INLINED (   __read)
Value:
static inline int ks_getc(kstream_t *ks) \
{ \
if (ks->is_eof && ks->begin >= ks->end) return -1; \
if (ks->begin >= ks->end) { \
ks->begin = 0; \
ks->end = __read(ks->f, ks->buf, ks->bufsize); \
if (ks->end < ks->bufsize) ks->is_eof = 1; \
if (ks->end == 0) return -1; \
} \
ks->seek_pos++; \
return (int)ks->buf[ks->begin++]; \
} \
static inline int ks_getuntil(kstream_t *ks, int delimiter, kstring_t *str, int *dret) \
{ return ks_getuntil2(ks, delimiter, str, dret, 0); }

Definition at line 67 of file kseq.h.

#define __KS_TYPE (   type_t)
Value:
typedef struct __kstream_t { \
int begin, end; \
int is_eof:2, bufsize:30; \
uint64_t seek_pos; \
type_t f; \
unsigned char *buf; \
} kstream_t;

Definition at line 40 of file kseq.h.

#define __KSEQ_BASIC (   SCOPE,
  type_t 
)
Value:
SCOPE kseq_t *kseq_init(type_t fd) \
{ \
kseq_t *s = (kseq_t*)calloc(1, sizeof(kseq_t)); \
s->f = ks_init(fd); \
return s; \
} \
SCOPE void kseq_destroy(kseq_t *ks) \
{ \
if (!ks) return; \
free(ks->name.s); free(ks->comment.s); free(ks->seq.s); free(ks->qual.s); \
ks_destroy(ks->f); \
free(ks); \
}

Definition at line 169 of file kseq.h.

#define __KSEQ_READ (   SCOPE)

Definition at line 189 of file kseq.h.

#define __KSEQ_TYPE (   type_t)
Value:
typedef struct { \
kstring_t name, comment, seq, qual; \
int last_char; \
kstream_t *f; \
} kseq_t;

Definition at line 231 of file kseq.h.

#define kroundup32 (   x)    (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))

Definition at line 92 of file kseq.h.

#define ks_eof (   ks)    ((ks)->is_eof && (ks)->begin >= (ks)->end)

Definition at line 49 of file kseq.h.

#define ks_rewind (   ks)    ((ks)->is_eof = (ks)->begin = (ks)->end = 0)

Definition at line 50 of file kseq.h.

#define KS_SEP_LINE   2

Definition at line 37 of file kseq.h.

#define KS_SEP_MAX   2

Definition at line 38 of file kseq.h.

#define KS_SEP_SPACE   0

Definition at line 35 of file kseq.h.

#define KS_SEP_TAB   1

Definition at line 36 of file kseq.h.

#define KSEQ_DECLARE (   type_t)
Value:
__KS_TYPE(type_t) \
__KSEQ_TYPE(type_t) \
extern kseq_t *kseq_init(type_t fd); \
void kseq_destroy(kseq_t *ks); \
int kseq_read(kseq_t *seq);

Definition at line 246 of file kseq.h.

#define KSEQ_INIT (   type_t,
  __read 
)    KSEQ_INIT2(static, type_t, __read)

Definition at line 244 of file kseq.h.

#define KSEQ_INIT2 (   SCOPE,
  type_t,
  __read 
)
Value:
KSTREAM_INIT(type_t, __read, 16384) \
__KSEQ_TYPE(type_t) \
__KSEQ_BASIC(SCOPE, type_t) \
__KSEQ_READ(SCOPE)

Definition at line 238 of file kseq.h.

#define kseq_rewind (   ks)    ((ks)->last_char = (ks)->f->is_eof = (ks)->f->begin = (ks)->f->end = 0)

Definition at line 167 of file kseq.h.

#define KSTREAM_DECLARE (   type_t,
  __read 
)
Value:
__KS_TYPE(type_t) \
extern int ks_getuntil2(kstream_t *ks, int delimiter, kstring_t *str, int *dret, int append); \
extern kstream_t *ks_init(type_t f); \
extern void ks_destroy(kstream_t *ks); \
__KS_INLINED(__read)

Definition at line 156 of file kseq.h.

#define KSTREAM_INIT (   type_t,
  __read,
  __bufsize 
)    KSTREAM_INIT2(static, type_t, __read, __bufsize)

Definition at line 154 of file kseq.h.

#define KSTREAM_INIT2 (   SCOPE,
  type_t,
  __read,
  __bufsize 
)
Value:
__KS_TYPE(type_t) \
__KS_BASIC(SCOPE, type_t, __bufsize) \
__KS_GETUNTIL(SCOPE, __read) \
__KS_INLINED(__read)

Definition at line 148 of file kseq.h.

#define KSTRING_T   kstring_t

Definition at line 84 of file kseq.h.

Typedef Documentation

typedef struct __kstring_t kstring_t