Skip to content

Commit 1f51094

Browse files
author
Iain Bancarz
committed
Intensity vectors as class members; do not repeatedly create/destroy vector objects
1 parent 727bb34 commit 1f51094

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

QC.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ QC::QC(string simPath, bool verbose=false) {
5050
exit(1);
5151
}
5252
qcsim->open(simPath);
53-
if (verbose) cout << "Opened .sim file " << simPath << endl;
53+
if (verbose) cerr << "Opened .sim file " << simPath << endl;
54+
// define vector objects to hold intensities
55+
intensity_int = new vector<uint16_t>();
56+
intensity_float = new vector<float>();
57+
if (verbose) cerr << "Created intensity vectors" << endl;
58+
int vectorSize = qcsim->numProbes * qcsim->numChannels;
59+
if (verbose) cerr << "Reserving space for " << vectorSize <<
60+
" intensities... ";
61+
intensity_int->reserve(vectorSize);
62+
intensity_float->reserve(vectorSize);
63+
if (verbose) cerr << "done." << endl;
5464
}
5565

5666
void QC::writeMagnitude(string outPath, bool verbose) {
@@ -102,8 +112,10 @@ void QC::writeXydiff(string outPath, bool verbose) {
102112
void QC::getNextMagnitudes(float magnitudes[], char *sampleName, Sim *sim) {
103113
// compute magnitudes for each probe from next sample in .sim input
104114
// can handle arbitrarily many intensity channels; also reads sample name
105-
vector<uint16_t> *intensity_int = new vector<uint16_t>;
106-
vector<float> *intensity_float = new vector<float>;
115+
//vector<uint16_t> *intensity_int = new vector<uint16_t>;
116+
//vector<float> *intensity_float = new vector<float>;
117+
intensity_float->clear();
118+
intensity_int->clear();
107119
if (sim->numberFormat == 0) {
108120
sim->getNextRecord(sampleName, intensity_float);
109121
} else {
@@ -120,8 +132,6 @@ void QC::getNextMagnitudes(float magnitudes[], char *sampleName, Sim *sim) {
120132
}
121133
magnitudes[i] = sqrt(total);
122134
}
123-
delete intensity_int;
124-
delete intensity_float;
125135
}
126136

127137
void QC::magnitudeByProbe(float magByProbe[], bool verbose=false) {

QC.h

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class QC {
5151

5252
private:
5353
Sim *qcsim;
54+
vector<uint16_t> *intensity_int;
55+
vector<float> *intensity_float;
56+
5457
void getNextMagnitudes(float magnitudes[], char* sampleName, Sim *sim);
5558
void magnitudeByProbe(float magByProbe[], bool verbose);
5659
void magnitudeBySample(float magBySample[], float magByProbe[],

0 commit comments

Comments
 (0)