]> git.donarmstrong.com Git - mothur.git/commitdiff
some bug fixes
authorwestcott <westcott>
Wed, 28 Jul 2010 15:09:56 +0000 (15:09 +0000)
committerwestcott <westcott>
Wed, 28 Jul 2010 15:09:56 +0000 (15:09 +0000)
33 files changed:
aligncommand.cpp
aligncommand.h
chimerabellerophoncommand.cpp
chimeraccodecommand.cpp
chimeraccodecommand.h
chimeracheckcommand.cpp
chimeracheckcommand.h
chimerapintailcommand.cpp
chimerapintailcommand.h
chimeraslayercommand.cpp
chimeraslayercommand.h
classifyotucommand.cpp
classifyseqscommand.cpp
classifyseqscommand.h
clustersplitcommand.cpp
collectcommand.cpp
distancecommand.cpp
engine.cpp
filterseqscommand.cpp
filterseqscommand.h
getoturepcommand.cpp
makefile
rarefactcommand.cpp
readtreecommand.cpp
screenseqscommand.cpp
screenseqscommand.h
seqsummarycommand.cpp
seqsummarycommand.h
sffinfocommand.cpp
summarycommand.cpp
validparameter.cpp
validparameter.h
venncommand.cpp

index ee27776c11912bd9fe346f300ffc867f5164223f..f19810e131b687ea372ae1914ecf3a02d03ef8d8 100644 (file)
@@ -45,7 +45,7 @@ AlignCommand::AlignCommand(string option)  {
                        OptionParser parser(option);
                        map<string, string> parameters = parser.getParameters(); 
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("align.seqs");
                        map<string, string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -261,7 +261,7 @@ int AlignCommand::execute(){
 #ifdef USE_MPI 
                                int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                MPIWroteAccnos = false;
                                
                                MPI_Status status; 
@@ -646,7 +646,7 @@ int AlignCommand::driver(linePair* line, string alignFName, string reportFName,
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& alignFile, MPI_File& reportFile, MPI_File& accnosFile, vector<long>& MPIPos){
+int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& alignFile, MPI_File& reportFile, MPI_File& accnosFile, vector<unsigned long int>& MPIPos){
        try {
                string outputString = "";
                MPI_Status statusReport; 
index 186ca63b15cbd09f881d29041de379dc5cf6b6b9..fb47874f8e1ff619a015b66b1f60952aafd61eb0 100644 (file)
@@ -43,7 +43,7 @@ private:
        void appendReportFiles(string, string);
        
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
        
        string candidateFileName, templateFileName, distanceFileName, search, align, outputDir;
index fd768a753c1798d7f26012f0c8d3f065db7c6252..91999094d68f247d3857f129e4d7428ce6f8f5ef 100644 (file)
@@ -27,7 +27,7 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.bellerophon");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
index 69c34016e1c091b2f0a792b6ed990c82a0509fd7..962c15b3134a836b1e2d25fcbeb983a914bb92fe 100644 (file)
@@ -27,7 +27,7 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.ccode");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -228,7 +228,7 @@ int ChimeraCcodeCommand::execute(){
                
                                int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -505,7 +505,7 @@ int ChimeraCcodeCommand::driver(linePair* line, string outputFName, string filen
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<long>& MPIPos){
+int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<unsigned long int>& MPIPos){
        try {
                                
                MPI_Status status; 
index c740a2f383cb5828e34c8bd2123e935f829de4a7..5989eb25e0c5c1488e8bdf69e03157bbe1e7e6fd 100644 (file)
@@ -39,7 +39,7 @@ private:
        int createProcesses(string, string, string);
        
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
 
        bool abort, filter;
index 44696cbbf883c3cde0814c8a615d69d01986a67c..264eb4c4ade8cfa2fd9f56246436b799ecb9d709 100644 (file)
@@ -26,7 +26,7 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.check");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -262,7 +262,7 @@ int ChimeraCheckCommand::execute(){
                
                                int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -490,7 +490,7 @@ int ChimeraCheckCommand::driver(linePair* line, string outputFName, string filen
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<long>& MPIPos){
+int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long int>& MPIPos){
        try {
                MPI_File outAccMPI;
                MPI_Status status; 
index 89dc6aa7144175a6130743fe97fec9eac466c350..84c75ac8b8ff49e85cec777ffb8d2beeec544990 100644 (file)
@@ -40,7 +40,7 @@ private:
        int createProcesses(string, string);
                
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
 
        bool abort, svg;
index fa7fd170fb15cd4f224df0094b139dd24c93c88d..f11e1cafe9b330aebd0edd1d12611255daebbf42 100644 (file)
@@ -27,7 +27,7 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.pintail");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -276,7 +276,7 @@ int ChimeraPintailCommand::execute(){
                #ifdef USE_MPI
                        int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -523,7 +523,7 @@ int ChimeraPintailCommand::driver(linePair* line, string outputFName, string fil
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<long>& MPIPos){
+int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<unsigned long int>& MPIPos){
        try {
                                
                MPI_Status status; 
index 9fc6f437c6724f3424e412b3af5ad0d59c06066e..93707458d3b7b7b09cd1b4eb3aa02f8f03bafa16 100644 (file)
@@ -40,7 +40,7 @@ private:
        int createProcesses(string, string, string);
        
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
 
        bool abort, filter;
index 89d89e38447e620dbdc12ec8aa33da955c40c012..321883be75a2a165bfc61e3e34a97c7de95e37cb 100644 (file)
@@ -29,7 +29,7 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("chimera.slayer");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -253,7 +253,7 @@ int ChimeraSlayerCommand::execute(){
                #ifdef USE_MPI  
                        int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -529,7 +529,7 @@ int ChimeraSlayerCommand::driver(linePair* line, string outputFName, string file
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<long>& MPIPos){
+int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<unsigned long int>& MPIPos){
        try {                           
                MPI_Status status; 
                int pid;
index c2d9c45cfa931e9510981a4ff0c82c1d1e0fa890..95541b2b6aac8a636242dba385c1114267416bb4 100644 (file)
@@ -39,7 +39,7 @@ private:
        int createProcesses(string, string, string);
                
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
 
        bool abort, realign;
index aac16371f1251fc4c7b78639427f95896aa4c223..00f04b08d6a6d42437faced7e76c736e6075d5cb 100644 (file)
@@ -250,7 +250,11 @@ int ClassifyOtuCommand::readNamesFile() {
                        inNames >> names;               //read from second column  A,B,C,D
                        gobble(inNames);
                        
-                       nameMap[name] = names;
+                       //parse names into vector
+                       vector<string> theseNames;
+                       splitAtComma(names, theseNames);
+
+                       for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = name;  }
                        
                        if (m->control_pressed) { inNames.close(); nameMap.clear(); return 0; }
                }
@@ -309,41 +313,46 @@ string ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList,
                
                size = 0;
                for (int i = 0; i < names.size(); i++) {
-                       
-                       if (m->control_pressed) { delete phylo; return conTax; }
-                       
-                       //is this sequence in the taxonomy file
-                       it = taxMap.find(names[i]);
-                       
-                       if (it == taxMap.end()) { //this name is not in taxonomy file, skip it
-                               m->mothurOut(names[i] + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine();
-                       }else{
+               
+                       //if namesfile include the names
+                       if (namefile != "") {
+                               //is this sequence in the name file - namemap maps seqName -> repSeqName
+                               it2 = nameMap.find(names[i]);
                                
-                               //if namesfile include the names
-                               if (namefile != "") {
-                                       //is this sequence in the name file
-                                       it2 = nameMap.find(names[i]);
+                               if (it2 == nameMap.end()) { //this name is not in name file, skip it
+                                       m->mothurOut(names[i] + " is not in your name file.  I will not include it in the consensus."); m->mothurOutEndLine();
+                               }else{
                                        
-                                       if (it2 == nameMap.end()) { //this name is not in name file, skip it
-                                               m->mothurOut(names[i] + " is not in your name file.  I will not include it in the consensus."); m->mothurOutEndLine();
+                                       //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
+                                       it = taxMap.find(it2->second);
+                       
+                                       if (it == taxMap.end()) { //this name is not in taxonomy file, skip it
+                                               if (names[i] != it->second) { m->mothurOut(names[i] + " is represented by " +  it2->second + " and is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
+                                               else {  m->mothurOut(names[i] + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
                                        }else{
-                                               
-                                               vector<string> nameFileNames;
-                                               splitAtComma(it2->second, nameFileNames);
-                                               
-                                               for (int j = 0; j < nameFileNames.size(); j++) {
-                                                       //add seq to tree
-                                                       phylo->addSeqToTree(nameFileNames[j], it->second);
-                                                       size++;
-                                               }
+                               
+                                               //add seq to tree
+                                               phylo->addSeqToTree(names[i], it->second);
+                                               size++;
                                        }
-                                       
+                               }
+                               
+                       }else{
+                               //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
+                               it = taxMap.find(names[i]);
+               
+                               if (it == taxMap.end()) { //this name is not in taxonomy file, skip it
+                                       m->mothurOut(names[i] + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine();
                                }else{
                                        //add seq to tree
                                        phylo->addSeqToTree(names[i], it->second);
                                        size++;
                                }
                        }
+
+                       
+                       if (m->control_pressed) { delete phylo; return conTax; }
+                       
                }
                
                //build tree
index a20a383b6125e135fc1aefeec47e2bc6b892f1e9..0635fdeb4cd9a72de87d786d6a0aa30056b99a7d 100644 (file)
@@ -32,7 +32,7 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
                        OptionParser parser(option);
                        map<string, string> parameters = parser.getParameters(); 
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("classify.seqs");
                        map<string, string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -414,7 +414,7 @@ int ClassifySeqsCommand::execute(){
 #ifdef USE_MPI 
                                int pid, end, numSeqsPerProcessor; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -841,7 +841,7 @@ int ClassifySeqsCommand::driver(linePair* line, string taxFName, string tempTFNa
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& newFile, MPI_File& tempFile, vector<long>& MPIPos){
+int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& newFile, MPI_File& tempFile, vector<unsigned long int>& MPIPos){
        try {
                MPI_Status statusNew; 
                MPI_Status statusTemp; 
index 3294118343bbf763fa93dc56b6a05a3f8043c5ca..03e6826d1276b4efbdf12b5fce0aeb4cdea8fb08 100644 (file)
@@ -61,7 +61,7 @@ private:
        
        int MPIReadNamesFile(string);
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<long>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&);
        #endif
 };
 
index deea384a46d58f9f7e3683c88009a3e16a45b760..d6855ccc0f08456d6ed1db9d15c504928546b688 100644 (file)
@@ -34,7 +34,7 @@ ClusterSplitCommand::ClusterSplitCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("cluster.split");
                
                        //check to make sure all parameters are valid for command
                        map<string,string>::iterator it;
index 88be43b9a283b3313eacb6093ffe4f496c6bc452..8c1565b901d5b885ad86b91d31cb7cc041138535 100644 (file)
@@ -137,12 +137,13 @@ int CollectCommand::execute(){
                
                vector<string> outputNames;
                
+               string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
-               else {  inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
+               else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
        
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); return 0; }
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         }  globaldata->Groups.clear(); if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        if (outputDir == "") { outputDir += hasPath(inputFileNames[p]); }
                        string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
@@ -221,7 +222,7 @@ int CollectCommand::execute(){
                        }
                
                        //if the users entered no valid calculators don't execute command
-                       if (cDisplays.size() == 0) { return 0; }
+                       if (cDisplays.size() == 0) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        read = new ReadOTUFile(inputFileNames[p]);      
                        read->read(&*globaldata); 
@@ -242,6 +243,7 @@ int CollectCommand::execute(){
                                delete order; globaldata->gorder = NULL;
                                delete validCalculator;
                                globaldata->Groups.clear();
+                               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                return 0;
                        }
 
@@ -256,6 +258,7 @@ int CollectCommand::execute(){
                                        delete order; globaldata->gorder = NULL;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                                }
 
@@ -306,6 +309,7 @@ int CollectCommand::execute(){
                                        delete read;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                        }
                                
@@ -341,6 +345,7 @@ int CollectCommand::execute(){
                                        delete order; globaldata->gorder = NULL;
                                        delete validCalculator;
                                        globaldata->Groups.clear();
+                                       if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
                                        return 0;
                                }
                                delete order;
@@ -354,8 +359,11 @@ int CollectCommand::execute(){
                        delete validCalculator;
                }
                
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
+               //return to shared mode if you changed above
+               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
 
+               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());         } return 0; }
+                               
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
index 503f64b21cfd0ae64ec7413c7bfc3dc993e7e2d3..05ed87cb960c5c61fff158384723ff9d3b2a1e3a 100644 (file)
@@ -32,7 +32,7 @@ DistanceCommand::DistanceCommand(string option) {
                        OptionParser parser(option);
                        map<string, string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("dist.seqs");
                        map<string, string>::iterator it2;
                
                        //check to make sure all parameters are valid for command
index 65349352d791f91aceeb850b114b697037984d41..7bcb4e41185bfa2104b3ef29432db0af7cbe58a2 100644 (file)
@@ -51,11 +51,12 @@ bool InteractEngine::getInput(){
                
                while(quitCommandCalled != 1){
 
+
                        mout->mothurOutEndLine();
                        
                        input = getCommand();   
                        mout->mothurOutEndLine();       
-                       
+               
                        if (mout->control_pressed) { input = "quit()"; }
                        
                        //allow user to omit the () on the quit command
@@ -331,7 +332,7 @@ bool ScriptEngine::getInput(){
                                        mout->executing = false;
                                                                        
                                        #ifdef USE_MPI
-                                       cout << pid << " is done in execute" << endl;
+                                       //cout << pid << " is done in execute" << endl;
                                                }
                                        #endif
                                }else {         
index 3784c3deab49a0c4302101372247f48f5ec3e89b..d2c7c6bb1f46e9e3ee1eef49ff83b6d4e840d173 100644 (file)
@@ -28,7 +28,7 @@ FilterSeqsCommand::FilterSeqsCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("filter.seqs");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -258,7 +258,7 @@ int FilterSeqsCommand::filterSequences() {
 #ifdef USE_MPI 
                                int pid, start, end, numSeqsPerProcessor, num; 
                                int tag = 2001;
-                               vector<long>MPIPos;
+                               vector<unsigned long int>MPIPos;
                                                
                                MPI_Status status; 
                                MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
@@ -393,7 +393,7 @@ int FilterSeqsCommand::filterSequences() {
 }
 #ifdef USE_MPI
 /**************************************************************************************/
-int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<long>& MPIPos) {     
+int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long int>& MPIPos) {        
        try {
                string outputString = "";
                int count = 0;
@@ -569,7 +569,7 @@ string FilterSeqsCommand::createFilter() {
 #ifdef USE_MPI 
                                int pid, numSeqsPerProcessor, num; 
                                int tag = 2001;
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_File inMPI; 
@@ -797,7 +797,7 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair*
 }
 #ifdef USE_MPI
 /**************************************************************************************/
-int FilterSeqsCommand::MPICreateFilter(int start, int num, Filters& F, MPI_File& inMPI, vector<long>& MPIPos) {        
+int FilterSeqsCommand::MPICreateFilter(int start, int num, Filters& F, MPI_File& inMPI, vector<unsigned long int>& MPIPos) {   
        try {
                
                MPI_Status status; 
index 2ec152bb557eb27970c3660136b1b879f658949d..e068405816e3d8c0bc1e21b2fb8316f779009526 100644 (file)
@@ -49,8 +49,8 @@ private:
        int driverRunFilter(string, string, string, linePair*);\r
        int driverCreateFilter(Filters& F, string filename, linePair* line);\r
        #ifdef USE_MPI\r
-       int driverMPIRun(int, int, MPI_File&, MPI_File&, vector<long>&);\r
-       int MPICreateFilter(int, int, Filters&, MPI_File&, vector<long>&);      \r
+       int driverMPIRun(int, int, MPI_File&, MPI_File&, vector<unsigned long int>&);\r
+       int MPICreateFilter(int, int, Filters&, MPI_File&, vector<unsigned long int>&); \r
        #endif\r
        int setLines(string);\r
        \r
index 89c62faba2f0d3350d3dea797bd2bebbe23074c3..b872d1a17b16b3472f189045621b325c2b816d36 100644 (file)
@@ -755,7 +755,7 @@ int GetOTURepCommand::processNames(string filename, string label) {
 
                        if (sequence != "not found") {
                                if (sorted == "") { //print them out
-                                       rep = rep + "|" + toString(i+1);
+                                       rep = rep + "\t" + toString(i+1);
                                        rep = rep + "|" + toString(binsize);
                                        if (groupfile != "") {
                                                rep = rep + "|" + group;
@@ -781,7 +781,7 @@ int GetOTURepCommand::processNames(string filename, string label) {
                        //print them
                        for (int i = 0; i < reps.size(); i++) {
                                string sequence = fasta->getSequence(reps[i].name);
-                               string outputName = reps[i].name + "|" + toString(reps[i].bin);
+                               string outputName = reps[i].name + "\t" + toString(reps[i].bin);
                                outputName = outputName + "|" + toString(reps[i].size);
                                if (groupfile != "") {
                                        outputName = outputName + "|" + reps[i].group;
@@ -794,6 +794,7 @@ int GetOTURepCommand::processNames(string filename, string label) {
                out.close();
                out2.close();
                
+               remove(filename.c_str());
                rename(tempNameFile.c_str(), filename.c_str());
                
                return 0;
index 3f0893c5ad82d811fb4c5cf05f86f0326b4561c8..dccd2c3d3dd12235530bba90da5ffeaa53b670cc 100644 (file)
--- a/makefile
+++ b/makefile
@@ -13,7 +13,7 @@
 
 CXXFLAGS += -O3
 
-MOTHUR_FILES = "\"Enter_your_default_path_here\""
+MOTHUR_FILES = "\"../Release\""
 ifeq  ($(strip $(MOTHUR_FILES)),"\"Enter_your_default_path_here\"")
 else
        CXXFLAGS += -DMOTHUR_FILES=${MOTHUR_FILES}
@@ -39,7 +39,7 @@ endif
 # if you do not want to use the readline library, set this to no.
 # make sure you have the library installed
 
-USEREADLINE ?= yes
+USEREADLINE ?= no
 
 ifeq  ($(strip $(USEREADLINE)),yes)
     CXXFLAGS += -DUSE_READLINE
@@ -48,7 +48,7 @@ ifeq  ($(strip $(USEREADLINE)),yes)
       -lncurses
 endif
 
-USEMPI ?= no
+USEMPI ?= yes
 
 ifeq  ($(strip $(USEMPI)),yes)
     CXX = mpic++
index 5d6b5d8b3160f0b6bc31199c1e7fc6e60f496254..217a1520bd11c3ef36e1cd48a7ed0e47326e32e8 100644 (file)
@@ -131,17 +131,18 @@ int RareFactCommand::execute(){
                
                vector<string> outputNames;
                
+               string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
-               else {  inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
-               
-               if (m->control_pressed) { return 0; }
+               else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
+                               
+               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
                        string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
                        globaldata->inputFileName = inputFileNames[p];
                        
-                       if (m->control_pressed) { return 0; }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        if (inputFileNames.size() > 1) {
                                m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
@@ -203,12 +204,12 @@ int RareFactCommand::execute(){
                        set<string> processedLabels;
                        set<string> userLabels = labels;
                        
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
                        
                        //as long as you are not at the end of the file or done wih the lines you want
                        while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                
-                               if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+                               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; delete order; globaldata->gorder = NULL; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
 
                                
                                if(allLines == 1 || labels.count(order->getLabel()) == 1){
@@ -246,7 +247,7 @@ int RareFactCommand::execute(){
                                order = (input->getOrderVector());
                        }
                        
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }  return 0; }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL; for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str()); }  return 0; }
 
                        //output error messages about any remaining user labels
                        set<string>::iterator it;
@@ -261,7 +262,7 @@ int RareFactCommand::execute(){
                                }
                        }
                        
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    } delete validCalculator; delete read; delete input; globaldata->ginput = NULL;  for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
 
                        //run last label if you need to
                        if (needToRun == true)  {
@@ -286,6 +287,8 @@ int RareFactCommand::execute(){
                        
                }
                
+               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
+               
                if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str()); } return 0; }
 
                m->mothurOutEndLine();
index 8e292af4db27b4bdbbba829fa5280c9723dfb2f7..07aa5b3e4071289a25400e7cb03f616b34ad18ba 100644 (file)
@@ -108,8 +108,10 @@ void ReadTreeCommand::help(){
        try {
                m->mothurOut("The read.tree command must be run before you execute a unifrac.weighted, unifrac.unweighted. \n");
                m->mothurOut("It also must be run before using the parsimony command, unless you are using the randomtree parameter.\n");
+               m->mothurOut("The read.tree command parameters are tree, group and name.\n");
                m->mothurOut("The read.tree command should be in the following format: read.tree(tree=yourTreeFile, group=yourGroupFile).\n");
                m->mothurOut("The tree and group parameters are both required.\n");
+               m->mothurOut("The name parameter allows you to enter a namefile.\n");
                m->mothurOut("Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n\n");
        }
        catch(exception& e) {
index 09b82cebe3138f44533aa477b0d24fa9165c0e08..b2fdaff640557e7f9b840748db2afbde438bf5e5 100644 (file)
@@ -28,7 +28,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("screen.seqs");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -179,7 +179,7 @@ int ScreenSeqsCommand::execute(){
 #ifdef USE_MPI 
                        int pid, end, numSeqsPerProcessor; 
                        int tag = 2001;
-                       vector<long> MPIPos;
+                       vector<unsigned long int> MPIPos;
                        
                        MPI_Status status; 
                        MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
@@ -749,7 +749,7 @@ int ScreenSeqsCommand::driver(linePair* line, string goodFName, string badFName,
 }
 //**********************************************************************************************************************
 #ifdef USE_MPI
-int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& goodFile, MPI_File& badFile, MPI_File& badAccnosFile, vector<long>& MPIPos, set<string>& badSeqNames){
+int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& goodFile, MPI_File& badFile, MPI_File& badAccnosFile, vector<unsigned long int>& MPIPos, set<string>& badSeqNames){
        try {
                string outputString = "";
                MPI_Status statusGood; 
index 314e6617f6b2ec76033636ec8a05f722b3274e49..071724f79cb45c69bb4c4237c072ddc462188439 100644 (file)
@@ -38,7 +38,7 @@ private:
        int createProcesses(string, string, string, string, set<string>&);
        
        #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<long>&, set<string>&);
+       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&, set<string>&);
        #endif
 
        bool abort;
index 66405394859d182134884e4141b53d377c7ae245..5009ff5c2eeb87e1cbe49fdd0f240355bfcaaf74 100644 (file)
@@ -27,7 +27,7 @@ SeqSummaryCommand::SeqSummaryCommand(string option)  {
                        OptionParser parser(option);
                        map<string,string> parameters = parser.getParameters();
                        
-                       ValidParameters validParameter;
+                       ValidParameters validParameter("summary.seqs");
                        map<string,string>::iterator it;
                        
                        //check to make sure all parameters are valid for command
@@ -113,7 +113,7 @@ int SeqSummaryCommand::execute(){
                                int tag = 2001;
                                int startTag = 1; int endTag = 2; int lengthTag = 3; int baseTag = 4; int lhomoTag = 5;
                                int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               vector<long> MPIPos;
+                               vector<unsigned long int> MPIPos;
                                
                                MPI_Status status; 
                                MPI_Status statusOut;
@@ -360,7 +360,7 @@ int SeqSummaryCommand::driverCreateSummary(vector<int>& startPosition, vector<in
 }
 #ifdef USE_MPI
 /**************************************************************************************/
-int SeqSummaryCommand::MPICreateSummary(int start, int num, vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, MPI_File& inMPI, MPI_File& outMPI, vector<long>& MPIPos) {    
+int SeqSummaryCommand::MPICreateSummary(int start, int num, vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long int>& MPIPos) {       
        try {
                
                int pid;
index 3e576a0b8aa276c6134cefb83fea9831d0520661..a62572673c3d7497007ab959157fd41dfb6b124b 100644 (file)
@@ -38,7 +38,7 @@ private:
        int setLines(string);
 
        #ifdef USE_MPI
-       int MPICreateSummary(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, MPI_File&, MPI_File&, vector<long>&);      
+       int MPICreateSummary(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, MPI_File&, MPI_File&, vector<unsigned long int>&); 
        #endif
 
 
index e2527ff3bc0bd7be5caa6124b6594bc172574e13..8c0e473a87e86453c8721b0f5c5b5bde947b703b 100644 (file)
-/*\r
- *  sffinfocommand.cpp\r
- *  Mothur\r
- *\r
- *  Created by westcott on 7/7/10.\r
- *  Copyright 2010 Schloss Lab. All rights reserved.\r
- *\r
- */\r
-\r
-#include "sffinfocommand.h"\r
-#include "endiannessmacros.h"\r
-\r
-//**********************************************************************************************************************\r
-\r
-SffInfoCommand::SffInfoCommand(string option)  {\r
-       try {\r
-               abort = false;\r
-               hasAccnos = false;\r
-               \r
-               //allow user to run help\r
-               if(option == "help") { help(); abort = true; }\r
-               \r
-               else {\r
-                       //valid paramters for this command\r
-                       string Array[] =  {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};\r
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));\r
-                       \r
-                       OptionParser parser(option);\r
-                       map<string, string> parameters = parser.getParameters();\r
-                       \r
-                       ValidParameters validParameter;\r
-                       //check to make sure all parameters are valid for command\r
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { \r
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }\r
-                       }\r
-                       \r
-                       //if the user changes the output directory command factory will send this info to us in the output parameter \r
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }\r
-                       \r
-                       //if the user changes the input directory command factory will send this info to us in the output parameter \r
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);        if (inputDir == "not found"){ inputDir = "";          }\r
-\r
-                       sffFilename = validParameter.validFile(parameters, "sff", false);\r
-                       if (sffFilename == "not found") { m->mothurOut("sff is a required parameter for the sffinfo command."); m->mothurOutEndLine(); abort = true;  }\r
-                       else { \r
-                               splitAtDash(sffFilename, filenames);\r
-                               \r
-                               //go through files and make sure they are good, if not, then disregard them\r
-                               for (int i = 0; i < filenames.size(); i++) {\r
-                                       if (inputDir != "") {\r
-                                               string path = hasPath(filenames[i]);\r
-                                               //if the user has not given a path then, add inputdir. else leave path alone.\r
-                                               if (path == "") {       filenames[i] = inputDir + filenames[i];         }\r
-                                       }\r
-       \r
-                                       ifstream in;\r
-                                       int ableToOpen = openInputFile(filenames[i], in, "noerror");\r
-                               \r
-                                       //if you can't open it, try default location\r
-                                       if (ableToOpen == 1) {\r
-                                               if (m->getDefaultPath() != "") { //default path is set\r
-                                                       string tryPath = m->getDefaultPath() + getSimpleName(filenames[i]);\r
-                                                       m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();\r
-                                                       ableToOpen = openInputFile(tryPath, in, "noerror");\r
-                                                       filenames[i] = tryPath;\r
-                                               }\r
-                                       }\r
-                                       in.close();\r
-                                       \r
-                                       if (ableToOpen == 1) { \r
-                                               m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine();\r
-                                               //erase from file list\r
-                                               filenames.erase(filenames.begin()+i);\r
-                                               i--;\r
-                                       }\r
-                               }\r
-                               \r
-                               //make sure there is at least one valid file left\r
-                               if (filenames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }\r
-                       }\r
-                       \r
-                       accnosName = validParameter.validFile(parameters, "accnos", false);\r
-                       if (accnosName == "not found") { accnosName = "";  }\r
-                       else { \r
-                               hasAccnos = true;\r
-                               splitAtDash(accnosName, accnosFileNames);\r
-                               \r
-                               //go through files and make sure they are good, if not, then disregard them\r
-                               for (int i = 0; i < accnosFileNames.size(); i++) {\r
-                                       if (inputDir != "") {\r
-                                               string path = hasPath(accnosFileNames[i]);\r
-                                               //if the user has not given a path then, add inputdir. else leave path alone.\r
-                                               if (path == "") {       accnosFileNames[i] = inputDir + accnosFileNames[i];             }\r
-                                       }\r
-       \r
-                                       ifstream in;\r
-                                       int ableToOpen = openInputFile(accnosFileNames[i], in, "noerror");\r
-                               \r
-                                       //if you can't open it, try default location\r
-                                       if (ableToOpen == 1) {\r
-                                               if (m->getDefaultPath() != "") { //default path is set\r
-                                                       string tryPath = m->getDefaultPath() + getSimpleName(accnosFileNames[i]);\r
-                                                       m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();\r
-                                                       ableToOpen = openInputFile(tryPath, in, "noerror");\r
-                                                       accnosFileNames[i] = tryPath;\r
-                                               }\r
-                                       }\r
-                                       in.close();\r
-                                       \r
-                                       if (ableToOpen == 1) { \r
-                                               m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();\r
-                                               //erase from file list\r
-                                               accnosFileNames.erase(accnosFileNames.begin()+i);\r
-                                               i--;\r
-                                       }\r
-                               }\r
-                               \r
-                               //make sure there is at least one valid file left\r
-                               if (accnosFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }\r
-                       }\r
-                       \r
-                       if (hasAccnos) {\r
-                               if (accnosFileNames.size() != filenames.size()) { abort = true; m->mothurOut("If you provide a accnos file, you must have one for each sff file."); m->mothurOutEndLine(); }\r
-                       }\r
-                       \r
-                       string temp = validParameter.validFile(parameters, "qfile", false);                     if (temp == "not found"){       temp = "T";                             }\r
-                       qual = isTrue(temp); \r
-                       \r
-                       temp = validParameter.validFile(parameters, "fasta", false);                            if (temp == "not found"){       temp = "T";                             }\r
-                       fasta = isTrue(temp); \r
-                       \r
-                       temp = validParameter.validFile(parameters, "flow", false);                                     if (temp == "not found"){       temp = "F";                             }\r
-                       flow = isTrue(temp); \r
-                       \r
-                       temp = validParameter.validFile(parameters, "trim", false);                                     if (temp == "not found"){       temp = "T";                             }\r
-                       trim = isTrue(temp); \r
-                       \r
-                       temp = validParameter.validFile(parameters, "sfftxt", false);                           if (temp == "not found"){       temp = "F";                             }\r
-                       sfftxt = isTrue(temp); \r
-               }\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "SffInfoCommand");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-\r
-void SffInfoCommand::help(){\r
-       try {\r
-               m->mothurOut("The sffinfo command reads a sff file and extracts the sequence data.\n");\r
-               m->mothurOut("The sffinfo command parameters are sff, fasta, qfile, accnos, flow, sfftxt, and trim. sff is required. \n");\r
-               m->mothurOut("The sff parameter allows you to enter the sff file you would like to extract data from.  You may enter multiple files by separating them by -'s.\n");\r
-               m->mothurOut("The fasta parameter allows you to indicate if you would like a fasta formatted file generated.  Default=True. \n");\r
-               m->mothurOut("The qfile parameter allows you to indicate if you would like a quality file generated.  Default=True. \n");\r
-               m->mothurOut("The flow parameter allows you to indicate if you would like a flowgram file generated.  Default=False. \n");\r
-               m->mothurOut("The sfftxt parameter allows you to indicate if you would like a sff.txt file generated.  Default=False. \n");\r
-               m->mothurOut("The trim parameter allows you to indicate if you would like a sequences and quality scores trimmed to the clipQualLeft and clipQualRight values.  Default=True. \n");\r
-               m->mothurOut("The accnos parameter allows you to provide a accnos file containing the names of the sequences you would like extracted. You may enter multiple files by separating them by -'s. \n");\r
-               m->mothurOut("Example sffinfo(sff=mySffFile.sff, trim=F).\n");\r
-               m->mothurOut("Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n\n");\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "help");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-\r
-SffInfoCommand::~SffInfoCommand(){}\r
-\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::execute(){\r
-       try {\r
-               \r
-               if (abort == true) { return 0; }\r
-               \r
-               for (int s = 0; s < filenames.size(); s++) {\r
-                       \r
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }\r
-                       \r
-                       int start = time(NULL);\r
-                       \r
-                       m->mothurOut("Extracting info from " + filenames[s] + " ..." ); m->mothurOutEndLine();\r
-                       \r
-                       string accnos = "";\r
-                       if (hasAccnos) { accnos = accnosFileNames[s]; }\r
-                       \r
-                       int numReads = extractSffInfo(filenames[s], accnos);\r
-\r
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to extract " + toString(numReads) + ".");\r
-               }\r
-               \r
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }\r
-               \r
-               //report output filenames\r
-               m->mothurOutEndLine();\r
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();\r
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }\r
-               m->mothurOutEndLine();\r
-\r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "execute");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::extractSffInfo(string input, string accnos){\r
-       try {\r
-               \r
-               if (outputDir == "") {  outputDir += hasPath(input); }\r
-               \r
-               if (accnos != "")       {  readAccnosFile(accnos);  }\r
-               else                            {       seqNames.clear();               }\r
-\r
-               ofstream outSfftxt, outFasta, outQual, outFlow;\r
-               string outFastaFileName, outQualFileName;\r
-               string sfftxtFileName = outputDir + getRootName(getSimpleName(input)) + "sff.txt";\r
-               string outFlowFileName = outputDir + getRootName(getSimpleName(input)) + "flow";\r
-               if (trim) {\r
-                       outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "fasta";\r
-                       outQualFileName = outputDir + getRootName(getSimpleName(input)) + "qual";\r
-               }else{\r
-                       outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "raw.fasta";\r
-                       outQualFileName = outputDir + getRootName(getSimpleName(input)) + "raw.qual";\r
-               }\r
-               \r
-               if (sfftxt) { openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName); }\r
-               if (fasta)      { openOutputFile(outFastaFileName, outFasta);   outputNames.push_back(outFastaFileName); }\r
-               if (qual)       { openOutputFile(outQualFileName, outQual);             outputNames.push_back(outQualFileName);  }\r
-               if (flow)       { openOutputFile(outFlowFileName, outFlow);             outputNames.push_back(outFlowFileName);  }\r
-               \r
-               ifstream in;\r
-               in.open(input.c_str(), ios::binary);\r
-               \r
-               CommonHeader header; \r
-               readCommonHeader(in, header);\r
-               \r
-               int count = 0;\r
-               \r
-               //check magic number and version\r
-               if (header.magicNumber != 779314790) { m->mothurOut("Magic Number is not correct, not a valid .sff file"); m->mothurOutEndLine(); return count; }\r
-               if (header.version != "0001") { m->mothurOut("Version is not supported, only support version 0001."); m->mothurOutEndLine(); return count; }\r
-       \r
-               //print common header\r
-               if (sfftxt) { printCommonHeader(outSfftxt, header); }\r
-       \r
-               //read through the sff file\r
-               while (!in.eof()) {\r
-                       \r
-                       bool print = true;\r
-                       \r
-                       //read header\r
-                       Header readheader;\r
-                       readHeader(in, readheader);\r
-                       \r
-                       //read data\r
-                       seqRead read; \r
-                       readSeqData(in, read, header.numFlowsPerRead, readheader.numBases);\r
-                               \r
-                       //if you have provided an accosfile and this seq is not in it, then dont print\r
-                       if (seqNames.size() != 0) {   if (seqNames.count(readheader.name) == 0) { print = false; }  }\r
-                       \r
-                       //print \r
-                       if (print) {\r
-                               if (sfftxt) { printHeader(outSfftxt, readheader); printSffTxtSeqData(outSfftxt, read, readheader); }\r
-                               if (fasta)      {       printFastaSeqData(outFasta, read, readheader);  }\r
-                               if (qual)       {       printQualSeqData(outQual, read, readheader);    }\r
-                               if (flow)       {       printFlowSeqData(outFlow, read, readheader);    }\r
-                       }\r
-                       \r
-                       count++;\r
-               \r
-                       //report progress\r
-                       if((count+1) % 10000 == 0){     m->mothurOut(toString(count+1)); m->mothurOutEndLine();         }\r
-               \r
-                       if (m->control_pressed) { count = 0; break;   }\r
-                       \r
-                       if (count >= header.numReads) { break; }\r
-               }\r
-               \r
-               //report progress\r
-               if (!m->control_pressed) {   if((count) % 10000 != 0){  m->mothurOut(toString(count)); m->mothurOutEndLine();           }  }\r
-               \r
-               in.close();\r
-               \r
-               if (sfftxt) {  outSfftxt.close();       }\r
-               if (fasta)      {  outFasta.close();    }\r
-               if (qual)       {  outQual.close();             }\r
-               if (flow)       {  outFlow.close();             }\r
-               \r
-               return count;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "extractSffInfo");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){\r
-       try {\r
-\r
-               if (!in.eof()) {\r
-\r
-                       //read magic number\r
-                       char buffer[4];\r
-                       in.read(buffer, 4);\r
-                       header.magicNumber = be_int4(*(unsigned int *)(&buffer));\r
-               \r
-                       //read version\r
-                       char buffer9[4];\r
-                       in.read(buffer9, 4);\r
-                       header.version = "";\r
-                       for (int i = 0; i < 4; i++) {  header.version += toString((int)(buffer9[i])); }\r
-                               \r
-                       //read offset\r
-                       char buffer2 [8];\r
-                       in.read(buffer2, 8);\r
-                       header.indexOffset =  be_int8(*(unsigned long int *)(&buffer2));\r
-                       \r
-                       //read index length\r
-                       char buffer3 [4];\r
-                       in.read(buffer3, 4);\r
-                       header.indexLength =  be_int4(*(unsigned int *)(&buffer3));\r
-                       \r
-                       //read num reads\r
-                       char buffer4 [4];\r
-                       in.read(buffer4, 4);\r
-                       header.numReads =  be_int4(*(unsigned int *)(&buffer4));\r
-                               \r
-                       //read header length\r
-                       char buffer5 [2];\r
-                       in.read(buffer5, 2);\r
-                       header.headerLength =  be_int2(*(unsigned short *)(&buffer5));\r
-                                       \r
-                       //read key length\r
-                       char buffer6 [2];\r
-                       in.read(buffer6, 2);\r
-                       header.keyLength = be_int2(*(unsigned short *)(&buffer6));\r
-                       \r
-                       //read number of flow reads\r
-                       char buffer7 [2];\r
-                       in.read(buffer7, 2);\r
-                       header.numFlowsPerRead =  be_int2(*(unsigned short *)(&buffer7));\r
-                               \r
-                       //read format code\r
-                       char buffer8 [1];\r
-                       in.read(buffer8, 1);\r
-                       header.flogramFormatCode = (int)(buffer8[0]);\r
-                       \r
-                       //read flow chars\r
-                       char* tempBuffer = new char[header.numFlowsPerRead];\r
-                       in.read(&(*tempBuffer), header.numFlowsPerRead); \r
-                       header.flowChars = tempBuffer;\r
-                       if (header.flowChars.length() > header.numFlowsPerRead) { header.flowChars = header.flowChars.substr(0, header.numFlowsPerRead);  }\r
-                       delete[] tempBuffer;\r
-                       \r
-                       //read key\r
-                       char* tempBuffer2 = new char[header.keyLength];\r
-                       in.read(&(*tempBuffer2), header.keyLength);\r
-                       header.keySequence = tempBuffer2;\r
-                       if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength);  }\r
-                       delete[] tempBuffer2;\r
-                               \r
-                       /* Pad to 8 chars */\r
-                       unsigned long int spotInFile = in.tellg();\r
-                       unsigned long int spot = (spotInFile + 7)& ~7;  // ~ inverts\r
-                       in.seekg(spot);\r
-                       \r
-               }else{\r
-                       m->mothurOut("Error reading sff common header."); m->mothurOutEndLine();\r
-               }\r
-\r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "readCommonHeader");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::readHeader(ifstream& in, Header& header){\r
-       try {\r
-       \r
-               if (!in.eof()) {\r
-                       \r
-                       //read header length\r
-                       char buffer [2];\r
-                       in.read(buffer, 2);\r
-                       header.headerLength = be_int2(*(unsigned short *)(&buffer));\r
-                                               \r
-                       //read name length\r
-                       char buffer2 [2];\r
-                       in.read(buffer2, 2);\r
-                       header.nameLength = be_int2(*(unsigned short *)(&buffer2));\r
-\r
-                       //read num bases\r
-                       char buffer3 [4];\r
-                       in.read(buffer3, 4);\r
-                       header.numBases =  be_int4(*(unsigned int *)(&buffer3));\r
-                       \r
-                       //read clip qual left\r
-                       char buffer4 [2];\r
-                       in.read(buffer4, 2);\r
-                       header.clipQualLeft =  be_int2(*(unsigned short *)(&buffer4));\r
-                       \r
-                       //read clip qual right\r
-                       char buffer5 [2];\r
-                       in.read(buffer5, 2);\r
-                       header.clipQualRight =  be_int2(*(unsigned short *)(&buffer5));\r
-                       \r
-                       //read clipAdapterLeft\r
-                       char buffer6 [2];\r
-                       in.read(buffer6, 2);\r
-                       header.clipAdapterLeft = be_int2(*(unsigned short *)(&buffer6));\r
-\r
-                       //read clipAdapterRight\r
-                       char buffer7 [2];\r
-                       in.read(buffer7, 2);\r
-                       header.clipAdapterRight = be_int2(*(unsigned short *)(&buffer7));\r
-               \r
-                       //read name\r
-                       char* tempBuffer = new char[header.nameLength];\r
-                       in.read(&(*tempBuffer), header.nameLength);\r
-                       header.name = tempBuffer;\r
-                       if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength);  }\r
-                       delete[] tempBuffer;\r
-                       \r
-                       /* Pad to 8 chars */\r
-                       unsigned long int spotInFile = in.tellg();\r
-                       unsigned long int spot = (spotInFile + 7)& ~7;\r
-                       in.seekg(spot);\r
-                       \r
-               }else{\r
-                       m->mothurOut("Error reading sff header info."); m->mothurOutEndLine();\r
-               }\r
-\r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "readHeader");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, int numBases){\r
-       try {\r
-       \r
-               if (!in.eof()) {\r
-       \r
-                       //read flowgram\r
-                       read.flowgram.resize(numFlowReads);\r
-                       for (int i = 0; i < numFlowReads; i++) {  \r
-                               char buffer [2];\r
-                               in.read(buffer, 2);\r
-                               read.flowgram[i] = be_int2(*(unsigned short *)(&buffer));\r
-                       }\r
-       \r
-                       //read flowIndex\r
-                       read.flowIndex.resize(numBases);\r
-                       for (int i = 0; i < numBases; i++) {  \r
-                               char temp[1];\r
-                               in.read(temp, 1);\r
-                               read.flowIndex[i] = be_int1(*(unsigned char *)(&temp));\r
-                       }\r
-       \r
-                       //read bases\r
-                       char* tempBuffer = new char[numBases];\r
-                       in.read(&(*tempBuffer), numBases);\r
-                       read.bases = tempBuffer;\r
-                       if (read.bases.length() > numBases) { read.bases = read.bases.substr(0, numBases);  }\r
-                       delete[] tempBuffer;\r
-\r
-                       //read qual scores\r
-                       read.qualScores.resize(numBases);\r
-                       for (int i = 0; i < numBases; i++) {  \r
-                               char temp[1];\r
-                               in.read(temp, 1);\r
-                               read.qualScores[i] = be_int1(*(unsigned char *)(&temp));\r
-                       }\r
-       \r
-                       /* Pad to 8 chars */\r
-                       unsigned long int spotInFile = in.tellg();\r
-                       unsigned long int spot = (spotInFile + 7)& ~7;\r
-                       in.seekg(spot);\r
-                       \r
-               }else{\r
-                       m->mothurOut("Error reading."); m->mothurOutEndLine();\r
-               }\r
-\r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "readSeqData");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printCommonHeader(ofstream& out, CommonHeader& header) {\r
-       try {\r
-       \r
-               out << "Common Header:\nMagic Number: " << header.magicNumber << endl;\r
-               out << "Version: " << header.version << endl;\r
-               out << "Index Offset: " << header.indexOffset << endl;\r
-               out << "Index Length: " << header.indexLength << endl;\r
-               out << "Number of Reads: " << header.numReads << endl;\r
-               out << "Header Length: " << header.headerLength << endl;\r
-               out << "Key Length: " << header.keyLength << endl;\r
-               out << "Number of Flows: " << header.numFlowsPerRead << endl;\r
-               out << "Format Code: " << header.flogramFormatCode << endl;\r
-               out << "Flow Chars: " << header.flowChars << endl;\r
-               out << "Key Sequence: " << header.keySequence << endl << endl;\r
-                       \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printCommonHeader");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printHeader(ofstream& out, Header& header) {\r
-       try {\r
-               \r
-               out << ">" << header.name << endl;\r
-               out << "Run Prefix: " << endl;\r
-               out << "Region #:  " << endl;\r
-               out << "XY Location: " << endl << endl;\r
-               \r
-               out << "Run Name:  " << endl;\r
-               out << "Analysis Name:  " << endl;\r
-               out << "Full Path: " << endl << endl;\r
-               \r
-               out << "Read Header Len: " << header.headerLength << endl;\r
-               out << "Name Length: " << header.nameLength << endl;\r
-               out << "# of Bases: " << header.numBases << endl;\r
-               out << "Clip Qual Left: " << header.clipQualLeft << endl;\r
-               out << "Clip Qual Right: " << header.clipQualRight << endl;\r
-               out << "Clip Adap Left: " << header.clipAdapterLeft << endl;\r
-               out << "Clip Adap Right: " << header.clipAdapterRight << endl << endl;\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printHeader");\r
-               exit(1);\r
-       }\r
-}\r
-\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& header) {\r
-       try {\r
-               \r
-               out << "FlowGram: ";\r
-               for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }\r
-               \r
-               out << endl <<  "Flow Indexes: ";\r
-               int sum = 0;\r
-               for (int i = 0; i < read.flowIndex.size(); i++) {  sum +=  read.flowIndex[i];  out << sum << '\t'; }\r
-               \r
-               //make the bases you want to clip lowercase and the bases you want to keep upper case\r
-               for (int i = 0; i < header.clipQualLeft; i++) { read.bases[i] = tolower(read.bases[i]); }\r
-               for (int i = header.clipQualLeft; i < (header.clipQualRight-header.clipQualLeft); i++) {   read.bases[i] = toupper(read.bases[i]);  }\r
-               for (int i = (header.clipQualRight-header.clipQualLeft); i < read.bases.length(); i++) {   read.bases[i] = tolower(read.bases[i]);  }\r
-               \r
-               out << endl <<  "Bases: " << read.bases << endl << "Quality Scores: ";\r
-               for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }\r
-       \r
-               \r
-               out << endl << endl;\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printSffTxtSeqData");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) {\r
-       try {\r
-               \r
-               string seq = read.bases;\r
-               \r
-               \r
-               if (trim) {\r
-                       seq = seq.substr(header.clipQualLeft, (header.clipQualRight-header.clipQualLeft));\r
-               }else{\r
-                       //if you wanted the sfftxt then you already converted the bases to the right case\r
-                       if (!sfftxt) {\r
-                               //make the bases you want to clip lowercase and the bases you want to keep upper case\r
-                               for (int i = 0; i < header.clipQualLeft; i++) { seq[i] = tolower(seq[i]);  }\r
-                               for (int i = header.clipQualLeft; i < (header.clipQualRight-header.clipQualLeft); i++) {   seq[i] = toupper(seq[i]);  }\r
-                               for (int i = (header.clipQualRight-header.clipQualLeft); i < seq.length(); i++) {   seq[i] = tolower(seq[i]);  }\r
-                       }\r
-               }\r
-               \r
-               out << ">" << header.name << endl;\r
-               out << seq << endl;\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printFastaSeqData");\r
-               exit(1);\r
-       }\r
-}\r
-\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& header) {\r
-       try {\r
-               \r
-               if (trim) {\r
-                       out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;\r
-                       for (int i = header.clipQualLeft; i < (header.clipQualRight-header.clipQualLeft); i++) {   out << read.qualScores[i] << '\t';  }\r
-               }else{\r
-                       out << ">" << header.name << " length=" << read.qualScores.size() << endl;\r
-                       for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }\r
-               }\r
-               \r
-               out << endl;\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printQualSeqData");\r
-               exit(1);\r
-       }\r
-}\r
-\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {\r
-       try {\r
-               \r
-               out << ">" << header.name << endl;\r
-               for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }\r
-               out << endl;\r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "printFlowSeqData");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************\r
-int SffInfoCommand::readAccnosFile(string filename) {\r
-       try {\r
-               //remove old names\r
-               seqNames.clear();\r
-               \r
-               ifstream in;\r
-               openInputFile(filename, in);\r
-               string name;\r
-               \r
-               while(!in.eof()){\r
-                       in >> name; gobble(in);\r
-                                               \r
-                       seqNames.insert(name);\r
-                       \r
-                       if (m->control_pressed) { seqNames.clear(); break; }\r
-               }\r
-               in.close();             \r
-               \r
-               return 0;\r
-       }\r
-       catch(exception& e) {\r
-               m->errorOut(e, "SffInfoCommand", "readAccnosFile");\r
-               exit(1);\r
-       }\r
-}\r
-//**********************************************************************************************************************/\r
+/*
+ *  sffinfocommand.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 7/7/10.
+ *  Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "sffinfocommand.h"
+#include "endiannessmacros.h"
+
+//**********************************************************************************************************************
+
+SffInfoCommand::SffInfoCommand(string option)  {
+       try {
+               abort = false;
+               hasAccnos = false;
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
+               
+               else {
+                       //valid paramters for this command
+                       string Array[] =  {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};
+                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+                       
+                       OptionParser parser(option);
+                       map<string, string> parameters = parser.getParameters();
+                       
+                       ValidParameters validParameter;
+                       //check to make sure all parameters are valid for command
+                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
+                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
+                       }
+                       
+                       //if the user changes the output directory command factory will send this info to us in the output parameter 
+                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
+                       
+                       //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 = "";          }
+
+                       sffFilename = validParameter.validFile(parameters, "sff", false);
+                       if (sffFilename == "not found") { m->mothurOut("sff is a required parameter for the sffinfo command."); m->mothurOutEndLine(); abort = true;  }
+                       else { 
+                               splitAtDash(sffFilename, filenames);
+                               
+                               //go through files and make sure they are good, if not, then disregard them
+                               for (int i = 0; i < filenames.size(); i++) {
+                                       if (inputDir != "") {
+                                               string path = hasPath(filenames[i]);
+                                               //if the user has not given a path then, add inputdir. else leave path alone.
+                                               if (path == "") {       filenames[i] = inputDir + filenames[i];         }
+                                       }
+       
+                                       ifstream in;
+                                       int ableToOpen = openInputFile(filenames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(filenames[i]);
+                                                       m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       filenames[i] = tryPath;
+                                               }
+                                       }
+                                       in.close();
+                                       
+                                       if (ableToOpen == 1) { 
+                                               m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine();
+                                               //erase from file list
+                                               filenames.erase(filenames.begin()+i);
+                                               i--;
+                                       }
+                               }
+                               
+                               //make sure there is at least one valid file left
+                               if (filenames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
+                       }
+                       
+                       accnosName = validParameter.validFile(parameters, "accnos", false);
+                       if (accnosName == "not found") { accnosName = "";  }
+                       else { 
+                               hasAccnos = true;
+                               splitAtDash(accnosName, accnosFileNames);
+                               
+                               //go through files and make sure they are good, if not, then disregard them
+                               for (int i = 0; i < accnosFileNames.size(); i++) {
+                                       if (inputDir != "") {
+                                               string path = hasPath(accnosFileNames[i]);
+                                               //if the user has not given a path then, add inputdir. else leave path alone.
+                                               if (path == "") {       accnosFileNames[i] = inputDir + accnosFileNames[i];             }
+                                       }
+       
+                                       ifstream in;
+                                       int ableToOpen = openInputFile(accnosFileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(accnosFileNames[i]);
+                                                       m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       accnosFileNames[i] = tryPath;
+                                               }
+                                       }
+                                       in.close();
+                                       
+                                       if (ableToOpen == 1) { 
+                                               m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
+                                               //erase from file list
+                                               accnosFileNames.erase(accnosFileNames.begin()+i);
+                                               i--;
+                                       }
+                               }
+                               
+                               //make sure there is at least one valid file left
+                               if (accnosFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
+                       }
+                       
+                       if (hasAccnos) {
+                               if (accnosFileNames.size() != filenames.size()) { abort = true; m->mothurOut("If you provide a accnos file, you must have one for each sff file."); m->mothurOutEndLine(); }
+                       }
+                       
+                       string temp = validParameter.validFile(parameters, "qfile", false);                     if (temp == "not found"){       temp = "T";                             }
+                       qual = isTrue(temp); 
+                       
+                       temp = validParameter.validFile(parameters, "fasta", false);                            if (temp == "not found"){       temp = "T";                             }
+                       fasta = isTrue(temp); 
+                       
+                       temp = validParameter.validFile(parameters, "flow", false);                                     if (temp == "not found"){       temp = "F";                             }
+                       flow = isTrue(temp); 
+                       
+                       temp = validParameter.validFile(parameters, "trim", false);                                     if (temp == "not found"){       temp = "T";                             }
+                       trim = isTrue(temp); 
+                       
+                       temp = validParameter.validFile(parameters, "sfftxt", false);                           if (temp == "not found"){       temp = "F";                             }
+                       sfftxt = isTrue(temp); 
+               }
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void SffInfoCommand::help(){
+       try {
+               m->mothurOut("The sffinfo command reads a sff file and extracts the sequence data.\n");
+               m->mothurOut("The sffinfo command parameters are sff, fasta, qfile, accnos, flow, sfftxt, and trim. sff is required. \n");
+               m->mothurOut("The sff parameter allows you to enter the sff file you would like to extract data from.  You may enter multiple files by separating them by -'s.\n");
+               m->mothurOut("The fasta parameter allows you to indicate if you would like a fasta formatted file generated.  Default=True. \n");
+               m->mothurOut("The qfile parameter allows you to indicate if you would like a quality file generated.  Default=True. \n");
+               m->mothurOut("The flow parameter allows you to indicate if you would like a flowgram file generated.  Default=False. \n");
+               m->mothurOut("The sfftxt parameter allows you to indicate if you would like a sff.txt file generated.  Default=False. \n");
+               m->mothurOut("The trim parameter allows you to indicate if you would like a sequences and quality scores trimmed to the clipQualLeft and clipQualRight values.  Default=True. \n");
+               m->mothurOut("The accnos parameter allows you to provide a accnos file containing the names of the sequences you would like extracted. You may enter multiple files by separating them by -'s. \n");
+               m->mothurOut("Example sffinfo(sff=mySffFile.sff, trim=F).\n");
+               m->mothurOut("Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n\n");
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "help");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+SffInfoCommand::~SffInfoCommand(){}
+
+//**********************************************************************************************************************
+int SffInfoCommand::execute(){
+       try {
+               
+               if (abort == true) { return 0; }
+               
+               for (int s = 0; s < filenames.size(); s++) {
+                       
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
+                       
+                       int start = time(NULL);
+                       
+                       m->mothurOut("Extracting info from " + filenames[s] + " ..." ); m->mothurOutEndLine();
+                       
+                       string accnos = "";
+                       if (hasAccnos) { accnos = accnosFileNames[s]; }
+                       
+                       int numReads = extractSffInfo(filenames[s], accnos);
+
+                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to extract " + toString(numReads) + ".");
+               }
+               
+               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
+               
+               //report output filenames
+               m->mothurOutEndLine();
+               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
+               m->mothurOutEndLine();
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "execute");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::extractSffInfo(string input, string accnos){
+       try {
+               
+               if (outputDir == "") {  outputDir += hasPath(input); }
+               
+               if (accnos != "")       {  readAccnosFile(accnos);  }
+               else                            {       seqNames.clear();               }
+
+               ofstream outSfftxt, outFasta, outQual, outFlow;
+               string outFastaFileName, outQualFileName;
+               string sfftxtFileName = outputDir + getRootName(getSimpleName(input)) + "sff.txt";
+               string outFlowFileName = outputDir + getRootName(getSimpleName(input)) + "flow";
+               if (trim) {
+                       outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "fasta";
+                       outQualFileName = outputDir + getRootName(getSimpleName(input)) + "qual";
+               }else{
+                       outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "raw.fasta";
+                       outQualFileName = outputDir + getRootName(getSimpleName(input)) + "raw.qual";
+               }
+               
+               if (sfftxt) { openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName); }
+               if (fasta)      { openOutputFile(outFastaFileName, outFasta);   outputNames.push_back(outFastaFileName); }
+               if (qual)       { openOutputFile(outQualFileName, outQual);             outputNames.push_back(outQualFileName);  }
+               if (flow)       { openOutputFile(outFlowFileName, outFlow);             outputNames.push_back(outFlowFileName);  }
+               
+               ifstream in;
+               in.open(input.c_str(), ios::binary);
+               
+               CommonHeader header; 
+               readCommonHeader(in, header);
+               
+               int count = 0;
+               
+               //check magic number and version
+               if (header.magicNumber != 779314790) { m->mothurOut("Magic Number is not correct, not a valid .sff file"); m->mothurOutEndLine(); return count; }
+               if (header.version != "0001") { m->mothurOut("Version is not supported, only support version 0001."); m->mothurOutEndLine(); return count; }
+       
+               //print common header
+               if (sfftxt) { printCommonHeader(outSfftxt, header); }
+       
+               //read through the sff file
+               while (!in.eof()) {
+                       
+                       bool print = true;
+                       
+                       //read header
+                       Header readheader;
+                       readHeader(in, readheader);
+                       
+                       //read data
+                       seqRead read; 
+                       readSeqData(in, read, header.numFlowsPerRead, readheader.numBases);
+                               
+                       //if you have provided an accosfile and this seq is not in it, then dont print
+                       if (seqNames.size() != 0) {   if (seqNames.count(readheader.name) == 0) { print = false; }  }
+                       
+                       //print 
+                       if (print) {
+                               if (sfftxt) { printHeader(outSfftxt, readheader); printSffTxtSeqData(outSfftxt, read, readheader); }
+                               if (fasta)      {       printFastaSeqData(outFasta, read, readheader);  }
+                               if (qual)       {       printQualSeqData(outQual, read, readheader);    }
+                               if (flow)       {       printFlowSeqData(outFlow, read, readheader);    }
+                       }
+                       
+                       count++;
+               
+                       //report progress
+                       if((count+1) % 10000 == 0){     m->mothurOut(toString(count+1)); m->mothurOutEndLine();         }
+               
+                       if (m->control_pressed) { count = 0; break;   }
+                       
+                       if (count >= header.numReads) { break; }
+               }
+               
+               //report progress
+               if (!m->control_pressed) {   if((count) % 10000 != 0){  m->mothurOut(toString(count)); m->mothurOutEndLine();           }  }
+               
+               in.close();
+               
+               if (sfftxt) {  outSfftxt.close();       }
+               if (fasta)      {  outFasta.close();    }
+               if (qual)       {  outQual.close();             }
+               if (flow)       {  outFlow.close();             }
+               
+               return count;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "extractSffInfo");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
+       try {
+
+               if (!in.eof()) {
+
+                       //read magic number
+                       char buffer[4];
+                       in.read(buffer, 4);
+                       header.magicNumber = be_int4(*(unsigned int *)(&buffer));
+               
+                       //read version
+                       char buffer9[4];
+                       in.read(buffer9, 4);
+                       header.version = "";
+                       for (int i = 0; i < 4; i++) {  header.version += toString((int)(buffer9[i])); }
+                               
+                       //read offset
+                       char buffer2 [8];
+                       in.read(buffer2, 8);
+                       header.indexOffset =  be_int8(*(unsigned long int *)(&buffer2));
+                       
+                       //read index length
+                       char buffer3 [4];
+                       in.read(buffer3, 4);
+                       header.indexLength =  be_int4(*(unsigned int *)(&buffer3));
+                       
+                       //read num reads
+                       char buffer4 [4];
+                       in.read(buffer4, 4);
+                       header.numReads =  be_int4(*(unsigned int *)(&buffer4));
+                               
+                       //read header length
+                       char buffer5 [2];
+                       in.read(buffer5, 2);
+                       header.headerLength =  be_int2(*(unsigned short *)(&buffer5));
+                                       
+                       //read key length
+                       char buffer6 [2];
+                       in.read(buffer6, 2);
+                       header.keyLength = be_int2(*(unsigned short *)(&buffer6));
+                       
+                       //read number of flow reads
+                       char buffer7 [2];
+                       in.read(buffer7, 2);
+                       header.numFlowsPerRead =  be_int2(*(unsigned short *)(&buffer7));
+                               
+                       //read format code
+                       char buffer8 [1];
+                       in.read(buffer8, 1);
+                       header.flogramFormatCode = (int)(buffer8[0]);
+                       
+                       //read flow chars
+                       char* tempBuffer = new char[header.numFlowsPerRead];
+                       in.read(&(*tempBuffer), header.numFlowsPerRead); 
+                       header.flowChars = tempBuffer;
+                       if (header.flowChars.length() > header.numFlowsPerRead) { header.flowChars = header.flowChars.substr(0, header.numFlowsPerRead);  }
+                       delete[] tempBuffer;
+                       
+                       //read key
+                       char* tempBuffer2 = new char[header.keyLength];
+                       in.read(&(*tempBuffer2), header.keyLength);
+                       header.keySequence = tempBuffer2;
+                       if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength);  }
+                       delete[] tempBuffer2;
+                               
+                       /* Pad to 8 chars */
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;  // ~ inverts
+                       in.seekg(spot);
+                       
+               }else{
+                       m->mothurOut("Error reading sff common header."); m->mothurOutEndLine();
+               }
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "readCommonHeader");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::readHeader(ifstream& in, Header& header){
+       try {
+       
+               if (!in.eof()) {
+                       
+                       //read header length
+                       char buffer [2];
+                       in.read(buffer, 2);
+                       header.headerLength = be_int2(*(unsigned short *)(&buffer));
+                                               
+                       //read name length
+                       char buffer2 [2];
+                       in.read(buffer2, 2);
+                       header.nameLength = be_int2(*(unsigned short *)(&buffer2));
+
+                       //read num bases
+                       char buffer3 [4];
+                       in.read(buffer3, 4);
+                       header.numBases =  be_int4(*(unsigned int *)(&buffer3));
+                       
+                       //read clip qual left
+                       char buffer4 [2];
+                       in.read(buffer4, 2);
+                       header.clipQualLeft =  be_int2(*(unsigned short *)(&buffer4));
+                       
+                       //read clip qual right
+                       char buffer5 [2];
+                       in.read(buffer5, 2);
+                       header.clipQualRight =  be_int2(*(unsigned short *)(&buffer5));
+                       
+                       //read clipAdapterLeft
+                       char buffer6 [2];
+                       in.read(buffer6, 2);
+                       header.clipAdapterLeft = be_int2(*(unsigned short *)(&buffer6));
+
+                       //read clipAdapterRight
+                       char buffer7 [2];
+                       in.read(buffer7, 2);
+                       header.clipAdapterRight = be_int2(*(unsigned short *)(&buffer7));
+               
+                       //read name
+                       char* tempBuffer = new char[header.nameLength];
+                       in.read(&(*tempBuffer), header.nameLength);
+                       header.name = tempBuffer;
+                       if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength);  }
+                       delete[] tempBuffer;
+                       
+                       /* Pad to 8 chars */
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;
+                       in.seekg(spot);
+                       
+               }else{
+                       m->mothurOut("Error reading sff header info."); m->mothurOutEndLine();
+               }
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "readHeader");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, int numBases){
+       try {
+       
+               if (!in.eof()) {
+       
+                       //read flowgram
+                       read.flowgram.resize(numFlowReads);
+                       for (int i = 0; i < numFlowReads; i++) {  
+                               char buffer [2];
+                               in.read(buffer, 2);
+                               read.flowgram[i] = be_int2(*(unsigned short *)(&buffer));
+                       }
+       
+                       //read flowIndex
+                       read.flowIndex.resize(numBases);
+                       for (int i = 0; i < numBases; i++) {  
+                               char temp[1];
+                               in.read(temp, 1);
+                               read.flowIndex[i] = be_int1(*(unsigned char *)(&temp));
+                       }
+       
+                       //read bases
+                       char* tempBuffer = new char[numBases];
+                       in.read(&(*tempBuffer), numBases);
+                       read.bases = tempBuffer;
+                       if (read.bases.length() > numBases) { read.bases = read.bases.substr(0, numBases);  }
+                       delete[] tempBuffer;
+
+                       //read qual scores
+                       read.qualScores.resize(numBases);
+                       for (int i = 0; i < numBases; i++) {  
+                               char temp[1];
+                               in.read(temp, 1);
+                               read.qualScores[i] = be_int1(*(unsigned char *)(&temp));
+                       }
+       
+                       /* Pad to 8 chars */
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;
+                       in.seekg(spot);
+                       
+               }else{
+                       m->mothurOut("Error reading."); m->mothurOutEndLine();
+               }
+
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "readSeqData");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::printCommonHeader(ofstream& out, CommonHeader& header) {
+       try {
+       
+               out << "Common Header:\nMagic Number: " << header.magicNumber << endl;
+               out << "Version: " << header.version << endl;
+               out << "Index Offset: " << header.indexOffset << endl;
+               out << "Index Length: " << header.indexLength << endl;
+               out << "Number of Reads: " << header.numReads << endl;
+               out << "Header Length: " << header.headerLength << endl;
+               out << "Key Length: " << header.keyLength << endl;
+               out << "Number of Flows: " << header.numFlowsPerRead << endl;
+               out << "Format Code: " << header.flogramFormatCode << endl;
+               out << "Flow Chars: " << header.flowChars << endl;
+               out << "Key Sequence: " << header.keySequence << endl << endl;
+                       
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printCommonHeader");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::printHeader(ofstream& out, Header& header) {
+       try {
+               
+               out << ">" << header.name << endl;
+               out << "Run Prefix: " << endl;
+               out << "Region #:  " << endl;
+               out << "XY Location: " << endl << endl;
+               
+               out << "Run Name:  " << endl;
+               out << "Analysis Name:  " << endl;
+               out << "Full Path: " << endl << endl;
+               
+               out << "Read Header Len: " << header.headerLength << endl;
+               out << "Name Length: " << header.nameLength << endl;
+               out << "# of Bases: " << header.numBases << endl;
+               out << "Clip Qual Left: " << header.clipQualLeft << endl;
+               out << "Clip Qual Right: " << header.clipQualRight << endl;
+               out << "Clip Adap Left: " << header.clipAdapterLeft << endl;
+               out << "Clip Adap Right: " << header.clipAdapterRight << endl << endl;
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printHeader");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& header) {
+       try {
+               
+               out << "Flowgram: ";
+               for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }
+               
+               out << endl <<  "Flow Indexes: ";
+               int sum = 0;
+               for (int i = 0; i < read.flowIndex.size(); i++) {  sum +=  read.flowIndex[i];  out << sum << '\t'; }
+               
+               //make the bases you want to clip lowercase and the bases you want to keep upper case
+               for (int i = 0; i < (header.clipQualLeft-1); i++) { read.bases[i] = tolower(read.bases[i]); }
+               for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) {   read.bases[i] = toupper(read.bases[i]);  }
+               for (int i = (header.clipQualRight-1); i < read.bases.length(); i++) {   read.bases[i] = tolower(read.bases[i]);  }
+               
+               out << endl <<  "Bases: " << read.bases << endl << "Quality Scores: ";
+               for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
+       
+               
+               out << endl << endl;
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printSffTxtSeqData");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) {
+       try {
+               
+               string seq = read.bases;
+               
+               
+               if (trim) {
+                       seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft+1));
+               }else{
+                       //if you wanted the sfftxt then you already converted the bases to the right case
+                       if (!sfftxt) {
+                               //make the bases you want to clip lowercase and the bases you want to keep upper case
+                               for (int i = 0; i < (header.clipQualLeft-1); i++) { seq[i] = tolower(seq[i]);  }
+                               for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++)  {   seq[i] = toupper(seq[i]);  }
+                               for (int i = (header.clipQualRight-1); i < seq.length(); i++) {   seq[i] = tolower(seq[i]);  }
+                       }
+               }
+               
+               out << ">" << header.name << endl;
+               out << seq << endl;
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printFastaSeqData");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& header) {
+       try {
+               
+               if (trim) {
+                       out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft+1) << endl;
+                       for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) {   out << read.qualScores[i] << '\t';  }
+               }else{
+                       out << ">" << header.name << " length=" << read.qualScores.size() << endl;
+                       for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
+               }
+               
+               out << endl;
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printQualSeqData");
+               exit(1);
+       }
+}
+
+//**********************************************************************************************************************
+int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {
+       try {
+               
+               out << ">" << header.name << endl;
+               for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }
+               out << endl;
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "printFlowSeqData");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+int SffInfoCommand::readAccnosFile(string filename) {
+       try {
+               //remove old names
+               seqNames.clear();
+               
+               ifstream in;
+               openInputFile(filename, in);
+               string name;
+               
+               while(!in.eof()){
+                       in >> name; gobble(in);
+                                               
+                       seqNames.insert(name);
+                       
+                       if (m->control_pressed) { seqNames.clear(); break; }
+               }
+               in.close();             
+               
+               return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SffInfoCommand", "readAccnosFile");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************/
index 5ad1ee6432bf17220e3b8fd2187734ba4a7a098a..b086dff619d18046dd0d3cbaabf109a2976421b3 100644 (file)
@@ -136,10 +136,11 @@ int SummaryCommand::execute(){
                
                vector<string> outputNames;
                
+               string hadShared = "";
                if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName);  }
-               else {  inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
+               else { hadShared = globaldata->getSharedFile(); inputFileNames = parseSharedFile(globaldata->getSharedFile());  globaldata->setFormat("rabund");  }
                
-               if (m->control_pressed) { return 0; }
+               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                
                for (int p = 0; p < inputFileNames.size(); p++) {
                        
@@ -204,7 +205,7 @@ int SummaryCommand::execute(){
                        }
                        
                        //if the users entered no valid calculators don't execute command
-                       if (sumCalculators.size() == 0) { return 0; }
+                       if (sumCalculators.size() == 0) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } return 0; }
                        
                        ofstream outputFileHandle;
                        openOutputFile(fileNameRoot, outputFileHandle);
@@ -231,11 +232,11 @@ int SummaryCommand::execute(){
                        set<string> processedLabels;
                        set<string> userLabels = labels;
                        
-                       if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
                        
                        while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
                                
-                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
+                               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
                                
                                if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
                                        
@@ -247,7 +248,7 @@ int SummaryCommand::execute(){
                                        for(int i=0;i<sumCalculators.size();i++){
                                                vector<double> data = sumCalculators[i]->getValues(sabund);
                                                
-                                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
+                                               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
 
                                                outputFileHandle << '\t';
                                                sumCalculators[i]->print(outputFileHandle);
@@ -269,7 +270,7 @@ int SummaryCommand::execute(){
                                        for(int i=0;i<sumCalculators.size();i++){
                                                vector<double> data = sumCalculators[i]->getValues(sabund);
                                                
-                                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
+                                               if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
                                                
                                                outputFileHandle << '\t';
                                                sumCalculators[i]->print(outputFileHandle);
@@ -286,7 +287,7 @@ int SummaryCommand::execute(){
                                sabund = input->getSAbundVector();
                        }
                        
-                       if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read;  delete input; globaldata->ginput = NULL; return 0;  }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read;  delete input; globaldata->ginput = NULL; return 0;  }
 
                        //output error messages about any remaining user labels
                        set<string>::iterator it;
@@ -311,7 +312,7 @@ int SummaryCommand::execute(){
                                for(int i=0;i<sumCalculators.size();i++){
                                        vector<double> data = sumCalculators[i]->getValues(sabund);
                                        
-                                       if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
+                                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read; delete sabund; globaldata->sabund = NULL; delete input; globaldata->ginput = NULL; return 0;  }
 
                                        outputFileHandle << '\t';
                                        sumCalculators[i]->print(outputFileHandle);
@@ -322,7 +323,7 @@ int SummaryCommand::execute(){
                        
                        outputFileHandle.close();
                        
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read;  delete input; globaldata->ginput = NULL; return 0;  }
+                       if (m->control_pressed) { if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  } for (int i = 0; i < outputNames.size(); i++) {  remove(outputNames[i].c_str());  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete validCalculator; delete read;  delete input; globaldata->ginput = NULL; return 0;  }
 
                        
                        delete input;  globaldata->ginput = NULL;
@@ -332,6 +333,8 @@ int SummaryCommand::execute(){
                        for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
                }
                
+               if (hadShared != "") {  globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile");  }
+               
                if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        remove(outputNames[i].c_str());  }  return 0;  }
                
                m->mothurOutEndLine();
index e82a9e8d4446430d125c168d66e0ababc8651655..1faa651cd85dea92784a7dcc20cfc1fd3a2a1a9d 100644 (file)
@@ -15,6 +15,20 @@ ValidParameters::ValidParameters() {
        try {
                m = MothurOut::getInstance();
                initParameterRanges();
+               commandName = "";
+       }
+       catch(exception& e) {
+               m->errorOut(e, "ValidParameters", "ValidParameters");
+               exit(1);
+       }
+}
+/***********************************************************************/
+
+ValidParameters::ValidParameters(string c) {
+       try {
+               m = MothurOut::getInstance();
+               initParameterRanges();
+               commandName = c;
        }
        catch(exception& e) {
                m->errorOut(e, "ValidParameters", "ValidParameters");
@@ -214,6 +228,8 @@ string ValidParameters::validFile(map<string, string>& container, string paramet
                                MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
                                MPI_Comm_size(MPI_COMM_WORLD, &processors);
                                
+                               if (commandName == "") { processors = 1; }
+                               
                                if (pid == 0) {
                        #endif
 
@@ -234,12 +250,26 @@ string ValidParameters::validFile(map<string, string>& container, string paramet
                        #ifdef USE_MPI  
                                        for(int i = 1; i < processors; i++) { 
                                                MPI_Send(&ableToOpen, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
+                                               
+                                               int length = container[parameter].length();
+                                               MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
+                                               MPI_Send(&(container[parameter][0]), length, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
+       
                                        }
                                }else {
                                        MPI_Recv(&ableToOpen, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
+                                       
+                                       int length;
+                                       MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
+                                       //recieve container
+                                       char* tempBuf = new char[length];
+                                       MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
+                                       
+                                       container[parameter] = tempBuf;
+                                       if (container[parameter].length() > length) { container[parameter] = container[parameter].substr(0, length);  }
+                                       delete tempBuf; 
                                }
                                
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                        #endif
                        
                                if (ableToOpen == 1) { 
index 782931f7a6ae998b896d89720116891acb080518..04d201d2c62152ec9f50cd5fce17d35b30d7b41e 100644 (file)
@@ -22,17 +22,19 @@ class ValidParameters {
 
        public:
                ValidParameters();
+               ValidParameters(string);
                ~ValidParameters();
                //bool isValidParameter(string, string, string) {return true;}
                bool isValidParameter(string, vector<string>, string);
                vector <string> addParameters(string[], int);
                void initParameterRanges();
-               string validFile(map<string, string>&, string, bool); //container, parameter, isFile
+               string validFile(map<string, string>&, string, bool); //container, parameter, isFile, commandName
 
        private:
                map<string, string>::iterator it;
                map<string, vector<string> > parameterRanges;
                MothurOut* m;
+               string commandName;
 
 };
 
index 35c814d2625a4f236667646801e01eb1b6c056bd..192611d15e01e2a307e5fca00287a817812968a9 100644 (file)
@@ -128,8 +128,11 @@ VennCommand::VennCommand(string option)  {
                                        }
                                }
                                
-                               venn = new Venn(outputDir);
+                               //if the users entered no valid calculators don't execute command
+                               if (vennCalculators.size() == 0) { m->mothurOut("No valid calculators given, please correct."); m->mothurOutEndLine(); abort = true;  }
+                               else {  venn = new Venn(outputDir);  }
                        }
+                       
                }
 
                
@@ -188,9 +191,6 @@ int VennCommand::execute(){
                string lastLabel;
                vector<string> outputNames;
                
-               //if the users entered no valid calculators don't execute command
-               if (vennCalculators.size() == 0) { return 0; }
-               
                if (format == "sharedfile") {
                        //you have groups
                        read = new ReadOTUFile(globaldata->inputFileName);