MCPcopy Create free account
hub / github.com/arq5x/bedtools2 / BedGraphFile

Class BedGraphFile

src/utils/bedGraphFile/bedGraphFile.h:103–200  ·  view source on GitHub ↗

BedGraphFile Class methods and elements

Source from the content-addressed store, hash-verified

101// BedGraphFile Class methods and elements
102//************************************************
103class BedGraphFile {
104
105public:
106
107 // Constructor
108 BedGraphFile(string &);
109
110 // Destructor
111 ~BedGraphFile(void);
112
113 // Open a BEDGraph file for reading (creates an istream pointer)
114 void Open(void);
115
116 // Close an opened BED file.
117 void Close(void);
118
119 // Get the next BED entry in an opened BED file.
120 template <typename T>
121 BedGraphLineStatus GetNextBedGraph (BEDGRAPH<T> &bedgraph, int &lineNum)
122 {
123 // make sure there are still lines to process.
124 // if so, tokenize, validate and return the BED entry.
125 if (_bedGraphStream->good()) {
126 string bedGraphLine;
127 vector<string> bedGraphFields;
128
129 // parse the bedStream pointer
130 getline(*_bedGraphStream, bedGraphLine);
131 if (_bedGraphStream->eof())
132 return BEDGRAPH_INVALID;
133 if (_bedGraphStream->bad()) {
134 cerr << "Error while reading file '" << bedGraphFile << "' : "
135 << strerror(errno) << endl;
136 exit(1);
137 }
138 lineNum++;
139
140 // split into a string vector.
141 Tokenize(bedGraphLine,bedGraphFields);
142 if (bedGraphLine[bedGraphLine.size()-1] == '\r') {
143 bedGraphLine.resize(bedGraphLine.size()-1);
144 }
145
146 // load the BED struct as long as it's a valid BED entry.
147 return parseLine(bedgraph, bedGraphFields, lineNum);
148 }
149
150 // default if file is closed or EOF
151 return BEDGRAPH_INVALID;
152 }
153
154 // the bedfile with which this instance is associated
155 string bedGraphFile;
156
157private:
158 // data
159 istream *_bedGraphStream;
160

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected