Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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); \
}
#define __KS_GETUNTIL (   SCOPE,
  __read 
)
#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: bgzf.h:69
#define str(x)
Definition: sam.c:66
#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;
#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); \
}
#define __KSEQ_READ (   SCOPE)
#define __KSEQ_TYPE (   type_t)
Value:
typedef struct { \
kstring_t name, comment, seq, qual; \
int last_char; \
kstream_t *f; \
} kseq_t;
struct __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_eof (   ks)    ((ks)->is_eof && (ks)->begin >= (ks)->end)
#define ks_rewind (   ks)    ((ks)->is_eof = (ks)->begin = (ks)->end = 0)
#define KS_SEP_LINE   2
#define KS_SEP_MAX   2
#define KS_SEP_SPACE   0
#define KS_SEP_TAB   1
#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);
#define __KSEQ_TYPE(type_t)
Definition: kseq.h:231
#define __KS_TYPE(type_t)
Definition: kseq.h:40
#define KSEQ_INIT (   type_t,
  __read 
)    KSEQ_INIT2(static, type_t, __read)
#define KSEQ_INIT2 (   SCOPE,
  type_t,
  __read 
)
Value:
KSTREAM_INIT(type_t, __read, 16384) \
__KSEQ_TYPE(type_t) \
__KSEQ_BASIC(SCOPE, type_t) \
#define __KSEQ_BASIC(SCOPE, type_t)
Definition: kseq.h:169
#define __KSEQ_TYPE(type_t)
Definition: kseq.h:231
#define KSTREAM_INIT(type_t, __read, __bufsize)
Definition: kseq.h:154
#define __KSEQ_READ(SCOPE)
Definition: kseq.h:189
#define kseq_rewind (   ks)    ((ks)->last_char = (ks)->f->is_eof = (ks)->f->begin = (ks)->f->end = 0)
#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); \
#define __KS_INLINED(__read)
Definition: kseq.h:67
Definition: bgzf.h:69
#define __KS_TYPE(type_t)
Definition: kseq.h:40
#define str(x)
Definition: sam.c:66
#define KSTREAM_INIT (   type_t,
  __read,
  __bufsize 
)    KSTREAM_INIT2(static, type_t, __read, __bufsize)
#define KSTREAM_INIT2 (   SCOPE,
  type_t,
  __read,
  __bufsize 
)
Value:
__KS_TYPE(type_t) \
__KS_BASIC(SCOPE, type_t, __bufsize) \
__KS_GETUNTIL(SCOPE, __read) \
#define __KS_INLINED(__read)
Definition: kseq.h:67
#define __KS_BASIC(SCOPE, type_t, __bufsize)
Definition: kseq.h:52
#define __KS_TYPE(type_t)
Definition: kseq.h:40
#define __KS_GETUNTIL(SCOPE, __read)
Definition: kseq.h:95
#define KSTRING_T   kstring_t

Typedef Documentation

typedef struct __kstring_t kstring_t