X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=flowdata.cpp;h=7d61f8c265e060f2dc0002c94f69edfd054f89ae;hp=39c1f8317a306c1a49488625725cbea7a4c6bd4e;hb=615301e57c25e241356a9c2380648d117709458d;hpb=902e0fcab76e75009ac43d3f4537e08182628d6f diff --git a/flowdata.cpp b/flowdata.cpp index 39c1f83..7d61f8c 100644 --- a/flowdata.cpp +++ b/flowdata.cpp @@ -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> flowData[i]; } - - updateEndFlow(); - translateFlow(); - - m->gobble(flowFile); + seqName = getSequenceName(flowFile); + flowFile >> endFlow; + if (!m->control_pressed) { + for(int i=0;i> flowData[i]; } + updateEndFlow(); + translateFlow(); + m->gobble(flowFile); + } + if(flowFile){ return 1; } else { return 0; } } @@ -62,22 +60,42 @@ bool FlowData::getNext(ifstream& flowFile){ } } +//******************************************************************************************************************** +string FlowData::getSequenceName(ifstream& flowFile) { + try { + string name = ""; + + flowFile >> name; + + if (name.length() != 0) { + m->checkName(name); + }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 signalIntensity){ signal++; @@ -92,7 +110,7 @@ void FlowData::updateEndFlow(){ break; } - deadSpot += 4; + deadSpot += baseFlow.length(); } endFlow = deadSpot; @@ -104,27 +122,49 @@ void FlowData::updateEndFlow(){ } //********************************************************************************************************************** - +//TATGCT +//1 0 0 0 0 1 +//then the second positive flow is for a T, but you saw a T between the last and previous flow adn it wasn't positive, so something is missing +//Becomes TNT void FlowData::translateFlow(){ - try{ - sequence = ""; - for(int i=0;i charInMiddle; + int oldspot = -1; + bool updateOld = false; + + for(int i=0;i= 1) { + if (oldspot == -1) { updateOld = true; } + else { //check for bases inbetween two 1's + if (charInMiddle.count(base) != 0) { //we want to covert to an N + sequence = sequence.substr(0, oldspot+1); + sequence += 'N'; + } + updateOld = true; + charInMiddle.clear(); + } + } for(int j=0;j 4){ sequence = sequence.substr(4); } else{ sequence = "NNNN"; } - } + } catch(exception& e) { m->errorOut(e, "FlowData", "translateFlow"); exit(1); @@ -138,7 +178,8 @@ void FlowData::capFlows(int mF){ try{ maxFlows = mF; - if(endFlow > maxFlows){ endFlow = maxFlows; } + if(endFlow > maxFlows){ endFlow = maxFlows; } + translateFlow(); } catch(exception& e) { @@ -149,6 +190,27 @@ void FlowData::capFlows(int mF){ //********************************************************************************************************************** +bool FlowData::hasGoodHomoP(){ + + try{ + + float maxIntensity = (float) maxHomoP + 0.49; + + for(int i=0;i maxIntensity){ + return 0; + } + } + return 1; + } + catch(exception& e) { + m->errorOut(e, "FlowData", "hasMinFlows"); + exit(1); + } +} + +//********************************************************************************************************************** + bool FlowData::hasMinFlows(int minFlows){ try{ @@ -219,7 +281,7 @@ string FlowData::getName(){ return seqName; } catch(exception& e) { - m->errorOut(e, "FlowData", "getSequence"); + m->errorOut(e, "FlowData", "getName"); exit(1); } }