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){
49 flowFile >> seqName >> endFlow;
50 for(int i=0;i<numFlows;i++) { flowFile >> flowData[i]; }
56 if(flowFile){ return 1; }
60 m->errorOut(e, "FlowData", "getNext");
66 //**********************************************************************************************************************
68 void FlowData::updateEndFlow(){
72 float maxIntensity = (float) maxHomoP + 0.49;
76 while(deadSpot < endFlow){
81 float intensity = flowData[i + deadSpot];
82 if(intensity > signalIntensity){
85 if(intensity < noiseIntensity || intensity > maxIntensity){
91 if(noise > 0 || signal == 0){
100 catch(exception& e) {
101 m->errorOut(e, "FlowData", "findDeadSpot");
106 //**********************************************************************************************************************
108 void FlowData::translateFlow(){
112 for(int i=0;i<endFlow;i++){
113 int intensity = (int)(flowData[i] + 0.5);
114 char base = baseFlow[i % 4];
116 for(int j=0;j<intensity;j++){
121 if(sequence.size() > 4){
122 sequence = sequence.substr(4);
128 catch(exception& e) {
129 m->errorOut(e, "FlowData", "translateFlow");
134 //**********************************************************************************************************************
136 void FlowData::capFlows(int mF){
141 if(endFlow > maxFlows){ endFlow = maxFlows; }
144 catch(exception& e) {
145 m->errorOut(e, "FlowData", "capFlows");
150 //**********************************************************************************************************************
152 bool FlowData::hasMinFlows(int minFlows){
156 if(endFlow >= minFlows){ pastMin = 1; }
160 catch(exception& e) {
161 m->errorOut(e, "FlowData", "hasMinFlows");
166 //**********************************************************************************************************************
168 Sequence FlowData::getSequence(){
171 return Sequence(seqName, sequence);
173 catch(exception& e) {
174 m->errorOut(e, "FlowData", "getSequence");
179 //**********************************************************************************************************************
181 void FlowData::printFlows(ofstream& outFlowFile){
183 // outFlowFile << '>' << seqName << locationString << " length=" << seqLength << " numflows=" << maxFlows << endl;
184 outFlowFile << seqName << ' ' << endFlow << ' ' << setprecision(2);
186 for(int i=0;i<maxFlows;i++){
187 outFlowFile << flowData[i] << ' ';
191 catch(exception& e) {
192 m->errorOut(e, "FlowData", "printFlows");
197 //**********************************************************************************************************************
199 void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
201 outFlowFile << seqName << '|' << scrapCode << ' ' << endFlow << ' ' << setprecision(2);
203 for(int i=0;i<numFlows;i++){
204 outFlowFile << flowData[i] << ' ';
208 catch(exception& e) {
209 m->errorOut(e, "FlowData", "printFlows");
214 //**********************************************************************************************************************
216 string FlowData::getName(){
221 catch(exception& e) {
222 m->errorOut(e, "FlowData", "getName");
227 //**********************************************************************************************************************