]> git.donarmstrong.com Git - mothur.git/blobdiff - flowdata.cpp
added checks to make sure windows processes completed their tasks.
[mothur.git] / flowdata.cpp
index a172a03337303f287c64ed0f8e7352cdfde3db57..5dc7dc3e6c780171f1ee5cacdb1d766864f18a18 100644 (file)
@@ -19,14 +19,14 @@ FlowData::~FlowData(){      /*      do nothing      */      }
 
 //**********************************************************************************************************************
 
-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 = "";
        }
@@ -42,17 +42,15 @@ FlowData::FlowData(int numFlows, float signal, float noise, int maxHomoP) :
 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;       }
        }
@@ -62,13 +60,33 @@ bool FlowData::getNext(ifstream& flowFile){
        }
        
 }
+//********************************************************************************************************************
+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{
                
-               int currLength = 0;
+               //int currLength = 0;
                float maxIntensity = (float) maxHomoP + 0.49;
                
                int deadSpot = 0;
@@ -138,7 +156,8 @@ void FlowData::capFlows(int mF){
        try{
                
                maxFlows = mF;
-               if(endFlow > maxFlows){ endFlow = maxFlows;     }               
+               if(endFlow > maxFlows){ endFlow = maxFlows;     }       
+        translateFlow();
                
        }
        catch(exception& e) {
@@ -212,3 +231,16 @@ void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
 }
 
 //**********************************************************************************************************************
+
+string FlowData::getName(){
+       
+       try{
+               return seqName;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "FlowData", "getName");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************