Debian Codegraph @

SeqLib/FastqReader.h

raw symbols SCIP
1 #ifndef SEQLIB_FASTQ_READER_H
2 #define SEQLIB_FASTQ_READER_H
3
4 #include <string>
5
6 #include <iostream>
7 #include <fstream>
8 #include <sys/stat.h>
9 #include <unistd.h>
10
11 // all kseq stuff is in UnaligedSequence
12 #include "SeqLib/UnalignedSequence.h"
13
14 namespace SeqLib{
15
16 /** Simple reader for FASTA/FASTQ files */
17 class FastqReader {
18
19 public:
20
21 /** Construct an empty FASTQ/FASTA reader */
22 FastqReader() {
23 seq = NULL;
24 fp = NULL;
25 }
26
27 /** Construct a reader and open a FASTQ/FASTA reader
28 * @param file Path to a FASTQ or FASTA file
29 */
30 FastqReader(const std::string& file);
31
32 /** Open a FASTQ/FASTA file for reading
33 * @param file Path to a FASTQ or FASTA file
34 * @return Returns true if opening was successful
35 */
36 bool Open(const std::string& file);
37
38 /** Retrieve the next sequence from the FASTA/FASTQ
39 * @param s Sequence to be filled in with Name, Seq, Qual and Strand
40 */
41 bool GetNextSequence(UnalignedSequence& s);
42
43 ~FastqReader() {
44 if (seq)
45 kseq_destroy(seq);
46 if (fp)
47 gzclose(fp);
48 }
49
50
51 private:
52
53 std::string m_file;
54
55 gzFile fp; // file handler for kseq
56 kseq_t * seq; // current read
57
58 };
59
60 }
61
62 #endif