]> git.donarmstrong.com Git - mothur.git/blobdiff - getgroupcommand.cpp
line and label no longer persist between commands. Added phylip formated output...
[mothur.git] / getgroupcommand.cpp
index b4d2d74d0cc72d6c7f4db7acbd4202e3ea5b9972..4d439592127e53ff8b61fc465ef5e27db238e49e 100644 (file)
 GetgroupCommand::GetgroupCommand(){
        try {
                globaldata = GlobalData::getInstance();
-               groupMap = globaldata->gGroupmap;
+               
+               //open shared file
+               sharedfile = globaldata->getSharedFile();
+               openInputFile(sharedfile, in);
+               
+               //open output file
+               outputFile = getRootName(globaldata->inputFileName) + "bootGroups";
+               openOutputFile(outputFile, out);
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -35,9 +42,43 @@ GetgroupCommand::~GetgroupCommand(){
 
 int GetgroupCommand::execute(){
        try {
-               vector<string> groupNames = groupMap->namesOfGroups;    
-               for(int i = 0; i < groupNames.size(); i++)
-                       cout << groupNames[i] << "\n";
+               int num, inputData, count;
+               count = 0;  
+               string holdLabel, nextLabel, groupN, label;
+               
+               //read in first row since you know there is at least 1 group.
+               in >> label >> groupN >> num;
+               holdLabel = label;
+               
+               //output first group
+               cout << groupN << endl;
+               out << groupN << '\t' << groupN << endl;        
+                       
+               //get rest of line
+               for(int i=0;i<num;i++){
+                       in >> inputData;
+               }
+               
+               if (in.eof() != true) { in >> nextLabel; }
+               
+               //read the rest of the groups info in
+               while ((nextLabel == holdLabel) && (in.eof() != true)) {
+                       in >> groupN >> num;
+                       count++;
+                       
+                       //output next group
+                       cout << groupN << endl;
+                       out << groupN << '\t' << groupN << endl;                                
+                       
+                       //fill vector.  
+                       for(int i=0;i<num;i++){
+                               in >> inputData;
+                       }
+                       
+                       if (in.eof() != true) { in >> nextLabel; }
+               }
+               
+               out.close();
                return 0;       
        }