]> git.donarmstrong.com Git - mothur.git/commitdiff
bugs found while testing
authorSarah Westcott <mothur.westcott@gmail.com>
Mon, 23 Apr 2012 19:21:30 +0000 (15:21 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Mon, 23 Apr 2012 19:21:30 +0000 (15:21 -0400)
commandoptionparser.cpp
cooccurrencecommand.cpp
makebiomcommand.cpp
mothurout.cpp
pcrseqscommand.h
prcseqscommand.cpp
seqsummarycommand.cpp
tree.cpp

index 3b45e48f4d992e470867a3071ff8d8f18c519dca..dfad533c8898ff3d79067d5f16c6869803e21e12 100644 (file)
@@ -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(); }
index e6c92594f49d8ab038abdb1587983ece722e5592..e6c298e17e88a2c192765dce5b41e21c90db67c2 100644 (file)
@@ -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<SharedRAbundVector*>& 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<int> initcolumntotal; initcolumntotal.resize(ncols, 0);
         vector<int> initrowtotal; initrowtotal.resize(nrows, 0);
         vector<double> stats;
index 70e3b1ad94698cc6369d64555dd70ed889a9c841..acd0500963d096acfb5d1ea453cc9186feafe783 100644 (file)
@@ -112,12 +112,12 @@ vector<string> 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";
index ae4cb524cba877f5a9ec843e1686569032c6528d..0431d36796dd32cf4ac404dee2843150a4b5b110 100644 (file)
@@ -1448,7 +1448,8 @@ map<string, int> 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);
                        
index 45ce6f3f153e6020f00c859b1928cc1d74ea2a55..420a5ebc3e4b0cb527a3c2c692797c0b627c3b46 100644 (file)
@@ -45,7 +45,7 @@ private:
        bool getOligos(vector<vector<string> >&, vector<vector<string> >&, vector<vector<string> >&);
     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<string> revPrimer, outputNames;
        vector<string> primers;
index d9c37769b07d24f40efbfef9e076da33f5c86c29..725136bf56a2512355cf170634b625bfa5df1581 100644 (file)
@@ -20,7 +20,6 @@ vector<string> 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<string> 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);
             
index 68d3bf583f9c7de2db85ebfa27a2fecdd7738922..1ea58c584054b9b4b5944db18d198fd49e78cc51 100644 (file)
@@ -414,7 +414,7 @@ int SeqSummaryCommand::driverCreateSummary(vector<int>& startPosition, vector<in
                                        //make sure this sequence is in the namefile, else error 
                                        map<string, int>::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; }
                                }
                                
index 7c9671bf9a91e02b23cfd40b44804c38e3e4354d..d9b4a9c1e8f4e31475aa5127adb38d339d1a8631 100644 (file)
--- a/tree.cpp
+++ b/tree.cpp
@@ -92,7 +92,6 @@ Tree::Tree(TreeMap* t, vector< vector<double> >& 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<double> >& sims) : tmap(t) {
         //build tree from matrix
         //initialize indexes
         map<int, int> 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<double> >& 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<double> >& 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;