37D928700F21331F001D4494 /* nameassignment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927F00F21331F001D4494 /* nameassignment.cpp */; };
37D928720F21331F001D4494 /* npshannon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927F40F21331F001D4494 /* npshannon.cpp */; };
37D928730F21331F001D4494 /* ordervector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927F70F21331F001D4494 /* ordervector.cpp */; };
- 37D928740F21331F001D4494 /* parselistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927F90F21331F001D4494 /* parselistcommand.cpp */; };
37D928750F21331F001D4494 /* progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927FB0F21331F001D4494 /* progress.cpp */; };
37D928760F21331F001D4494 /* quitcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927FD0F21331F001D4494 /* quitcommand.cpp */; };
37D928770F21331F001D4494 /* rabundvector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927FF0F21331F001D4494 /* rabundvector.cpp */; };
37D927F60F21331F001D4494 /* observable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = observable.h; sourceTree = SOURCE_ROOT; };
37D927F70F21331F001D4494 /* ordervector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ordervector.cpp; sourceTree = SOURCE_ROOT; };
37D927F80F21331F001D4494 /* ordervector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ordervector.hpp; sourceTree = SOURCE_ROOT; };
- 37D927F90F21331F001D4494 /* parselistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parselistcommand.cpp; sourceTree = SOURCE_ROOT; };
- 37D927FA0F21331F001D4494 /* parselistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parselistcommand.h; sourceTree = SOURCE_ROOT; };
37D927FB0F21331F001D4494 /* progress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = progress.cpp; sourceTree = SOURCE_ROOT; };
37D927FC0F21331F001D4494 /* progress.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = progress.hpp; sourceTree = SOURCE_ROOT; };
37D927FD0F21331F001D4494 /* quitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = quitcommand.cpp; sourceTree = SOURCE_ROOT; };
7E5A17AE0FE57292003C6A03 /* mergefilecommand.cpp */,
375873F70F7D649C0040F377 /* nocommands.h */,
375873F60F7D649C0040F377 /* nocommands.cpp */,
- 37D927FA0F21331F001D4494 /* parselistcommand.h */,
- 37D927F90F21331F001D4494 /* parselistcommand.cpp */,
3792946E0F2E191800B9034A /* parsimonycommand.h */,
3792946F0F2E191800B9034A /* parsimonycommand.cpp */,
37D927FE0F21331F001D4494 /* quitcommand.h */,
37D928700F21331F001D4494 /* nameassignment.cpp in Sources */,
37D928720F21331F001D4494 /* npshannon.cpp in Sources */,
37D928730F21331F001D4494 /* ordervector.cpp in Sources */,
- 37D928740F21331F001D4494 /* parselistcommand.cpp in Sources */,
37D928750F21331F001D4494 /* progress.cpp in Sources */,
37D928760F21331F001D4494 /* quitcommand.cpp in Sources */,
37D928770F21331F001D4494 /* rabundvector.cpp in Sources */,
globaldata = GlobalData::getInstance();
globaldata->argv = path;
- string logFileName = "mothur.logFile";
- remove(logFileName.c_str());
system("clear");
}
string options = "";
int quitCommandCalled = 0;
- mothurOut("mothur v.1.4.1");
- mothurOutEndLine();
- mothurOut("Last updated: 6/23/2009");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("by");
- mothurOutEndLine();
- mothurOut("Patrick D. Schloss");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Department of Microbiology");
- mothurOutEndLine();
- mothurOut("pschloss@micro.umass.edu");
- mothurOutEndLine();
- mothurOut("http://schloss.micro.umass.edu/mothur");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Distributed under the GNU General Public License");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Type 'help()' for information on the commands that are available");
- mothurOutEndLine();
- mothurOutEndLine();
- mothurOut("Type 'quit()' to exit program");
- mothurOutEndLine();
-
+
while(quitCommandCalled != 1){
mothurOutEndLine();
openedBatch = openInputFile(batchFileName, inputBatchFile);
globaldata->argv = path;
- string logFileName = "mothur.logFile";
- remove(logFileName.c_str());
-
+
system("clear");
// char buffer = ' ';
listOfCommands = commandString.substr(1, (commandString.length()-1));
globaldata->argv = path;
- string logFileName = "mothur.logFile";
- remove(logFileName.c_str());
-
+
system("clear");
}
int main(int argc, char *argv[]){
try {
+
+ //remove old logfile
+ string logFileName = "mothur.logFile";
+ remove(logFileName.c_str());
+
+ //version
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ #if defined (__APPLE__) || (__MACH__)
+ mothurOutJustToLog("Mac version");
+ mothurOutEndLine(); mothurOutEndLine();
+ #else
+ mothurOutJustToLog("Linux version");
+ mothurOutEndLine(); mothurOutEndLine();
+ #endif
+
+ #else
+ mothurOutJustToLog("Windows version");
+ mothurOutEndLine(); mothurOutEndLine();
+ #endif
+
+
+ //header
+ mothurOut("mothur v.1.4.1");
+ mothurOutEndLine();
+ mothurOut("Last updated: 6/23/2009");
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOut("by");
+ mothurOutEndLine();
+ mothurOut("Patrick D. Schloss");
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOut("Department of Microbiology");
+ mothurOutEndLine();
+ mothurOut("pschloss@micro.umass.edu");
+ mothurOutEndLine();
+ mothurOut("http://schloss.micro.umass.edu/mothur");
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOut("Distributed under the GNU General Public License");
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOut("Type 'help()' for information on the commands that are available");
+ mothurOutEndLine();
+ mothurOutEndLine();
+ mothurOut("Type 'quit()' to exit program");
+ mothurOutEndLine();
+
+
//srand(54321);
srand( (unsigned)time( NULL ) );
+++ /dev/null
-/*
- * parselistcommand.cpp
- * Dotur
- *
- * Created by Sarah Westcott on 1/2/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "parselistcommand.h"
-
-//**********************************************************************************************************************
-ParseListCommand::ParseListCommand(){
- try {
- globaldata = GlobalData::getInstance();
-
- //read in group map info.
- //groupMap = new GroupMap(globaldata->getGroupFile());
- //groupMap->readMap();
- groupMap = globaldata->gGroupmap;
-
- //fill filehandles with neccessary ofstreams
- int i;
- ofstream* temp;
- SharedListVector* templist;
- for (i=0; i<groupMap->getNumGroups(); i++) {
- temp = new ofstream;
- templist = new SharedListVector();
- filehandles[groupMap->namesOfGroups[i]] = temp;
- mapOfLists[groupMap->namesOfGroups[i]] = templist;
- }
-
- //set fileroot
- fileroot = getRootName(globaldata->getListFile());
-
- //clears file before we start to write to it below
- for (int i=0; i<groupMap->getNumGroups(); i++) {
- remove((fileroot + groupMap->namesOfGroups[i] + ".list").c_str());
- }
-
- }
- catch(exception& e) {
- errorOut(e, "ParseListCommand", "ParseListCommand");
- exit(1);
- }
-
-}
-/***********************************************************************/
-void ParseListCommand::parse(int index, SharedListVector* list) {
- try {
- string member, bin, groupName;
- bin = list->get(index);
-
- while (bin.find_first_of(',') != -1) {//while you still have sequences
- member = bin.substr(0,bin.find_first_of(','));
- if ((bin.find_first_of(',')+1) <= bin.length()) { //checks to make sure you don't have comma at end of string
- bin = bin.substr(bin.find_first_of(',')+1, bin.length());
- }
-
- groupName = groupMap->getGroup(member);
- if (groupName != "not found") {
- listGroups[groupName] = listGroups[groupName] + "," + member; //adds prefix to the correct group.
- }else {
- mothurOut("Error: Sequence '" + toString(member) + "' was not found in the group file, please correct\n");
- }
- }
-
- //save last name after comma
- groupName = groupMap->getGroup(bin);
- if (groupName != "not found") {
- listGroups[groupName] = listGroups[groupName] + "," + bin; //adds prefix to the correct group.
- }else {
- mothurOut("Error: Sequence '" + toString(bin) + "' was not found in the group file, please correct\n");
- }
- }
- catch(exception& e) {
- errorOut(e, "ParseListCommand", "parse");
- exit(1);
- }
-}
-
-//**********************************************************************************************************************
-
-int ParseListCommand::execute(){
- try{
-
- int count = 1;
-
- //read in listfile
- read = new ReadOTUFile(globaldata->inputFileName);
- read->read(&*globaldata);
- input = globaldata->ginput;
- list = globaldata->gSharedList;
- string lastLabel = list->getLabel();
-
- //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
- set<string> processedLabels;
- set<string> userLabels = globaldata->labels;
- set<int> userLines = globaldata->lines;
-
- //parses and sets each groups listvector
- //as long as you are not at the end of the file or done wih the lines you want
- while((list != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
-
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lastLabel) == 1){
- mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
- process(list);
-
- processedLabels.insert(list->getLabel());
- userLabels.erase(list->getLabel());
- userLines.erase(count);
- }
-
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
- delete list;
- list = input->getSharedListVector(lastLabel);
-
- mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
- process(list);
-
- processedLabels.insert(list->getLabel());
- userLabels.erase(list->getLabel());
- }
-
-
- lastLabel = list->getLabel();
-
- delete list;
- list = input->getSharedListVector();
- count++;
- }
-
- //output error messages about any remaining user labels
- set<string>::iterator it;
- bool needToRun = false;
- for (it = userLabels.begin(); it != userLabels.end(); it++) {
- mothurOut("Your file does not include the label " + *it);
- if (processedLabels.count(lastLabel) != 1) {
- mothurOut(". I will use " + lastLabel + "."); mothurOutEndLine();
- needToRun = true;
- }else {
- mothurOut(". Please refer to " + lastLabel + "."); mothurOutEndLine();
- }
- }
-
- //run last line if you need to
- if (needToRun == true) {
- delete list;
- list = input->getSharedListVector(lastLabel);
-
- mothurOut(list->getLabel() + "\t" + toString(count)); mothurOutEndLine();
- process(list);
- delete list;
- }
-
- globaldata->gSharedList = NULL;
- //delete list vectors to fill with parsed data
- for (it2 = mapOfLists.begin(); it2 != mapOfLists.end(); it2++) {
- delete it2->second;
- }
- for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
- delete it2->second;
- }
-
- delete input; globaldata->ginput = NULL;
- delete read;
-
-
- return 0;
- }
- catch(exception& e) {
- errorOut(e, "ParseListCommand", "execute");
- exit(1);
- }
-}
-//**********************************************************************************************************************
-
-ParseListCommand::~ParseListCommand(){
-
-
-}
-//**********************************************************************************************************************
-void ParseListCommand::process(SharedListVector* thisList) {
- try {
- string seq;
-
- for(int i=0; i<thisList->size(); i++) {
- parse(i, thisList); //parses data[i] list of sequence names
- for (it=listGroups.begin(); it != listGroups.end(); it++) { //loop through map and set new list vectors
- seq = it->second;
- seq = seq.substr(1, seq.length()); //rips off extra comma
- mapOfLists[it->first]->push_back(seq); //sets new listvector for each group
- }
- listGroups.clear();
- }
- //prints each new list file
- for (int i=0; i<groupMap->getNumGroups(); i++) {
- openOutputFileAppend(fileroot + groupMap->namesOfGroups[i] + ".list", *(filehandles[groupMap->namesOfGroups[i]]));
- mapOfLists[groupMap->namesOfGroups[i]]->setLabel(thisList->getLabel());
- mapOfLists[groupMap->namesOfGroups[i]]->print(*(filehandles[groupMap->namesOfGroups[i]]));
- mapOfLists[groupMap->namesOfGroups[i]]->clear();
- (*(filehandles[groupMap->namesOfGroups[i]])).close();
- }
-
- }
- catch(exception& e) {
- errorOut(e, "ParseListCommand", "process");
- exit(1);
- }
-}
+++ /dev/null
-#ifndef PARSELISTCOMMAND_H
-#define PARSELISTCOMMAND_H
-/*
- * parselistcommand.h
- * Dotur
- *
- * Created by Sarah Westcott on 1/2/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "rabundvector.hpp"
-#include "sharedlistvector.h"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "readotu.h"
-
-
-/* The parselist() command:
- The parselist command is similar to the shared command.
- It parses a list file and separates it into groups. It outputs a .list file for each group.
- The parselist command parameter options are listfile and groupfile.
- The parselist command should be in the following format: parselist(listfile=yourListFile, groupfile=yourGroupFile).
- The listfile parameter and groupfile paramater are required. */
-
-class GlobalData;
-
-class ParseListCommand : public Command {
-
-public:
- ParseListCommand();
- ~ParseListCommand();
- int execute();
- void help() {}
-
-private:
- GlobalData* globaldata;
- GroupMap* groupMap;
- InputData* input;
- ReadOTUFile* read;
- map<string, ofstream*> filehandles;
- map<string, SharedListVector*> mapOfLists;
- SharedListVector* list;
- map<string, string> listGroups; //maps group name to sequences from that group in a specific OTU
- map<string, string>::iterator it;
- map<string, SharedListVector*>::iterator it2;
- map<string, ofstream*>::iterator it3;
- void parse(int, SharedListVector*);
- void process(SharedListVector*);
- string fileroot;
-};
-
-#endif
if (globaldata->getFormat() == "shared") {
- parselist = new ParseListCommand();
- parselist->execute();
- delete parselist;
-
shared = new SharedCommand();
shared->execute();
delete shared;
#include "inputdata.h"
#include "groupmap.h"
#include "sharedcommand.h"
-#include "parselistcommand.h"
/* The read.otu must be run before you execute a collect.single, rarefaction.single, summary.single,
collect.shared, rarefaction.shared or summary.shared command. Mothur will generate a .list, .rabund and .sabund
//ReadOTUFile* read;
InputData* input;
Command* shared;
- Command* parselist;
GroupMap* groupMap;
string filename, listfile, orderfile, sharedfile, line, label, groupfile, sabundfile, rabundfile, format;
filename = getRootName(filename);
filename = filename + "shared";
openOutputFile(filename, out);
+
+ groupMap = globaldata->gGroupmap;
+
+ //fill filehandles with neccessary ofstreams
+ int i;
+ ofstream* temp;
+ for (i=0; i<groupMap->getNumGroups(); i++) {
+ temp = new ofstream;
+ filehandles[groupMap->namesOfGroups[i]] = temp;
+ }
+
+ //set fileroot
+ fileroot = getRootName(globaldata->getListFile());
+
+ //clears file before we start to write to it below
+ for (int i=0; i<groupMap->getNumGroups(); i++) {
+ remove((fileroot + groupMap->namesOfGroups[i] + ".rabund").c_str());
+ }
+
}
catch(exception& e) {
errorOut(e, "SharedCommand", "SharedCommand");
int SharedCommand::execute(){
try {
- mothurOut("creating sharedfile..."); mothurOutEndLine();
//lookup.clear();
int count = 1;
string errorOff = "no error";
if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){
+
lookup = SharedList->getSharedRAbundVector();
+ mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
+
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
lookup = SharedList->getSharedRAbundVector();
+ mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
+
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
SharedList = input->getSharedListVector(lastLabel); //get new list vector to process
lookup = SharedList->getSharedRAbundVector();
+ mothurOut(lookup[0]->getLabel() + "\t" + toString(count)); mothurOutEndLine();
+
printSharedData(lookup); //prints info to the .shared file
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
delete SharedList;
out.close();
- mothurOut("complete."); mothurOutEndLine();
+ for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
+ delete it3->second;
+ }
+
+
return 0;
}
catch(exception& e) {
for (int i = 0; i < thislookup.size(); i++) {
out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
thislookup[i]->print(out);
+
+ openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
+ (*filehandles[thislookup[i]->getGroup()]) << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
+ thislookup[i]->print(*(filehandles[thislookup[i]->getGroup()]));
+ (*(filehandles[thislookup[i]->getGroup()])).close();
}
}
ReadOTUFile* read;
SharedListVector* SharedList;
InputData* input;
- //map<string, SharedRAbundVector*>::iterator it;
- //vector<SharedRAbundVector*> lookup;
+ GroupMap* groupMap;
ofstream out;
- string filename;
+ string filename, fileroot;
bool firsttime;
+ map<string, ofstream*> filehandles;
+ map<string, ofstream*>::iterator it3;
};