Skip to content

Commit 37786e6

Browse files
author
iainrb
committed
Rename Fcr and FcrData classes to FcrWriter and FcrReader, respectively
1 parent 62d03f4 commit 37786e6

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

Fcr.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ using namespace std;
5050

5151
const static double pi = 3.141593;
5252

53-
Fcr::Fcr() {
53+
FcrWriter::FcrWriter() {
5454
// empty constructor
5555
}
5656

57-
double Fcr::BAF(double theta, Egt egt, long snpIndex) {
57+
double FcrWriter::BAF(double theta, Egt egt, long snpIndex) {
5858
// estimate the B allele frequency by interpolating between known clusters
5959
float *meanTheta = new float[egt.GENOTYPES_PER_SNP];
6060
egt.getMeanTheta(snpIndex, meanTheta);
@@ -73,7 +73,7 @@ double Fcr::BAF(double theta, Egt egt, long snpIndex) {
7373
}
7474

7575
// sanity check on manifest and gtc file
76-
void Fcr::compareNumberOfSNPs(Manifest *manifest, Gtc *gtc) {
76+
void FcrWriter::compareNumberOfSNPs(Manifest *manifest, Gtc *gtc) {
7777
if (manifest->snps.size() != gtc->xRawIntensity.size()) {
7878
ostringstream msg;
7979
msg << "Size mismatch: Manifest contains " << manifest->snps.size()
@@ -84,7 +84,7 @@ void Fcr::compareNumberOfSNPs(Manifest *manifest, Gtc *gtc) {
8484
}
8585
}
8686

87-
void Fcr::illuminaCoordinates(double x, double y, double &theta, double &r) {
87+
void FcrWriter::illuminaCoordinates(double x, double y, double &theta, double &r) {
8888
// convert (x,y) cartesian coordinates to Illumina coordinates (theta, r)
8989
// these are ***NOT*** standard polar coordinates!
9090
// the angle theta is rescaled s.t. pi/2 radians = 1 "Illumina angular unit"
@@ -94,7 +94,7 @@ void Fcr::illuminaCoordinates(double x, double y, double &theta, double &r) {
9494

9595
}
9696

97-
string Fcr::createHeader(string content, int samples, int snps) {
97+
string FcrWriter::createHeader(string content, int samples, int snps) {
9898
// generate standard FCR header
9999
// content argument is typically the manifest name
100100
// includes data set summary, and column heads for main body
@@ -127,7 +127,7 @@ string Fcr::createHeader(string content, int samples, int snps) {
127127
return header;
128128
}
129129

130-
double Fcr::logR(double theta, double r, Egt egt, long snpIndex) {
130+
double FcrWriter::logR(double theta, double r, Egt egt, long snpIndex) {
131131
// calculate the LogR metric for given (theta, r) of sample
132132
// snpIndex is position in the manifest (starting from 0)
133133
// get (theta, R) for AA, AB, BB from EGT and interpolate
@@ -151,7 +151,7 @@ double Fcr::logR(double theta, double r, Egt egt, long snpIndex) {
151151
}
152152

153153

154-
void Fcr::write(Egt *egt, Manifest *manifest, ostream *outStream,
154+
void FcrWriter::write(Egt *egt, Manifest *manifest, ostream *outStream,
155155
vector<string> infiles, vector<string> sampleNames) {
156156
// 'main' method to generate FCR and write to given output stream
157157
Gtc *gtc = new Gtc();
@@ -207,7 +207,7 @@ void Fcr::write(Egt *egt, Manifest *manifest, ostream *outStream,
207207
}
208208

209209

210-
FcrData::FcrData(string infile) {
210+
FcrReader::FcrReader(string infile) {
211211
ifstream inStream;
212212
string line;
213213
bool body = false;
@@ -268,8 +268,8 @@ FcrData::FcrData(string infile) {
268268
this->header = parseHeader(header_lines);
269269
}
270270

271-
bool FcrData::equivalent(FcrData other, bool verbose) {
272-
// check for equality on data fields with another FcrData object
271+
bool FcrReader::equivalent(FcrReader other, bool verbose) {
272+
// check for equality on data fields with another FcrReader object
273273
bool equal = true;
274274
double epsilon = 1e-5;
275275
if (totalPairs != other.totalPairs) {
@@ -370,7 +370,7 @@ bool FcrData::equivalent(FcrData other, bool verbose) {
370370

371371
}
372372

373-
bool FcrData::equivalentHeaders(FcrData other, bool verbose) {
373+
bool FcrReader::equivalentHeaders(FcrReader other, bool verbose) {
374374
map<string, string> myHead = this->header;
375375
map<string, string> otherHead = other.header;
376376
bool equivalent = true;
@@ -392,7 +392,7 @@ bool FcrData::equivalentHeaders(FcrData other, bool verbose) {
392392
return equivalent;
393393
}
394394

395-
map<string, string> FcrData::parseHeader(vector<string> input) {
395+
map<string, string> FcrReader::parseHeader(vector<string> input) {
396396
// parse header fields
397397
vector<unsigned int> keyLengths(headerKeys.size(), 0);
398398
for (unsigned int i=0; i<headerKeys.size(); i++) {
@@ -422,7 +422,7 @@ map<string, string> FcrData::parseHeader(vector<string> input) {
422422
return header;
423423
}
424424

425-
vector<string> FcrData::splitByWhiteSpace(string str) {
425+
vector<string> FcrReader::splitByWhiteSpace(string str) {
426426
// split line into tokens by iterating over a stringstream
427427
string buffer;
428428
stringstream ss(str); // Insert the string into a stream

Fcr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242

4343
using namespace std;
4444

45-
class Fcr {
45+
class FcrWriter {
4646

4747
public:
48-
Fcr();
48+
FcrWriter();
4949
double BAF(double theta, Egt egt, long snpIndex);
5050
void compareNumberOfSNPs(Manifest *manifest, Gtc *gtc);
5151
void illuminaCoordinates(double x, double y, double &theta, double &r);
@@ -55,7 +55,7 @@ class Fcr {
5555

5656
};
5757

58-
class FcrData {
58+
class FcrReader {
5959
// Container for data in an FCR file
6060
// Intended only for running tests
6161
// "Real" FCR files are typically too big to slurp into memory
@@ -65,7 +65,7 @@ class FcrData {
6565
string fileKey;
6666
vector<string> headerKeys;
6767
map<string, string> header;
68-
FcrData(string infile);
68+
FcrReader(string infile);
6969
vector<string> snps;
7070
vector<string> samples;
7171
vector<string> alleles_a;
@@ -79,10 +79,10 @@ class FcrData {
7979
vector<int> y_raw;
8080
vector<double> logR;
8181
vector<double> baf;
82-
bool equivalent(FcrData other, bool verbose=true);
82+
bool equivalent(FcrReader other, bool verbose=true);
8383

8484
private:
85-
bool equivalentHeaders(FcrData other, bool verbose=true);
85+
bool equivalentHeaders(FcrReader other, bool verbose=true);
8686
map<string, string> parseHeader(vector<string> header);
8787
vector<string> splitByWhiteSpace(string str);
8888

commands.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void Commander::commandFCR(string infile, string outfile, string manfile, string
257257
vector<string> infiles; // list of GTC files to process
258258
Manifest *manifest = new Manifest();
259259
Egt *egt = new Egt();
260-
Fcr *fcr = new Fcr(); // Final Call Report generator
260+
FcrWriter *fcrWriter = new FcrWriter(); // Final Call Report generator
261261
ofstream outFStream;
262262
ostream *outStream;
263263
if (outfile == "-") {
@@ -272,9 +272,10 @@ void Commander::commandFCR(string infile, string outfile, string manfile, string
272272
egt->open(egtfile);
273273
// now we have output stream, GTC paths, populated manifest and EGT
274274
// write output to an FCR file
275-
fcr->write(egt, manifest, outStream, infiles, sampleNames);
275+
fcrWriter->write(egt, manifest, outStream, infiles, sampleNames);
276276
delete manifest;
277277
delete egt;
278+
delete fcrWriter;
278279
}
279280

280281

test_simtools.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,28 +207,28 @@ class FcrTest : public TestBase
207207
{
208208
public:
209209

210-
void testFcrClass(void)
210+
void testFcrWriterClass(void)
211211
{
212212
string infile = "data/humancoreexome-12v1-1_a.egt";
213-
Fcr *fcr;
213+
FcrWriter *fcrWriter;
214214
Egt *egt;
215215
egt = new Egt();
216216
egt->open(infile);
217-
TS_ASSERT_THROWS_NOTHING(new Fcr());
218-
fcr = new Fcr();
217+
TS_ASSERT_THROWS_NOTHING(new FcrWriter());
218+
fcrWriter = new FcrWriter();
219219
double r;
220220
double theta;
221221
double x = 3.0;
222222
double y = 4.0;
223-
fcr->illuminaCoordinates(x, y, theta, r);
223+
fcrWriter->illuminaCoordinates(x, y, theta, r);
224224
TS_ASSERT_DELTA(r, 7.0, 1e-6);
225225
TS_ASSERT_DELTA(theta, 0.5903345, 1e-6);
226-
double baf = fcr->BAF(0.738881, *egt, 0);
226+
double baf = fcrWriter->BAF(0.738881, *egt, 0);
227227
TS_ASSERT_DELTA(baf, 0.75, 1e-6);
228-
double logR = fcr->logR(1, 0.73881, *egt, 0);
228+
double logR = fcrWriter->logR(1, 0.73881, *egt, 0);
229229
TS_ASSERT_DELTA(logR, -0.7180, 1e-4);
230230
delete egt;
231-
delete fcr;
231+
delete fcrWriter;
232232
}
233233
};
234234

@@ -331,14 +331,14 @@ class SimtoolsTest : public TestBase
331331
int size = 4657; // expected file size
332332
assertFileSize(outfile, size);
333333
TS_TRACE("FCR output file is of expected length");
334-
FcrData data_ref = FcrData(normfile);
334+
FcrReader data_ref = FcrReader(normfile);
335335
TS_ASSERT(data_ref.totalPairs == 50);
336336
TS_ASSERT(data_ref.snps.size() == 50);
337337
TS_ASSERT(data_ref.samples.size() == 50);
338338
TS_ASSERT(data_ref.header["Num SNPs"].compare("10")==0);
339339
TS_ASSERT(data_ref.header["Num Samples"].compare("5")==0);
340340
TS_ASSERT(data_ref.equivalent(data_ref));
341-
FcrData data_test = FcrData(outfile);
341+
FcrReader data_test = FcrReader(outfile);
342342
TS_TRACE("Created and tested FCRData objects");
343343
TS_ASSERT(data_ref.equivalent(data_test));
344344
TS_TRACE("FCR output file is equivalent to reference copy");

0 commit comments

Comments
 (0)