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

Method GetNextBedGraph

src/utils/bedGraphFile/bedGraphFile.h:121–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 1

LoadNextBedgraphItemMethod · 0.80

Calls 4

TokenizeFunction · 0.85
resizeMethod · 0.80
eofMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected