From 9d241ddf4c0e2467298a523e21a3b0de46902448 Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Mon, 23 Apr 2012 09:40:43 -0400 Subject: [PATCH] added check for positive values in pairwise.seqs gap extend, gap open and mismatch. fixed segfault in concurrence command. --- cooccurrencecommand.cpp | 7 ++----- makebiomcommand.cpp | 10 +++++++++- pairwiseseqscommand.cpp | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp index 6864f79..e6c9259 100644 --- a/cooccurrencecommand.cpp +++ b/cooccurrencecommand.cpp @@ -279,7 +279,6 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp vector columntotal; columntotal.resize(thisLookUp.size(), 0); vector rowtotal; rowtotal.resize(numOTUS, 0); - int rowcount = 0; for (int i = 0; i < thisLookUp.size(); i++) { for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) { if (m->control_pressed) { return 0; } @@ -288,12 +287,10 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp if(abund > 0) { initmatrix[i][j] = 1; co_matrix[j][i] = 1; - rowcount++; - columntotal[j]++; + rowtotal[j]++; + columntotal[i]++; } } - rowtotal[i] = rowcount; - rowcount = 0; } //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. diff --git a/makebiomcommand.cpp b/makebiomcommand.cpp index 41f2316..70e3b1a 100644 --- a/makebiomcommand.cpp +++ b/makebiomcommand.cpp @@ -168,7 +168,7 @@ MakeBiomCommand::MakeBiomCommand(string option) { //initialize outputTypes vector tempOutNames; - outputTypes["relabund"] = tempOutNames; + outputTypes["biom"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); @@ -328,6 +328,14 @@ int MakeBiomCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } + //set sabund file as new current sabundfile + string current = ""; + itTypes = outputTypes.find("biom"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setBiomFile(current); } + } + + 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/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index 98b0fde..a4ccbf8 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -203,12 +203,15 @@ PairwiseSeqsCommand::PairwiseSeqsCommand(string option) { temp = validParameter.validFile(parameters, "mismatch", false); if (temp == "not found"){ temp = "-1.0"; } m->mothurConvert(temp, misMatch); + if (misMatch > 0) { m->mothurOut("[ERROR]: mismatch must be negative.\n"); abort=true; } temp = validParameter.validFile(parameters, "gapopen", false); if (temp == "not found"){ temp = "-2.0"; } m->mothurConvert(temp, gapOpen); + if (gapOpen > 0) { m->mothurOut("[ERROR]: gapopen must be negative.\n"); abort=true; } temp = validParameter.validFile(parameters, "gapextend", false); if (temp == "not found"){ temp = "-1.0"; } m->mothurConvert(temp, gapExtend); + if (gapExtend > 0) { m->mothurOut("[ERROR]: gapextend must be negative.\n"); abort=true; } temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); -- 2.39.2