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; }
142 catch(exception& e) {
143 m->errorOut(e, "FlowData", "capFlows");
148 //**********************************************************************************************************************
150 bool FlowData::hasMinFlows(int minFlows){
154 if(endFlow >= minFlows){ pastMin = 1; }
158 catch(exception& e) {
159 m->errorOut(e, "FlowData", "hasMinFlows");
164 //**********************************************************************************************************************
166 Sequence FlowData::getSequence(){
169 return Sequence(seqName, sequence);
171 catch(exception& e) {
172 m->errorOut(e, "FlowData", "getSequence");
177 //**********************************************************************************************************************
179 void FlowData::printFlows(ofstream& outFlowFile){
181 // outFlowFile << '>' << seqName << locationString << " length=" << seqLength << " numflows=" << maxFlows << endl;
182 outFlowFile << seqName << ' ' << endFlow << ' ' << setprecision(2);
184 for(int i=0;i<maxFlows;i++){
185 outFlowFile << flowData[i] << ' ';
189 catch(exception& e) {
190 m->errorOut(e, "FlowData", "printFlows");
195 //**********************************************************************************************************************
197 void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
199 outFlowFile << seqName << '|' << scrapCode << ' ' << endFlow << ' ' << setprecision(2);
201 for(int i=0;i<numFlows;i++){
202 outFlowFile << flowData[i] << ' ';
206 catch(exception& e) {
207 m->errorOut(e, "FlowData", "printFlows");
212 //**********************************************************************************************************************
214 string FlowData::getName(){
219 catch(exception& e) {
220 m->errorOut(e, "FlowData", "getName");
225 //**********************************************************************************************************************