]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedrabundvector.cpp
added list parameter to get.seqs and remove.seqs and added readline library for inter...
[mothur.git] / sharedrabundvector.cpp
index 0a69e4c37849171e01544da40f2c09bbd86d40b0..25f9dd3bea207be00b1b35e264d604dd1e9b3a54 100644 (file)
@@ -93,14 +93,16 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                for(int i=0;i<num;i++){
                        f >> inputData;
                        
-                       lookup[0]->push_back(inputData, i, groupN); //abundance, bin, group
-                       push_back(inputData, i, groupN);
+                       lookup[0]->push_back(inputData, groupN); //abundance, bin, group
+                       push_back(inputData, groupN);
                        numSeqs += inputData;
                        numBins++;
                        if (inputData > maxRank) { maxRank = inputData; }
                        
                }
                
+               gobble(f);
+               
                if (f.eof() != true) { f >> nextLabel; }
                
                //read the rest of the groups info in
@@ -123,9 +125,10 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0),
                        //fill vector.  
                        for(int i=0;i<num;i++){
                                f >> inputData;
-                               lookup[count]->push_back(inputData, i, groupN); //abundance, bin, group
+                               lookup[count]->push_back(inputData, groupN); //abundance, bin, group
                        }
                        
+                       gobble(f);
                                
                        if (f.eof() != true) { f >> nextLabel; }
                }
@@ -199,12 +202,12 @@ vector <individual> SharedRAbundVector::getData(){
 }
 /***********************************************************************/
 
-void SharedRAbundVector::push_back(int binSize, int otu, string groupName){
+void SharedRAbundVector::push_back(int binSize, string groupName){
        try {
                individual newGuy;
                newGuy.abundance = binSize;
                newGuy.group = groupName;
-               newGuy.bin = otu;
+               newGuy.bin = data.size();
                
                data.push_back(newGuy);
                numBins++;
@@ -379,12 +382,15 @@ vector<SharedRAbundVector*> SharedRAbundVector::getSharedRAbundVectors(){
 
 RAbundVector SharedRAbundVector::getRAbundVector() {
        try {
-               RAbundVector rav(data.size());
+               RAbundVector rav;
                
                for (int i = 0; i < data.size(); i++) {
-                       rav.set(i, data[i].abundance);
+                       if(data[i].abundance != 0) {
+                               rav.push_back(data[i].abundance);
+                       }
                }
-       
+               
+               rav.setLabel(label);
                return rav;
        }
        catch(exception& e) {