From: westcott Date: Tue, 15 Mar 2011 18:14:35 +0000 (+0000) Subject: adding current file class X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=f6c7165727bc17a5fbbcbb774d75ccffeb7f3da5 adding current file class --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 54db537..7d1df46 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -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 */; }; @@ -329,6 +330,8 @@ A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amovacommand.h; sourceTree = ""; }; A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = amovacommand.cpp; sourceTree = ""; }; + A7AACFBA132FE008003D6C4D /* currentfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = currentfile.h; sourceTree = ""; }; + A7AACFBB132FE008003D6C4D /* currentfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = currentfile.cpp; sourceTree = ""; }; A7E9B64F12D37EC300DA6239 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = ""; }; A7E9B65012D37EC300DA6239 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = ""; }; A7E9B65112D37EC300DA6239 /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aligncommand.cpp; sourceTree = ""; }; @@ -946,6 +949,8 @@ A7E9B6B212D37EC400DA6239 /* commandoptionparser.hpp */, A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */, A7E9BA4212D3960D00DA6239 /* containers */, + A7AACFBA132FE008003D6C4D /* currentfile.h */, + A7AACFBB132FE008003D6C4D /* currentfile.cpp */, A7E9B6C912D37EC400DA6239 /* display.h */, A7E9B6D112D37EC400DA6239 /* dlibshuff.cpp */, A7E9B6D212D37EC400DA6239 /* dlibshuff.h */, @@ -1933,6 +1938,7 @@ A7FA10021302E097003860FE /* mantelcommand.cpp in Sources */, A799F5B91309A3E000AEEFA0 /* makefastqcommand.cpp in Sources */, A71CB160130B04A2001E7287 /* anosimcommand.cpp in Sources */, + A7AACFBC132FE008003D6C4D /* currentfile.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/aligncommand.cpp b/aligncommand.cpp index 7bed27f..cfedd3b 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -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(); } diff --git a/amovacommand.cpp b/amovacommand.cpp index b9b5dee..74fbda7 100644 --- a/amovacommand.cpp +++ b/amovacommand.cpp @@ -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); diff --git a/blastdb.cpp b/blastdb.cpp index 979d507..bc92e1c 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -140,6 +140,7 @@ vector 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; } } diff --git a/chimeraslayer.cpp b/chimeraslayer.cpp index eb00b59..b334f90 100644 --- a/chimeraslayer.cpp +++ b/chimeraslayer.cpp @@ -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 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()); diff --git a/command.hpp b/command.hpp index ddb7763..2d1981a 100644 --- a/command.hpp +++ b/command.hpp @@ -17,11 +17,12 @@ #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 getValidParameters() = 0; virtual vector getRequiredParameters() = 0; //adding "or" as the last element indicates one of the previous is needed virtual vector 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 >::iterator itTypes; }; #endif diff --git a/currentfile.cpp b/currentfile.cpp new file mode 100644 index 0000000..6990a2a --- /dev/null +++ b/currentfile.cpp @@ -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 index 0000000..8acf2a9 --- /dev/null +++ b/currentfile.h @@ -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 + diff --git a/maligner.cpp b/maligner.cpp index 30e9936..7f0cd0a 100644 --- a/maligner.cpp +++ b/maligner.cpp @@ -551,9 +551,9 @@ vector 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 Maligner::getBlastSeqs(Sequence* q, int num) { } //cout << mergedResults[i] << endl; } -//cout << endl; +//cout << "done " << q->getName() << endl; delete queryRight; delete queryLeft;