X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedordervector.cpp;h=4cc1d18fd80179af4ce8c5069a4e8144ca95dd81;hb=c5c7502f435e1413c19e373dab1dfebcaa67588d;hp=575ae18ea050e90c416efa480181773799a25af5;hpb=fd282e6b4be2560f5b1bd154a9e8d24b798eefaf;p=mothur.git diff --git a/sharedordervector.cpp b/sharedordervector.cpp index 575ae18..4cc1d18 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -11,8 +11,7 @@ using namespace std; #include "sharedordervector.h" -#include "utilities.hpp" -#include + /***********************************************************************/ @@ -26,25 +25,77 @@ SharedOrderVector::SharedOrderVector(string id, vector ov) : updateStats(); } -/*********************************************************************** - -//does not work since we don't have a shared order file format yet. +/***********************************************************************/ +//This function is used to read a .shared file for the collect.shared, rarefaction.shared and summary.shared commands +//if you don't use a list and groupfile. SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { try { - int hold; - - f >> label; - f >> hold; - - data.assign(hold, -1); - - int inputData; - - for(int i=0;igGroupmap == NULL) { groupmap = new GroupMap(); } + + int num, inputData, pos, count; + count = 0; numSeqs = 0; + string holdLabel, nextLabel, groupN; + individual newguy; + + //read in first row since you know there is at least 1 group. + f >> label >> groupN >> num; + holdLabel = label; + + if (globaldata->gGroupmap == NULL) { + //save group in groupmap + groupmap->namesOfGroups.push_back(groupN); + groupmap->groupIndex[groupN] = 0; + } + + for(int i=0;i> inputData; - set(i, inputData, inputData, group); + + for (int j = 0; j < inputData; j++) { + push_back(i+1, i+1, groupN); + numSeqs++; + } + } + + //save position in file in case next line is a new label. + pos = f.tellg(); + + if (f.eof() != true) { f >> nextLabel; } + + //read the rest of the groups info in + while ((nextLabel == holdLabel) && (f.eof() != true)) { + f >> groupN >> num; + count++; + + if (globaldata->gGroupmap == NULL) { + //save group in groupmap + groupmap->namesOfGroups.push_back(groupN); + groupmap->groupIndex[groupN] = count; + } + + for(int i=0;i> inputData; + + for (int j = 0; j < inputData; j++) { + push_back(i+1, i+1, groupN); + numSeqs++; + } + } + + //save position in file in case next line is a new label. + pos = f.tellg(); + + if (f.eof() != true) { f >> nextLabel; } + } + + //put file pointer back since you are now at a new distance label + f.seekg(pos, ios::beg); + + if (globaldata->gGroupmap == NULL) { globaldata->gGroupmap = groupmap; } updateStats(); } @@ -57,10 +108,8 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { exit(1); } } - /***********************************************************************/ - int SharedOrderVector::getNumBins(){ if(needToUpdate == 1){ updateStats(); } return numBins;