MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / writeToFile

Method writeToFile

src/GenomeDensity.cpp:161–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161void GenomeDensity::writeToFile(std::string outFileName,std::string type, bool ifBinary) {
162 std::ofstream file;
163 if (ifBinary)
164 file.open(outFileName.c_str(), ios::in | ios::binary);
165 else
166 file.open(outFileName.c_str());
167
168 class IntPoint {
169 public:
170 string chr;
171 int pos;
172 int value;
173 };
174 class FloatPoint {
175 public:
176 string chr;
177 int pos;
178 float value;
179 };
180 const string sep = "\t";
181 map<string,ChrDensity>::iterator it;
182 if (type.compare("norm")==0) {
183 IntPoint x;
184 for ( it=gd_.begin() ; it != gd_.end(); it++ ) {
185 x.chr = (*it).first;
186 for (int i = 0; i<(*it).second.getLength();i++) {
187 x.pos = i;
188 x.value = (*it).second.getCoverageAtI(i);
189 if (ifBinary)
190 file.write((char*)&x, sizeof (IntPoint));
191 else {
192 file << x.chr+sep;
193 file << x.pos;
194 file << sep;
195 file << x.value;
196 file << "\n";
197 }
198 }
199 }
200 }
201 else {
202 FloatPoint x;
203 for ( it=gd_.begin() ; it != gd_.end(); it++ ) {
204 x.chr = (*it).first;
205 for (int i = 0; i<(*it).second.getLength();i++) {
206 x.pos = i;
207 x.value = (*it).second.getDensityAtI(i);
208 if (ifBinary)
209 file.write((char*)&x, sizeof (FloatPoint));
210 else {
211 file << x.chr+sep;
212 file << x.pos;
213 file << sep;
214 file << x.value;
215 file << "\n";
216 }
217 }
218 }

Callers

nothing calls this directly

Calls 4

compareMethod · 0.80
getCoverageAtIMethod · 0.80
getDensityAtIMethod · 0.80
getLengthMethod · 0.45

Tested by

no test coverage detected