X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=shhhercommand.cpp;h=803b6cb7955af18d441d6c160e5aafb797c3a057;hb=f6b5fea6e0fcc395235dfbfb466b9b6a031b540a;hp=d8f538b56109e2faa290cb060c314186e8be318a;hpb=7f708111e16093634c2b96c5695a44d1d218520d;p=mothur.git diff --git a/shhhercommand.cpp b/shhhercommand.cpp index d8f538b..803b6cb 100644 --- a/shhhercommand.cpp +++ b/shhhercommand.cpp @@ -128,8 +128,10 @@ ShhherCommand::ShhherCommand(string option) { if (path == "") { parameters["file"] = inputDir + it->second; } } } - - + + //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 flowFileName = validParameter.validFile(parameters, "flow", true); flowFilesFileName = validParameter.validFile(parameters, "file", true); @@ -146,13 +148,15 @@ ShhherCommand::ShhherCommand(string option) { } else{ ofstream temp; - + + string thisoutputDir = m->hasPath(flowFilesFileName); //if user entered a file with a path then preserve it + //flow.files = 9 character offset - compositeFASTAFileName = outputDir + flowFilesFileName.substr(0, flowFilesFileName.length()-10) + "shhh.fasta"; + compositeFASTAFileName = thisoutputDir + m->getRootName(m->getSimpleName(flowFilesFileName)) + "shhh.fasta"; m->openOutputFile(compositeFASTAFileName, temp); temp.close(); - compositeNamesFileName = outputDir + flowFilesFileName.substr(0, flowFilesFileName.length()-10) + "shhh.names"; + compositeNamesFileName = thisoutputDir + m->getRootName(m->getSimpleName(flowFilesFileName)) + "shhh.names"; m->openOutputFile(compositeNamesFileName, temp); temp.close(); } @@ -214,17 +218,10 @@ ShhherCommand::ShhherCommand(string option) { if (flowFileVector.size() == 0) { m->mothurOut("[ERROR]: no valid files."); m->mothurOutEndLine(); abort = true; } } else{ + if (outputDir == "") { outputDir = m->hasPath(flowFileName); } flowFileVector.push_back(flowFileName); } - - - //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 = ""; - outputDir += m->hasPath(flowFileName); //if user entered a file with a path then preserve it - } - - + //check for optional parameter and set defaults // ...at some point should added some additional type checking... string temp; @@ -1772,7 +1769,7 @@ void ShhherCommand::writeNames(vector otuCounts){ if(compositeNamesFileName != ""){ - m->appendFiles(nameFileName, uchimecompositeNamesFileName); + m->appendFiles(nameFileName, compositeNamesFileName); } } catch(exception& e) { @@ -2403,8 +2400,7 @@ int ShhherCommand::getUniques(int numSeqs, int numFlowCells, vector& uniq } uniqueFlowDataIntI.resize(numFlowCells * numUniques); uniqueLengths.resize(numUniques); - uniqueFlowgrams.resize(numFlowCells * numUniques); - + flowDataPrI.resize(numSeqs * numFlowCells, 0); for(int i=0;icontrol_pressed) { break; } flowDataPrI[i] = getProbIntensity(flowDataIntI[i]); } @@ -2987,7 +2983,7 @@ void ShhherCommand::writeQualities(int numOTUs, int numFlowCells, string filenam try { string thisOutputDir = outputDir; - if (outputDir == "") { thisOutputDir += m->hasPath(filename); } + if (outputDir == "") { thisOutputDir = m->hasPath(filename); } string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.qual"; ofstream qualityFile; @@ -3095,7 +3091,7 @@ void ShhherCommand::writeQualities(int numOTUs, int numFlowCells, string filenam void ShhherCommand::writeSequences(string thisCompositeFASTAFileName, int numOTUs, int numFlowCells, string filename, vector otuCounts, vector& uniqueFlowgrams, vector& seqNameVector, vector >& aaI, vector& centroids){ try { string thisOutputDir = outputDir; - if (outputDir == "") { thisOutputDir += m->hasPath(filename); } + if (outputDir == "") { thisOutputDir = m->hasPath(filename); } string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.fasta"; ofstream fastaFile; m->openOutputFile(fastaFileName, fastaFile); @@ -3143,7 +3139,7 @@ void ShhherCommand::writeSequences(string thisCompositeFASTAFileName, int numOTU void ShhherCommand::writeNames(string thisCompositeNamesFileName, int numOTUs, string filename, vector otuCounts, vector& seqNameVector, vector >& aaI, vector& nSeqsPerOTU){ try { string thisOutputDir = outputDir; - if (outputDir == "") { thisOutputDir += m->hasPath(filename); } + if (outputDir == "") { thisOutputDir = m->hasPath(filename); } string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.names"; ofstream nameFile; m->openOutputFile(nameFileName, nameFile); @@ -3181,7 +3177,7 @@ void ShhherCommand::writeNames(string thisCompositeNamesFileName, int numOTUs, s void ShhherCommand::writeGroups(string filename, int numSeqs, vector& seqNameVector){ try { string thisOutputDir = outputDir; - if (outputDir == "") { thisOutputDir += m->hasPath(filename); } + if (outputDir == "") { thisOutputDir = m->hasPath(filename); } string fileRoot = thisOutputDir + m->getRootName(m->getSimpleName(filename)); string groupFileName = fileRoot + "shhh.groups"; ofstream groupFile; @@ -3206,7 +3202,7 @@ void ShhherCommand::writeGroups(string filename, int numSeqs, vector& se void ShhherCommand::writeClusters(string filename, int numOTUs, int numFlowCells, vector otuCounts, vector& centroids, vector& uniqueFlowgrams, vector& seqNameVector, vector >& aaI, vector& nSeqsPerOTU, vector& lengths, vector& flowDataIntI){ try { string thisOutputDir = outputDir; - if (outputDir == "") { thisOutputDir += m->hasPath(filename); } + if (outputDir == "") { thisOutputDir = m->hasPath(filename); } string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.counts"; ofstream otuCountsFile; m->openOutputFile(otuCountsFileName, otuCountsFile);