5 * Created by Pat Schloss on 12/22/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
12 //**********************************************************************************************************************
14 FlowData::FlowData(){}
16 //**********************************************************************************************************************
18 FlowData::~FlowData(){ /* do nothing */ }
20 //**********************************************************************************************************************
22 FlowData::FlowData(int numFlows, float signal, float noise, int maxHomoP, string baseFlow) :
23 numFlows(numFlows), signalIntensity(signal), noiseIntensity(noise), maxHomoP(maxHomoP), baseFlow(baseFlow){
26 m = MothurOut::getInstance();
28 flowData.assign(numFlows, 0);
34 m->errorOut(e, "FlowData", "FlowData");
40 //**********************************************************************************************************************
42 bool FlowData::getNext(ifstream& flowFile){
45 seqName = getSequenceName(flowFile);
47 if (!m->control_pressed) {
48 for(int i=0;i<numFlows;i++) { flowFile >> flowData[i]; }
54 if(flowFile){ return 1; }
58 m->errorOut(e, "FlowData", "getNext");
63 //********************************************************************************************************************
64 string FlowData::getSequenceName(ifstream& flowFile) {
70 if (name.length() != 0) {
71 for (int i = 0; i < name.length(); i++) {
72 if (name[i] == ':') { name[i] = '_'; m->changedSeqNames = true; }
74 }else{ m->mothurOut("Error in reading your flowfile, at position " + toString(flowFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); m->control_pressed = true; }
79 m->errorOut(e, "FlowData", "getSequenceName");
84 //**********************************************************************************************************************
86 void FlowData::updateEndFlow(){
90 float maxIntensity = (float) maxHomoP + 0.49;
94 while(deadSpot < endFlow){
99 float intensity = flowData[i + deadSpot];
100 if(intensity > signalIntensity){
103 if(intensity < noiseIntensity || intensity > maxIntensity){
109 if(noise > 0 || signal == 0){
118 catch(exception& e) {
119 m->errorOut(e, "FlowData", "findDeadSpot");
124 //**********************************************************************************************************************
126 void FlowData::translateFlow(){
130 for(int i=0;i<endFlow;i++){
131 int intensity = (int)(flowData[i] + 0.5);
132 char base = baseFlow[i % 4];
134 for(int j=0;j<intensity;j++){
139 if(sequence.size() > 4){
140 sequence = sequence.substr(4);
146 catch(exception& e) {
147 m->errorOut(e, "FlowData", "translateFlow");
152 //**********************************************************************************************************************
154 void FlowData::capFlows(int mF){
159 if(endFlow > maxFlows){ endFlow = maxFlows; }
163 catch(exception& e) {
164 m->errorOut(e, "FlowData", "capFlows");
169 //**********************************************************************************************************************
171 bool FlowData::hasMinFlows(int minFlows){
175 if(endFlow >= minFlows){ pastMin = 1; }
179 catch(exception& e) {
180 m->errorOut(e, "FlowData", "hasMinFlows");
185 //**********************************************************************************************************************
187 Sequence FlowData::getSequence(){
190 return Sequence(seqName, sequence);
192 catch(exception& e) {
193 m->errorOut(e, "FlowData", "getSequence");
198 //**********************************************************************************************************************
200 void FlowData::printFlows(ofstream& outFlowFile){
202 // outFlowFile << '>' << seqName << locationString << " length=" << seqLength << " numflows=" << maxFlows << endl;
203 outFlowFile << seqName << ' ' << endFlow << ' ' << setprecision(2);
205 for(int i=0;i<maxFlows;i++){
206 outFlowFile << flowData[i] << ' ';
210 catch(exception& e) {
211 m->errorOut(e, "FlowData", "printFlows");
216 //**********************************************************************************************************************
218 void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
220 outFlowFile << seqName << '|' << scrapCode << ' ' << endFlow << ' ' << setprecision(2);
222 for(int i=0;i<numFlows;i++){
223 outFlowFile << flowData[i] << ' ';
227 catch(exception& e) {
228 m->errorOut(e, "FlowData", "printFlows");
233 //**********************************************************************************************************************
235 string FlowData::getName(){
240 catch(exception& e) {
241 m->errorOut(e, "FlowData", "getName");
246 //**********************************************************************************************************************