From 86c838c428a9e7d26f902f5492738241fa72c4e7 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 26 Apr 2011 19:44:22 +0000 Subject: [PATCH] added current as option is lists of file names, processors now outputted with current options added flow type to current files, added queryName != templateName in decalc.findclosest for slayer --- aligncommand.cpp | 90 +++++++++-------- chimerabellerophoncommand.cpp | 89 ++++++++++------- chimeraccodecommand.cpp | 88 ++++++++++------- chimeracheckcommand.cpp | 178 ++++++++++++++++++++-------------- chimerapintailcommand.cpp | 86 +++++++++------- chimeraslayercommand.cpp | 176 +++++++++++++++++++-------------- classifyseqscommand.cpp | 170 +++++++++++++++++++------------- decalc.cpp | 9 +- degapseqscommand.cpp | 85 +++++++++------- filterseqscommand.cpp | 93 ++++++++++-------- getcurrentcommand.cpp | 4 + makegroupcommand.cpp | 88 ++++++++++------- mothurout.cpp | 8 +- mothurout.h | 5 +- pairwiseseqscommand.cpp | 87 ++++++++++------- screenseqscommand.cpp | 97 +++++++++++++++++- screenseqscommand.h | 3 +- setcurrentcommand.cpp | 25 ++++- setcurrentcommand.h | 2 +- sffinfocommand.cpp | 174 ++++++++++++++++++++------------- trimflowscommand.cpp | 10 +- 21 files changed, 979 insertions(+), 588 deletions(-) diff --git a/aligncommand.cpp b/aligncommand.cpp index 60a1dc2..a75f9d0 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -167,50 +167,64 @@ AlignCommand::AlignCommand(string option) { for (int i = 0; i < candidateFileNames.size(); i++) { //candidateFileNames[i] = m->getFullPathName(candidateFileNames[i]); - if (inputDir != "") { - string path = m->hasPath(candidateFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { candidateFileNames[i] = inputDir + candidateFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(candidateFileNames[i], in, "noerror"); - in.close(); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(candidateFileNames[i]); - m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - candidateFileNames[i] = tryPath; + bool ignore = false; + if (candidateFileNames[i] == "current") { + candidateFileNames[i] = m->getFastaFile(); + if (candidateFileNames[i] != "") { m->mothurOut("Using " + candidateFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + candidateFileNames.erase(candidateFileNames.begin()+i); + i--; } } - //if you can't open it, try output location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]); - m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - candidateFileNames[i] = tryPath; - } - } + if (!ignore) { - + if (inputDir != "") { + string path = m->hasPath(candidateFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { candidateFileNames[i] = inputDir + candidateFileNames[i]; } + } + + int ableToOpen; + ifstream in; + ableToOpen = m->openInputFile(candidateFileNames[i], in, "noerror"); + in.close(); + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(candidateFileNames[i]); + m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + candidateFileNames[i] = tryPath; + } + } + + //if you can't open it, try output location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]); + m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + candidateFileNames[i] = tryPath; + } + } + + - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + candidateFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - candidateFileNames.erase(candidateFileNames.begin()+i); - i--; + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + candidateFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + candidateFileNames.erase(candidateFileNames.begin()+i); + i--; + } } - } //make sure there is at least one valid file left diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp index db0a04c..1fcb4fc 100644 --- a/chimerabellerophoncommand.cpp +++ b/chimerabellerophoncommand.cpp @@ -113,50 +113,65 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - in.close(); + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } - } //make sure there is at least one valid file left diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index 2586e28..d9dfe16 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -127,48 +127,64 @@ ChimeraCcodeCommand::ChimeraCcodeCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; - } - } + if (!ignore) { - in.close(); + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } + } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index 067babd..c28934c 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -124,48 +124,65 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; - } - } + if (!ignore) { - in.close(); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] +". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } + } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] +". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } @@ -187,50 +204,65 @@ ChimeraCheckCommand::ChimeraCheckCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < nameFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(nameFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { nameFileNames[i] = inputDir + nameFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]); - m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - nameFileNames[i] = tryPath; + bool ignore = false; + if (nameFileNames[i] == "current") { + nameFileNames[i] = m->getNameFile(); + if (nameFileNames[i] != "") { m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + nameFileNames.erase(nameFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]); - m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - nameFileNames[i] = tryPath; - } - } + if (!ignore) { - in.close(); + if (inputDir != "") { + string path = m->hasPath(nameFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { nameFileNames[i] = inputDir + nameFileNames[i]; } + } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - nameFileNames.erase(nameFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]); + m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + nameFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]); + m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + nameFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + nameFileNames.erase(nameFileNames.begin()+i); + i--; + } } - } //make sure there is at least one valid file left diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index f861554..b11887d 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -148,47 +148,63 @@ ChimeraPintailCommand::ChimeraPintailCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } - - in.close(); + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 9b49a4f..40e074c 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -27,7 +27,7 @@ vector ChimeraSlayerCommand::setParameters(){ CommandParameter pminbs("minbs", "Number", "", "90", "", "", "",false,false); parameters.push_back(pminbs); CommandParameter psearch("search", "Multiple", "kmer-blast-distance", "distance", "", "", "",false,false); parameters.push_back(psearch); CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); - CommandParameter prealign("realign", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(prealign); + CommandParameter prealign("realign", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prealign); CommandParameter ptrim("trim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptrim); CommandParameter psplit("split", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psplit); CommandParameter pnumwanted("numwanted", "Number", "", "15", "", "", "",false,false); parameters.push_back(pnumwanted); @@ -148,47 +148,63 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } - - in.close(); + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } @@ -206,47 +222,63 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < nameFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(nameFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { nameFileNames[i] = inputDir + nameFileNames[i]; } - } - int ableToOpen; - ifstream in; - - ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]); - m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - nameFileNames[i] = tryPath; + bool ignore = false; + if (nameFileNames[i] == "current") { + nameFileNames[i] = m->getNameFile(); + if (nameFileNames[i] != "") { m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + nameFileNames.erase(nameFileNames.begin()+i); + i--; } } - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]); - m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - nameFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(nameFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { nameFileNames[i] = inputDir + nameFileNames[i]; } + } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror"); + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]); + m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + nameFileNames[i] = tryPath; + } + } + + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]); + m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + nameFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + nameFileNames.erase(nameFileNames.begin()+i); + i--; } - } - - in.close(); - - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - nameFileNames.erase(nameFileNames.begin()+i); - i--; } } diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 1619656..9d5a625 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -182,47 +182,63 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } - - in.close(); + + int ableToOpen; + + ifstream in; + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } @@ -249,47 +265,61 @@ ClassifySeqsCommand::ClassifySeqsCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < namefileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(namefileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { namefileNames[i] = inputDir + namefileNames[i]; } - } - int ableToOpen; - - ifstream in; - ableToOpen = m->openInputFile(namefileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(namefileNames[i]); - m->mothurOut("Unable to open " + namefileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - namefileNames[i] = tryPath; + bool ignore = false; + if (namefileNames[i] == "current") { + namefileNames[i] = m->getNameFile(); + if (namefileNames[i] != "") { m->mothurOut("Using " + namefileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + namefileNames.erase(namefileNames.begin()+i); + i--; } } - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(namefileNames[i]); - m->mothurOut("Unable to open " + namefileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - namefileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(namefileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { namefileNames[i] = inputDir + namefileNames[i]; } } - } - in.close(); + int ableToOpen; + + ifstream in; + ableToOpen = m->openInputFile(namefileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + namefileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); abort = true; - //erase from file list - namefileNames.erase(namefileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(namefileNames[i]); + m->mothurOut("Unable to open " + namefileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + namefileNames[i] = tryPath; + } + } + + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(namefileNames[i]); + m->mothurOut("Unable to open " + namefileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + namefileNames[i] = tryPath; + } + } + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + namefileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); abort = true; + //erase from file list + namefileNames.erase(namefileNames.begin()+i); + i--; + } } - } } diff --git a/decalc.cpp b/decalc.cpp index 609b895..6725871 100644 --- a/decalc.cpp +++ b/decalc.cpp @@ -867,11 +867,12 @@ vector DeCalculator::findClosest(Sequence* querySeq, vectorgetName() << '\t' << dists[i].dist << endl; - - Sequence* temp = new Sequence(db[dists[i].index]->getName(), db[dists[i].index]->getAligned()); //have to make a copy so you can trim and filter without stepping on eachother. + if (db[dists[i].index]->getName() != querySeq->getName()) { + Sequence* temp = new Sequence(db[dists[i].index]->getName(), db[dists[i].index]->getAligned()); //have to make a copy so you can trim and filter without stepping on eachother. - seqsMatches.push_back(temp); - indexes.push_back(dists[i].index); + seqsMatches.push_back(temp); + indexes.push_back(dists[i].index); + } } return seqsMatches; diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp index 00f627d..c90064f 100644 --- a/degapseqscommand.cpp +++ b/degapseqscommand.cpp @@ -101,46 +101,61 @@ DegapSeqsCommand::DegapSeqsCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - ifstream in; - int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; - } - } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - in.close(); + if (!ignore) { + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } + } + + ifstream in; + int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index a677eef..613dfda 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -132,51 +132,66 @@ FilterSeqsCommand::FilterSeqsCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastafileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastafileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastafileNames[i] = inputDir + fastafileNames[i]; } - } - - ifstream in; - int ableToOpen = m->openInputFile(fastafileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastafileNames[i]); - m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastafileNames[i] = tryPath; - } - } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]); - m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastafileNames[i] = tryPath; + bool ignore = false; + if (fastafileNames[i] == "current") { + fastafileNames[i] = m->getFastaFile(); + if (fastafileNames[i] != "") { m->mothurOut("Using " + fastafileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastafileNames.erase(fastafileNames.begin()+i); + i--; } } - in.close(); + if (!ignore) { + if (inputDir != "") { + string path = m->hasPath(fastafileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastafileNames[i] = inputDir + fastafileNames[i]; } + } + + ifstream in; + int ableToOpen = m->openInputFile(fastafileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastafileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastafileNames.erase(fastafileNames.begin()+i); - i--; - }else{ - string simpleName = m->getSimpleName(fastafileNames[i]); - filterFileName += simpleName.substr(0, simpleName.find_first_of('.')); + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastafileNames[i]); + m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastafileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]); + m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastafileNames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastafileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastafileNames.erase(fastafileNames.begin()+i); + i--; + }else{ + string simpleName = m->getSimpleName(fastafileNames[i]); + filterFileName += simpleName.substr(0, simpleName.find_first_of('.')); + } + in.close(); } - in.close(); } //make sure there is at least one valid file left diff --git a/getcurrentcommand.cpp b/getcurrentcommand.cpp index 9289ba6..5f52356 100644 --- a/getcurrentcommand.cpp +++ b/getcurrentcommand.cpp @@ -135,6 +135,10 @@ int GetCurrentCommand::execute(){ m->setAccnosFile(""); }else if (types[i] == "taxonomy") { m->setTaxonomyFile(""); + }else if (types[i] == "flow") { + m->setFlowFile(""); + }else if (types[i] == "processors") { + m->setProcessors("1"); }else if (types[i] == "all") { m->clearCurrentFiles(); }else { diff --git a/makegroupcommand.cpp b/makegroupcommand.cpp index 326a96e..7ca4aa6 100644 --- a/makegroupcommand.cpp +++ b/makegroupcommand.cpp @@ -102,46 +102,64 @@ MakeGroupCommand::MakeGroupCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - ifstream in; - int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { + m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); + filename += m->getRootName(m->getSimpleName(fastaFileNames[i])); + } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } - in.close(); + + ifstream in; + int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; - }else{ filename += m->getRootName(m->getSimpleName(fastaFileNames[i])); } + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + }else{ filename += m->getRootName(m->getSimpleName(fastaFileNames[i])); } + } } //prevent giantic file name diff --git a/mothurout.cpp b/mothurout.cpp index 6529622..2b06799 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -39,6 +39,8 @@ void MothurOut::printCurrentFiles() { if (sharedfile != "") { mothurOut("shared=" + sharedfile); mothurOutEndLine(); } if (taxonomyfile != "") { mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine(); } if (treefile != "") { mothurOut("tree=" + treefile); mothurOutEndLine(); } + if (flowfile != "") { mothurOut("flow=" + flowfile); mothurOutEndLine(); } + if (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); } } catch(exception& e) { @@ -70,6 +72,8 @@ bool MothurOut::hasCurrentFiles() { if (sharedfile != "") { return true; } if (taxonomyfile != "") { return true; } if (treefile != "") { return true; } + if (flowfile != "") { return true; } + if (processors != "1") { return true; } return hasCurrent; @@ -101,7 +105,9 @@ void MothurOut::clearCurrentFiles() { sfffile = ""; oligosfile = ""; accnosfile = ""; - taxonomyfile = ""; + taxonomyfile = ""; + flowfile = ""; + processors = "1"; } catch(exception& e) { errorOut(e, "MothurOut", "clearCurrentFiles"); diff --git a/mothurout.h b/mothurout.h index 9446bf9..f6f505d 100644 --- a/mothurout.h +++ b/mothurout.h @@ -118,6 +118,7 @@ class MothurOut { string getOligosFile() { return oligosfile; } string getAccnosFile() { return accnosfile; } string getTaxonomyFile() { return taxonomyfile; } + string getFlowFile() { return flowfile; } string getProcessors() { return processors; } void setListFile(string f) { listfile = getFullPathName(f); } @@ -139,6 +140,7 @@ class MothurOut { void setOligosFile(string f) { oligosfile = getFullPathName(f); } void setAccnosFile(string f) { accnosfile = getFullPathName(f); } void setTaxonomyFile(string f) { taxonomyfile = getFullPathName(f); } + void setFlowFile(string f) { flowfile = getFullPathName(f); } void setProcessors(string p) { processors = p; } void printCurrentFiles(); @@ -171,6 +173,7 @@ class MothurOut { accnosfile = ""; taxonomyfile = ""; processors = "1"; + flowfile = ""; gui = false; }; ~MothurOut(); @@ -180,7 +183,7 @@ class MothurOut { string releaseDate, version; string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile; - string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors; + string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile; ofstream out; diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index 9866753..1aa133f 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -141,48 +141,63 @@ PairwiseSeqsCommand::PairwiseSeqsCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < fastaFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(fastaFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } - } - - int ableToOpen; - ifstream in; - - ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + bool ignore = false; + if (fastaFileNames[i] == "current") { + fastaFileNames[i] = m->getFastaFile(); + if (fastaFileNames[i] != "") { m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; } } - //if you can't open it, try output location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); - m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - fastaFileNames[i] = tryPath; + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(fastaFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { fastaFileNames[i] = inputDir + fastaFileNames[i]; } } - } + + int ableToOpen; + ifstream in; + + ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror"); - in.close(); + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + //if you can't open it, try output location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + fastaFileNames[i] = tryPath; + } + } + + in.close(); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - fastaFileNames.erase(fastaFileNames.begin()+i); - i--; + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + fastaFileNames.erase(fastaFileNames.begin()+i); + i--; + } } } diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 0b7f3f0..7318f90 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -16,6 +16,7 @@ vector ScreenSeqsCommand::setParameters(){ CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta); CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname); CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup); + CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile); CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(palignreport); CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart); CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend); @@ -43,7 +44,7 @@ string ScreenSeqsCommand::getHelpString(){ try { string helpString = ""; helpString += "The screen.seqs command reads a fastafile and creates .....\n"; - helpString += "The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, group, optimize, criteria and processors.\n"; + helpString += "The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, group, qfile, optimize, criteria and processors.\n"; helpString += "The fasta parameter is required.\n"; helpString += "The start parameter .... The default is -1.\n"; helpString += "The end parameter .... The default is -1.\n"; @@ -78,6 +79,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(){ outputTypes["group"] = tempOutNames; outputTypes["alignreport"] = tempOutNames; outputTypes["accnos"] = tempOutNames; + outputTypes["qfile"] = tempOutNames; } catch(exception& e) { m->errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand"); @@ -114,6 +116,7 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option) { outputTypes["group"] = tempOutNames; outputTypes["alignreport"] = tempOutNames; outputTypes["accnos"] = tempOutNames; + outputTypes["qfile"] = 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); @@ -151,6 +154,15 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option) { //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["alignreport"] = inputDir + it->second; } } + + it = parameters.find("qfile"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["qfile"] = inputDir + it->second; } + } + } //check for required parameters @@ -166,6 +178,10 @@ ScreenSeqsCommand::ScreenSeqsCommand(string option) { if (groupfile == "not open") { abort = true; } else if (groupfile == "not found") { groupfile = ""; } + qualfile = validParameter.validFile(parameters, "qfile", true); + if (qualfile == "not open") { abort = true; } + else if (qualfile == "not found") { qualfile = ""; } + namefile = validParameter.validFile(parameters, "name", true); if (namefile == "not open") { namefile = ""; abort = true; } else if (namefile == "not found") { namefile = ""; } @@ -461,6 +477,7 @@ int ScreenSeqsCommand::execute(){ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } if(alignreport != "") { screenAlignReport(badSeqNames); } + if(qualfile != "") { screenQual(badSeqNames); } if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; } @@ -492,6 +509,11 @@ int ScreenSeqsCommand::execute(){ if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } } + + itTypes = outputTypes.find("qfile"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } + } m->mothurOut("It took " + toString(time(NULL) - start) + " secs to screen " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); @@ -906,6 +928,79 @@ int ScreenSeqsCommand::screenAlignReport(set badSeqNames){ exit(1); } +} +//*************************************************************************************************************** + +int ScreenSeqsCommand::screenQual(set badSeqNames){ + try { + ifstream in; + m->openInputFile(qualfile, in); + set::iterator it; + + string goodQualFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + "good" + m->getExtension(qualfile); + outputNames.push_back(goodQualFile); outputTypes["qfile"].push_back(goodQualFile); + ofstream goodQual; m->openOutputFile(goodQualFile, goodQual); + + while(!in.eof()){ + + if (m->control_pressed) { goodQual.close(); in.close(); remove(goodQualFile.c_str()); return 0; } + + string saveName = ""; + string name = ""; + string scores = ""; + + in >> name; + + if (name.length() != 0) { + saveName = name.substr(1); + while (!in.eof()) { + char c = in.get(); + if (c == 10 || c == 13){ break; } + else { name += c; } + } + m->gobble(in); + } + + while(in){ + char letter= in.get(); + if(letter == '>'){ in.putback(letter); break; } + else{ scores += letter; } + } + + m->gobble(in); + + it = badSeqNames.find(saveName); + + if(it != badSeqNames.end()){ + badSeqNames.erase(it); + }else{ + goodQual << name << endl << scores; + } + + m->gobble(in); + } + + in.close(); + goodQual.close(); + + //we were unable to remove some of the bad sequences + if (badSeqNames.size() != 0) { + for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) { + m->mothurOut("Your qual file does not include the sequence " + *it + " please correct."); + m->mothurOutEndLine(); + } + } + + if (m->control_pressed) { remove(goodQualFile.c_str()); return 0; } + + return 0; + + } + catch(exception& e) { + m->errorOut(e, "ScreenSeqsCommand", "screenQual"); + exit(1); + } + } //********************************************************************************************************************** diff --git a/screenseqscommand.h b/screenseqscommand.h index b8ab242..602326c 100644 --- a/screenseqscommand.h +++ b/screenseqscommand.h @@ -42,6 +42,7 @@ private: int screenNameGroupFile(set); int screenGroupFile(set); int screenAlignReport(set); + int screenQual(set); int driver(linePair*, string, string, string, set&); int createProcesses(string, string, string, set&); @@ -51,7 +52,7 @@ private: #endif bool abort; - string fastafile, namefile, groupfile, alignreport, outputDir; + string fastafile, namefile, groupfile, alignreport, outputDir, qualfile; int startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength, processors, criteria; vector outputNames; vector optimize; diff --git a/setcurrentcommand.cpp b/setcurrentcommand.cpp index 16685b2..75d1f94 100644 --- a/setcurrentcommand.cpp +++ b/setcurrentcommand.cpp @@ -12,7 +12,9 @@ //********************************************************************************************************************** vector SetCurrentCommand::setParameters(){ try { - + + CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); + CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pflow); CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pphylip); CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcolumn); CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta); @@ -261,6 +263,14 @@ SetCurrentCommand::SetCurrentCommand(string option) { //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["taxonomy"] = inputDir + it->second; } } + + it = parameters.find("flow"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["flow"] = inputDir + it->second; } + } } //check for parameters @@ -359,6 +369,15 @@ SetCurrentCommand::SetCurrentCommand(string option) { else if (taxonomyfile == "not found") { taxonomyfile = ""; } if (taxonomyfile != "") { m->setTaxonomyFile(taxonomyfile); } + flowfile = validParameter.validFile(parameters, "flow", true); + if (flowfile == "not open") { m->mothurOut("Ignoring: " + parameters["flow"]); m->mothurOutEndLine(); flowfile = ""; } + else if (flowfile == "not found") { flowfile = ""; } + if (flowfile != "") { m->setFlowFile(flowfile); } + + processors = validParameter.validFile(parameters, "processors", false); + if (processors == "not found") { processors = "1"; } + if (processors != "") { m->setProcessors(processors); } + clearTypes = validParameter.validFile(parameters, "clear", false); if (clearTypes == "not found") { clearTypes = ""; } else { m->splitAtDash(clearTypes, types); } @@ -422,6 +441,10 @@ int SetCurrentCommand::execute(){ m->setAccnosFile(""); }else if (types[i] == "taxonomy") { m->setTaxonomyFile(""); + }else if (types[i] == "flow") { + m->setFlowFile(""); + }else if (types[i] == "processors") { + m->setProcessors("1"); }else if (types[i] == "all") { m->clearCurrentFiles(); }else { diff --git a/setcurrentcommand.h b/setcurrentcommand.h index 5a40e4a..4ce90a2 100644 --- a/setcurrentcommand.h +++ b/setcurrentcommand.h @@ -37,7 +37,7 @@ private: vector types; string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile; - string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile; + string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile; }; diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index 5478ca4..8c50247 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -116,46 +116,60 @@ SffInfoCommand::SffInfoCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < filenames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(filenames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { filenames[i] = inputDir + filenames[i]; } - } - - ifstream in; - int ableToOpen = m->openInputFile(filenames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(filenames[i]); - m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - filenames[i] = tryPath; + bool ignore = false; + if (filenames[i] == "current") { + filenames[i] = m->getSFFFile(); + if (filenames[i] != "") { m->mothurOut("Using " + filenames[i] + " as input file for the sff parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current sfffile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + filenames.erase(filenames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(filenames[i]); - m->mothurOut("Unable to open " + filenames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - filenames[i] = tryPath; + if (!ignore) { + if (inputDir != "") { + string path = m->hasPath(filenames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { filenames[i] = inputDir + filenames[i]; } } - } - - in.close(); + + ifstream in; + int ableToOpen = m->openInputFile(filenames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - filenames.erase(filenames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(filenames[i]); + m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + filenames[i] = tryPath; + } + } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(filenames[i]); + m->mothurOut("Unable to open " + filenames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + filenames[i] = tryPath; + } + } + + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + filenames.erase(filenames.begin()+i); + i--; + } } } @@ -171,44 +185,59 @@ SffInfoCommand::SffInfoCommand(string option) { //go through files and make sure they are good, if not, then disregard them for (int i = 0; i < accnosFileNames.size(); i++) { - if (inputDir != "") { - string path = m->hasPath(accnosFileNames[i]); - //if the user has not given a path then, add inputdir. else leave path alone. - if (path == "") { accnosFileNames[i] = inputDir + accnosFileNames[i]; } - } - - ifstream in; - int ableToOpen = m->openInputFile(accnosFileNames[i], in, "noerror"); - - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getDefaultPath() != "") { //default path is set - string tryPath = m->getDefaultPath() + m->getSimpleName(accnosFileNames[i]); - m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - accnosFileNames[i] = tryPath; + bool ignore = false; + if (accnosFileNames[i] == "current") { + accnosFileNames[i] = m->getAccnosFile(); + if (accnosFileNames[i] != "") { m->mothurOut("Using " + accnosFileNames[i] + " as input file for the accnos parameter where you had given current."); m->mothurOutEndLine(); } + else { + m->mothurOut("You have no current accnosfile, ignoring current."); m->mothurOutEndLine(); ignore=true; + //erase from file list + accnosFileNames.erase(accnosFileNames.begin()+i); + i--; } } - //if you can't open it, try default location - if (ableToOpen == 1) { - if (m->getOutputDir() != "") { //default path is set - string tryPath = m->getOutputDir() + m->getSimpleName(accnosFileNames[i]); - m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ifstream in2; - ableToOpen = m->openInputFile(tryPath, in2, "noerror"); - in2.close(); - accnosFileNames[i] = tryPath; + + if (!ignore) { + + if (inputDir != "") { + string path = m->hasPath(accnosFileNames[i]); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { accnosFileNames[i] = inputDir + accnosFileNames[i]; } } - } - in.close(); + + ifstream in; + int ableToOpen = m->openInputFile(accnosFileNames[i], in, "noerror"); - if (ableToOpen == 1) { - m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); - //erase from file list - accnosFileNames.erase(accnosFileNames.begin()+i); - i--; + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getDefaultPath() != "") { //default path is set + string tryPath = m->getDefaultPath() + m->getSimpleName(accnosFileNames[i]); + m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + accnosFileNames[i] = tryPath; + } + } + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(accnosFileNames[i]); + m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); + accnosFileNames[i] = tryPath; + } + } + in.close(); + + if (ableToOpen == 1) { + m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); + //erase from file list + accnosFileNames.erase(accnosFileNames.begin()+i); + i--; + } } } @@ -301,7 +330,12 @@ int SffInfoCommand::execute(){ itTypes = outputTypes.find("qfile"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } - } + } + + itTypes = outputTypes.find("flow"); + if (itTypes != outputTypes.end()) { + if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFlowFile(current); } + } //report output filenames m->mothurOutEndLine(); diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index c4b5f43..bb0fa04 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -136,8 +136,14 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { //check for required parameters flowFileName = validParameter.validFile(parameters, "flow", true); - if (flowFileName == "not found") { m->mothurOut("flow is a required parameter for the trim.flows command."); m->mothurOutEndLine(); abort = true; } - else if (flowFileName == "not open") { abort = true; } + if (flowFileName == "not found") { + flowFileName = m->getFlowFile(); + if (flowFileName != "") { m->mothurOut("Using " + flowFileName + " as input file for the flow parameter."); m->mothurOutEndLine(); } + else { + m->mothurOut("No valid current flow file. You must provide a flow file."); m->mothurOutEndLine(); + abort = true; + } + }else if (flowFileName == "not open") { flowFileName = ""; abort = true; } //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"){ -- 2.39.2