]> git.donarmstrong.com Git - mothur.git/commitdiff
adding current file class
authorwestcott <westcott>
Tue, 15 Mar 2011 18:14:35 +0000 (18:14 +0000)
committerwestcott <westcott>
Tue, 15 Mar 2011 18:14:35 +0000 (18:14 +0000)
Mothur.xcodeproj/project.pbxproj
aligncommand.cpp
amovacommand.cpp
blastdb.cpp
chimeraslayer.cpp
command.hpp
currentfile.cpp [new file with mode: 0644]
currentfile.h [new file with mode: 0644]
maligner.cpp

index 54db537321479e37e03dae775a265b3206e13bdb..7d1df469e1864cca4a54ff8091839754cbcf9d0c 100644 (file)
@@ -18,6 +18,7 @@
                A75790591301749D00A30DAB /* homovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75790581301749D00A30DAB /* homovacommand.cpp */; };
                A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */; };
                A7A61F2D130062E000E05B6B /* amovacommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A61F2C130062E000E05B6B /* amovacommand.cpp */; };
+               A7AACFBC132FE008003D6C4D /* currentfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7AACFBB132FE008003D6C4D /* currentfile.cpp */; };
                A7E9B88112D37EC400DA6239 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B64F12D37EC300DA6239 /* ace.cpp */; };
                A7E9B88212D37EC400DA6239 /* aligncommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B65112D37EC300DA6239 /* aligncommand.cpp */; };
                A7E9B88312D37EC400DA6239 /* alignment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B65312D37EC300DA6239 /* alignment.cpp */; };
                A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
                A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amovacommand.h; sourceTree = "<group>"; };
                A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = amovacommand.cpp; sourceTree = "<group>"; };
+               A7AACFBA132FE008003D6C4D /* currentfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = currentfile.h; sourceTree = "<group>"; };
+               A7AACFBB132FE008003D6C4D /* currentfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = currentfile.cpp; sourceTree = "<group>"; };
                A7E9B64F12D37EC300DA6239 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
                A7E9B65012D37EC300DA6239 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = "<group>"; };
                A7E9B65112D37EC300DA6239 /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aligncommand.cpp; sourceTree = "<group>"; };
                                A7E9B6B212D37EC400DA6239 /* commandoptionparser.hpp */,
                                A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */,
                                A7E9BA4212D3960D00DA6239 /* containers */,
+                               A7AACFBA132FE008003D6C4D /* currentfile.h */,
+                               A7AACFBB132FE008003D6C4D /* currentfile.cpp */,
                                A7E9B6C912D37EC400DA6239 /* display.h */,
                                A7E9B6D112D37EC400DA6239 /* dlibshuff.cpp */,
                                A7E9B6D212D37EC400DA6239 /* dlibshuff.h */,
                                A7FA10021302E097003860FE /* mantelcommand.cpp in Sources */,
                                A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */,
                                A71CB160130B04A2001E7287 /* anosimcommand.cpp in Sources */,
+                               A7AACFBC132FE008003D6C4D /* currentfile.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7bed27f7725f78425a3c2e8f61f528b24b00c830..cfedd3b3ca44effd5d1029936c8636db63d568bd 100644 (file)
@@ -137,8 +137,11 @@ AlignCommand::AlignCommand(string option)  {
                        }else if (templateFileName == "not open") { abort = true; }     
                        
                        candidateFileName = validParameter.validFile(parameters, "candidate", false);
-                       if (candidateFileName == "not found") { m->mothurOut("candidate is a required parameter for the align.seqs command."); m->mothurOutEndLine(); abort = true;  }
-                       else { 
+                       if (candidateFileName == "not found") { 
+                               //check currentFiles for a fasta file
+                               if (currentFiles->getFastaFile() != "") {  candidateFileName = currentFiles->getFastaFile(); m->mothurOut("Using " + candidateFileName + " as candidate file."); m->mothurOutEndLine();
+                               }else { m->mothurOut("candidate is a required parameter for the align.seqs command."); m->mothurOutEndLine(); abort = true;  }
+                       }else { 
                                m->splitAtDash(candidateFileName, candidateFileNames);
                                
                                //go through files and make sure they are good, if not, then disregard them
@@ -168,7 +171,7 @@ AlignCommand::AlignCommand(string option)  {
                                                }
                                        }
                                        
-                                       //if you can't open it, try default location
+                                       //if you can't open it, try output location
                                        if (ableToOpen == 1) {
                                                if (m->getOutputDir() != "") { //default path is set
                                                        string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]);
@@ -463,7 +466,14 @@ int AlignCommand::execute(){
                        m->mothurOutEndLine();
                }
                
-               
+               //set align file as new current fastafile
+               string currentFasta = "";
+               itTypes = outputTypes.find("fasta");
+               if (itTypes != outputTypes.end()) {
+                       if ((itTypes->second).size() != 0) { currentFasta = (itTypes->second)[0]; }
+               }
+               currentFiles->setFastaFile(currentFasta);
+               cout << "current fasta = " << currentFiles->getFastaFile() << endl;
                m->mothurOutEndLine();
                m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
index b9b5deeb5e670ef2f119eb09bded37ab870efe4d..74fbda7ff6164128551bead9cfb4c8bfabb7ba0e 100644 (file)
@@ -115,12 +115,12 @@ AmovaCommand::AmovaCommand(string option) {
                        
                        phylipFileName = validParameter.validFile(parameters, "phylip", true);
                        if (phylipFileName == "not open") { phylipFileName = ""; abort = true; }
-                       else if (phylipFileName == "not found") { phylipFileName = ""; }        
-                       else if (designFileName == "not found") {
-                               designFileName = "";
-                               m->mothurOut("You must provide an phylip file.");
-                               m->mothurOutEndLine();
-                               abort = true;
+                       else if (phylipFileName == "not found") { 
+                               phylipFileName = ""; 
+                               
+                               //check currentFiles for a phylip file
+                               if (currentFiles->getPhylipFile() != "") {  phylipFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + phylipFileName + " as phylip file."); m->mothurOutEndLine();
+                               }else { m->mothurOut("You must provide an phylip file."); m->mothurOutEndLine(); abort = true;  }
                        }       
                        
                        //check for required parameters
@@ -128,9 +128,10 @@ AmovaCommand::AmovaCommand(string option) {
                        if (designFileName == "not open") { abort = true; }
                        else if (designFileName == "not found") {
                                designFileName = "";
-                               m->mothurOut("You must provide an design file.");
-                               m->mothurOutEndLine();
-                               abort = true;
+                               
+                               //check currentFiles for a design file
+                               if (currentFiles->getDesignFile() != "") {  designFileName = currentFiles->getPhylipFile(); m->mothurOut("Using " + designFileName + " as phylip file."); m->mothurOutEndLine();
+                               }else { m->mothurOut("You must provide an design file."); m->mothurOutEndLine(); abort = true;  }
                        }       
 
                        string temp = validParameter.validFile(parameters, "iters", false);
index 979d507c23d61b4537d62a1a4736721624616fb2..bc92e1c5f083831a88ec2d10e7a0fe94c68bb6b7 100644 (file)
@@ -140,6 +140,7 @@ vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n) {
                
                while(!m8FileHandle.eof()){
                        m8FileHandle >> dummy >> templateAccession >> searchScore;
+                       //cout << templateAccession << '\t' << searchScore << endl;
                        
                        //get rest of junk in line
                        while (!m8FileHandle.eof())     {       char c = m8FileHandle.get(); if (c == 10 || c == 13){   break;  }       } 
index eb00b59a324e5ef93850fa2a0aa16e1a0216a9dc..b334f909a7411d6dd00b3eda311740b7e93a80b8 100644 (file)
@@ -258,7 +258,7 @@ int ChimeraSlayer::doPrep() {
                }else if (searchMethod == "blast") {
                
                        //generate blastdb
-                       databaseLeft = new BlastDB(-2.0, -1.0, match, misMatch);
+                       databaseLeft = new BlastDB(-1.0, -1.0, 1, -3);
                        for (int i = 0; i < templateSeqs.size(); i++) {         databaseLeft->addSequence(*templateSeqs[i]);    }
                        databaseLeft->generateDB();
                        databaseLeft->setNumSeqs(templateSeqs.size());
@@ -384,7 +384,7 @@ vector<Sequence*> ChimeraSlayer::getTemplate(Sequence* q) {
                }else if (searchMethod == "blast") {
                        
                        //generate blastdb
-                       databaseLeft = new BlastDB(-2.0, -1.0, match, misMatch);
+                       databaseLeft = new BlastDB(-1.0, -1.0, 1, -3);
                        for (int i = 0; i < thisTemplate.size(); i++) { if (m->control_pressed) { return thisTemplate; }  databaseLeft->addSequence(*thisTemplate[i]);  }
                        databaseLeft->generateDB();
                        databaseLeft->setNumSeqs(thisTemplate.size());
index ddb776356a183e0c310997ea7f9cb0acfc5e5c02..2d1981aa4cca8d7e608e3708750fc079600d1265 100644 (file)
 #include "optionparser.h"
 #include "validparameter.h"
 #include "mothurout.h"
+#include "currentfile.h"
 
 class Command {
        
        public:
-               Command() {  m = MothurOut::getInstance();  }
+               Command() {  m = MothurOut::getInstance(); currentFiles = CurrentFile::getInstance();  }
                virtual vector<string> getValidParameters() = 0;
                virtual vector<string> getRequiredParameters() = 0; //adding "or" as the last element indicates one of the previous is needed
                virtual vector<string> getRequiredFiles() = 0; //adding "or" as the last element indicates one of the previous is needed
@@ -31,7 +32,10 @@ class Command {
                virtual ~Command() { }
        protected:
                MothurOut* m;
+               CurrentFile* currentFiles;
                bool calledHelp;
+       
+               map<string, vector<string> >::iterator itTypes;
 };
 
 #endif
diff --git a/currentfile.cpp b/currentfile.cpp
new file mode 100644 (file)
index 0000000..6990a2a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  currentfile.cpp
+ *  Mothur
+ *
+ *  Created by westcott on 3/15/11.
+ *  Copyright 2011 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "currentfile.h"
+
+/******************************************************/
+CurrentFile* CurrentFile::getInstance() {
+       if(_uniqueInstance == 0) {
+               _uniqueInstance = new CurrentFile();
+       }
+       return _uniqueInstance;
+}
+/*********************************************************************************************/
+CurrentFile::CurrentFile() { 
+       phylipfile = "";
+       columnfile = "";
+       listfile = "";
+       rabundfile = "";
+       sabundfile = "";
+       namefile = "";
+       groupfile = "";
+       designfile = "";
+       orderfile = "";
+       treefile = "";
+       sharedfile = "";
+       ordergroupfile = "";
+       relabundfile = "";
+       fastafile = "";
+       qualfile = "";
+       sfffile = "";
+       oligosfile = "";
+}
+/*********************************************************************************************/
+CurrentFile::~CurrentFile() { 
+       _uniqueInstance = 0; 
+}
+/*********************************************************************************************/
+
+
diff --git a/currentfile.h b/currentfile.h
new file mode 100644 (file)
index 0000000..8acf2a9
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef CURRENTFILE_H
+#define CURRENTFILE_H
+
+/*
+ *  currentfile.h
+ *  Mothur
+ *
+ *  Created by westcott on 3/15/11.
+ *  Copyright 2011 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "mothur.h"
+
+/***********************************************/
+
+class CurrentFile {
+       
+public:
+       
+       static CurrentFile* getInstance();
+       
+       string getPhylipFile()          { return phylipfile;            }
+       string getColumnFile()          { return columnfile;            }
+       string getListFile()            { return listfile;                      }
+       string getRabundFile()          { return rabundfile;            }
+       string getSabundFile()          { return sabundfile;            }
+       string getNameFile()            { return namefile;                      }       
+       string getGroupFile()           { return groupfile;                     }       
+       string getOrderFile()           { return orderfile;                     }
+       string getOrderGroupFile()      { return ordergroupfile;        }
+       string getTreeFile()            { return treefile;                      }
+       string getSharedFile()          { return sharedfile;            }
+       string getRelAbundFile()        { return relabundfile;          }
+       string getDesignFile()          { return designfile;            }
+       string getFastaFile()           { return fastafile;                     }
+       string getSFFFile()                     { return sfffile;                       }
+       string getQualFile()            { return qualfile;                      }
+       string getOligosFile()          { return oligosfile;            }
+       
+       
+       void setListFile(string f)                      { listfile = f;                         }
+       void setTreeFile(string f)                      { treefile = f;                         }
+       void setGroupFile(string f)                     { groupfile = f;                        }               
+       void setPhylipFile(string f)            { phylipfile = f;                       }
+       void setColumnFile(string f)            { columnfile = f;                       }
+       void setNameFile(string f)                      { namefile = f;                         }       
+       void setRabundFile(string f)            { rabundfile = f;                       }
+       void setSabundFile(string f)            { sabundfile = f;                       }
+       void setSharedFile(string f)            { sharedfile = f;                       }
+       void setRelAbundFile(string f)          { relabundfile = f;                     }
+       void setOrderFile(string f)                     { orderfile = f;                        }
+       void setOrderGroupFile(string f)        { ordergroupfile = f;           }
+       void setDesignFile(string f)            { designfile = f;                       }
+       void setFastaFile(string f)                     { fastafile = f;                        }
+       void setSFFFile(string f)                       { sfffile = f;                          }
+       void setQualFile(string f)                      { qualfile = f;                         }
+       void setOligosFile(string f)            { oligosfile = f;                       }
+       
+private:
+       static CurrentFile* _uniqueInstance;
+       CurrentFile( const CurrentFile& ); // Disable copy constructor
+       void operator=( const CurrentFile& ); // Disable assignment operator
+       CurrentFile();
+       ~CurrentFile();
+       
+       string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile;
+       string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile;
+       
+       
+};
+/***********************************************/
+
+#endif
+
index 30e993678a92895146ac289f132ab9dc2f7ac73b..7f0cd0a85ffded74edea865c2d2d9378d53d9dd8 100644 (file)
@@ -551,9 +551,9 @@ vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
                }
                
                if (mergedResults.size() < numWanted) { numWanted = mergedResults.size(); }
-//cout << q->getName() <<  endl;               
+//cout << q->getName() << " merged results size = " << mergedResults.size() << '\t' << "numwanted = " << numWanted <<  endl;           
                for (int i = 0; i < numWanted; i++) {
-//cout << db[mergedResults[i]]->getName() << endl;     
+//cout << db[mergedResults[i]]->getName()  << '\t' << mergedResults[i] << endl;        
                        if (db[mergedResults[i]]->getName() != q->getName()) { 
                                Sequence* temp = new Sequence(db[mergedResults[i]]->getName(), db[mergedResults[i]]->getAligned());
                                refResults.push_back(temp);
@@ -561,7 +561,7 @@ vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
                        }
 //cout << mergedResults[i] << endl;
                }
-//cout << endl;                
+//cout << "done " << q->getName()  << endl;            
                delete queryRight;
                delete queryLeft;