ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/tophat_cpp/FastaTools.h
Revision: 165
Committed: Fri Feb 10 01:04:05 2012 UTC (12 years, 6 months ago) by gpertea
File size: 1632 byte(s)
Log Message:
sync back with Daehwan. Test bam_merge for memory leaks!

Line File contents
1 //
2 // FastaTools.h
3 // TopHat
4 //
5 // Created by Harold Pimentel on 10/27/11.
6 //
7
8 #ifndef TopHat_FastaTools_h
9 #define TopHat_FastaTools_h
10
11 #ifdef HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include <cassert>
16 #include <cstdlib>
17 #include <cstring>
18 #include <fstream>
19 // #include <ifstream>
20 #include <iostream>
21 #include <map>
22 #include <string>
23 #include <utility>
24 #include <vector>
25
26 #include "common.h"
27
28 #define LINE_BUF_SIZE 1024
29 #define ID_BUF_SIZE 1024
30 #define DESC_BUF_SIZE 1024
31
32 struct FastaRecord {
33 // The identifier after ">"
34 std::string id_;
35
36 // The description after the identifier
37 std::string desc_;
38
39 // The sequence
40 std::string seq_;
41
42 };
43
44 class FastaReader {
45 public:
46 FastaReader();
47 FastaReader(std::string fname);
48 ~FastaReader();
49 void init(std::string fname);
50 bool good() const;
51 void next(FastaRecord* rec);
52 private:
53 std::string fname_;
54 std::string prev_line_;
55
56 std::ifstream ifstream_;
57
58 // We assume the description is no longer than 2048 characters long
59 // TODO: Think of a better way of doing this in the future.
60 char line_buf_[LINE_BUF_SIZE];
61
62 char id_buf_[ID_BUF_SIZE];
63
64 char desc_buf_[DESC_BUF_SIZE];
65
66 // variable to check if stream is primed (has already been initialized)
67 bool isPrimed_;
68 };
69
70 class FastaWriter {
71 public:
72 FastaWriter();
73 FastaWriter(std::string fname);
74 ~FastaWriter();
75 void init(std::string fname);
76 void write(FastaRecord* rec, size_t column_size = 60);
77 private:
78 std::string fname_;
79
80 std::ofstream ofstream_;
81
82 bool isPrimed_;
83 };
84 #endif

Properties

Name Value
svn:executable *