From dec4333b64891e0b923c862446cf2e3befa7e3d3 Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Mon, 23 Apr 2012 15:21:30 -0400 Subject: [PATCH] bugs found while testing --- commandoptionparser.cpp | 8 ++++++-- cooccurrencecommand.cpp | 15 ++++----------- makebiomcommand.cpp | 4 ++-- mothurout.cpp | 3 ++- pcrseqscommand.h | 2 +- prcseqscommand.cpp | 23 +++++++++++++---------- seqsummarycommand.cpp | 2 +- tree.cpp | 18 ++++++++---------- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/commandoptionparser.cpp b/commandoptionparser.cpp index 3b45e48..dfad533 100644 --- a/commandoptionparser.cpp +++ b/commandoptionparser.cpp @@ -22,8 +22,12 @@ CommandOptionParser::CommandOptionParser(string input){ optionString = ""; commandString = ""; - if(openParen != -1 && closeParen != -1){ - commandString = input.substr(0, openParen); //commandString contains everything before "(" + if(openParen != -1 && closeParen != -1){ + //gobble extra spaces + int spot = 0; + for (int i = 0; i < input.length(); i++) { if (!(isspace(input[i]))) { spot = i; break; } } + if (spot > openParen) { spot = 0; } + commandString = input.substr(spot, openParen-spot); //commandString contains everything before "(" optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")". } else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); } diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp index e6c9259..e6c298e 100644 --- a/cooccurrencecommand.cpp +++ b/cooccurrencecommand.cpp @@ -136,7 +136,7 @@ CooccurrenceCommand::CooccurrenceCommand(string option) { m->mothurOut("[ERROR]: " + metric + " is not a valid metric option for the cooccurrence command. Choices are cscore, checker, combo, vratio."); m->mothurOutEndLine(); abort = true; } - matrix = validParameter.validFile(parameters, "matrix", false); if (matrix == "not found") { matrix = "sim2"; } + matrix = validParameter.validFile(parameters, "matrixmodel", false); if (matrix == "not found") { matrix = "sim2"; } if ((matrix != "sim1") && (matrix != "sim2") && (matrix != "sim3") && (matrix != "sim4") && (matrix != "sim5" ) && (matrix != "sim6" ) && (matrix != "sim7" ) && (matrix != "sim8" ) && (matrix != "sim9" )) { m->mothurOut("[ERROR]: " + matrix + " is not a valid matrix option for the cooccurrence command. Choices are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8, sim9."); m->mothurOutEndLine(); abort = true; @@ -295,17 +295,10 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp //nrows is ncols of inital matrix. All the functions need this value. They assume the transposition has already taken place and nrows and ncols refer to that matrix. //comatrix and initmatrix are still vectors of vectors of ints as in the original script. The abundancevector is only what was read in ie not a co-occurrence matrix! - int ncols = numOTUS;//rows of inital matrix - int nrows = thisLookUp.size();//groups + int nrows = numOTUS;//rows of inital matrix + int ncols = thisLookUp.size();//groups double initscore = 0.0; - //transpose matrix - int newmatrows = ncols; - int newmatcols = nrows; - - //swap for transposed matrix - nrows = newmatrows;//ncols; - ncols = newmatcols;//nrows; - + vector initcolumntotal; initcolumntotal.resize(ncols, 0); vector initrowtotal; initrowtotal.resize(nrows, 0); vector stats; diff --git a/makebiomcommand.cpp b/makebiomcommand.cpp index 70e3b1a..acd0500 100644 --- a/makebiomcommand.cpp +++ b/makebiomcommand.cpp @@ -112,12 +112,12 @@ vector MakeBiomCommand::setParameters(){ string MakeBiomCommand::getHelpString(){ try { string helpString = ""; - helpString += "The make.biom command parameters are shared, groups, matrixtype and label. shared is required, unless you have a valid current file.\n"; + helpString += "The make.biom command parameters are shared, contaxonomy, groups, matrixtype and label. shared is required, unless you have a valid current file.\n"; helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n"; helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n"; helpString += "The matrixtype parameter allows you to select what type you would like to make. Choices are sparse and dense, default is sparse.\n"; + helpString += "The contaxonomy file is the taxonomy file outputted by classify.otu(list=yourListfile, taxonomy=yourTaxonomyFile). Be SURE that the you are the constaxonomy file distance matches the shared file distance. ie, for *.0.03.cons.taxonomy set label=0.03. Mothur is smart enough to handle shared files that have been subsampled.\n"; helpString += "The make.biom command should be in the following format: make.biom(shared=yourShared, groups=yourGroups, label=yourLabels).\n"; - helpString += "The contaxonomy file is the taxonomy file outputted by classify.otu(list=yourListfile, taxonomy=yourTaxonomyFile). Be SURE that the you are the constaxonomy file distance matches the shared file distance. ie, for *.0.03.cons.taxonomy set label=0.03. Mothur is smart enough to handle shared files that have been subsampled after the classify.otu command was run on the list and taxonomy file.\n"; helpString += "Example make.biom(shared=abrecovery.an.shared, groups=A-B-C).\n"; helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n"; helpString += "The make.biom command outputs a .biom file.\n"; diff --git a/mothurout.cpp b/mothurout.cpp index ae4cb52..0431d36 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -1448,7 +1448,8 @@ map MothurOut::readNames(string namefile) { if (control_pressed) { break; } string firstCol, secondCol; - in >> firstCol >> secondCol; gobble(in); + in >> firstCol; gobble(in); + in >> secondCol; gobble(in); int num = getNumNames(secondCol); diff --git a/pcrseqscommand.h b/pcrseqscommand.h index 45ce6f3..420a5eb 100644 --- a/pcrseqscommand.h +++ b/pcrseqscommand.h @@ -45,7 +45,7 @@ private: bool getOligos(vector >&, vector >&, vector >&); bool abort, keepprimer, keepdots; string fastafile, oligosfile, taxfile, groupfile, namefile, ecolifile, outputDir, nomatch; - int start, end, pdiffs, processors, length; + int start, end, processors, length; vector revPrimer, outputNames; vector primers; diff --git a/prcseqscommand.cpp b/prcseqscommand.cpp index d9c3776..725136b 100644 --- a/prcseqscommand.cpp +++ b/prcseqscommand.cpp @@ -20,7 +20,6 @@ vector PcrSeqsCommand::setParameters(){ CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart); CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend); CommandParameter pnomatch("nomatch", "Multiple", "reject-keep", "reject", "", "", "",false,false); parameters.push_back(pnomatch); - CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs); CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); CommandParameter pkeepprimer("keepprimer", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepprimer); CommandParameter pkeepdots("keepdots", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pkeepdots); @@ -40,8 +39,15 @@ vector PcrSeqsCommand::setParameters(){ string PcrSeqsCommand::getHelpString(){ try { string helpString = ""; - helpString += "The pcr.seqs command reads a fasta file ...\n"; - + helpString += "The pcr.seqs command reads a fasta file.\n"; + helpString += "The pcr.seqs command parameters are fasta, oligos, name, group, taxonomy, ecoli, start, end, nomatch, processors, keepprimer and keepdots.\n"; + helpString += "The ecoli parameter is used to provide a fasta file containing a single reference sequence (e.g. for e. coli) this must be aligned. Mothur will trim to the start and end positions of the reference sequence.\n"; + helpString += "The start parameter allows you to provide a starting position to trim to.\n"; + helpString += "The end parameter allows you to provide a ending position to trim from.\n"; + helpString += "The nomatch parameter allows you to decide what to do with sequences where the primer is not found. Default=reject, meaning remove from fasta file. if nomatch=true, then do nothing to sequence.\n"; + helpString += "The processors parameter allows you to use multiple processors.\n"; + helpString += "The keepprimer parameter allows you to keep the primer, default=false.\n"; + helpString += "The keepdots parameter allows you to keep the leading and trailing .'s, default=true.\n"; helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n"; helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Pcr.seqs .\n"; return helpString; @@ -159,8 +165,6 @@ PcrSeqsCommand::PcrSeqsCommand(string option) { } - //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 = ""; } //check for required parameters fastafile = validParameter.validFile(parameters, "fasta", true); @@ -171,7 +175,9 @@ PcrSeqsCommand::PcrSeqsCommand(string option) { }else if (fastafile == "not open") { fastafile = ""; abort = true; } else { m->setFastaFile(fastafile); } - + //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 = m->hasPath(fastafile); } + //check for optional parameter and set defaults // ...at some point should added some additional type checking... string temp; @@ -204,10 +210,7 @@ PcrSeqsCommand::PcrSeqsCommand(string option) { if (taxfile == "not found"){ taxfile = ""; } else if(taxfile == "not open"){ taxfile = ""; abort = true; } else { m->setTaxonomyFile(taxfile); } - - temp = validParameter.validFile(parameters, "pdiffs", false); if (temp == "not found") { temp = "0"; } - m->mothurConvert(temp, pdiffs); - + temp = validParameter.validFile(parameters, "start", false); if (temp == "not found") { temp = "-1"; } m->mothurConvert(temp, start); diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 68d3bf5..1ea58c5 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -414,7 +414,7 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vector::iterator it = nameMap.find(current.getName()); - if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } + if (it == nameMap.end()) { m->mothurOut("[ERROR]: '" + current.getName() + "' is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } else { num = it->second; } } diff --git a/tree.cpp b/tree.cpp index 7c9671b..d9b4a9c 100644 --- a/tree.cpp +++ b/tree.cpp @@ -92,7 +92,6 @@ Tree::Tree(TreeMap* t, vector< vector >& sims) : tmap(t) { m = MothurOut::getInstance(); if (m->runParse == true) { parseTreeFile(); m->runParse = false; } - //for(int i = 0; i < globaldata->Treenames.size(); i++) { cout << i << '\t' << globaldata->Treenames[i] << endl; } numLeaves = m->Treenames.size(); numNodes = 2*numLeaves - 1; @@ -134,12 +133,11 @@ Tree::Tree(TreeMap* t, vector< vector >& sims) : tmap(t) { //build tree from matrix //initialize indexes map indexes; //maps row in simMatrix to vector index in the tree - int numGroups = (tmap->getNamesOfGroups()).size(); - for (int g = 0; g < numGroups; g++) { indexes[g] = g; } + for (int g = 0; g < numLeaves; g++) { indexes[g] = g; } //do merges and create tree structure by setting parents and children //there are numGroups - 1 merges to do - for (int i = 0; i < (numGroups - 1); i++) { + for (int i = 0; i < (numLeaves - 1); i++) { float largest = -1000.0; if (m->control_pressed) { break; } @@ -154,11 +152,11 @@ Tree::Tree(TreeMap* t, vector< vector >& sims) : tmap(t) { //set non-leaf node info and update leaves to know their parents //non-leaf - tree[numGroups + i].setChildren(indexes[row], indexes[column]); + tree[numLeaves + i].setChildren(indexes[row], indexes[column]); //parents - tree[indexes[row]].setParent(numGroups + i); - tree[indexes[column]].setParent(numGroups + i); + tree[indexes[row]].setParent(numLeaves + i); + tree[indexes[column]].setParent(numLeaves + i); //blength = distance / 2; float blength = ((1.0 - largest) / 2); @@ -168,12 +166,12 @@ Tree::Tree(TreeMap* t, vector< vector >& sims) : tmap(t) { tree[indexes[column]].setBranchLength(blength - tree[indexes[column]].getLengthToLeaves()); //set your length to leaves to your childs length plus branchlength - tree[numGroups + i].setLengthToLeaves(tree[indexes[row]].getLengthToLeaves() + tree[indexes[row]].getBranchLength()); + tree[numLeaves + i].setLengthToLeaves(tree[indexes[row]].getLengthToLeaves() + tree[indexes[row]].getBranchLength()); //update index - indexes[row] = numGroups+i; - indexes[column] = numGroups+i; + indexes[row] = numLeaves+i; + indexes[column] = numLeaves+i; //remove highest value that caused the merge. sims[row][column] = -1000.0; -- 2.39.2