-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfastqreader.h
69 lines (59 loc) · 1.35 KB
/
fastqreader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef FASTQ_READER_H
#define FASTQ_READER_H
#include <stdio.h>
#include <stdlib.h>
#include "read.h"
#ifdef DYNAMIC_ZLIB
#include <zlib.h>
#else
#include "zlib/zlib.h"
#endif
#include "common.h"
#include <iostream>
#include <fstream>
class FastqReader{
public:
FastqReader(string filename, bool hasQuality = true, bool phred64=false);
~FastqReader();
bool isZipped();
void getBytes(size_t& bytesRead, size_t& bytesTotal);
//this function is not thread-safe
//do not call read() of a same FastqReader object from different threads concurrently
Read* read();
bool eof();
bool hasNoLineBreakAtEnd();
public:
static bool isZipFastq(string filename);
static bool isFastq(string filename);
static bool test();
private:
void init();
void close();
string getLine();
void clearLineBreaks(char* line);
void readToBuf();
private:
string mFilename;
gzFile mZipFile;
FILE* mFile;
bool mZipped;
bool mHasQuality;
bool mPhred64;
char* mBuf;
int mBufDataLen;
int mBufUsedLen;
bool mStdinMode;
bool mHasNoLineBreakAtEnd;
};
class FastqReaderPair{
public:
FastqReaderPair(FastqReader* left, FastqReader* right);
FastqReaderPair(string leftName, string rightName, bool hasQuality = true, bool phred64 = false, bool interleaved = false);
~FastqReaderPair();
ReadPair* read();
public:
FastqReader* mLeft;
FastqReader* mRight;
bool mInterleaved;
};
#endif