From 6f9dc7ca71d7b8ed4aba2824f76ae6b29da89f3b Mon Sep 17 00:00:00 2001 From: westcott Date: Fri, 22 May 2009 18:48:55 +0000 Subject: [PATCH] changed defaults in allign.seqs command --- aligncommand.cpp | 4 ++-- errorchecking.cpp | 23 ++++++++++++++--------- errorchecking.h | 2 +- globaldata.cpp | 20 ++++++++++---------- globaldata.hpp | 4 ++-- helpcommand.cpp | 13 ++++++------- sharedrabundvector.cpp | 6 ++++-- validparameter.cpp | 2 +- venn.cpp | 22 +++++++--------------- venncommand.cpp | 2 +- 10 files changed, 48 insertions(+), 50 deletions(-) diff --git a/aligncommand.cpp b/aligncommand.cpp index f5eb48c..242e9a8 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -41,8 +41,8 @@ AlignCommand::AlignCommand(){ try { globaldata = GlobalData::getInstance(); - candidateFileName = globaldata->inputFileName; - templateFileName = globaldata->getTemplateFile(); + candidateFileName = globaldata->getCandidateFile(); + templateFileName = globaldata->getFastaFile(); openInputFile(candidateFileName, in); convert(globaldata->getKSize(), kmerSize); convert(globaldata->getMatch(), match); diff --git a/errorchecking.cpp b/errorchecking.cpp index f8b34bb..c5396cf 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -119,7 +119,7 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "ends" ) { ends = value; } if (parameter == "processors" ) { processors = value; } if (parameter == "size" ) { size = value; } - if (parameter == "template") { templatefile = value; } + if (parameter == "candidate") { candidatefile = value; } if (parameter == "search") { search = value; } if (parameter == "ksize") { ksize = value; } if (parameter == "align") { align = value; } @@ -169,7 +169,7 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "ends" ) { ends = value; } if (parameter == "processors" ) { processors = value; } if (parameter == "size" ) { size = value; } - if (parameter == "template") { templatefile = value; } + if (parameter == "candidate") { candidatefile = value; } if (parameter == "search") { search = value; } if (parameter == "ksize") { ksize = value; } if (parameter == "align") { align = value; } @@ -263,11 +263,16 @@ bool ErrorCheck::checkInput(string input) { } } - if ((commandName == "filter.seqs") || (commandName == "dist.seqs") || (commandName == "align.seqs")) { + if ((commandName == "filter.seqs") || (commandName == "dist.seqs")) { if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) { - cout << "You must enter either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs, dist.seqs or align.seqs command." << endl; return false; - }else if ((commandName == "align.seqs") && (templatefile == "")) { - cout << "You must enter a template to use the align.seqs command." << endl; return false; + cout << "You must enter either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs or dist.seqs command." << endl; return false; + } + validateSeqsFiles(); + } + + if (commandName == "align.seqs") { + if ((fastafile == "") || (candidatefile == "")) { + cout << "You must enter fasta and a candidate file to use the align.seqs command." << endl; return false; } validateSeqsFiles(); } @@ -578,8 +583,8 @@ void ErrorCheck::validateSeqsFiles() { errorFree = false; } } - }else if (templatefile != "") { - ableToOpen = openInputFile(templatefile, filehandle); + }else if (candidatefile != "") { + ableToOpen = openInputFile(candidatefile, filehandle); filehandle.close(); if (ableToOpen == 1) { //unable to open errorFree = false; @@ -676,7 +681,7 @@ void ErrorCheck::clear() { fastafile = ""; nexusfile = ""; clustalfile = ""; - templatefile = ""; + candidatefile = ""; line = ""; label = ""; method = "furthest"; diff --git a/errorchecking.h b/errorchecking.h index 5057ab0..c667167 100644 --- a/errorchecking.h +++ b/errorchecking.h @@ -36,7 +36,7 @@ class ErrorCheck { void refresh(); string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, cutoff, format; string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, trump, soft, filter, scale, ends, processors, size; - string templatefile, search, ksize, align, match, mismatch, gapopen, gapextend; + string candidatefile, search, ksize, align, match, mismatch, gapopen, gapextend; string commandName, optionText; bool errorFree; diff --git a/globaldata.cpp b/globaldata.cpp index 0078d69..e9b3088 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -86,7 +86,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "ends" ) { ends = value; } if (key == "processors" ) { processors = value; } if (key == "size" ) { size = value; } - if (key == "template") { templatefile = value; } + if (key == "candidate") { candidatefile = value; } if (key == "search") { search = value; } if (key == "ksize") { ksize = value; } if (key == "align") { align = value; } @@ -157,7 +157,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "ends" ) { ends = value; } if (key == "processors" ) { processors = value; } if (key == "size" ) { size = value; } - if (key == "template") { templatefile = value; } + if (key == "candidate") { candidatefile = value; } if (key == "search") { search = value; } if (key == "ksize") { ksize = value; } if (key == "align") { align = value; } @@ -303,7 +303,7 @@ string GlobalData::getScale() { return scale; } string GlobalData::getEnds() { return ends; } string GlobalData::getProcessors() { return processors; } string GlobalData::getSize() { return size; } -string GlobalData::getTemplateFile() { return templatefile;} +string GlobalData::getCandidateFile() { return candidatefile;} string GlobalData::getSearch() { return search; } string GlobalData::getKSize() { return ksize; } string GlobalData::getAlign() { return align; } @@ -357,7 +357,7 @@ void GlobalData::clear() { clustalfile = ""; treefile = ""; sharedfile = ""; - templatefile = ""; + candidatefile = ""; cutoff = "10.00"; format = ""; precision = "100"; @@ -382,12 +382,12 @@ void GlobalData::clear() { ends = "T"; //yes processors = "1"; size = "1000"; - search = "suffix"; + search = "kmer"; ksize = "7"; - align = "blast"; + align = "needleman"; match = "1.0"; mismatch = "-1.0"; - gapopen = "-5.0"; + gapopen = "-1.0"; gapextend = "-2.0"; } @@ -411,12 +411,12 @@ void GlobalData::reset() { ends = "T"; processors = "1"; size = "1000"; - search = "suffix"; + search = "kmer"; ksize = "7"; - align = "blast"; + align = "needleman"; match = "1.0"; mismatch = "-1.0"; - gapopen = "-5.0"; + gapopen = "-1.0"; gapextend = "-2.0"; } /*******************************************************/ diff --git a/globaldata.hpp b/globaldata.hpp index 0c25489..b3b0798 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -78,7 +78,7 @@ public: string getEnds(); string getProcessors(); string getSize(); - string getTemplateFile(); + string getCandidateFile(); string getSearch(); string getKSize(); string getAlign(); @@ -122,7 +122,7 @@ public: private: string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, line, label, randomtree, groups; - string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale, ends, processors, templatefile, search, ksize, align, match, size; + string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, trump, soft, filter, scale, ends, processors, candidatefile, search, ksize, align, match, size; string mismatch, gapopen, gapextend; diff --git a/helpcommand.cpp b/helpcommand.cpp index 6abe7af..b890c99 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -84,19 +84,18 @@ int HelpCommand::execute(){ cout << "Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc)." << "\n" << "\n"; }else if (globaldata->helpRequest == "align.seqs") { cout << "The align.seqs command reads a file containing sequences and creates an alignment file and a report file." << "\n"; - cout << "The align.seqs command parameters are fasta, phylip, clustal, nexus, template, search, ksize, align, match, mismatch, gapopen and gapextend. " << "\n"; - cout << "You must use one of the following parameters for your candidate filename: fasta, phylip, clustal or nexus. " << "\n"; + cout << "The align.seqs command parameters are fasta, candidate, search, ksize, align, match, mismatch, gapopen and gapextend. " << "\n"; cout << "The template parameter is also required." << "\n"; - cout << "The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer and blast. The default is suffix." << "\n"; - cout << "The align parameter allows you to specify the alignment method to use. Your options are: gotoh, needleman, blast and noalign. The default is blast." << "\n"; + cout << "The search parameter allows you to specify the method to find most similar template. Your options are: suffix, kmer and blast. The default is kmer." << "\n"; + cout << "The align parameter allows you to specify the alignment method to use. Your options are: gotoh, needleman, blast and noalign. The default is needleman." << "\n"; cout << "The ksize parameter allows you to specify the kmer size for finding most similar template to candidate. The default is 7." << "\n"; cout << "The match parameter allows you to specify the bonus for having the same base. The default is 1.0." << "\n"; cout << "The mistmatch parameter allows you to specify the penalty for having different bases. The default is -1.0." << "\n"; - cout << "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -5.0." << "\n"; + cout << "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -1.0." << "\n"; cout << "The gapextend parameter allows you to specify the penalty for extending a gap in an alignment. The default is -2.0." << "\n"; cout << "The align.seqs command should be in the following format: " << "\n"; - cout << "align.seqs(fasta=yourFastaFile, template=yourTemplateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty) " << "\n"; - cout << "Example align.seqs(fasta=candidate.fasta, template=core.filtered, align=kmer, search=gotoh, ksize=8, match=2.0, mismatch=3.0, gapopen=-2.0, gapextend=-1.0)" << "\n"; + cout << "align.seqs(fasta=yourTemplateFile, candidate=yourCandidateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty) " << "\n"; + cout << "Example align.seqs(candidate=candidate.fasta, fasta=core.filtered, align=kmer, search=gotoh, ksize=8, match=2.0, mismatch=3.0, gapopen=-2.0, gapextend=-1.0)" << "\n"; cout << "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile)." << "\n" << "\n"; }else if (globaldata->helpRequest == "collect.single") { cout << "The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. " << "\n"; diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 1711012..386017d 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -78,7 +78,8 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), holdLabel = label; //add new vector to lookup - lookup.push_back(new SharedRAbundVector()); + SharedRAbundVector* temp = new SharedRAbundVector(); + lookup.push_back(temp); lookup[0]->setLabel(label); lookup[0]->setGroup(groupN); @@ -117,7 +118,8 @@ SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), } //add new vector to lookup - lookup.push_back(new SharedRAbundVector()); + temp = new SharedRAbundVector(); + lookup.push_back(temp); lookup[count]->setLabel(label); lookup[count]->setGroup(groupN); diff --git a/validparameter.cpp b/validparameter.cpp index 6719e2c..ddec9d1 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -294,7 +294,7 @@ void ValidParameters::initCommandParameters() { string distanceArray[] = {"fasta","phylip","clustal","nexus", "calc", "ends", "cutoff", "processors"}; commandParameters["dist.seqs"] = addParameters(distanceArray, sizeof(distanceArray)/sizeof(string)); - string AlignArray[] = {"fasta","phylip","clustal","nexus", "template", "search", "ksize", "align", "match", "mismatch", "gapopen", "gapextend"}; + string AlignArray[] = {"fasta", "candidate", "search", "ksize", "align", "match", "mismatch", "gapopen", "gapextend"}; commandParameters["align.seqs"] = addParameters(AlignArray, sizeof(AlignArray)/sizeof(string)); string quitArray[] = {}; diff --git a/venn.cpp b/venn.cpp index 2c57960..27dc4ac 100644 --- a/venn.cpp +++ b/venn.cpp @@ -115,7 +115,6 @@ void Venn::getPic(vector lookup, vector vCalcs delete singleCalc; } - delete sabund; /******************* 2 Groups **************************/ }else if (lookup.size() == 2) { @@ -185,8 +184,6 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg.close(); delete singleCalc; } - delete sabundA; - delete sabundB; /******************* 3 Groups **************************/ }else if (lookup.size() == 3) { @@ -197,7 +194,7 @@ void Venn::getPic(vector lookup, vector vCalcs sA = lookup[0]->getSAbundVector(); sabundA = &sA; sB = lookup[1]->getSAbundVector(); sabundB = &sB; sC = lookup[2]->getSAbundVector(); sabundC = &sC; - + //make a file for each calculator for(int i=0;i lookup, vector vCalcs sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0]; //if any of the possible m's are - throw them out - if (sharedABC1 < 0.0) { sharedABC1 = 0; } - if (sharedABC2 < 0.0) { sharedABC2 = 0; } - if (sharedABC3 < 0.0) { sharedABC3 = 0; } + if (sharedABC1 < 0.00001) { sharedABC1 = 0; } + if (sharedABC2 < 0.00001) { sharedABC2 = 0; } + if (sharedABC3 < 0.00001) { sharedABC3 = 0; } //sharedABC is the minimum of the 3 possibilities if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; } @@ -297,7 +294,7 @@ void Venn::getPic(vector lookup, vector vCalcs sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC); sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC); } - + //image window outsvg << "\n"; outsvg << "\n"; @@ -350,10 +347,9 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg << "\n\n"; outsvg.close(); delete singleCalc; + } - delete sabundA; - delete sabundB; - delete sabundC; + /******************* 4 Groups **************************/ }else if (lookup.size() == 4) { @@ -517,10 +513,6 @@ void Venn::getPic(vector lookup, vector vCalcs delete singleCalc; } } - delete sabundA; - delete sabundB; - delete sabundC; - delete sabundD; } } diff --git a/venncommand.cpp b/venncommand.cpp index a934126..ced4c48 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -121,7 +121,7 @@ int VennCommand::execute(){ cout << "Error: Too many groups chosen. You may use up to 4 groups with the venn command. I will use the first four groups in your groupfile." << endl; for (int i = lookup.size(); i > 3; i--) { delete lookup[i]; lookup.pop_back(); } } - + //util->getSharedVectors(globaldata->Groups, lookup, order); //fills group vectors from order vector. venn->getPic(lookup, vennCalculators); } -- 2.39.2