]> git.donarmstrong.com Git - mothur.git/blobdiff - splitabundcommand.cpp
changes for 1.16.0
[mothur.git] / splitabundcommand.cpp
index 924ed690571d9aa5f9861bc41b14a4fad8a1db47..80145bfee4f3bfad04ae5becb2f5198e7a109abb 100644 (file)
@@ -9,6 +9,58 @@
 
 #include "splitabundcommand.h"
 
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getValidParameters(){        
+       try {
+               string Array[] =  {"name","group","list","label","accnos","groups","fasta","cutoff","outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+SplitAbundCommand::SplitAbundCommand(){        
+       try {
+               abort = true;
+               //initialize outputTypes
+               vector<string> tempOutNames;
+               outputTypes["list"] = tempOutNames;
+               outputTypes["name"] = tempOutNames;
+               outputTypes["accnos"] = tempOutNames;
+               outputTypes["group"] = tempOutNames;
+               outputTypes["fasta"] = tempOutNames;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "SplitAbundCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getRequiredParameters(){     
+       try {
+               string Array[] =  {"fasta","list","name","or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> SplitAbundCommand::getRequiredFiles(){  
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SplitAbundCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 SplitAbundCommand::SplitAbundCommand(string option)  {
        try {
@@ -33,7 +85,15 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                        for (it = parameters.begin(); it != parameters.end(); it++) { 
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
-                                               
+                       
+                       //initialize outputTypes
+                       vector<string> tempOutNames;
+                       outputTypes["list"] = tempOutNames;
+                       outputTypes["name"] = tempOutNames;
+                       outputTypes["accnos"] = tempOutNames;
+                       outputTypes["group"] = tempOutNames;
+                       outputTypes["fasta"] = tempOutNames;                    
+                                                                                               
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -42,7 +102,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                                it = parameters.find("list");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["list"] = inputDir + it->second;             }
                                }
@@ -50,7 +110,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                                it = parameters.find("group");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["group"] = inputDir + it->second;            }
                                }
@@ -58,7 +118,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                                it = parameters.find("fasta");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
                                }
@@ -66,7 +126,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                                it = parameters.find("name");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["name"] = inputDir + it->second;             }
                                }
@@ -109,7 +169,7 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                                if (groupfile != "") {  Groups = groupMap->namesOfGroups;  } 
                                else {  m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = "";   }
                        }else { 
-                               splitAtDash(groups, Groups);
+                               m->splitAtDash(groups, Groups);
                        }
                        
                        if ((groupfile == "") && (groups != "")) {  m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = "";  Groups.clear(); }
@@ -122,12 +182,12 @@ SplitAbundCommand::SplitAbundCommand(string option)  {
                        label = validParameter.validFile(parameters, "label", false);                   
                        if (label == "not found") { label = "";  allLines = 1; }
                        else { 
-                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                        
                        string temp = validParameter.validFile(parameters, "accnos", false);            if (temp == "not found") { temp = "F"; }
-                       accnos = isTrue(temp); 
+                       accnos = m->isTrue(temp); 
                        
                        temp = validParameter.validFile(parameters, "cutoff", false);                           if (temp == "not found") { temp = "0"; }
                        convert(temp, cutoff); 
@@ -176,25 +236,7 @@ int SplitAbundCommand::execute(){
                if (abort == true) {    return 0;       }
                
                if (listfile != "") { //you are using a listfile to determine abundance
-                       if (outputDir == "") { outputDir = hasPath(listfile); }
-               
-                       //remove old files so you can append later....
-                       string fileroot = outputDir + getRootName(getSimpleName(listfile));
-                       if (Groups.size() == 0) {
-                               remove((fileroot + "rare.list").c_str());
-                               remove((fileroot + "abund.list").c_str());
-                               
-                               outputNames.push_back((fileroot + "rare.list"));
-                               outputNames.push_back((fileroot + "abund.list"));
-                       }else{
-                               for (int i=0; i<Groups.size(); i++) {
-                                       remove((fileroot + Groups[i] + ".rare.list").c_str());
-                                       remove((fileroot + Groups[i] + ".abund.list").c_str());
-                                       
-                                       outputNames.push_back((fileroot + Groups[i] + ".rare.list"));
-                                       outputNames.push_back((fileroot + Groups[i] + ".abund.list"));
-                               }
-                       }
+                       if (outputDir == "") { outputDir = m->hasPath(listfile); }
                        
                        //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
                        set<string> processedLabels;
@@ -223,7 +265,7 @@ int SplitAbundCommand::execute(){
                                                userLabels.erase(list->getLabel());
                                }
                                
-                               if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                               if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                                string saveLabel = list->getLabel();
                                                
                                                delete list;
@@ -280,7 +322,7 @@ int SplitAbundCommand::execute(){
                        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str()); }       return 0;       }
                                                                        
                }else { //you are using the namefile to determine abundance
-                       if (outputDir == "") { outputDir = hasPath(namefile); }
+                       if (outputDir == "") { outputDir = m->hasPath(namefile); }
                        
                        splitNames(); 
                        writeNames();
@@ -316,7 +358,7 @@ int SplitAbundCommand::splitList(ListVector* thisList) {
                        string bin = thisList->get(i);
                                                
                        vector<string> names;
-                       splitAtComma(bin, names);  //parses bin into individual sequence names
+                       m->splitAtComma(bin, names);  //parses bin into individual sequence names
                        int size = names.size();
                                
                        if (size <= cutoff) {
@@ -326,9 +368,11 @@ int SplitAbundCommand::splitList(ListVector* thisList) {
                        }
                }//end for
 
-               writeList(thisList);
                
                string tag = thisList->getLabel() + ".";
+               
+               writeList(thisList, tag);
+               
                if (groupfile != "")                            {  parseGroup(tag);             }
                if (accnos)                                                     {  writeAccnos(tag);    }
                if (fastafile != "")                            {  parseFasta(tag);             }
@@ -342,7 +386,7 @@ int SplitAbundCommand::splitList(ListVector* thisList) {
        }
 }
 /**********************************************************************************************************************/
-int SplitAbundCommand::writeList(ListVector* thisList) { 
+int SplitAbundCommand::writeList(ListVector* thisList, string tag) { 
        try {
                
                map<string, ofstream*> filehandles;
@@ -364,13 +408,13 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + getRootName(getSimpleName(listfile))  + "rare.list";
-                       openOutputFileAppend(rare, rout);
-                       outputNames.push_back(rare);
+                       string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare.list";
+                       m->openOutputFile(rare, rout);
+                       outputNames.push_back(rare); outputTypes["list"].push_back(rare);
                        
-                       string abund = outputDir + getRootName(getSimpleName(listfile))  + "abund.list";
-                       openOutputFileAppend(abund, aout);
-                       outputNames.push_back(abund);
+                       string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund.list";
+                       m->openOutputFile(abund, aout);
+                       outputNames.push_back(abund); outputTypes["list"].push_back(abund);
 
                        if (rareNames.size() != 0)      {  rout << thisList->getLabel() << '\t' << numRareBins << '\t';         }
                        if (abundNames.size() != 0) {   aout << thisList->getLabel() << '\t' << numAbundBins << '\t';   }
@@ -380,7 +424,7 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                        
                                string bin = list->get(i); 
                        
-                               int size = getNumNames(bin);
+                               int size = m->getNumNames(bin);
                        
                                if (size <= cutoff) {  rout << bin << '\t';  }
                                else                            {  aout << bin << '\t'; }
@@ -393,7 +437,7 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                        aout.close();
                        
                }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + getRootName(getSimpleName(listfile));
+                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(listfile));
                        ofstream* temp;
                        ofstream* temp2;
                        //map<string, bool> wroteFile;
@@ -406,8 +450,10 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               openOutputFileAppend(fileroot + Groups[i] + ".rare.list", *(filehandles[Groups[i]+".rare"]));
-                               openOutputFileAppend(fileroot + Groups[i] + ".abund.list", *(filehandles[Groups[i]+".abund"]));
+                               m->openOutputFile(fileroot + Groups[i] + tag + ".rare.list", *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(fileroot + Groups[i] + tag + ".abund.list", *(filehandles[Groups[i]+".abund"]));
+                               outputNames.push_back(fileroot + Groups[i] + tag + ".rare.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".rare.list");
+                               outputNames.push_back(fileroot + Groups[i] + tag + ".abund.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".abund.list");
                        }
                        
                        map<string, string> groupVector;
@@ -426,7 +472,7 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                                string bin = list->get(i); 
                        
                                vector<string> names;
-                               splitAtComma(bin, names);  //parses bin into individual sequence names
+                               m->splitAtComma(bin, names);  //parses bin into individual sequence names
                        
                                //parse bin into list of sequences in each group
                                for (int j = 0; j < names.size(); j++) {
@@ -439,7 +485,7 @@ int SplitAbundCommand::writeList(ListVector* thisList) {
                                        
                                        string group = groupMap->getGroup(names[j]);
                                
-                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                itGroup = groupBins.find(group+rareAbund);
                                                if(itGroup == groupBins.end()) {
                                                        groupBins[group+rareAbund] = names[j];  //add first name
@@ -483,17 +529,17 @@ int SplitAbundCommand::splitNames() { //namefile
                        
                //open input file
                ifstream in;
-               openInputFile(namefile, in);
+               m->openInputFile(namefile, in);
                
                while (!in.eof()) {
                        if (m->control_pressed) { break; }
                        
                        string firstCol, secondCol;
-                       in >> firstCol >> secondCol; gobble(in);
+                       in >> firstCol >> secondCol; m->gobble(in);
                        
                        nameMap[firstCol] = secondCol;
                        
-                       int size = getNumNames(secondCol);
+                       int size = m->getNumNames(secondCol);
                                
                        if (size <= cutoff) {
                                rareNames.insert(firstCol); 
@@ -516,13 +562,13 @@ int SplitAbundCommand::readNamesFile() {
        try {
                //open input file
                ifstream in;
-               openInputFile(namefile, in);
+               m->openInputFile(namefile, in);
                
                while (!in.eof()) {
                        if (m->control_pressed) { break; }
                        
                        string firstCol, secondCol;
-                       in >> firstCol >> secondCol; gobble(in);
+                       in >> firstCol >> secondCol; m->gobble(in);
                        
                        nameMap[firstCol] = secondCol;
                }
@@ -547,7 +593,7 @@ int SplitAbundCommand::createNameMap(ListVector* thisList) {
                                string bin = thisList->get(i);
                                                        
                                vector<string> names;
-                               splitAtComma(bin, names);  //parses bin into individual sequence names
+                               m->splitAtComma(bin, names);  //parses bin into individual sequence names
                                
                                for (int j = 0; j < names.size(); j++) {  nameMap[names[j]] = names[j];  }
                        }//end for
@@ -570,13 +616,13 @@ int SplitAbundCommand::writeNames() { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + getRootName(getSimpleName(namefile))  + "rare.names";
-                       openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare.names";
+                       m->openOutputFile(rare, rout);
+                       outputNames.push_back(rare); outputTypes["name"].push_back(rare);
                        
-                       string abund = outputDir + getRootName(getSimpleName(namefile))  + "abund.names";
-                       openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund.names";
+                       m->openOutputFile(abund, aout);
+                       outputNames.push_back(abund); outputTypes["name"].push_back(abund);
                        
                        if (rareNames.size() != 0) {
                                for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
@@ -593,7 +639,7 @@ int SplitAbundCommand::writeNames() { //namefile
                        aout.close();
                        
                }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + getRootName(getSimpleName(namefile));
+                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(namefile));
                        ofstream* temp;
                        ofstream* temp2;
                        map<string, ofstream*> filehandles;
@@ -605,13 +651,13 @@ int SplitAbundCommand::writeNames() { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
-                               openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
+                               m->openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
                                vector<string> names;
-                               splitAtComma(itName->second, names);  //parses bin into individual sequence names
+                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
                                
                                string rareAbund;
                                if (rareNames.count(itName->first) != 0) { //you are a rare name
@@ -626,7 +672,7 @@ int SplitAbundCommand::writeNames() { //namefile
                                        
                                        string group = groupMap->getGroup(names[i]);
                                        
-                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                itout = outputStrings.find(group+rareAbund);
                                                if (itout == outputStrings.end()) {  
                                                        outputStrings[group+rareAbund] = names[i] + '\t' + names[i];
@@ -642,7 +688,7 @@ int SplitAbundCommand::writeNames() { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + it3->first + ".names");  
+                               outputNames.push_back(fileroot + it3->first + ".names");  outputTypes["name"].push_back(fileroot + it3->first + ".names");
                                delete it3->second;
                        }
                }
@@ -667,18 +713,18 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        ofstream rout;
                        
                        
-                       string rare = outputDir + getRootName(getSimpleName(inputFile))  + tag + "rare.accnos";
-                       openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare.accnos";
+                       m->openOutputFile(rare, rout);
+                       outputNames.push_back(rare); outputTypes["accnos"].push_back(rare); 
                        
                        for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
                                rout << (*itRare) << endl;
                        }
                        rout.close();
                
-                       string abund = outputDir + getRootName(getSimpleName(inputFile)) + tag  + "abund.accnos";
-                       openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund.accnos";
+                       m->openOutputFile(abund, aout);
+                       outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
                        
                        for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
                                aout << (*itAbund) << endl;
@@ -686,7 +732,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        aout.close();
                        
                }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + getRootName(getSimpleName(inputFile));
+                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(inputFile));
                        ofstream* temp;
                        ofstream* temp2;
                        map<string, ofstream*> filehandles;
@@ -698,15 +744,15 @@ int SplitAbundCommand::writeAccnos(string tag) {
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
-                               openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        //write rare
                        for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
                                        string group = groupMap->getGroup(*itRare);
                                        
-                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                *(filehandles[group+".rare"]) << *itRare << endl;
                                        }
                        }
@@ -715,7 +761,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
                                        string group = groupMap->getGroup(*itAbund);
                                        
-                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                *(filehandles[group+".abund"]) << *itAbund << endl;
                                        }
                        }
@@ -723,7 +769,7 @@ int SplitAbundCommand::writeAccnos(string tag) {
                        //close files
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".accnos");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".accnos");  outputTypes["accnos"].push_back(fileroot + tag + it3->first + ".accnos");
                                delete it3->second;
                        }
                }
@@ -746,17 +792,17 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + getRootName(getSimpleName(groupfile))  + tag + "rare.groups";
-                       openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare.groups";
+                       m->openOutputFile(rare, rout);
+                       outputNames.push_back(rare); outputTypes["group"].push_back(rare);
                
-                       string abund = outputDir + getRootName(getSimpleName(groupfile))  + tag + "abund.groups";
-                       openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund.groups";
+                       m->openOutputFile(abund, aout);
+                       outputNames.push_back(abund); outputTypes["group"].push_back(abund);
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
                                vector<string> names;
-                               splitAtComma(itName->second, names);  //parses bin into individual sequence names
+                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
                                
                                for (int i = 0; i < names.size(); i++) {
                                
@@ -778,7 +824,7 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        aout.close(); 
 
                }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + getRootName(getSimpleName(groupfile));
+                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(groupfile));
                        ofstream* temp;
                        ofstream* temp2;
                        map<string, ofstream*> filehandles;
@@ -790,13 +836,13 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
-                               openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
                                vector<string> names;
-                               splitAtComma(itName->second, names);  //parses bin into individual sequence names
+                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
                                
                                string rareAbund;
                                if (rareNames.count(itName->first) != 0) { //you are a rare name
@@ -809,7 +855,7 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                                
                                        string group = groupMap->getGroup(names[i]);
                                                                        
-                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                *(filehandles[group+rareAbund]) << names[i] << '\t' << group << endl;
                                        }
                                }
@@ -817,7 +863,7 @@ int SplitAbundCommand::parseGroup(string tag) { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".groups");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".groups");  outputTypes["group"].push_back(fileroot + tag + it3->first + ".groups");
                                delete it3->second;
                        }
                }
@@ -840,22 +886,22 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        ofstream aout;
                        ofstream rout;
                        
-                       string rare = outputDir + getRootName(getSimpleName(fastafile))  + tag + "rare.fasta";
-                       openOutputFile(rare, rout);
-                       outputNames.push_back(rare);
+                       string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare.fasta";
+                       m->openOutputFile(rare, rout);
+                       outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
                
-                       string abund = outputDir + getRootName(getSimpleName(fastafile))  + tag + "abund.fasta";
-                       openOutputFile(abund, aout);
-                       outputNames.push_back(abund);
+                       string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund.fasta";
+                       m->openOutputFile(abund, aout);
+                       outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
                
                        //open input file
                        ifstream in;
-                       openInputFile(fastafile, in);
+                       m->openInputFile(fastafile, in);
        
                        while (!in.eof()) {
                                if (m->control_pressed) { break; }
                
-                               Sequence seq(in); gobble(in);
+                               Sequence seq(in); m->gobble(in);
                                
                                if (seq.getName() != "") { 
                                        
@@ -879,7 +925,7 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        aout.close(); 
 
                }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + getRootName(getSimpleName(fastafile));
+                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(fastafile));
                        ofstream* temp;
                        ofstream* temp2;
                        map<string, ofstream*> filehandles;
@@ -891,18 +937,18 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                                temp2 = new ofstream;
                                filehandles[Groups[i]+".abund"] = temp2;
                                
-                               openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
-                               openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
+                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
                        }
                        
                        //open input file
                        ifstream in;
-                       openInputFile(fastafile, in);
+                       m->openInputFile(fastafile, in);
        
                        while (!in.eof()) {
                                if (m->control_pressed) { break; }
                
-                               Sequence seq(in); gobble(in);
+                               Sequence seq(in); m->gobble(in);
                                
                                if (seq.getName() != "") { 
                                        map<string, string>::iterator itNames = nameMap.find(seq.getName());
@@ -911,7 +957,7 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                                                m->mothurOut(seq.getName() + " is not in your namesfile, ignoring."); m->mothurOutEndLine();
                                        }else{
                                                vector<string> names;
-                                               splitAtComma(itNames->second, names);  //parses bin into individual sequence names
+                                               m->splitAtComma(itNames->second, names);  //parses bin into individual sequence names
                                
                                                string rareAbund;
                                                if (rareNames.count(itNames->first) != 0) { //you are a rare name
@@ -924,7 +970,7 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                                
                                                        string group = groupMap->getGroup(seq.getName());
                                        
-                                                       if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+                                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
                                                                seq.printSequence(*(filehandles[group+rareAbund]));
                                                        }else if(group == "not found") {
                                                                m->mothurOut(seq.getName() + " is not in your groupfile. Ignoring."); m->mothurOutEndLine();
@@ -937,7 +983,7 @@ int SplitAbundCommand::parseFasta(string tag) { //namefile
                        
                        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
                                (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".fasta");  
+                               outputNames.push_back(fileroot + tag + it3->first + ".fasta");  outputTypes["fasta"].push_back(fileroot + tag + it3->first + ".fasta");
                                delete it3->second;
                        }
                }