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 flowFile >> seqName >> endFlow;
46 //cout << "in Flowdata " + seqName << endl;
47 for(int i=0;i<numFlows;i++) { flowFile >> flowData[i]; }
48 //cout << "in Flowdata read " << seqName + " done" << endl;
53 if(flowFile){ return 1; }
57 m->errorOut(e, "FlowData", "getNext");
63 //**********************************************************************************************************************
65 void FlowData::updateEndFlow(){
69 float maxIntensity = (float) maxHomoP + 0.49;
73 while(deadSpot < endFlow){
78 float intensity = flowData[i + deadSpot];
79 if(intensity > signalIntensity){
82 if(intensity < noiseIntensity || intensity > maxIntensity){
88 if(noise > 0 || signal == 0){
98 m->errorOut(e, "FlowData", "findDeadSpot");
103 //**********************************************************************************************************************
105 void FlowData::translateFlow(){
109 for(int i=0;i<endFlow;i++){
110 int intensity = (int)(flowData[i] + 0.5);
111 char base = baseFlow[i % 4];
113 for(int j=0;j<intensity;j++){
118 if(sequence.size() > 4){
119 sequence = sequence.substr(4);
125 catch(exception& e) {
126 m->errorOut(e, "FlowData", "translateFlow");
131 //**********************************************************************************************************************
133 void FlowData::capFlows(int mF){
138 if(endFlow > maxFlows){ endFlow = maxFlows; }
141 catch(exception& e) {
142 m->errorOut(e, "FlowData", "capFlows");
147 //**********************************************************************************************************************
149 bool FlowData::hasMinFlows(int minFlows){
153 if(endFlow >= minFlows){ pastMin = 1; }
157 catch(exception& e) {
158 m->errorOut(e, "FlowData", "hasMinFlows");
163 //**********************************************************************************************************************
165 Sequence FlowData::getSequence(){
168 return Sequence(seqName, sequence);
170 catch(exception& e) {
171 m->errorOut(e, "FlowData", "getSequence");
176 //**********************************************************************************************************************
178 void FlowData::printFlows(ofstream& outFlowFile){
180 // outFlowFile << '>' << seqName << locationString << " length=" << seqLength << " numflows=" << maxFlows << endl;
181 outFlowFile << seqName << ' ' << endFlow << ' ' << setprecision(2);
183 for(int i=0;i<maxFlows;i++){
184 outFlowFile << flowData[i] << ' ';
188 catch(exception& e) {
189 m->errorOut(e, "FlowData", "printFlows");
194 //**********************************************************************************************************************
196 void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
198 outFlowFile << seqName << '|' << scrapCode << ' ' << endFlow << ' ' << setprecision(2);
200 for(int i=0;i<numFlows;i++){
201 outFlowFile << flowData[i] << ' ';
205 catch(exception& e) {
206 m->errorOut(e, "FlowData", "printFlows");
211 //**********************************************************************************************************************
213 string FlowData::getName(){
218 catch(exception& e) {
219 m->errorOut(e, "FlowData", "getName");
224 //**********************************************************************************************************************