X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=seqnoise.cpp;h=8c712c3ab8bb08c8b8e9282e59e97b03c77d29fc;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=578daafffe4273fae5564781d1407ddc0bd869aa;hpb=e0dc0bcef2a0f7e1f63abb531dbb1ad533da98ca;p=mothur.git diff --git a/seqnoise.cpp b/seqnoise.cpp index 578daaf..8c712c3 100644 --- a/seqnoise.cpp +++ b/seqnoise.cpp @@ -9,6 +9,8 @@ #include "seqnoise.h" #include "sequence.hpp" +#include "listvector.hpp" +#include "inputdata.h" #define MIN_DELTA 1.0e-6 #define MIN_ITER 20 @@ -138,69 +140,132 @@ int seqNoise::getListData(string listFileName, double cutOff, vector& otuDa ifstream listFile; m->openInputFile(listFileName, listFile); - double threshold; - int numOTUs; - if(listFile.peek() == 'u'){ m->getline(listFile); } + bool adjustCutoff = true; + string lastLabel = ""; + + while(!listFile.eof()){ + + ListVector list(listFile); m->gobble(listFile); //10/18/13 - change to reading with listvector to accomodate changes to the listfiel format. ie. adding header labels. + + string thisLabel = list.getLabel(); + lastLabel = thisLabel; + + if (thisLabel == "unique") {} //skip to next label in listfile + else { + double threshold; + m->mothurConvert(thisLabel, threshold); + + if(threshold < cutOff){} //skip to next label in listfile + else{ + adjustCutoff = false; + int numOTUs = list.getNumBins(); + otuFreq.resize(numOTUs, 0); + + for(int i=0;icontrol_pressed) { return 0; } + + string otu = list.get(i); + int count = 0; + string number = ""; + + for(int j=0;jcontrol_pressed) { return 0; } + otuBySeqLookUp[otuData[i]].push_back(i); + } + for(int i=0;icontrol_pressed) { return 0; } + for(int j=otuBySeqLookUp[i].size();j> threshold; + //the listfile does not contain a threshold greater than the cutoff so use highest value + if (adjustCutoff) { + + InputData input(listFileName, "list"); + ListVector* list = input.getListVector(lastLabel); + + int numOTUs = list->getNumBins(); + otuFreq.resize(numOTUs, 0); - if(threshold < cutOff){ - m->getline(listFile); - } - else{ - listFile >> numOTUs; - otuFreq.resize(numOTUs, 0); + for(int i=0;icontrol_pressed) { return 0; } - - string otu; - listFile >> otu; - - int count = 0; - - string number = ""; - - for(int j=0;jcontrol_pressed) { return 0; } - otuBySeqLookUp.resize(numOTUs); + string otu = list->get(i); - int numSeqs = otuData.size(); + int count = 0; + string number = ""; - for(int i=0;icontrol_pressed) { return 0; } - otuBySeqLookUp[otuData[i]].push_back(i); - } - for(int i=0;icontrol_pressed) { return 0; } - for(int j=otuBySeqLookUp[i].size();jcontrol_pressed) { return 0; } + otuBySeqLookUp[otuData[i]].push_back(i); + } + for(int i=0;icontrol_pressed) { return 0; } + for(int j=otuBySeqLookUp[i].size();j