Using klib

This commit is contained in:
Haoyu Cheng
2019-05-10 16:14:01 -04:00
parent 0b209dd1e9
commit eee68408be
7 changed files with 438 additions and 251 deletions
+6 -64
View File
@@ -4,73 +4,15 @@
#include<stdint.h>
#include <string.h>
#include <stdlib.h>
#include <zlib.h>
#include "kseq.h"
#define FASTQ 1
#define FASTQGZ 2
KSEQ_INIT(gzFile, gzread)
#define NAME_SZIE 25
#define SEQ_SZIE 20000
void init_kseq(char* file);
void destory_kseq();
int get_read(kseq_t *s);
typedef struct
{
char* centext;
uint32_t length;
uint32_t size;
}str_v;
inline void init_str_v(str_v* buf, uint32_t length)
{
buf->size = length + 1;
buf->length = 0;
buf->centext = (char*)malloc(sizeof(char)*buf->size);
}
inline void append_str(str_v* buf, char* input)
{
int length = strlen(input);
buf->length = buf->length + length;
if (buf->length > buf->size)
{
buf->centext = (char*)realloc(buf->centext, buf->length + 1);
}
memcpy(buf->centext + buf->length - length, input, length);
buf->centext[buf->length] = '\0';
}
inline void clear_str(str_v* buf)
{
buf->length = 0;
}
typedef struct
{
str_v name;
str_v seq;
str_v qual;
} Read;
inline void init_Read(Read* r)
{
init_str_v(&r->name, NAME_SZIE);
init_str_v(&r->seq, SEQ_SZIE);
init_str_v(&r->qual, SEQ_SZIE);
}
inline void clear_read(Read* r)
{
clear_str(&r->name);
clear_str(&r->seq);
clear_str(&r->qual);
}
int initiReadAllReads(char *fileName);
int inputRead(Read *read);
#endif