forked from chienchi/FaQCs
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfastq.h
43 lines (33 loc) · 1.32 KB
/
fastq.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
#ifndef __FASTQ
#define __FASTQ
#include <string>
#include <fstream>
#include <zlib.h>
// Make sure that we have been compiled against a version of zlib that
// supports writing uncompressed files
#if (ZLIB_VERNUM < 0x1280)
#error "Please compile with a zlib version >= 1.2.8"
#endif
#define MIN_QUALITY_SCORE 0
#define MAX_QUALITY_SCORE 41
inline char quality_score(const char m_quality, const char m_offset)
{
// Please note that negative scores *are* allowed! The solexa+64 quality scores
// start at -5 (granted this is an old format, but we don't know what will the
// future will hold).
// Don't allow negative quality scores
//if(m_offset > m_quality){
// throw __FILE__ ":quality_score: Negative quality score!";
//}
// Clamp the actual quality score to be greater than zero. This will need to change
// if a future format defines meaningfull negative quality scores!
const char ret = std::max(0, m_quality - m_offset);
if(ret > MAX_QUALITY_SCORE){
throw __FILE__ ":quality_score: Found a quality score value that is greater than the maximum allowed quality score";
}
return ret;
};
bool next_read(gzFile m_fin, std::string &m_def, std::string &m_seq, std::string &m_quality);
void write_read(gzFile m_fout, const std::string &m_def, const std::string &m_seq,
const std::string &m_quality);
#endif // __FASTQ