]> git.donarmstrong.com Git - mothur.git/commitdiff
changes while testing 1.27
authorSarah Westcott <mothur.westcott@gmail.com>
Mon, 6 Aug 2012 12:38:00 +0000 (08:38 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Mon, 6 Aug 2012 12:38:00 +0000 (08:38 -0400)
22 files changed:
clustercommand.cpp
clusterdoturcommand.cpp
clustersplitcommand.cpp
clustersplitcommand.h
countseqscommand.cpp
flowdata.cpp
groupmap.cpp
hcluster.cpp
mgclustercommand.h
mothurout.cpp
readmatrix.hpp
sequenceparser.cpp
sharedcommand.cpp
shhhercommand.cpp
shhhercommand.h
sparsedistancematrix.cpp
subsamplecommand.cpp
treegroupscommand.h
treemap.cpp
trimflowscommand.cpp
trimseqscommand.cpp
weightedlinkage.cpp

index 19eaf85bc04fdce079f21a189c7d5bd4baa6eca0..5a469963875ab3673e4d9b892e9ecf472f5af09e 100644 (file)
@@ -481,12 +481,12 @@ void ClusterCommand::printData(string label){
                loops = 0;
                start = time(NULL);
         
+        oldRAbund.setLabel(label);
         if (countfile == "") {
             oldRAbund.print(rabundFile);
             oldRAbund.getSAbundVector().print(sabundFile);
         }
-        
-        oldRAbund.setLabel(label);
+       
         if (m->isTrue(showabund)) {
             oldRAbund.getSAbundVector().print(cout);
         }
index 34d2e0eed2bdbf9b97b2997a73fc7cf6f8e60b2f..2515b5c15129434f4d45c19f798c76c7645ad369 100644 (file)
@@ -352,11 +352,12 @@ int ClusterDoturCommand::execute(){
 
 void ClusterDoturCommand::printData(string label){
        try {
-       
-               oldRAbund.setLabel(label);
-               oldRAbund.print(rabundFile);
-               oldRAbund.getSAbundVector().print(sabundFile);
-               
+        oldRAbund.setLabel(label);
+        if (countfile == "") {
+            oldRAbund.print(rabundFile);
+            oldRAbund.getSAbundVector().print(sabundFile);
+        }
+
                oldRAbund.getSAbundVector().print(cout);
                
                oldList.setLabel(label);
index 09be4aaafc3ab9fd794678a578d22ed57329febf..b3ce0f938c90d55fcfb86360677e3fd5e93a01b5 100644 (file)
@@ -1035,7 +1035,7 @@ vector<string>  ClusterSplitCommand::createProcesses(vector< map<string, string>
                //Above fork() will clone, so memory is separate, but that's not the case with windows, 
                //Taking advantage of shared memory to allow both threads to add labels.
                //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
+               /*
                vector<clusterData*> pDataArray; 
                DWORD   dwThreadIdArray[processors-1];
                HANDLE  hThreadArray[processors-1]; 
@@ -1073,7 +1073,7 @@ vector<string>  ClusterSplitCommand::createProcesses(vector< map<string, string>
                        CloseHandle(hThreadArray[i]);
                        delete pDataArray[i];
                }
-
+*/
        #endif          
         
         return listFiles;
index 29dc69a05ad20ad7a19b7956fc3c55928ac5db35..e079197c1ea60d15e2454ad7433e90d2cfbbc611 100644 (file)
@@ -76,7 +76,7 @@ private:
 // anything to do with mothur's use of copy constructors in many of our data structures. ie. listvector 
 // is copied by nameassignment and passed to read which passes to the thread?  -westcott 2-8-12
 ////////////////////////////////////////////////////////////////////////////////////////////////////
-/**************************************************************************************************/
+/**************************************************************************************************
 //custom data structure for threads to use.
 // This is passed by void pointer so it can be any data type
 // that can be passed using a single void pointer (LPVOID).
@@ -106,7 +106,7 @@ struct clusterData {
        }
 };
 
-/**************************************************************************************************/
+/**************************************************************************************************
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 #else
 static DWORD WINAPI MyClusterThreadFunction(LPVOID lpParam){ 
@@ -258,7 +258,7 @@ static DWORD WINAPI MyClusterThreadFunction(LPVOID lpParam){
 } 
 #endif
 
-
+*/
 
 
 #endif
index 210dd9641a1736f8b0ea509f96b210dbbe3bd2e1..7b9aebfbd63d496600a518bca7404f7a4cf4ada0 100644 (file)
@@ -450,6 +450,26 @@ map<int, string> CountSeqsCommand::processNameFile(string name) {
                in.close();
         out.close();
                
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //parse names into vector
+                    vector<string> theseNames;
+                    m->splitAtComma(secondCol, theseNames);
+                    for (int i = 0; i < theseNames.size(); i++) {  out << theseNames[i] << '\t' << count << endl;  }
+                    indexToNames[count] = firstCol;
+                    pairDone = false; 
+                    count++;
+                }
+            }
+
+        }
+        
         return indexToNames;
     }
        catch(exception& e) {
@@ -502,6 +522,26 @@ map<int, string> CountSeqsCommand::getGroupNames(string filename, set<string>& n
                }
                in.close();
         out.close();
+        
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    it = groupIndex.find(secondCol);
+                    if (it == groupIndex.end()) { //add group, assigning the group and number so we can use vectors above
+                        groupIndex[secondCol] = count;
+                        count++;
+                    }
+                    out << firstCol << '\t' << groupIndex[secondCol] << endl; 
+                    namesOfGroups.insert(secondCol);
+                    pairDone = false; 
+                }
+            }
+        }
                
         for (it = groupIndex.begin(); it != groupIndex.end(); it++) {  indexToGroups[it->second] = it->first;  }
         
index 1420f84b992a54ed6dfb6d3a28d8452a083691de..1fe7d7faf1e31ee486890980c4731ddebfdca8fb 100644 (file)
@@ -43,13 +43,15 @@ bool FlowData::getNext(ifstream& flowFile){
        
        try {
                flowFile >> seqName >> endFlow; 
-               //cout << "in Flowdata " + seqName << endl;
-               for(int i=0;i<numFlows;i++)     {       flowFile >> flowData[i];        }
-               //cout << "in Flowdata read " << seqName + " done" << endl;
-               updateEndFlow(); 
-               translateFlow();
-               
-               m->gobble(flowFile);
+        if (seqName.length() != 0) {
+            //cout << "in Flowdata " + seqName << endl;
+            for(int i=0;i<numFlows;i++)        {       flowFile >> flowData[i];        }
+            //cout << "in Flowdata read " << seqName + " done" << endl;
+            updateEndFlow(); 
+            translateFlow();
+            m->gobble(flowFile);
+               }else{ m->mothurOut("Error in reading your flowfile, at position " + toString(flowFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
+            
                if(flowFile){   return 1;       }
                else            {       return 0;       }
        }
index 612b2364d617432d64819413b8d8eb03d9865a64..5b81210e89365a9d98048d10c92e9c518fe01938 100644 (file)
@@ -57,6 +57,28 @@ int GroupMap::readMap() {
         }
                fileHandle.close();
         
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    it = groupmap.find(seqName);
+                    
+                    if (it != groupmap.end()) { error = 1; m->mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        groupmap[seqName] = seqGroup;  //store data in map
+                        seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
+                    }
+                    pairDone = false; 
+                } 
+            }
+        }
+        
                m->setAllGroups(namesOfGroups);
                return error;
     }
@@ -101,6 +123,29 @@ int GroupMap::readDesignMap() {
         }
                fileHandle.close();
         
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    it = groupmap.find(seqName);
+                    
+                    if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        groupmap[seqName] = seqGroup;  //store data in map
+                        seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
+                    }
+                    pairDone = false; 
+                } 
+            }
+
+        }
+        
                m->setAllGroups(namesOfGroups);
                return error;
     }
@@ -148,6 +193,28 @@ int GroupMap::readDesignMap(string filename) {
         }
                fileHandle.close();
         
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    it = groupmap.find(seqName);
+                    
+                    if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        groupmap[seqName] = seqGroup;  //store data in map
+                        seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
+                    }
+                    pairDone = false; 
+                } 
+            }
+        }
+        
                m->setAllGroups(namesOfGroups);
                return error;
     }
index 6cd45314194fccce192c7654e2d8994aff6766c5..f8f48095b2ec55a8dce91d55881271f2f1837218 100644 (file)
@@ -10,7 +10,6 @@
 #include "hcluster.h"
 #include "rabundvector.hpp"
 #include "listvector.hpp"
-#include "sparsematrix.hpp"
 
 /***********************************************************************/
 HCluster::HCluster(RAbundVector* rav, ListVector* lv, string ms, string d, NameAssignment* n, float c) :  rabund(rav), list(lv), method(ms), distfile(d), nameMap(n), cutoff(c) {
index c9c23c80f88d0ab0c98ae058748c544a561b76d3..b5b295f1edb4495d321a7e614db1e8309d8bc481 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "command.hpp"
 #include "readblast.h"
-#include "sparsematrix.hpp"
 #include "nameassignment.hpp"
 #include "cluster.hpp"
 #include "hcluster.h"
index 9704464bf80326c87d4afa556e3353b95fcbf37e..1a3bf79f50dad4e0a66e9910bb4abfe8c2cff944 100644 (file)
@@ -1544,7 +1544,6 @@ vector<string> MothurOut::splitWhiteSpace(string input){
 //**********************************************************************************************************************
 int MothurOut::readTax(string namefile, map<string, string>& taxMap) {
        try {
-               
         //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1575,6 +1574,23 @@ int MothurOut::readTax(string namefile, map<string, string>& taxMap) {
             }
                }
                in.close();
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //are there confidence scores, if so remove them
+                    if (secondCol.find_first_of('(') != -1) {  removeConfidences(secondCol);   }
+                    taxMap[firstCol] = secondCol;
+                    if (debug) {  mothurOut("[DEBUG]: name = '" + firstCol + "' tax = '" + secondCol + "'\n");  }
+                    pairDone = false; 
+                }
+            } 
+        }
                
                return taxMap.size();
 
@@ -1587,7 +1603,6 @@ int MothurOut::readTax(string namefile, map<string, string>& taxMap) {
 /**********************************************************************************************************************/
 int MothurOut::readNames(string namefile, map<string, string>& nameMap, bool redund) { 
        try {
-               
                //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1618,6 +1633,23 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, bool red
             }
                }
                in.close();
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //parse names into vector
+                    vector<string> theseNames;
+                    splitAtComma(secondCol, theseNames);
+                    for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = firstCol;  }
+                    pairDone = false; 
+                }
+            }  
+        }
                
                return nameMap.size();
                
@@ -1630,7 +1662,6 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, bool red
 /**********************************************************************************************************************/
 int MothurOut::readNames(string namefile, map<string, string>& nameMap, int flip) { 
        try {
-               
                //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1658,6 +1689,20 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, int flip
             }
                }
                in.close();
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    nameMap[secondCol] = firstCol;
+                    pairDone = false; 
+                }
+            } 
+        }
                
                return nameMap.size();
                
@@ -1670,7 +1715,7 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, int flip
 /**********************************************************************************************************************/
 int MothurOut::readNames(string namefile, map<string, string>& nameMap, map<string, int>& nameCount) { 
        try {
-               nameMap.clear(); nameCount.clear();
+               nameMap.clear(); nameCount.clear();
                //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1703,6 +1748,24 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, map<stri
                }
                in.close();
                
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    //parse names into vector
+                    vector<string> theseNames;
+                    splitAtComma(secondCol, theseNames);
+                    for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = firstCol;  }
+                    nameCount[firstCol] = theseNames.size();
+                    pairDone = false; 
+                }
+            }
+
+        }
                return nameMap.size();
                
        }
@@ -1714,7 +1777,6 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap, map<stri
 /**********************************************************************************************************************/
 int MothurOut::readNames(string namefile, map<string, string>& nameMap) { 
        try {
-               
                //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1739,6 +1801,17 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap) {
             }
                }
                in.close();
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { nameMap[firstCol] = secondCol; pairDone = false; }
+            }
+        }
                
                return nameMap.size();
                
@@ -1750,8 +1823,7 @@ int MothurOut::readNames(string namefile, map<string, string>& nameMap) {
 }
 /**********************************************************************************************************************/
 int MothurOut::readNames(string namefile, map<string, vector<string> >& nameMap) { 
-       try {
-               
+       try {        
                //open input file
                ifstream in;
                openInputFile(namefile, in);
@@ -1782,6 +1854,22 @@ int MothurOut::readNames(string namefile, map<string, vector<string> >& nameMap)
                }
                in.close();
         
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    vector<string> temp;
+                    splitAtComma(secondCol, temp);
+                    nameMap[firstCol] = temp;
+                    pairDone = false;  
+                } 
+            }
+        }
+        
                return nameMap.size();
        }
        catch(exception& e) {
@@ -1792,7 +1880,6 @@ int MothurOut::readNames(string namefile, map<string, vector<string> >& nameMap)
 /**********************************************************************************************************************/
 map<string, int> MothurOut::readNames(string namefile) { 
        try {
-               
                map<string, int> nameMap;
                
                //open input file
@@ -1823,6 +1910,20 @@ map<string, int> MothurOut::readNames(string namefile) {
             }
                }
         in.close();
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    int num = getNumNames(secondCol);
+                    nameMap[firstCol] = num;
+                    pairDone = false;  
+                } 
+            }
+        }
                
                return nameMap;
                
@@ -1875,6 +1976,29 @@ int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, m
                }
         in.close();
         
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    int num = getNumNames(secondCol);
+                    
+                    map<string, string>::iterator it = fastamap.find(firstCol);
+                    if (it == fastamap.end()) {
+                        error = 1;
+                        mothurOut("[ERROR]: " + firstCol + " is not in your fastafile, but is in your namesfile, please correct."); mothurOutEndLine();
+                    }else {
+                        seqPriorityNode temp(num, it->second, firstCol);
+                        nameVector.push_back(temp);
+                    }
+                    
+                    pairDone = false;  
+                } 
+            }
+        }
                return error;
        }
        catch(exception& e) {
@@ -1885,7 +2009,7 @@ int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, m
 //**********************************************************************************************************************
 set<string> MothurOut::readAccnos(string accnosfile){
        try {
-               set<string> names;
+               set<string> names;
                ifstream in;
                openInputFile(accnosfile, in);
                string name;
@@ -1903,6 +2027,10 @@ set<string> MothurOut::readAccnos(string accnosfile){
         }
                in.close();     
                
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            for (int i = 0; i < pieces.size(); i++) {  names.insert(pieces[i]);  } 
+        }
                return names;
        }
        catch(exception& e) {
@@ -1930,6 +2058,11 @@ int MothurOut::readAccnos(string accnosfile, vector<string>& names){
             for (int i = 0; i < pieces.size(); i++) {  names.push_back(pieces[i]);  }
         }
                in.close();     
+        
+        if (rest != "") {
+            vector<string> pieces = splitWhiteSpace(rest);
+            for (int i = 0; i < pieces.size(); i++) {  names.push_back(pieces[i]);  }
+        }
                
                return 0;
        }
index 90d5b430de4a1ce73e5a9c03880333c4b39febad..bc3874e7f424d24a4a3dbf1465559c916d7423f0 100644 (file)
@@ -16,7 +16,6 @@
 #include "counttable.h"
 #include "sparsedistancematrix.h"
 
-class SparseMatrix;
 
 class ReadMatrix {
 
index 08e5ae8b859280da965566ea9bf4d6dce3b202c7..2aff07ebad9eb0b642a17d59289704b2c85ec9ac 100644 (file)
@@ -59,7 +59,7 @@ SequenceParser::SequenceParser(string groupFile, string fastaFile, string nameFi
                in.close();
                                 
                if (error == 1) { m->control_pressed = true; }
-                                
+               
                //read name file
                ifstream inName;
                m->openInputFile(nameFile, inName);
@@ -148,6 +148,78 @@ SequenceParser::SequenceParser(string groupFile, string fastaFile, string nameFi
             }
                }
                inName.close();
+        
+        //in case file does not end in white space
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  firstCol = pieces[i]; columnOne=false; }
+                else  { secondCol = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { //save one line
+                    if (m->debug) { m->mothurOut("[DEBUG]: reading names: " + firstCol + '\t' + secondCol + ".\n"); }
+                    vector<string> names;
+                    m->splitAtChar(secondCol, names, ',');
+                    
+                    //get aligned string for these seqs from the fasta file
+                    string alignedString = "";
+                    map<string, string>::iterator itAligned = seqName.find(names[0]);
+                    if (itAligned == seqName.end()) {
+                        error = 1; m->mothurOut("[ERROR]: " + names[0] + " is in your name file and not in your fasta file, please correct."); m->mothurOutEndLine();
+                    }else {
+                        alignedString = itAligned->second;
+                    }
+                    
+                    //separate by group - parse one line in name file
+                    map<string, string> splitMap; //group -> name1,name2,...
+                    map<string, string>::iterator it;
+                    for (int i = 0; i < names.size(); i++) {
+                        
+                        string group = groupMap->getGroup(names[i]);
+                        if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + names[i] + " is in your name file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
+                        else { 
+                            
+                            it = splitMap.find(group);
+                            if (it != splitMap.end()) { //adding seqs to this group
+                                (it->second) += "," + names[i];
+                                thisnames1.insert(names[i]);
+                                countName++;
+                            }else { //first sighting of this group
+                                splitMap[group] = names[i];
+                                countName++;
+                                thisnames1.insert(names[i]);
+                                
+                                //is this seq in the fasta file?
+                                if (i != 0) { //if not then we need to add a duplicate sequence to the seqs for this group so the new "fasta" and "name" files will match
+                                    Sequence tempSeq(names[i], alignedString); //get the first guys sequence string since he's in the fasta file.
+                                    seqs[group].push_back(tempSeq);
+                                }
+                            }
+                        }
+                        
+                        allSeqsMap[names[i]] = names[0];
+                    }
+                    
+                    
+                    //fill nameMapPerGroup - holds all lines in namefile separated by group
+                    for (it = splitMap.begin(); it != splitMap.end(); it++) {
+                        //grab first name
+                        string firstName = "";
+                        for(int i = 0; i < (it->second).length(); i++) {
+                            if (((it->second)[i]) != ',') {
+                                firstName += ((it->second)[i]);
+                            }else { break; }
+                        }
+                        
+                        //group1 -> seq1 -> seq1,seq2,seq3
+                        nameMapPerGroup[it->first][firstName] = it->second;
+                    }
+                    
+                    pairDone = false; 
+                }
+            }
+        }
                
                if (error == 1) { m->control_pressed = true; }
                        
index 1150e53735481aea3377ec81f78c0d2544f324e6..e6e790d1687f27a7607555c176bd7b1ebcd44363 100644 (file)
@@ -825,7 +825,7 @@ int SharedCommand::createSharedFromListGroup(string filename) {
         int error = ListGroupSameSeqs(namesSeqs, SharedList);
         
         if ((!pickedGroups) && (SharedList->getNumSeqs() != numGroupNames)) {  //if the user has not specified any groups and their files don't match exit with error
-            m->mothurOut("Your group file contains " + toString(numGroupNames) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); 
+            m->mothurOut("Your group file contains " + toString(numGroupNames) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); m->control_pressed = true;
             
             out.close(); m->mothurRemove(filename); //remove blank shared file you made
             
index c34f25de509c78b9e1b97b7c303142864e3c7e01..c40963999f953e2cfc534afcfdaec1a1e56b8c72 100644 (file)
@@ -1039,7 +1039,12 @@ void ShhherCommand::getFlowData(){
         
         float intensity;
         
-        flowFile >> numFlowCells;
+        string numFlowTest;
+        flowFile >> numFlowTest;
+        
+        if (!m->isContainingOnlyDigits(numFlowTest)) { m->mothurOut("[ERROR]: expected a number and got " + numFlowTest + ", quitting. Did you use the flow parameter instead of the file parameter?"); m->mothurOutEndLine(); exit(1); }
+        else { convert(numFlowTest, numFlowCells); }
+        
         int index = 0;//pcluster
         while(!flowFile.eof()){
             
@@ -1376,17 +1381,17 @@ string ShhherCommand::cluster(string distFileName, string namesFileName){
     try {
         
         ReadMatrix* read = new ReadColumnMatrix(distFileName);         
-        read->setCutoff(cutoff);
-        
-        NameAssignment* clusterNameMap = new NameAssignment(namesFileName);
-        clusterNameMap->readMap();
-        read->read(clusterNameMap);
-        
-        ListVector* list = read->getListVector();
-        SparseMatrix* matrix = read->getMatrix();
+               read->setCutoff(cutoff);
+               
+               NameAssignment* clusterNameMap = new NameAssignment(namesFileName);
+               clusterNameMap->readMap();
+               read->read(clusterNameMap);
         
-        delete read; 
-        delete clusterNameMap; 
+               ListVector* list = read->getListVector();
+               SparseDistanceMatrix* matrix = read->getDMatrix();
+               
+               delete read; 
+               delete clusterNameMap; 
         
         RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
         
@@ -2029,7 +2034,7 @@ int ShhherCommand::createProcesses(vector<string> filenames){
                //Windows version shared memory, so be careful when passing variables through the shhhFlowsData struct. 
                //Above fork() will clone, so memory is separate, but that's not the case with windows, 
                //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
+               /*
                vector<shhhFlowsData*> pDataArray; 
                DWORD   dwThreadIdArray[processors-1];
                HANDLE  hThreadArray[processors-1]; 
@@ -2060,7 +2065,7 @@ int ShhherCommand::createProcesses(vector<string> filenames){
                        CloseHandle(hThreadArray[i]);
                        delete pDataArray[i];
                }
-               
+               */
         #endif
         
         for (int i=0;i<processIDS.size();i++) { 
@@ -2382,7 +2387,12 @@ int ShhherCommand::getFlowData(string filename, vector<string>& thisSeqNameVecto
                thisFlowDataIntI.clear();
                thisNameMap.clear();
                
-               flowFile >> numFlowCells;
+               string numFlowTest;
+        flowFile >> numFlowTest;
+        
+        if (!m->isContainingOnlyDigits(numFlowTest)) { m->mothurOut("[ERROR]: expected a number and got " + numFlowTest + ", quitting. Did you use the flow parameter instead of the file parameter?"); m->mothurOutEndLine(); exit(1); }
+        else { convert(numFlowTest, numFlowCells); }
+        
         if (m->debug) { m->mothurOut("[DEBUG]: numFlowCells = " + toString(numFlowCells) + ".\n"); }
                int index = 0;//pcluster
                while(!flowFile.eof()){
index 03f171e8a85cf0ebe363381793fbaea7e69950ab..9820ccef15f6db94747913eda42e468dba771064 100644 (file)
@@ -18,7 +18,6 @@
 #include "sabundvector.hpp"
 #include "listvector.hpp"
 #include "cluster.hpp"
-#include "sparsematrix.hpp"
 #include <cfloat>
 
 //**********************************************************************************************************************
@@ -167,7 +166,7 @@ private:
        
 };
 
-/**************************************************************************************************/
+/**************************************************************************************************
 //custom data structure for threads to use.
 // This is passed by void pointer so it can be any data type
 // that can be passed using a single void pointer (LPVOID).
@@ -203,7 +202,7 @@ struct shhhFlowsData {
        }
 };
 
-/**************************************************************************************************/
+/**************************************************************************************************
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 #else
 static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){ 
@@ -234,7 +233,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             int numFlowCells;
             
             //int numSeqs = getFlowData(flowFileName, seqNameVector, lengths, flowDataIntI, nameMap, numFlowCells);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             
             ifstream flowFile;
            // cout << "herethread " << flowFileName << '\t' << &flowFile << endl;
@@ -279,13 +278,13 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 }
             }
           //  cout << "here" << endl; 
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
        
                        if (pDataArray->m->control_pressed) { return 0; }
                        
                        pDataArray->m->mothurOut("Identifying unique flowgrams...\n");
                        //int numUniques = getUniques(numSeqs, numFlowCells, uniqueFlowgrams, uniqueCount, uniqueLengths, mapSeqToUnique, mapUniqueToSeq, lengths, flowDataPrI, flowDataIntI);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             int numUniques = 0;
             uniqueFlowgrams.assign(numFlowCells * numSeqs, -1);
             uniqueCount.assign(numSeqs, 0);                                                    //      anWeights
@@ -364,7 +363,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 }
             }            
             
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
                        
                        if (pDataArray->m->control_pressed) { return 0; }
                        
@@ -374,7 +373,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             double begClock = clock();
             
             //flowDistParentFork(numFlowCells, distFileName, numUniques, mapUniqueToSeq, mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);  
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             ostringstream outStream;
             outStream.setf(ios::fixed, ios::floatfield);
             outStream.setf(ios::dec, ios::basefield);
@@ -390,7 +389,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 
                 for(int j=0;j<i;j++){
                     //float flowDistance = calcPairwiseDist(numFlowCells, mapUniqueToSeq[i], mapUniqueToSeq[j], mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);
-                    /*****************************************************************************************************/
+                    /*****************************************************************************************************
                     int seqA = mapUniqueToSeq[i]; int seqB = mapUniqueToSeq[j];
                     int minLength = lengths[mapSeqToUnique[seqA]];
                     if(lengths[seqB] < minLength){     minLength = lengths[mapSeqToUnique[seqB]];      }
@@ -413,7 +412,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                     }
                     
                     flowDistance /= (float) minLength;
-                    /*****************************************************************************************************/
+                    /*****************************************************************************************************
 
                     if(flowDistance < 1e-6){
                         outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << 0.000000 << endl;
@@ -439,14 +438,14 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 pDataArray->m->mothurOut("\t" + toString((clock()-thisbegClock)/CLOCKS_PER_SEC));
                 pDataArray->m->mothurOutEndLine();
             }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
             pDataArray->m->mothurOutEndLine();
             pDataArray->m->mothurOut("Total time: " + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/CLOCKS_PER_SEC) + '\n');
             
                        string namesFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.names";
                        //createNamesFile(numSeqs, numUniques, namesFileName, seqNameVector, mapSeqToUnique, mapUniqueToSeq);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             vector<string> duplicateNames(numUniques, "");
             for(int i=0;i<numSeqs;i++){
                 duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
@@ -460,14 +459,14 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 nameFile << mapUniqueToSeq[i] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
             }
             nameFile.close();
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
                        if (pDataArray->m->control_pressed) { return 0; }
                        
                        pDataArray->m->mothurOut("\nClustering flowgrams...\n");
             string listFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.list";
                        //cluster(listFileName, distFileName, namesFileName);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             ReadMatrix* read = new ReadColumnMatrix(distFileName);     
             read->setCutoff(pDataArray->cutoff);
             
@@ -502,7 +501,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             listFileOut.close();
             
             delete matrix;     delete cluster; delete rabund; delete list;
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
                        if (pDataArray->m->control_pressed) { return 0; }
             
@@ -516,7 +515,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             
                        
                        //int numOTUs = getOTUData(numSeqs, listFileName, otuData, cumNumSeqs, nSeqsPerOTU, aaP, aaI, seqNumber, seqIndex, nameMap);
-                       /*****************************************************************************************************/
+                       /*****************************************************************************************************
             ifstream listFile;
             pDataArray->m->openInputFile(listFileName, listFile);
             string label;
@@ -596,7 +595,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             seqIndex = seqNumber;
             
             listFile.close();      
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
                        if (pDataArray->m->control_pressed) { return 0; }
                        
@@ -643,7 +642,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                                double cycClock = clock();
                                unsigned long long cycTime = time(NULL);
                                //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 int indexFill = 0;
                 for(int i=0;i<numOTUs;i++){
                     
@@ -657,13 +656,13 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                         indexFill++;
                     }
                 }
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                                
                                if (pDataArray->m->control_pressed) { break; }
                 
                                //calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber);
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 for(int i=0;i<numOTUs;i++){
                     
                     if (pDataArray->m->control_pressed) { break; }
@@ -708,7 +707,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                             
                             for(int k=0;k<position;k++){
                                // double dist = getDistToCentroid(anL[k], nI, lengths[nI], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                                /*****************************************************************************************************/
+                                /*****************************************************************************************************
                                 int flowAValue = anL[k] * numFlowCells;
                                 int flowBValue = nI * numFlowCells;
                                 
@@ -721,7 +720,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                                 }
                                 
                                 dist = dist / (double)lengths[nI];
-                                /*****************************************************************************************************/
+                                /*****************************************************************************************************
                                 adF[k] += dist * tauValue;
                             }
                         }
@@ -743,12 +742,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                         centroids[i] = -1;                     
                     }
                 }
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                                if (pDataArray->m->control_pressed) { break; }
                 
                                //maxDelta = getNewWeights(numOTUs, cumNumSeqs, nSeqsPerOTU, singleTau, seqNumber, weight);  
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 double maxChange = 0;
                 
                 for(int i=0;i<numOTUs;i++){
@@ -768,12 +767,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                     if(difference > maxChange){        maxChange = difference; }
                 }
                 maxDelta = maxChange;
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                 if (pDataArray->m->control_pressed) { break; }
                 
                                //double nLL = getLikelihood(numSeqs, numOTUs, nSeqsPerOTU, seqNumber, cumNumSeqs, seqIndex, dist, weight); 
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 vector<long double> P(numSeqs, 0);
                 int effNumOTUs = 0;
                 
@@ -804,12 +803,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 }
                 
                 nLL = nLL -(double)numSeqs * log(pDataArray->sigma);
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                 if (pDataArray->m->control_pressed) { break; }
                 
                                //checkCentroids(numOTUs, centroids, weight);
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 vector<int> unique(numOTUs, 1);
                 
                 for(int i=0;i<numOTUs;i++){
@@ -837,12 +836,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                         }
                     }
                 }
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                                if (pDataArray->m->control_pressed) { break; }
                                
                                //calcNewDistances(numSeqs, numOTUs, nSeqsPerOTU,  dist, weight, change, centroids, aaP, singleTau, aaI, seqNumber, seqIndex, uniqueFlowgrams, flowDataIntI, numFlowCells, lengths);
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
                 int total = 0;
                 vector<double> newTau(numOTUs,0);
                 vector<double> norms(numSeqs, 0);
@@ -860,7 +859,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                         
                         if(weight[j] > MIN_WEIGHT && change[j] == 1){
                             //dist[indexOffset + j] = getDistToCentroid(centroids[j], i, lengths[i], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                            /*****************************************************************************************************/
+                            /*****************************************************************************************************
                             int flowAValue = centroids[j] * numFlowCells;
                             int flowBValue = i * numFlowCells;
                             
@@ -873,7 +872,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                             }
                             
                             dist[indexOffset + j] = distTemp / (double)lengths[i];
-                            /*****************************************************************************************************/
+                            /*****************************************************************************************************
 
                         }
                         
@@ -917,7 +916,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                     
                 }
 
-                /*****************************************************************************************************/
+                /*****************************************************************************************************
 
                                if (pDataArray->m->control_pressed) { break; }
                                
@@ -931,7 +930,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                        
                        pDataArray->m->mothurOut("\nFinalizing...\n");
                        //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             int indexFill = 0;
             for(int i=0;i<numOTUs;i++){
                 
@@ -945,12 +944,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                     indexFill++;
                 }
             }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
                        if (pDataArray->m->control_pressed) { break; }
                        
                        //setOTUs(numOTUs, numSeqs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, otuData, singleTau, dist, aaP, aaI);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             vector<double> bigTauMatrix(numOTUs * numSeqs, 0.0000);
             
             for(int i=0;i<numOTUs;i++){
@@ -993,7 +992,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             }
             
             //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);   
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             indexFill = 0;
             for(int i=0;i<numOTUs;i++){
                 
@@ -1009,7 +1008,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             }
             /*****************************************************************************************************/
 
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
                        if (pDataArray->m->control_pressed) { break; }
                        
@@ -1017,7 +1016,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                        for(int i=0;i<numSeqs;i++)      {       otuCounts[otuData[i]]++;        }
                        
                        //calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber);       
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             for(int i=0;i<numOTUs;i++){
                 
                 if (pDataArray->m->control_pressed) { break; }
@@ -1062,7 +1061,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                         
                         for(int k=0;k<position;k++){
                             // double dist = getDistToCentroid(anL[k], nI, lengths[nI], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                            /*****************************************************************************************************/
+                            /*****************************************************************************************************
                             int flowAValue = anL[k] * numFlowCells;
                             int flowBValue = nI * numFlowCells;
                             
@@ -1075,7 +1074,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                             }
                             
                             dist = dist / (double)lengths[nI];
-                            /*****************************************************************************************************/
+                            /*****************************************************************************************************
                             adF[k] += dist * tauValue;
                         }
                     }
@@ -1098,13 +1097,13 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 }
             }
 
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
             if (pDataArray->m->control_pressed) { break; }
             
                        //writeQualities(numOTUs, numFlowCells, flowFileName, otuCounts, nSeqsPerOTU, seqNumber, singleTau, flowDataIntI, uniqueFlowgrams, cumNumSeqs, mapUniqueToSeq, seqNameVector, centroids, aaI); 
             if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             string thisOutputDir = pDataArray->outputDir;
             if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
             string qualityFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.qual";
@@ -1200,11 +1199,11 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             }
             qualityFile.close();
             pDataArray->outputNames.push_back(qualityFileName);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
            // writeSequences(thisCompositeFASTAFileName, numOTUs, numFlowCells, flowFileName, otuCounts, uniqueFlowgrams, seqNameVector, aaI, centroids);
             if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             thisOutputDir = pDataArray->outputDir;
             if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
             string fastaFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.fasta";
@@ -1243,11 +1242,11 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 pDataArray->m->appendFiles(fastaFileName, pDataArray->thisCompositeFASTAFileName);
             }
 
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
             //writeNames(thisCompositeNamesFileName, numOTUs, flowFileName, otuCounts, seqNameVector, aaI, nSeqsPerOTU);                               
             if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             thisOutputDir = pDataArray->outputDir;
             if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
             string nameFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.names";
@@ -1275,11 +1274,11 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             if(pDataArray->thisCompositeNameFileName != ""){
                 pDataArray->m->appendFiles(nameFileName, pDataArray->thisCompositeNameFileName);
             }          
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
             //writeClusters(flowFileName, numOTUs, numFlowCells,otuCounts, centroids, uniqueFlowgrams, seqNameVector, aaI, nSeqsPerOTU, lengths, flowDataIntI);                        
             if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             thisOutputDir = pDataArray->outputDir;
             if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
             string otuCountsFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.counts";
@@ -1327,12 +1326,12 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
                 }
             }
             otuCountsFile.close();
-            pDataArray->outputNames.push_back(otuCountsFileName);
-            /*****************************************************************************************************/
+            pDataArray->outputNames.push_back(otuCountsFileName)
+            /*****************************************************************************************************
 
             //writeGroups(flowFileName, numSeqs, seqNameVector);                                               
             if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
             thisOutputDir = pDataArray->outputDir;
             if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
             string fileRoot = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName));
@@ -1346,7 +1345,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
             }
             groupFile.close();
             pDataArray->outputNames.push_back(groupFileName);
-            /*****************************************************************************************************/
+            /*****************************************************************************************************
 
             pDataArray->m->mothurOut("Total time to process " + flowFileName + ":\t" + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/(double)CLOCKS_PER_SEC) + '\n');
                }
@@ -1362,7 +1361,7 @@ static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){
        }
 } 
 #endif
-
+*/
 
 #endif
 
index 7d505239d88b4d817b3b6c5fd3609c6c18e785b4..b315c487da1e39053307870560ca165d1068c49a 100644 (file)
@@ -126,7 +126,7 @@ ull SparseDistanceMatrix::getSmallestCell(ull& row){
                return col;
        }
        catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "getSmallestCell");
+               m->errorOut(e, "SparseDistanceMatrix", "getSmallestCell");
                exit(1);
        }
 }
@@ -141,7 +141,7 @@ int SparseDistanceMatrix::sortSeqVec(){
         return 0;
     }
        catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "getSmallestCell");
+               m->errorOut(e, "SparseDistanceMatrix", "sortSeqVec");
                exit(1);
        }
 }
index f9cb1e60e43d59d9d1a6ce760b3031de0e92c301..8c5761d7209df23b3a8127475772e3d80b89967e 100644 (file)
@@ -808,7 +808,7 @@ int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + thislookup[0]->getLabel() + getOutputFileNameTag("shared", sharedfile);        
+               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + thislookup[0]->getLabel() + "." +getOutputFileNameTag("shared", sharedfile);        
         SubSample sample;
         vector<string> subsampledLabels = sample.getSample(thislookup, size);
         
index b0ae730d98aa8af6da4fecabe3cf0f7aa03df2d4..6790afb73984377c1aba8f6488a3cf1c2e544280 100644 (file)
@@ -19,7 +19,6 @@
 #include "readmatrix.hpp"
 #include "readcolumn.h"
 #include "readphylip.h"
-#include "sparsematrix.hpp"
 #include "sharedsobscollectsummary.h"
 #include "sharedchao1.h"
 #include "sharedace.h"
@@ -69,8 +68,6 @@
        They can also use as many or as few calculators as they wish. */
        
 
-typedef list<PCell>::iterator MatData;
-
 class TreeGroupCommand : public Command {
        
 public:
index 42ec336dd53d9da3c0ac44b997cdc7509a89c9cf..7b9fd32a43cbfa8b2ef213889c3a1d4add7661a8 100644 (file)
@@ -13,6 +13,9 @@
 
  TreeMap::TreeMap(string filename) {
        m = MothurOut::getInstance();
+    ofstream out2;
+    m->openOutputFileAppend(filename, out2);
+    out2 << endl; out2.close();
        groupFileName = filename;
        m->openInputFile(filename, fileHandle);
 }
 /************************************************************/
 int TreeMap::readMap(string gf) {
     try {
+        ofstream out2;
+        m->openOutputFileAppend(gf, out2);
+        out2 << endl; out2.close();
+        
         groupFileName = gf;
         m->openInputFile(gf, fileHandle);
         
@@ -65,6 +72,34 @@ int TreeMap::readMap(string gf) {
         }
         fileHandle.close();
         
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
+                    if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        namesOfSeqs.push_back(seqName);
+                        treemap[seqName].groupname = seqGroup; //store data in map
+                        
+                        it2 = seqsPerGroup.find(seqGroup);
+                        if (it2 == seqsPerGroup.end()) { //if it's a new group
+                            seqsPerGroup[seqGroup] = 1;
+                        }else {//it's a group we already have
+                            seqsPerGroup[seqGroup]++;
+                        }                              
+                    }
+                    pairDone = false; 
+                } 
+            }
+        }
+        
         return error;
     }
        catch(exception& e) {
@@ -116,6 +151,34 @@ int TreeMap::readMap() {
         }
         fileHandle.close();
         
+        if (rest != "") {
+            vector<string> pieces = m->splitWhiteSpace(rest);
+            
+            for (int i = 0; i < pieces.size(); i++) {
+                if (columnOne) {  seqName = pieces[i]; columnOne=false; }
+                else  { seqGroup = pieces[i]; pairDone = true; columnOne=true; }
+                
+                if (pairDone) { 
+                    setNamesOfGroups(seqGroup);
+                    
+                    map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
+                    if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
+                    else {
+                        namesOfSeqs.push_back(seqName);
+                        treemap[seqName].groupname = seqGroup; //store data in map
+                        
+                        it2 = seqsPerGroup.find(seqGroup);
+                        if (it2 == seqsPerGroup.end()) { //if it's a new group
+                            seqsPerGroup[seqGroup] = 1;
+                        }else {//it's a group we already have
+                            seqsPerGroup[seqGroup]++;
+                        }                              
+                    }
+                    pairDone = false; 
+                } 
+            }
+        }
+        
         return error;
     }
        catch(exception& e) {
index d45f20cae1f0516c014d42cf7e6afaef57d2a1a2..6a3535fb4af55ee1b217c9a18c4fc83e08db7539 100644 (file)
@@ -423,11 +423,9 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN
                        string trashCode = "";
                        
                        flowData.getNext(flowFile); 
-                       //cout << "driver good bit " << flowFile.good() << endl;        
                        flowData.capFlows(maxFlows);    
                        
                        Sequence currSeq = flowData.getSequence();
-                       
                        if(!flowData.hasMinFlows(minFlows)){    //screen to see if sequence is of a minimum number of flows
                                success = 0;
                                trashCode += 'l';
index 637a720edd26433dfd79b66d8d327109bdd25d7f..ae8dfb7efbb7826f40459ef87198ab72480a65ea 100644 (file)
@@ -611,7 +611,6 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string
                        QualityScores currQual;
                        if(qFileName != ""){
                                currQual = QualityScores(qFile);  m->gobble(qFile);
-                if ((m->debug)&&(count>15800)) { m->mothurOut("[DEBUG]: " + toString(count) + " fasta = " + currSeq.getName() + '\n'); m->mothurOut("[DEBUG]: " + toString(getpid()) + '\n'); }
                        }
                        
                        string origSeq = currSeq.getUnaligned();
index 19c41ce555b87ed296e134bf6d403752a07b5159..c1e4d51be52b95b7eec757930532a8d231f07ea5 100644 (file)
@@ -5,7 +5,6 @@
 #include "mothur.h"
 #include "cluster.hpp"
 #include "rabundvector.hpp"
-#include "sparsematrix.hpp"
 
 /* This class implements the WPGMA, weighted average neighbor clustering algorithm */