//**********************************************************************************************************************
-FlowData::FlowData(int numFlows, float signal, float noise, int maxHomoP) :
- numFlows(numFlows), signalIntensity(signal), noiseIntensity(noise), maxHomoP(maxHomoP){
+FlowData::FlowData(int numFlows, float signal, float noise, int maxHomoP, string baseFlow) :
+ numFlows(numFlows), signalIntensity(signal), noiseIntensity(noise), maxHomoP(maxHomoP), baseFlow(baseFlow){
try {
m = MothurOut::getInstance();
flowData.assign(numFlows, 0);
- baseFlow = "TACG";
+// baseFlow = "TACG";
seqName = "";
locationString = "";
}
bool FlowData::getNext(ifstream& flowFile){
try {
-
- string lengthString;
- string flowString;
-
- flowFile >> seqName >> endFlow;
- for(int i=0;i<numFlows;i++) { flowFile >> flowData[i]; }
-
- updateEndFlow();
- translateFlow();
-
- m->gobble(flowFile);
+ seqName = getSequenceName(flowFile);
+ flowFile >> endFlow;
+ if (!m->control_pressed) {
+ for(int i=0;i<numFlows;i++) { flowFile >> flowData[i]; }
+ updateEndFlow();
+ translateFlow();
+ m->gobble(flowFile);
+ }
+
if(flowFile){ return 1; }
else { return 0; }
}
}
}
+//********************************************************************************************************************
+string FlowData::getSequenceName(ifstream& flowFile) {
+ try {
+ string name = "";
+
+ flowFile >> name;
+
+ if (name.length() != 0) {
+ for (int i = 0; i < name.length(); i++) {
+ if (name[i] == ':') { name[i] = '_'; m->changedSeqNames = true; }
+ }
+ }else{ m->mothurOut("Error in reading your flowfile, at position " + toString(flowFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); m->control_pressed = true; }
+
+ return name;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "FlowData", "getSequenceName");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
void FlowData::updateEndFlow(){
try{
+ if (baseFlow.length() > 4) { return; }
+
//int currLength = 0;
float maxIntensity = (float) maxHomoP + 0.49;
int deadSpot = 0;
-
+
while(deadSpot < endFlow){
int signal = 0;
int noise = 0;
- for(int i=0;i<4;i++){
+ for(int i=0;i<baseFlow.length();i++){
float intensity = flowData[i + deadSpot];
if(intensity > signalIntensity){
signal++;
break;
}
- deadSpot += 4;
+ deadSpot += baseFlow.length();
}
endFlow = deadSpot;
sequence = "";
for(int i=0;i<endFlow;i++){
int intensity = (int)(flowData[i] + 0.5);
- char base = baseFlow[i % 4];
+ char base = baseFlow[i % baseFlow.length()];
for(int j=0;j<intensity;j++){
sequence += base;
}
}
-
+
if(sequence.size() > 4){
sequence = sequence.substr(4);
}
try{
maxFlows = mF;
- if(endFlow > maxFlows){ endFlow = maxFlows; }
+ if(endFlow > maxFlows){ endFlow = maxFlows; }
+ translateFlow();
}
catch(exception& e) {
return seqName;
}
catch(exception& e) {
- m->errorOut(e, "FlowData", "getSequence");
+ m->errorOut(e, "FlowData", "getName");
exit(1);
}
}