//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
candidateFileName = validParameter.validFile(parameters, "candidate", false);
if (candidateFileName == "not found") { m->mothurOut("candidate is a required parameter for the align.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(candidateFileName, candidateFileNames);
+ m->splitAtDash(candidateFileName, candidateFileNames);
//go through files and make sure they are good, if not, then disregard them
for (int i = 0; i < candidateFileNames.size(); i++) {
if (inputDir != "") {
- string path = hasPath(candidateFileNames[i]);
+ 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 = openInputFile(candidateFileNames[i], in, "noerror");
+ ableToOpen = m->openInputFile(candidateFileNames[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() + getSimpleName(candidateFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(candidateFileNames[i]);
m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
candidateFileNames[i] = tryPath;
}
}
convert(temp, processors);
temp = validParameter.validFile(parameters, "flip", false); if (temp == "not found"){ temp = "f"; }
- flip = isTrue(temp);
+ flip = m->isTrue(temp);
temp = validParameter.validFile(parameters, "threshold", false); if (temp == "not found"){ temp = "0.50"; }
convert(temp, threshold);
m->mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); m->mothurOutEndLine();
- if (outputDir == "") { outputDir += hasPath(candidateFileNames[s]); }
- string alignFileName = outputDir + getRootName(getSimpleName(candidateFileNames[s])) + "align";
- string reportFileName = outputDir + getRootName(getSimpleName(candidateFileNames[s])) + "align.report";
- string accnosFileName = outputDir + getRootName(getSimpleName(candidateFileNames[s])) + "flip.accnos";
+ if (outputDir == "") { outputDir += m->hasPath(candidateFileNames[s]); }
+ string alignFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "align";
+ string reportFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "align.report";
+ string accnosFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "flip.accnos";
bool hasAccnos = true;
int numFastaSeqs = 0;
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(candidateFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
}
#else
- vector<unsigned long int> positions = divideFile(candidateFileNames[s], processors);
-
+
+ vector<unsigned long int> positions = m->divideFile(candidateFileNames[s], processors);
+
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
}
if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); return 0; }
//delete accnos file if its blank else report to user
- if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
+ if (m->isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
else {
m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
if (!flip) {
vector<string> nonBlankAccnosFiles;
//delete blank accnos files generated with multiple processes
for(int i=0;i<processors;i++){
- if (!(isBlank(accnosFileName + toString(processIDS[i]) + ".temp"))) {
+ if (!(m->isBlank(accnosFileName + toString(processIDS[i]) + ".temp"))) {
nonBlankAccnosFiles.push_back(accnosFileName + toString(processIDS[i]) + ".temp");
}else { remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str()); }
}
if (m->control_pressed) { remove(accnosFileName.c_str()); remove(alignFileName.c_str()); remove(reportFileName.c_str()); return 0; }
//delete accnos file if its blank else report to user
- if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
+ if (m->isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; }
else {
m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
if (!flip) {
int AlignCommand::driver(linePair* filePos, string alignFName, string reportFName, string accnosFName, string filename){
try {
ofstream alignmentFile;
- openOutputFile(alignFName, alignmentFile);
+ m->openOutputFile(alignFName, alignmentFile);
ofstream accnosFile;
- openOutputFile(accnosFName, accnosFile);
+ m->openOutputFile(accnosFName, accnosFile);
NastReport report(reportFName);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 0; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
int origNumBases = candidateSeq->getNumBases();
string originalUnaligned = candidateSeq->getUnaligned();
//pass numSeqs to parent
ofstream out;
string tempFile = alignFileName + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = alignFileName + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
ofstream output;
ifstream input;
- openOutputFileAppend(filename, output);
- openInputFile(temp, input);
+ m->openOutputFileAppend(filename, output);
+ m->openInputFile(temp, input);
while(char c = input.get()){
if(input.eof()) { break; }
ofstream output;
ifstream input;
- openOutputFileAppend(filename, output);
- openInputFile(temp, input);
+ m->openOutputFileAppend(filename, output);
+ m->openInputFile(temp, input);
while (!input.eof()) { char c = input.get(); if (c == 10 || c == 13){ break; } } // get header line
MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer
if (pid == 0) {
- positions = setFilePosFasta(fastaFileName, numSeqs); //fills MPIPos, returns numSeqs
+ positions = m->setFilePosFasta(fastaFileName, numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
ifstream fastaFile;
- openInputFile(fastaFileName, fastaFile);
+ m->openInputFile(fastaFileName, fastaFile);
while (!fastaFile.eof()) {
- Sequence temp(fastaFile); gobble(fastaFile);
+ Sequence temp(fastaFile); m->gobble(fastaFile);
if (m->control_pressed) { templateSequences.clear(); break; }
ifstream kmerFileTest(kmerDBName.c_str());
if(kmerFileTest){
- bool GoodFile = checkReleaseVersion(kmerFileTest, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
if (GoodFile) { needToGenerate = false; }
}
#endif
/************calculate the probablity that each word will be in a specific taxonomy*************/
string tfileroot = tfile.substr(0,tfile.find_last_of(".")+1);
- string tempfileroot = getRootName(getSimpleName(tempFile));
+ string tempfileroot = m->getRootName(m->getSimpleName(tempFile));
string phyloTreeName = tfileroot + "tree.train";
string phyloTreeSumName = tfileroot + "tree.sum";
string probFileName = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.prob";
#endif
- openOutputFile(probFileName, out);
+ m->openOutputFile(probFileName, out);
//output mothur version
out << "#" << m->getVersion() << endl;
out << numKmers << endl;
- openOutputFile(probFileName2, out2);
+ m->openOutputFile(probFileName2, out2);
//output mothur version
out2 << "#" << m->getVersion() << endl;
MPI_File_open(MPI_COMM_WORLD, inFileName2, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI2); //comm, filename, mode, info, filepointer
if (pid == 0) {
- positions = setFilePosEachLine(inNumName, num);
- positions2 = setFilePosEachLine(inName, num2);
+ positions = m->setFilePosEachLine(inNumName, num);
+ positions2 = m->setFilePosEachLine(inName, num2);
for(int i = 1; i < processors; i++) {
MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
//read version
- string line = getline(in); gobble(in);
+ string line = m->getline(in); m->gobble(in);
- in >> numKmers; gobble(in);
+ in >> numKmers; m->gobble(in);
//initialze probabilities
wordGenusProb.resize(numKmers);
vector<float> zeroCountProb; zeroCountProb.resize(numKmers);
//read version
- string line2 = getline(inNum); gobble(inNum);
+ string line2 = m->getline(inNum); m->gobble(inNum);
while (inNum) {
inNum >> zeroCountProb[count] >> num[count];
count++;
- gobble(inNum);
+ m->gobble(inNum);
}
inNum.close();
wordGenusProb[kmer][name] = prob;
}
- gobble(in);
+ m->gobble(in);
}
in.close();
bool good = true;
vector<string> lines;
- lines.push_back(getline(file1));
- lines.push_back(getline(file2));
- lines.push_back(getline(file3));
- lines.push_back(getline(file4));
+ lines.push_back(m->getline(file1));
+ lines.push_back(m->getline(file2));
+ lines.push_back(m->getline(file3));
+ lines.push_back(m->getline(file4));
//before we added this check
if ((lines[0][0] != '#') || (lines[1][0] != '#') || (lines[2][0] != '#') || (lines[3][0] != '#')) { good = false; }
string version = m->getVersion();
vector<string> versionVector;
- splitAtChar(version, versionVector, '.');
+ m->splitAtChar(version, versionVector, '.');
//check each files version
for (int i = 0; i < lines.size(); i++) {
vector<string> linesVector;
- splitAtChar(lines[i], linesVector, '.');
+ m->splitAtChar(lines[i], linesVector, '.');
if (versionVector.size() != linesVector.size()) { good = false; break; }
else {
try {
ofstream outTemp;
- openOutputFile(file, outTemp);
+ m->openOutputFile(file, outTemp);
//lets you know what part of the pref matrix you are writing
outTemp << tempLine.start << '\t' << tempLine.num << endl;
try {
ifstream inTemp;
- openInputFile(file, inTemp);
+ m->openInputFile(file, inTemp);
int start, num;
//lets you know what part of the pref matrix you are writing
- inTemp >> start >> num; gobble(inTemp);
+ inTemp >> start >> num; m->gobble(inTemp);
for (int i = start; i < num; i++) {
inTemp >> pref[i][j].name >> pref[i][j].leftParent >> pref[i][j].rightParent;
inTemp >> pref[i][j].score >> pref[i][j].closestLeft >> pref[i][j].closestRight >> pref[i][j].midpoint;
- gobble(inTemp);
+ m->gobble(inTemp);
}
}
//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 += hasPath(globaldata->getListFile()); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->getListFile()); //if user entered a file with a path then preserve it
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else if (groupfile == "not found") { groupfile = ""; }
if (abort == false) {
-// openInputFile(fastafile, in);
+// m->openInputFile(fastafile, in);
fasta = new FastaMap();
if (groupfile != "") {
groupMap = new GroupMap(groupfile);
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
void BinSeqCommand::readNamesFile() {
try {
vector<string> dupNames;
- openInputFile(namesfile, inNames);
+ m->openInputFile(namesfile, inNames);
string name, names, sequence;
dupNames.clear();
//parse names into vector
- splitAtComma(names, dupNames);
+ m->splitAtComma(names, dupNames);
//store names in fasta map
sequence = fasta->getSequence(name);
fasta->push_back(dupNames[i], sequence);
}
- gobble(inNames);
+ m->gobble(inNames);
}
inNames.close();
try {
string binnames, name, sequence;
- string outputFileName = outputDir + getRootName(getSimpleName(globaldata->getListFile())) + list->getLabel() + ".fasta";
- openOutputFile(outputFileName, out);
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->getListFile())) + list->getLabel() + ".fasta";
+ m->openOutputFile(outputFileName, out);
//save to output list of output file names
outputNames.push_back(outputFileName);
// to the pairwise entry in the Sequence class for the
// candidate and template Sequence objects
ifstream blastFile;
- openInputFile(blastFileName, blastFile);
+ m->openInputFile(blastFileName, blastFile);
seqAaln = "";
seqBaln = "";
vector<int> topMatches;
ofstream queryFile;
- openOutputFile((queryFileName+seq->getName()), queryFile);
+ m->openOutputFile((queryFileName+seq->getName()), queryFile);
queryFile << '>' << seq->getName() << endl;
queryFile << seq->getUnaligned() << endl;
queryFile.close();
system(blastCommand.c_str());
ifstream m8FileHandle;
- openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
+ m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
string dummy;
int templateAccession;
- gobble(m8FileHandle);
+ m->gobble(m8FileHandle);
while(!m8FileHandle.eof()){
m8FileHandle >> dummy >> templateAccession >> searchScore;
//get rest of junk in line
while (!m8FileHandle.eof()) { char c = m8FileHandle.get(); if (c == 10 || c == 13){ break; } }
- gobble(m8FileHandle);
+ m->gobble(m8FileHandle);
topMatches.push_back(templateAccession);
}
m8FileHandle.close();
vector<int> topMatches;
ofstream queryFile;
- openOutputFile((queryFileName+seq->getName()), queryFile);
+ m->openOutputFile((queryFileName+seq->getName()), queryFile);
queryFile << '>' << seq->getName() << endl;
queryFile << seq->getUnaligned() << endl;
queryFile.close();
system(blastCommand.c_str());
ifstream m8FileHandle;
- openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
+ m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error");
string dummy;
int templateAccession;
- gobble(m8FileHandle);
+ m->gobble(m8FileHandle);
while(!m8FileHandle.eof()){
m8FileHandle >> dummy >> templateAccession >> searchScore;
//get rest of junk in line
while (!m8FileHandle.eof()) { char c = m8FileHandle.get(); if (c == 10 || c == 13){ break; } }
- gobble(m8FileHandle);
+ m->gobble(m8FileHandle);
topMatches.push_back(templateAccession);
//cout << templateAccession << endl;
}
try {
ofstream unalignedFastaFile;
- openOutputFileAppend(dbFileName, unalignedFastaFile);
+ m->openOutputFileAppend(dbFileName, unalignedFastaFile);
// generating a fasta file with unaligned template
unalignedFastaFile << '>' << count << endl; // sequences, which will be input to formatdb
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
else {
if (calc == "default") { calc = "jclass-thetayc"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "1000"; }
}
//you have a label the user want that is smaller than this label and the last label has not already been processed
- if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = order->getLabel();
delete order;
//open an ostream for each calc to print to
for (int z = 0; z < treeCalculators.size(); z++) {
//create a new filename
- outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
- openOutputFile(outputFile, *(out[z]));
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[z]->getName() + ".boot" + order->getLabel() + ".tre";
+ m->openOutputFile(outputFile, *(out[z]));
outputNames.push_back(outputFile);
}
//set global data to calc trees
globaldata->gTree = trees[k];
- string filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
+ string filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
consensus = new ConcensusCommand(filename);
consensus->execute();
delete consensus;
it = parameters.find("sabund");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["sabund"] = inputDir + it->second; }
}
string label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
vector<string> outputNames;
//prepare full output directory
- outputDir = getFullPathName(outputDir);
+ outputDir = m->getFullPathName(outputDir);
//get location of catchall
GlobalData* globaldata = GlobalData::getInstance();
string path = globaldata->argv;
path = path.substr(0, (path.find_last_of('m')));
- path = getFullPathName(path);
+ path = m->getFullPathName(path);
string catchAllCommandExe = "";
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
userLabels.erase(sabund->getLabel());
}
- if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = sabund->getLabel();
delete sabund;
//**********************************************************************************************************************
string CatchAllCommand::process(SAbundVector* sabund) {
try {
- string filename = outputDir + getRootName(getSimpleName(sabundfile)) + sabund->getLabel() + ".catchall";
- filename = getFullPathName(filename);
+ string filename = outputDir + m->getRootName(m->getSimpleName(sabundfile)) + sabund->getLabel() + ".catchall";
+ filename = m->getFullPathName(filename);
ofstream out;
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
for (int i = 1; i <= sabund->getMaxRank(); i++) {
int temp = sabund->get(i);
distCalc = new eachGapDist();
decalc = new DeCalculator();
- mapInfo = outputDir + getRootName(getSimpleName(fastafile)) + "mapinfo";
+ mapInfo = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "mapinfo";
#ifdef USE_MPI
#else
ofstream out2;
- openOutputFile(mapInfo, out2);
+ m->openOutputFile(mapInfo, out2);
out2 << "Place in masked, filtered and trimmed sequence\tPlace in original alignment" << endl;
out2.close();
try {
ofstream out2;
- openOutputFileAppend(mapInfo, out2);
+ m->openOutputFileAppend(mapInfo, out2);
out2 << querySeq->getName() << endl;
for (it = spotMap.begin(); it!= spotMap.end(); it++) {
//delete inFileName;
if (pid == 0) {
- positions = setFilePosFasta(file, numSeqs); //fills MPIPos, returns numSeqs
+ positions = m->setFilePosFasta(file, numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
ifstream in;
- openInputFile(file, in);
+ m->openInputFile(file, in);
//read in seqs and store in vector
while(!in.eof()){
if (m->control_pressed) { return container; }
- Sequence* current = new Sequence(in); gobble(in);
+ Sequence* current = new Sequence(in); m->gobble(in);
if (count == 0) { length = current->getAligned().length(); count++; } //gets first seqs length
else if (length != current->getAligned().length()) { unaligned = true; }
#else
ifstream infile;
- openInputFile(filename, infile);
+ m->openInputFile(filename, infile);
if (!infile.eof()) {
Sequence temp(infile);
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.bellerophon command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
string temp;
temp = validParameter.validFile(parameters, "filter", false); if (temp == "not found") { temp = "F"; }
- filter = isTrue(temp);
+ filter = m->isTrue(temp);
temp = validParameter.validFile(parameters, "correction", false); if (temp == "not found") { temp = "T"; }
- correction = isTrue(temp);
+ correction = m->isTrue(temp);
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found") { temp = "1"; }
convert(temp, processors);
chimera = new Bellerophon(fastaFileNames[i], filter, correction, window, increment, processors, outputDir);
- string outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "bellerophon.chimeras";
- string accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "bellerophon.accnos";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "bellerophon.chimeras";
+ string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "bellerophon.accnos";
chimera->getChimeras();
#else
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ofstream out2;
- openOutputFile(accnosFileName, out2);
+ m->openOutputFile(accnosFileName, out2);
numSeqs = chimera->print(out, out2);
out.close();
it = parameters.find("template");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.ccode command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
templatefile = validParameter.validFile(parameters, "template", true);
if (maskfile == "not found") { maskfile = ""; }
else if (maskfile != "default") {
if (inputDir != "") {
- string path = hasPath(maskfile);
+ string path = m->hasPath(maskfile);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { maskfile = inputDir + maskfile; }
}
ifstream in;
- int ableToOpen = openInputFile(maskfile, in);
+ int ableToOpen = m->openInputFile(maskfile, in);
if (ableToOpen == 1) { abort = true; }
in.close();
}
string temp;
temp = validParameter.validFile(parameters, "filter", false); if (temp == "not found") { temp = "F"; }
- filter = isTrue(temp);
+ filter = m->isTrue(temp);
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found") { temp = "1"; }
convert(temp, processors);
string outputFileName, accnosFileName;
if (maskfile != "") {
- outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.chimeras";
- accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.accnos";
+ outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.chimeras";
+ accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.accnos";
}else {
- outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "ccode.chimeras";
- accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "ccode.accnos";
+ outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ccode.chimeras";
+ accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ccode.accnos";
}
- string mapInfo = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "mapinfo";
+ string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "mapinfo";
if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; }
MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
delete buf2;
- MPIPos = setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
ofstream outHeader;
- string tempHeader = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + maskfile + "ccode.chimeras.tempHeader";
- openOutputFile(tempHeader, outHeader);
+ string tempHeader = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + "ccode.chimeras.tempHeader";
+ m->openOutputFile(tempHeader, outHeader);
outHeader << "For full window mapping info refer to " << mapInfo << endl << endl;
outHeader.close();
- vector<unsigned long int> positions = divideFile(fastaFileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastaFileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
//append output files
for(int i=1;i<processors;i++){
- appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
+ m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
remove((outputFileName + toString(processIDS[i]) + ".temp").c_str());
}
//append output files
for(int i=1;i<processors;i++){
- appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
+ m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str());
}
#endif
- appendFiles(outputFileName, tempHeader);
+ m->appendFiles(outputFileName, tempHeader);
remove(outputFileName.c_str());
rename(tempHeader.c_str(), outputFileName.c_str());
int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string filename, string accnos){
try {
ofstream out;
- openOutputFile(outputFName, out);
+ m->openOutputFile(outputFName, out);
ofstream out2;
- openOutputFile(accnos, out2);
+ m->openOutputFile(accnos, out2);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 1; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
istringstream iss (tempBuf,istringstream::in);
delete buf4;
- Sequence* candidateSeq = new Sequence(iss); gobble(iss);
+ Sequence* candidateSeq = new Sequence(iss); m->gobble(iss);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
//pass numSeqs to parent
ofstream out;
string tempFile = outputFileName + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
it = parameters.find("template");
//user has given a template file
if(it != parameters.end()){
- string path = hasPath(it->second);
+ string path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.check command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
namefile = validParameter.validFile(parameters, "name", false);
if (namefile == "not found") { namefile = ""; }
else {
- splitAtDash(namefile, nameFileNames);
+ m->splitAtDash(namefile, nameFileNames);
//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 = hasPath(nameFileNames[i]);
+ 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 = openInputFile(nameFileNames[i], in, "noerror");
+ 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() + getSimpleName(nameFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]);
m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
nameFileNames[i] = tryPath;
}
}
convert(temp, ksize);
temp = validParameter.validFile(parameters, "svg", false); if (temp == "not found") { temp = "F"; }
- svg = isTrue(temp);
+ svg = m->isTrue(temp);
if (nameFileNames.size() != 0) { svg = true; }
temp = validParameter.validFile(parameters, "increment", false); if (temp == "not found") { temp = "10"; }
if (m->control_pressed) { delete chimera; return 0; }
- string outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "chimeracheck.chimeras";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "chimeracheck.chimeras";
outputNames.push_back(outputFileName);
#ifdef USE_MPI
if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } delete chimera; return 0; }
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastaFileNames[i], numSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastaFileNames[i], numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int j = 1; j < processors; j++) {
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastaFileNames[i], processors);
+ vector<unsigned long int> positions = m->divideFile(fastaFileNames[i], processors);
for (int s = 0; s < (positions.size()-1); s++) {
lines.push_back(new linePair(positions[s], positions[(s+1)]));
//append output files
for(int j=1;j<processors;j++){
- appendFiles((outputFileName + toString(processIDS[j]) + ".temp"), outputFileName);
+ m->appendFiles((outputFileName + toString(processIDS[j]) + ".temp"), outputFileName);
remove((outputFileName + toString(processIDS[j]) + ".temp").c_str());
}
int ChimeraCheckCommand::driver(linePair* filePos, string outputFName, string filename){
try {
ofstream out;
- openOutputFile(outputFName, out);
+ m->openOutputFile(outputFName, out);
ofstream out2;
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 1; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
//find chimeras
istringstream iss (tempBuf,istringstream::in);
delete buf4;
- Sequence* candidateSeq = new Sequence(iss); gobble(iss);
+ Sequence* candidateSeq = new Sequence(iss); m->gobble(iss);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
//find chimeras
//pass numSeqs to parent
ofstream out;
string tempFile = outputFileName + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
delete buffer;
while(!iss.eof()) {
- iss >> name; gobble(iss);
+ iss >> name; m->gobble(iss);
names[name] = name;
}
#else
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
while (!in.eof()) {
- in >> name; gobble(in);
+ in >> name; m->gobble(in);
names[name] = name;
}
in.close();
string file = outputDir + querySeq->getName() + ".chimeracheck.svg";
ofstream outsvg;
- openOutputFile(file, outsvg);
+ m->openOutputFile(file, outsvg);
int width = (info.size()*5) + 150;
it = parameters.find("template");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
it = parameters.find("conservation");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["conservation"] = inputDir + it->second; }
}
it = parameters.find("quantile");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["quantile"] = inputDir + it->second; }
}
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.pintail command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
string temp;
temp = validParameter.validFile(parameters, "filter", false); if (temp == "not found") { temp = "F"; }
- filter = isTrue(temp);
+ filter = m->isTrue(temp);
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found") { temp = "1"; }
convert(temp, processors);
if (maskfile == "not found") { maskfile = ""; }
else if (maskfile != "default") {
if (inputDir != "") {
- string path = hasPath(maskfile);
+ string path = m->hasPath(maskfile);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { maskfile = inputDir + maskfile; }
}
ifstream in;
- int ableToOpen = openInputFile(maskfile, in);
+ int ableToOpen = m->openInputFile(maskfile, in);
if (ableToOpen == 1) { abort = true; }
in.close();
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
templatefile = validParameter.validFile(parameters, "template", true);
else if (consfile == "not found") {
consfile = "";
//check for consfile
- string tempConsFile = getRootName(inputDir + getSimpleName(templatefile)) + "freq";
+ string tempConsFile = m->getRootName(inputDir + m->getSimpleName(templatefile)) + "freq";
ifstream FileTest(tempConsFile.c_str());
if(FileTest){
- bool GoodFile = checkReleaseVersion(FileTest, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(FileTest, m->getVersion());
if (GoodFile) {
m->mothurOut("I found " + tempConsFile + " in your input file directory. I will use it to save time."); m->mothurOutEndLine(); consfile = tempConsFile; FileTest.close();
}
//check for quantile to save the time
string tempQuan = "";
if ((!filter) && (maskfile == "")) {
- tempQuan = inputDir + getRootName(getSimpleName(templatefile)) + "pintail.quan";
+ tempQuan = inputDir + m->getRootName(m->getSimpleName(templatefile)) + "pintail.quan";
}else if ((!filter) && (maskfile != "")) {
- tempQuan = inputDir + getRootName(getSimpleName(templatefile)) + "pintail.masked.quan";
+ tempQuan = inputDir + m->getRootName(m->getSimpleName(templatefile)) + "pintail.masked.quan";
}else if ((filter) && (maskfile != "")) {
- tempQuan = inputDir + getRootName(getSimpleName(templatefile)) + "pintail.filtered." + getSimpleName(getRootName(fastaFileNames[s])) + "masked.quan";
+ tempQuan = inputDir + m->getRootName(m->getSimpleName(templatefile)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "masked.quan";
}else if ((filter) && (maskfile == "")) {
- tempQuan = inputDir + getRootName(getSimpleName(templatefile)) + "pintail.filtered." + getSimpleName(getRootName(fastaFileNames[s])) + "quan";
+ tempQuan = inputDir + m->getRootName(m->getSimpleName(templatefile)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "quan";
}
ifstream FileTest(tempQuan.c_str());
if(FileTest){
- bool GoodFile = checkReleaseVersion(FileTest, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(FileTest, m->getVersion());
if (GoodFile) {
m->mothurOut("I found " + tempQuan + " in your input file directory. I will use it to save time."); m->mothurOutEndLine(); quanfile = tempQuan; FileTest.close();
}
string outputFileName, accnosFileName;
if (maskfile != "") {
- outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + maskfile + ".pintail.chimeras";
- accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + maskfile + ".pintail.accnos";
+ outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".pintail.chimeras";
+ accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".pintail.accnos";
}else {
- outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "pintail.chimeras";
- accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "pintail.accnos";
+ outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "pintail.chimeras";
+ accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "pintail.accnos";
}
if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; }
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
MPI_File_close(&outMPIAccnos);
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastaFileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastaFileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
//append output files
for(int i=1;i<processors;i++){
- appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
+ m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
remove((outputFileName + toString(processIDS[i]) + ".temp").c_str());
}
//append output files
for(int i=1;i<processors;i++){
- appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
+ m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str());
}
int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string filename, string accnos){
try {
ofstream out;
- openOutputFile(outputFName, out);
+ m->openOutputFile(outputFName, out);
ofstream out2;
- openOutputFile(accnos, out2);
+ m->openOutputFile(accnos, out2);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 1; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
istringstream iss (tempBuf,istringstream::in);
delete buf4;
- Sequence* candidateSeq = new Sequence(iss); gobble(iss);
+ Sequence* candidateSeq = new Sequence(iss); m->gobble(iss);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
//pass numSeqs to parent
ofstream out;
string tempFile = outputFileName + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
bool needToGenerateLeft = true;
if(kmerFileTestLeft){
- bool GoodFile = checkReleaseVersion(kmerFileTestLeft, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(kmerFileTestLeft, m->getVersion());
if (GoodFile) { needToGenerateLeft = false; }
}
bool needToGenerateRight = true;
if(kmerFileTestRight){
- bool GoodFile = checkReleaseVersion(kmerFileTestRight, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(kmerFileTestRight, m->getVersion());
if (GoodFile) { needToGenerateRight = false; }
}
it = parameters.find("template");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the chimera.slayer command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
templatefile = validParameter.validFile(parameters, "template", true);
convert(temp, parents);
temp = validParameter.validFile(parameters, "realign", false); if (temp == "not found") { temp = "f"; }
- realign = isTrue(temp);
+ realign = m->isTrue(temp);
search = validParameter.validFile(parameters, "search", false); if (search == "not found") { search = "distance"; }
chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign);
- string outputFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "slayer.chimeras";
- string accnosFileName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "slayer.accnos";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.chimeras";
+ string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.accnos";
if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; }
MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
delete buf2;
- MPIPos = setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
ofstream outHeader;
- string tempHeader = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "slayer.chimeras.tempHeader";
- openOutputFile(tempHeader, outHeader);
+ string tempHeader = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.chimeras.tempHeader";
+ m->openOutputFile(tempHeader, outHeader);
chimera->printHeader(outHeader);
outHeader.close();
- vector<unsigned long int> positions = divideFile(fastaFileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastaFileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
//append output files
for(int i=1;i<processors;i++){
- appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
+ m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
remove((outputFileName + toString(processIDS[i]) + ".temp").c_str());
}
//append output files
for(int i=1;i<processors;i++){
- appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
+ m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
remove((accnosFileName + toString(processIDS[i]) + ".temp").c_str());
}
#endif
- appendFiles(outputFileName, tempHeader);
+ m->appendFiles(outputFileName, tempHeader);
remove(outputFileName.c_str());
rename(tempHeader.c_str(), outputFileName.c_str());
int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string filename, string accnos){
try {
ofstream out;
- openOutputFile(outputFName, out);
+ m->openOutputFile(outputFName, out);
ofstream out2;
- openOutputFile(accnos, out2);
+ m->openOutputFile(accnos, out2);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 1; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
delete buf4;
- Sequence* candidateSeq = new Sequence(iss); gobble(iss);
+ Sequence* candidateSeq = new Sequence(iss); m->gobble(iss);
if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
//pass numSeqs to parent
ofstream out;
string tempFile = outputFileName + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
convert(temp, numbases);
temp = validParameter.validFile(parameters, "countgaps", false); if (temp == "not found") { temp = "f"; }
- countGaps = isTrue(temp);
+ countGaps = m->isTrue(temp);
keep = validParameter.validFile(parameters, "keep", false); if (keep == "not found") { keep = "front"; }
if (abort == true) { return 0; }
- string outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + "chop.fasta";
- string outputFileNameAccnos = outputDir + getRootName(getSimpleName(fastafile)) + "chop.accnos";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta";
+ string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos";
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ofstream outAcc;
- openOutputFile(outputFileNameAccnos, outAcc);
+ m->openOutputFile(outputFileNameAccnos, outAcc);
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
bool wroteAccnos = false;
//delete inFileName;
if (pid == 0) { //only one process needs to scan file
- positions = setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs
+ positions = m->setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
//need to know number of template seqs for suffixdb
if (method == "suffix") {
ifstream inFASTA;
- openInputFile(tempFile, inFASTA);
- getNumSeqs(inFASTA, numSeqs);
+ m->openInputFile(tempFile, inFASTA);
+ m->getNumSeqs(inFASTA, numSeqs);
inFASTA.close();
}
kmerDBName = tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
ifstream kmerFileTest(kmerDBName.c_str());
if(kmerFileTest){
- bool GoodFile = checkReleaseVersion(kmerFileTest, m->getVersion());
+ bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
if (GoodFile) { needToGenerate = false; }
}
}
if (needToGenerate) {
ifstream fastaFile;
- openInputFile(tempFile, fastaFile);
+ m->openInputFile(tempFile, fastaFile);
while (!fastaFile.eof()) {
Sequence temp(fastaFile);
- gobble(fastaFile);
+ m->gobble(fastaFile);
names.push_back(temp.getName());
database->readKmerDB(kmerFileTest);
ifstream fastaFile;
- openInputFile(tempFile, fastaFile);
+ m->openInputFile(tempFile, fastaFile);
while (!fastaFile.eof()) {
Sequence temp(fastaFile);
- gobble(fastaFile);
+ m->gobble(fastaFile);
names.push_back(temp.getName());
}
//delete inFileName;
if (pid == 0) {
- positions = setFilePosEachLine(file, num);
+ positions = m->setFilePosEachLine(file, num);
//send file positions to all processes
for(int i = 1; i < processors; i++) {
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
ifstream inTax;
- openInputFile(file, inTax);
+ m->openInputFile(file, inTax);
//read template seqs and save
while (!inTax.eof()) {
phyloTree->addSeqToTree(name, taxInfo);
- gobble(inTax);
+ m->gobble(inTax);
}
inTax.close();
#endif
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; allLines = 1; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
convert(temp, cutoff);
temp = validParameter.validFile(parameters, "probs", false); if (temp == "not found"){ temp = "true"; }
- probs = isTrue(temp);
+ probs = m->isTrue(temp);
if ((cutoff < 51) || (cutoff > 100)) { m->mothurOut("cutoff must be above 50, and no greater than 100."); m->mothurOutEndLine(); abort = true; }
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
try {
ifstream inNames;
- openInputFile(namefile, inNames);
+ m->openInputFile(namefile, inNames);
string name, names;
while(inNames){
inNames >> name; //read from first column A
inNames >> names; //read from second column A,B,C,D
- gobble(inNames);
+ m->gobble(inNames);
//parse names into vector
vector<string> theseNames;
- splitAtComma(names, theseNames);
+ m->splitAtComma(names, theseNames);
for (int i = 0; i < theseNames.size(); i++) { nameMap[theseNames[i]] = name; }
try {
ifstream in;
- openInputFile(taxfile, in);
+ m->openInputFile(taxfile, in);
string name, tax;
while(!in.eof()){
in >> name >> tax;
- gobble(in);
+ m->gobble(in);
//are there confidence scores, if so remove them
if (tax.find_first_of('(') != -1) { removeConfidences(tax); }
//parse names into vector
string binnames = thisList->get(bin);
- splitAtComma(binnames, names);
+ m->splitAtComma(binnames, names);
//create a tree containing sequences from this bin
PhyloTree* phylo = new PhyloTree();
int size;
//create output file
- if (outputDir == "") { outputDir += hasPath(listfile); }
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
ofstream out;
- string outputFile = outputDir + getRootName(getSimpleName(listfile)) + processList->getLabel() + ".cons.taxonomy";
- openOutputFile(outputFile, out);
+ string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".cons.taxonomy";
+ m->openOutputFile(outputFile, out);
outputNames.push_back(outputFile);
//for each bin in the list vector
it = parameters.find("template");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["template"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
fastaFileName = validParameter.validFile(parameters, "fasta", false);
if (fastaFileName == "not found") { m->mothurOut("fasta is a required parameter for the classify.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastaFileName, fastaFileNames);
+ m->splitAtDash(fastaFileName, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
if (namefile == "not found") { namefile = ""; }
else {
- splitAtDash(namefile, namefileNames);
+ m->splitAtDash(namefile, namefileNames);
//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 = hasPath(namefileNames[i]);
+ 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 = openInputFile(namefileNames[i], in, "noerror");
+ 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() + getSimpleName(namefileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(namefileNames[i]);
m->mothurOut("Unable to open " + namefileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
namefileNames[i] = tryPath;
}
}
groupfile = validParameter.validFile(parameters, "group", false);
if (groupfile == "not found") { groupfile = ""; }
else {
- splitAtDash(groupfile, groupfileNames);
+ m->splitAtDash(groupfile, groupfileNames);
//go through files and make sure they are good, if not, then disregard them
for (int i = 0; i < groupfileNames.size(); i++) {
if (inputDir != "") {
- string path = hasPath(groupfileNames[i]);
+ string path = m->hasPath(groupfileNames[i]);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { groupfileNames[i] = inputDir + groupfileNames[i]; }
}
int ableToOpen;
ifstream in;
- ableToOpen = openInputFile(groupfileNames[i], in, "noerror");
+ ableToOpen = m->openInputFile(groupfileNames[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() + getSimpleName(groupfileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(groupfileNames[i]);
m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
groupfileNames[i] = tryPath;
}
}
convert(temp, cutoff);
temp = validParameter.validFile(parameters, "probs", false); if (temp == "not found"){ temp = "true"; }
- probs = isTrue(temp);
+ probs = m->isTrue(temp);
temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "100"; }
convert(temp, iters);
m->mothurOut("Classifying sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
- string RippedTaxName = getRootName(getSimpleName(taxonomyFileName));
- RippedTaxName = getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1));
+ string RippedTaxName = m->getRootName(m->getSimpleName(taxonomyFileName));
+ RippedTaxName = m->getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1));
if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); }
RippedTaxName += ".";
- if (outputDir == "") { outputDir += hasPath(fastaFileNames[s]); }
- string newTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy";
- string tempTaxonomyFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
- string taxSummary = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + RippedTaxName + "tax.summary";
+ if (outputDir == "") { outputDir += m->hasPath(fastaFileNames[s]); }
+ string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy";
+ string tempTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
+ string taxSummary = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "tax.summary";
if ((method == "knn") && (search == "distance")) {
- string DistName = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "match.dist";
+ string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "match.dist";
classify->setDistName(DistName); outputNames.push_back(DistName);
}
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastaFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastaFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
- vector<unsigned long int> positions = divideFile(fastaFileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastaFileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
nameMap.clear(); //remove old names
ifstream inNames;
- openInputFile(namefileNames[s], inNames);
+ m->openInputFile(namefileNames[s], inNames);
string firstCol, secondCol;
while(!inNames.eof()) {
- inNames >> firstCol >> secondCol; gobble(inNames);
+ inNames >> firstCol >> secondCol; m->gobble(inNames);
vector<string> temp;
- splitAtComma(secondCol, temp);
+ m->splitAtComma(secondCol, temp);
nameMap[firstCol] = temp;
}
if (namefile == "") { taxaSum.summarize(tempTaxonomyFile); }
else {
ifstream in;
- openInputFile(tempTaxonomyFile, in);
+ m->openInputFile(tempTaxonomyFile, in);
//read in users taxonomy file and add sequences to tree
string name, taxon;
while(!in.eof()){
- in >> name >> taxon; gobble(in);
+ in >> name >> taxon; m->gobble(in);
itNames = nameMap.find(name);
//print summary file
ofstream outTaxTree;
- openOutputFile(taxSummary, outTaxTree);
+ m->openOutputFile(taxSummary, outTaxTree);
taxaSum.print(outTaxTree);
outTaxTree.close();
//output taxonomy with the unclassified bins added
ifstream inTax;
- openInputFile(newTaxonomyFile, inTax);
+ m->openInputFile(newTaxonomyFile, inTax);
ofstream outTax;
string unclass = newTaxonomyFile + ".unclass.temp";
- openOutputFile(unclass, outTax);
+ m->openOutputFile(unclass, outTax);
//get maxLevel from phylotree so you know how many 'unclassified's to add
int maxLevel = taxaSum.getMaxLevel();
while (!inTax.eof()) {
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } remove(unclass.c_str()); delete classify; return 0; }
- inTax >> name >> taxon; gobble(inTax);
+ inTax >> name >> taxon; m->gobble(inTax);
string newTax = addUnclassifieds(taxon, maxLevel);
//pass numSeqs to parent
ofstream out;
string tempFile = filename + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = filename + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
ofstream output;
ifstream input;
- openOutputFileAppend(filename, output);
- openInputFile(temp, input);
+ m->openOutputFileAppend(filename, output);
+ m->openInputFile(temp, input);
while(char c = input.get()){
if(input.eof()) { break; }
int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempTFName, string filename){
try {
ofstream outTax;
- openOutputFile(taxFName, outTax);
+ m->openOutputFile(taxFName, outTax);
ofstream outTaxSimple;
- openOutputFile(tempTFName, outTaxSimple);
+ m->openOutputFile(tempTFName, outTaxSimple);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
string taxonomy;
while (!done) {
if (m->control_pressed) { return 0; }
- Sequence* candidateSeq = new Sequence(inFASTA); gobble(inFASTA);
+ Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
if (candidateSeq->getName() != "") {
taxonomy = classify->getTaxonomy(candidateSeq);
string firstCol, secondCol;
while(!iss.eof()) {
- iss >> firstCol >> secondCol; gobble(iss);
+ iss >> firstCol >> secondCol; m->gobble(iss);
vector<string> temp;
- splitAtComma(secondCol, temp);
+ m->splitAtComma(secondCol, temp);
nameMap[firstCol] = temp;
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = 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 = hasPath(inputFile); }
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(inputFile); }
string temp;
temp = validParameter.validFile(parameters, "version", false); if (temp == "not found"){ temp = "F"; }
- version = isTrue(temp);
+ version = m->isTrue(temp);
temp = validParameter.validFile(parameters, "verbose", false); if (temp == "not found"){ temp = "F"; }
- verbose = isTrue(temp);
+ verbose = m->isTrue(temp);
temp = validParameter.validFile(parameters, "quiet", false); if (temp == "not found"){ temp = "F"; }
- quiet = isTrue(temp);
+ quiet = m->isTrue(temp);
seed = validParameter.validFile(parameters, "seed", false); if (seed == "not found"){ seed = "*"; }
temp = validParameter.validFile(parameters, "norandom", false); if (temp == "not found"){ temp = "F"; }
- norandom = isTrue(temp);
+ norandom = m->isTrue(temp);
temp = validParameter.validFile(parameters, "shuffle", false); if (temp == "not found"){ temp = "F"; }
- shuffle = isTrue(temp);
+ shuffle = m->isTrue(temp);
temp = validParameter.validFile(parameters, "neighbor", false); if (temp == "not found"){ temp = "T"; }
- neighbor = isTrue(temp);
+ neighbor = m->isTrue(temp);
temp = validParameter.validFile(parameters, "DNA", false); if (temp == "not found"){ temp = "F"; }
- DNA = isTrue(temp);
+ DNA = m->isTrue(temp);
temp = validParameter.validFile(parameters, "protein", false); if (temp == "not found"){ temp = "F"; }
- protein = isTrue(temp);
+ protein = m->isTrue(temp);
temp = validParameter.validFile(parameters, "jukes", false); if (temp == "not found"){ temp = "F"; }
- jukes = isTrue(temp);
+ jukes = m->isTrue(temp);
temp = validParameter.validFile(parameters, "kimura", false); if (temp == "not found"){ temp = "F"; }
- kimura = isTrue(temp);
+ kimura = m->isTrue(temp);
temp = validParameter.validFile(parameters, "stdout", false); if (temp == "not found"){ temp = "F"; }
- stdoutWanted = isTrue(temp);
+ stdoutWanted = m->isTrue(temp);
matrixout = validParameter.validFile(parameters, "matrixout", false); if (matrixout == "not found"){ matrixout = ""; }
ntrees = validParameter.validFile(parameters, "ntrees", false); if (ntrees == "not found"){ ntrees = "1"; }
temp = validParameter.validFile(parameters, "expblen", false); if (temp == "not found"){ temp = "F"; }
- expblen = isTrue(temp);
+ expblen = m->isTrue(temp);
temp = validParameter.validFile(parameters, "expdist", false); if (temp == "not found"){ temp = "F"; }
- expdist = isTrue(temp);
+ expdist = m->isTrue(temp);
if ((fastafile != "") && ((!DNA) && (!protein))) { m->mothurOut("You must specify the type of sequences you are using: DNA or protein"); m->mothurOutEndLine(); abort=true; }
}
if (abort == true) { return 0; }
//prepare filename
- string outputName = outputDir + getRootName(getSimpleName(inputFile)) + "tre";
+ string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
//get location of clearcut
GlobalData* globaldata = GlobalData::getInstance();
// sequence in the distance matrix.
//ofstream outtemp;
//string temp = "temp";
-//openOutputFile(temp, outtemp);
+//m->openOutputFile(temp, outtemp);
//cout << lv->size() << endl;
seqVec = vector<MatVec>(lv->size());
for (MatData currentCell = dMatrix->begin(); currentCell != dMatrix->end(); currentCell++) {
convert(temp, precision);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; }
- hard = isTrue(temp);
+ hard = m->isTrue(temp);
temp = validParameter.validFile(parameters, "cutoff", false);
if (temp == "not found") { temp = "10"; }
else if(method == "weighted"){ cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method); }
tag = cluster->getTag();
- if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
- fileroot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
+ if (outputDir == "") { outputDir += m->hasPath(globaldata->inputFileName); }
+ fileroot = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName));
- openOutputFile(fileroot+ tag + ".sabund", sabundFile);
- openOutputFile(fileroot+ tag + ".rabund", rabundFile);
- openOutputFile(fileroot+ tag + ".list", listFile);
+ m->openOutputFile(fileroot+ tag + ".sabund", sabundFile);
+ m->openOutputFile(fileroot+ tag + ".rabund", rabundFile);
+ m->openOutputFile(fileroot+ tag + ".list", listFile);
outputNames.push_back(fileroot+ tag + ".sabund");
outputNames.push_back(fileroot+ tag + ".rabund");
return 0;
}
- if (print_start && isTrue(timing)) {
+ if (print_start && m->isTrue(timing)) {
m->mothurOut("Clustering (" + tag + ") dist " + toString(matrix->getSmallDist()) + "/"
- + toString(roundDist(matrix->getSmallDist(), precision))
+ + toString(m->roundDist(matrix->getSmallDist(), precision))
+ "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
cout.flush();
print_start = false;
float dist = matrix->getSmallDist();
float rndDist;
if (hard) {
- rndDist = ceilDist(dist, precision);
+ rndDist = m->ceilDist(dist, precision);
}else{
- rndDist = roundDist(dist, precision);
+ rndDist = m->roundDist(dist, precision);
}
if(previousDist <= 0.0000 && dist != previousDist){
oldList = *list;
}
- if (print_start && isTrue(timing)) {
+ if (print_start && m->isTrue(timing)) {
m->mothurOut("Clustering (" + tag + ") for distance " + toString(previousDist) + "/" + toString(rndPreviousDist)
+ "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
cout.flush();
listFile.close();
if (saveCutoff != cutoff) {
- if (hard) { saveCutoff = ceilDist(saveCutoff, precision); }
- else { saveCutoff = roundDist(saveCutoff, precision); }
+ if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); }
+ else { saveCutoff = m->roundDist(saveCutoff, precision); }
m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine();
}
m->mothurOutEndLine();
- //if (isTrue(timing)) {
+ //if (m->isTrue(timing)) {
m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
//}
void ClusterCommand::printData(string label){
try {
- if (isTrue(timing)) {
+ if (m->isTrue(timing)) {
m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
+ "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
}
start = time(NULL);
oldRAbund.setLabel(label);
- if (isTrue(showabund)) {
+ if (m->isTrue(showabund)) {
oldRAbund.getSAbundVector().print(cout);
}
oldRAbund.print(rabundFile);
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
convert(temp, precision);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; }
- hard = isTrue(temp);
+ hard = m->isTrue(temp);
temp = validParameter.validFile(parameters, "large", false); if (temp == "not found") { temp = "F"; }
- large = isTrue(temp);
+ large = m->isTrue(temp);
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = "1"; }
convert(temp, processors);
if (namefile == "") { //you need to make a namefile for split matrix
ofstream out;
namefile = phylipfile + ".names";
- openOutputFile(namefile, out);
+ m->openOutputFile(namefile, out);
for (int i = 0; i < listToMakeNameFile->getNumBins(); i++) {
string bin = listToMakeNameFile->get(i);
out << bin << '\t' << bin << endl;
for(int i=0;i<processors;i++){
string filename = toString(processIDS[i]) + ".temp";
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
- in >> tag; gobble(in);
+ in >> tag; m->gobble(in);
while(!in.eof()) {
string tempName;
- in >> tempName; gobble(in);
+ in >> tempName; m->gobble(in);
listFileNames.push_back(tempName);
}
in.close();
//get labels
filename = toString(processIDS[i]) + ".temp.labels";
ifstream in2;
- openInputFile(filename, in2);
+ m->openInputFile(filename, in2);
float tempCutoff;
- in2 >> tempCutoff; gobble(in2);
+ in2 >> tempCutoff; m->gobble(in2);
if (tempCutoff < cutoff) { cutoff = tempCutoff; }
while(!in2.eof()) {
string tempName;
- in2 >> tempName; gobble(in2);
+ in2 >> tempName; m->gobble(in2);
if (labels.count(tempName) == 0) { labels.insert(tempName); }
}
in2.close();
//read in singletons
if (singleton != "none") {
ifstream in;
- openInputFile(singleton, in);
+ m->openInputFile(singleton, in);
string firstCol, secondCol;
listSingle = new ListVector();
while (!in.eof()) {
- in >> firstCol >> secondCol; gobble(in);
+ in >> firstCol >> secondCol; m->gobble(in);
listSingle->push_back(secondCol);
}
in.close();
string filledInList = listNames[k] + "filledInTemp";
ofstream outFilled;
- openOutputFile(filledInList, outFilled);
+ m->openOutputFile(filledInList, outFilled);
//for each label needed
for(int l = 0; l < orderFloat.size(); l++){
//**********************************************************************************************************************
int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> userLabels, ListVector* listSingle){
try {
- if (outputDir == "") { outputDir += hasPath(distfile); }
- fileroot = outputDir + getRootName(getSimpleName(distfile));
+ if (outputDir == "") { outputDir += m->hasPath(distfile); }
+ fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
- openOutputFile(fileroot+ tag + ".sabund", outSabund);
- openOutputFile(fileroot+ tag + ".rabund", outRabund);
- openOutputFile(fileroot+ tag + ".list", outList);
+ m->openOutputFile(fileroot+ tag + ".sabund", outSabund);
+ m->openOutputFile(fileroot+ tag + ".rabund", outRabund);
+ m->openOutputFile(fileroot+ tag + ".list", outList);
outputNames.push_back(fileroot+ tag + ".sabund");
outputNames.push_back(fileroot+ tag + ".rabund");
if (listSingle != NULL) {
for (int j = 0; j < listSingle->getNumBins(); j++) {
outList << listSingle->get(j) << '\t';
- rabund->push_back(getNumNames(listSingle->get(j)));
+ rabund->push_back(m->getNumNames(listSingle->get(j)));
}
}
else {
for (int j = 0; j < list->getNumBins(); j++) {
outList << list->get(j) << '\t';
- rabund->push_back(getNumNames(list->get(j)));
+ rabund->push_back(m->getNumNames(list->get(j)));
}
delete list;
}
RAbundVector oldRAbund = oldList->getRAbundVector();
oldRAbund.setLabel(label);
- if (isTrue(showabund)) {
+ if (m->isTrue(showabund)) {
oldRAbund.getSAbundVector().print(cout);
}
oldRAbund.print(outRabund);
//write out names to file
string filename = toString(getpid()) + ".temp";
ofstream out;
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
out << tag << endl;
for (int j = 0; j < listFileNames.size(); j++) { out << listFileNames[j] << endl; }
out.close();
//print out labels
ofstream outLabels;
filename = toString(getpid()) + ".temp.labels";
- openOutputFile(filename, outLabels);
+ m->openOutputFile(filename, outLabels);
outLabels << cutoff << endl;
for (set<string>::iterator it = labels.begin(); it != labels.end(); it++) {
else if(method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, cutoff, method); }
tag = cluster->getTag();
- if (outputDir == "") { outputDir += hasPath(thisDistFile); }
- fileroot = outputDir + getRootName(getSimpleName(thisDistFile));
+ if (outputDir == "") { outputDir += m->hasPath(thisDistFile); }
+ fileroot = outputDir + m->getRootName(m->getSimpleName(thisDistFile));
ofstream listFile;
- openOutputFile(fileroot+ tag + ".list", listFile);
+ m->openOutputFile(fileroot+ tag + ".list", listFile);
listFileNames.push_back(fileroot+ tag + ".list");
float dist = matrix->getSmallDist();
float rndDist;
if (hard) {
- rndDist = ceilDist(dist, precision);
+ rndDist = m->ceilDist(dist, precision);
}else{
- rndDist = roundDist(dist, precision);
+ rndDist = m->roundDist(dist, precision);
}
if(previousDist <= 0.0000 && dist != previousDist){
remove(thisNamefile.c_str());
if (saveCutoff != cutoff) {
- if (hard) { saveCutoff = ceilDist(saveCutoff, precision); }
- else { saveCutoff = roundDist(saveCutoff, precision); }
+ if (hard) { saveCutoff = m->ceilDist(saveCutoff, precision); }
+ else { saveCutoff = m->roundDist(saveCutoff, precision); }
m->mothurOut("Cutoff was " + toString(cutoff) + " changed cutoff to " + toString(saveCutoff)); m->mothurOutEndLine();
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; }
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } globaldata->Groups.clear(); if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } return 0; }
- if (outputDir == "") { outputDir += hasPath(inputFileNames[p]); }
- string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
+ if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); }
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
globaldata->inputFileName = inputFileNames[p];
if (inputFileNames.size() > 1) {
}
//you have a label the user want that is smaller than this label and the last label has not already been processed
- if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = order->getLabel();
delete order;
input = globaldata->ginput;
vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
- string sharedFileRoot = getRootName(filename);
+ string sharedFileRoot = m->getRootName(filename);
//clears file before we start to write to it below
for (int i=0; i<lookup.size(); i++) {
for (int i = 0; i < lookup.size(); i++) {
RAbundVector rav = lookup[i]->getRAbundVector();
- openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
+ m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
rav.print(*(filehandles[lookup[i]->getGroup()]));
(*(filehandles[lookup[i]->getGroup()])).close();
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
}
globaldata->Groups = Groups;
convert(temp, freq);
temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; }
- all = isTrue(temp);
+ all = m->isTrue(temp);
if (abort == false) {
- if (outputDir == "") { outputDir += hasPath(globaldata->inputFileName); }
- string fileNameRoot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
+ if (outputDir == "") { outputDir += m->hasPath(globaldata->inputFileName); }
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName));
format = globaldata->getFormat();
int i;
}
//you have a label the user want that is smaller than this label and the last label has not already been processed
- if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = order->getLabel();
delete order;
//open file for pairing not included in the tree
notIncluded = filename + ".cons.pairs";
- openOutputFile(notIncluded, out2);
+ m->openOutputFile(notIncluded, out2);
consensusTree = new Tree();
}
outputFile = filename + ".cons.tre";
- openOutputFile(outputFile, out);
+ m->openOutputFile(outputFile, out);
consensusTree->printForBoot(out);
try {
vector<float> prob;
- string freqfile = getRootName(filename) + "freq";
+ string freqfile = m->getRootName(filename) + "freq";
ofstream outFreq;
- openOutputFile(freqfile, outFreq);
+ m->openOutputFile(freqfile, outFreq);
outFreq << "#" << m->getVersion() << endl;
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = 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 = "";
- outputDir += hasPath(inFastaName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(inFastaName); //if user entered a file with a path then preserve it
}
oldNameMapFName = validParameter.validFile(parameters, "name", true);
if (abort == true) { return 0; }
//prepare filenames and open files
- string outNameFile = outputDir + getRootName(getSimpleName(inFastaName)) + "names";
- string outFastaFile = outputDir + getRootName(getSimpleName(inFastaName)) + "unique" + getExtension(inFastaName);
+ string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names";
+ string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName);
FastaMap fastamap;
fastafile = validParameter.validFile(parameters, "fasta", false);
if (fastafile == "not found") { fastafile = ""; m->mothurOut("fasta is a required parameter for the degap.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastafile, fastaFileNames);
+ m->splitAtDash(fastafile, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
}
m->mothurOut("Degapping sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
ifstream inFASTA;
- openInputFile(fastaFileNames[s], inFASTA);
+ m->openInputFile(fastaFileNames[s], inFASTA);
ofstream outFASTA;
- string degapFile = outputDir + getRootName(getSimpleName(fastaFileNames[s])) + "ng.fasta";
- openOutputFile(degapFile, outFASTA);
+ string degapFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ng.fasta";
+ m->openOutputFile(degapFile, outFASTA);
while(!inFASTA.eof()){
if (m->control_pressed) { inFASTA.close(); outFASTA.close(); remove(degapFile.c_str()); for (int j = 0; j < outputNames.size(); j++) { remove(outputNames[j].c_str()); } return 0; }
- Sequence currSeq(inFASTA); gobble(inFASTA);
+ Sequence currSeq(inFASTA); m->gobble(inFASTA);
if (currSeq.getName() != "") {
outFASTA << ">" << currSeq.getName() << endl;
outFASTA << currSeq.getUnaligned() << endl;
it2 = parameters.find("fasta");
//user has given a template file
if(it2 != parameters.end()){
- path = hasPath(it2->second);
+ path = m->hasPath(it2->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it2->second; }
}
it2 = parameters.find("oldfasta");
//user has given a template file
if(it2 != parameters.end()){
- path = hasPath(it2->second);
+ path = m->hasPath(it2->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["oldfasta"] = inputDir + it2->second; }
}
it2 = parameters.find("column");
//user has given a template file
if(it2 != parameters.end()){
- path = hasPath(it2->second);
+ path = m->hasPath(it2->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it2->second; }
}
else if (fastafile == "not open") { abort = true; }
else{
ifstream inFASTA;
- openInputFile(fastafile, inFASTA);
+ m->openInputFile(fastafile, inFASTA);
alignDB = SequenceDB(inFASTA);
inFASTA.close();
}
//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 += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
else {
if (calc == "default") { calc = "onegap"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "countends", false); if(temp == "not found"){ temp = "T"; }
ValidCalculators validCalculator;
- if (isTrue(countends) == true) {
+ if (m->isTrue(countends) == true) {
for (int i=0; i<Estimators.size(); i++) {
if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) {
if (Estimators[i] == "nogaps") { distCalculator = new ignoreGaps(); }
string outputFile;
if (output == "lt") { //does the user want lower triangle phylip formatted file
- outputFile = outputDir + getRootName(getSimpleName(fastafile)) + "phylip.dist";
+ outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip.dist";
remove(outputFile.c_str());
//output numSeqs to phylip formatted dist file
}else if (output == "column") { //user wants column format
- outputFile = outputDir + getRootName(getSimpleName(fastafile)) + "dist";
+ outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist";
//so we don't accidentally overwrite
if (outputFile == column) {
remove(outputFile.c_str());
}else { //assume square
- outputFile = outputDir + getRootName(getSimpleName(fastafile)) + "square.dist";
+ outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist";
remove(outputFile.c_str());
}
//append and remove temp files
for (; it != processIDS.end(); it++) {
- appendFiles((outputFile + toString(it->second) + ".temp"), outputFile);
+ m->appendFiles((outputFile + toString(it->second) + ".temp"), outputFile);
remove((outputFile + toString(it->second) + ".temp").c_str());
}
}
ifstream fileHandle;
fileHandle.open(outputFile.c_str());
if(fileHandle) {
- gobble(fileHandle);
+ m->gobble(fileHandle);
if (fileHandle.eof()) { m->mothurOut(outputFile + " is blank. This can result if there are no distances below your cutoff."); m->mothurOutEndLine(); }
}
//we had to rename the column file so we didnt overwrite above, but we want to keep old name
if (outputFile == column) {
string tempcolumn = column + ".old";
- appendFiles(tempcolumn, outputFile);
+ m->appendFiles(tempcolumn, outputFile);
remove(tempcolumn.c_str());
}else{
- appendFiles(outputFile, column);
+ m->appendFiles(outputFile, column);
remove(outputFile.c_str());
outputFile = column;
}
try{
//sort file by first column so the distances for each row are together
- string outfile = getRootName(outputFile) + "sorted.dist.temp";
+ string outfile = m->getRootName(outputFile) + "sorted.dist.temp";
//use the unix sort
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//output to new file distance for each row and save positions in file where new row begins
ifstream in;
- openInputFile(outfile, in);
+ m->openInputFile(outfile, in);
ofstream out;
- openOutputFile(outputFile, out);
+ m->openOutputFile(outputFile, out);
out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
rowDists[first] = 0.00; //distance to yourself is 0.0
in.seekg(0);
- //openInputFile(outfile, in);
+ //m->openInputFile(outfile, in);
while(!in.eof()) {
if (m->control_pressed) { in.close(); remove(outfile.c_str()); out.close(); return 0; }
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (first != currentRow) {
//print out last row
try{
//sort file by first column so the distances for each row are together
- string outfile = getRootName(outputFile) + "sorted.dist.temp";
+ string outfile = m->getRootName(outputFile) + "sorted.dist.temp";
//use the unix sort
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//output to new file distance for each row and save positions in file where new row begins
ifstream in;
- openInputFile(outfile, in);
+ m->openInputFile(outfile, in);
ofstream out;
- openOutputFile(outputFile, out);
+ m->openOutputFile(outputFile, out);
out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
rowDists[first] = 0.00; //distance to yourself is 0.0
in.seekg(0);
- //openInputFile(outfile, in);
+ //m->openInputFile(outfile, in);
while(!in.eof()) {
if (m->control_pressed) { in.close(); remove(outfile.c_str()); out.close(); return 0; }
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (first != currentRow) {
//print out last row
//make sure the 2 fasta files have the same alignment length
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
int fastaAlignLength = 0;
if (in) {
Sequence tempIn(in);
in.close();
ifstream in2;
- openInputFile(oldfastafile, in2);
+ m->openInputFile(oldfastafile, in2);
int oldfastaAlignLength = 0;
if (in2) {
Sequence tempIn2(in2);
set<string> namesOldFasta;
ifstream inFasta;
- openInputFile(oldfastafile, inFasta);
+ m->openInputFile(oldfastafile, inFasta);
while (!inFasta.eof()) {
if (m->control_pressed) { inFasta.close(); return good; }
alignDB.push_back(temp); //add to DB
}
- gobble(inFasta);
+ m->gobble(inFasta);
}
inFasta.close();
//read through the column file checking names and removing distances above the cutoff
ifstream inDist;
- openInputFile(column, inDist);
+ m->openInputFile(column, inDist);
ofstream outDist;
string outputFile = column + ".temp";
- openOutputFile(outputFile, outDist);
+ m->openOutputFile(outputFile, outDist);
string name1, name2;
float dist;
while (!inDist.eof()) {
if (m->control_pressed) { inDist.close(); outDist.close(); remove(outputFile.c_str()); return good; }
- inDist >> name1 >> name2 >> dist; gobble(inDist);
+ inDist >> name1 >> name2 >> dist; m->gobble(inDist);
//both names are in fasta file and distance is below cutoff
if ((namesOldFasta.count(name1) == 0) || (namesOldFasta.count(name2) == 0)) { good = false; break; }
}
catch(exception& e) {
- m->errorOut(e, "DistanceCommand", "appendFiles");
+ m->errorOut(e, "DistanceCommand", "m->appendFiles");
exit(1);
}
}
/**************************************************************************************************
-void DistanceCommand::appendFiles(string temp, string filename) {
+void DistanceCommand::m->appendFiles(string temp, string filename) {
try{
ofstream output;
ifstream input;
//open output file in append mode
- openOutputFileAppend(filename, output);
- openInputFile(temp, input);
+ m->openOutputFileAppend(filename, output);
+ m->openInputFile(temp, input);
while(char c = input.get()){
if(input.eof()) { break; }
output.close();
}
catch(exception& e) {
- m->errorOut(e, "DistanceCommand", "appendFiles");
+ m->errorOut(e, "DistanceCommand", "m->appendFiles");
exit(1);
}
}
bool abort;
vector<string> Estimators; //holds estimators to be used
- //void appendFiles(string, string);
+ //void m->appendFiles(string, string);
void createProcesses(string);
int driver(/*Dist*, SequenceDB, */int, int, string, float);
//break apart path variable by ':'
vector<string> dirs;
- splitAtChar(envPath, dirs, delim);
+ mout->splitAtChar(envPath, dirs, delim);
//get path related to mothur
string mothurPath = "";
string nextCommand = "";
mout->mothurOut("mothur > ");
- getline(cin, nextCommand);
+ m->getline(cin, nextCommand);
mout->mothurOutJustToLog(toString(nextCommand));
return nextCommand;
try {
globaldata = GlobalData::getInstance();
- openedBatch = openInputFile(batchFileName, inputBatchFile);
+ openedBatch = mout->openInputFile(batchFileName, inputBatchFile);
string temppath = path.substr(0, (path.find_last_of('m')));
//break apart path variable by ':'
vector<string> dirs;
- splitAtChar(envPath, dirs, delim);
+ mout->splitAtChar(envPath, dirs, delim);
//get path related to mothur
string mothurPath = "";
}
}
- gobble(inputBatchFile);
+ mout->gobble(inputBatchFile);
}
inputBatchFile.close();
string nextcommand = "";
if (inputBatchFile.eof()) { nextcommand = "quit()"; }
- else { nextcommand = getline(inputBatchFile); }
+ else { nextcommand = mout->getline(inputBatchFile); }
return nextcommand;
}
//break apart path variable by ':'
vector<string> dirs;
- splitAtChar(envPath, dirs, delim);
+ mout->splitAtChar(envPath, dirs, delim);
//get path related to mothur
string mothurPath = "";
void FastaMap::readFastaFile(string inFileName) {
try {
ifstream in;
- openInputFile(inFileName, in);
+ m->openInputFile(inFileName, in);
string name, sequence, line;
sequence = "";
string temp;
// data[sequence].groupnumber++;
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
}
void FastaMap::readFastaFile(string inFastaFile, string oldNameFileName){ //prints data
ifstream oldNameFile;
- openInputFile(oldNameFileName, oldNameFile);
+ m->openInputFile(oldNameFileName, oldNameFile);
map<string,string> oldNameMap;
string name, list;
oldNameFile >> name >> list;
oldNameMap[name] = list;
- gobble(oldNameFile);
+ m->gobble(oldNameFile);
}
oldNameFile.close();
ifstream inFASTA;
- openInputFile(inFastaFile, inFASTA);
+ m->openInputFile(inFastaFile, inFASTA);
string sequence;
while(!inFASTA.eof()){
if (m->control_pressed) { break; }
// data[sequence].groupnumber++;
}
}
- gobble(inFASTA);
+ m->gobble(inFASTA);
}
void FastaMap::printNamesFile(string outFileName){ //prints data
try {
ofstream outFile;
- openOutputFile(outFileName, outFile);
+ m->openOutputFile(outFileName, outFile);
// two column file created with groupname and them list of identical sequence names
for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
void FastaMap::printCondensedFasta(string outFileName){ //prints data
try {
ofstream out;
- openOutputFile(outFileName, out);
+ m->openOutputFile(outFileName, out);
//creates a fasta file
for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
if (m->control_pressed) { break; }
void ThreeColumnFile::initFile(string label){
try {
if(counter != 0){
- openOutputFile(outName, outFile);
- openInputFile(inName, inFile);
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t' << label << "\tlci\thci" << endl;
}
else{
- openOutputFile(outName, outFile);
+ m->openOutputFile(outName, outFile);
outFile << "numsampled\t" << label << "\tlci\thci" << endl;
}
try {
if(counter != 0){
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
}
void ColumnFile::initFile(string label, vector<string> tags){
try {
if(counter != 0){
- openOutputFile(outName, outFile);
- openInputFile(inName, inFile);
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t';
for(int i = 0; i < tags.size(); i++) {
outFile << endl;
}
else{
- openOutputFile(outName, outFile);
+ m->openOutputFile(outName, outFile);
for(int i = 0; i < tags.size(); i++) {
outFile << label + tags[i] << '\t';
}
if(counter != 0){
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(iters.length());
for (int i = 1; i< data.size(); i++) {
void SharedThreeColumnFile::initFile(string label){
try {
if(counter != 0){
- openOutputFile(outName, outFile);
- openInputFile(inName, inFile);
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t' << label << "\tlci\thci" << endl;
}
else{
- openOutputFile(outName, outFile);
+ m->openOutputFile(outName, outFile);
outFile << "numsampled\t" << groupLabel << '\t' << label << "\tlci\thci" << endl;
}
try {
if(counter != 0){
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
}
void OneColumnFile::initFile(string label){
try {
if(counter != 0){
- openOutputFile(outName, outFile);
- openInputFile(inName, inFile);
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t' << label << endl;
}
else{
- openOutputFile(outName, outFile);
+ m->openOutputFile(outName, outFile);
outFile << "numsampled\t" << label << endl;
}
try {
if(counter != 0){
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << endl;
}
void SharedOneColumnFile::initFile(string label){
try {
if(counter != 0){
- openOutputFile(outName, outFile);
- openInputFile(inName, inFile);
+ m->openOutputFile(outName, outFile);
+ m->openInputFile(inName, inFile);
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << '\t' << label << endl;
}
else{
- openOutputFile(outName, outFile);
+ m->openOutputFile(outName, outFile);
outFile << "sampled\t" << label << endl;
}
}
if(counter != 0){
string inputBuffer;
- inputBuffer = getline(inFile);
+ inputBuffer = m->getline(inFile);
outFile << inputBuffer << setprecision(2) << '\t' << dataOutput << endl;
}
class Filters {
public:
- Filters() {};
+ Filters() { m = MothurOut::getInstance(); };
~Filters(){};
string getFilter() { return filter; }
void doHard(string hard) {
ifstream fileHandle;
- openInputFile(hard, fileHandle);
+ m->openInputFile(hard, fileHandle);
fileHandle >> filter;
int alignmentLength, numSeqs;
float soft;
char trump;
+ MothurOut* m;
};
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("hard");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["hard"] = inputDir + it->second; }
}
fasta = validParameter.validFile(parameters, "fasta", false);
if (fasta == "not found") { m->mothurOut("fasta is a required parameter for the filter.seqs command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fasta, fastafileNames);
+ m->splitAtDash(fasta, fastafileNames);
//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 = hasPath(fastafileNames[i]);
+ 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 = openInputFile(fastafileNames[i], in, "noerror");
+ 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() + getSimpleName(fastafileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastafileNames[i]);
m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastafileNames[i] = tryPath;
}
}
fastafileNames.erase(fastafileNames.begin()+i);
i--;
}else{
- string simpleName = getSimpleName(fastafileNames[i]);
+ string simpleName = m->getSimpleName(fastafileNames[i]);
filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
}
in.close();
//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 += hasPath(fastafileNames[0]); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafileNames[0]); //if user entered a file with a path then preserve it
}
}
//check for optional parameter and set defaults
if (abort == true) { return 0; }
ifstream inFASTA;
- openInputFile(fastafileNames[0], inFASTA);
+ m->openInputFile(fastafileNames[0], inFASTA);
Sequence testSeq(inFASTA);
alignmentLength = testSeq.getAlignLength();
ofstream outFilter;
string filterFile = outputDir + filterFileName + ".filter";
- openOutputFile(filterFile, outFilter);
+ m->openOutputFile(filterFile, outFilter);
outFilter << filter << endl;
outFilter.close();
outputNames.push_back(filterFile);
for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear();
- string filteredFasta = outputDir + getRootName(getSimpleName(fastafileNames[s])) + "filter.fasta";
+ string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + "filter.fasta";
#ifdef USE_MPI
int pid, start, end, numSeqsPerProcessor, num;
int tag = 2001;
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
numSeqs += num;
//send file positions to all processes
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastafileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastafileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
//append fasta files
for(int i=1;i<processors;i++){
- appendFiles((fastafileNames[s] + toString(processIDS[i]) + ".temp"), filteredFasta);
+ m->appendFiles((fastafileNames[s] + toString(processIDS[i]) + ".temp"), filteredFasta);
remove((fastafileNames[s] + toString(processIDS[i]) + ".temp").c_str());
}
}
istringstream iss (tempBuf,istringstream::in);
delete buf4;
- Sequence seq(iss); gobble(iss);
+ Sequence seq(iss); m->gobble(iss);
if (seq.getName() != "") {
string align = seq.getAligned();
int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string inputFilename, linePair* filePos) {
try {
ofstream out;
- openOutputFile(outputFilename, out);
+ m->openOutputFile(outputFilename, out);
ifstream in;
- openInputFile(inputFilename, in);
+ m->openInputFile(inputFilename, in);
in.seekg(filePos->start);
if (m->control_pressed) { in.close(); out.close(); return 0; }
- Sequence seq(in); gobble(in);
+ Sequence seq(in); m->gobble(in);
if (seq.getName() != "") {
string align = seq.getAligned();
string filterSeq = "";
//pass numSeqs to parent
ofstream out;
string tempFile = filename + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = filename + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
F.setLength(alignmentLength);
- if(trump != '*' || isTrue(vertical) || soft != 0){
+ if(trump != '*' || m->isTrue(vertical) || soft != 0){
F.initialize();
}
else { F.setFilter(string(alignmentLength, '1')); }
numSeqs = 0;
- if(trump != '*' || isTrue(vertical) || soft != 0){
+ if(trump != '*' || m->isTrue(vertical) || soft != 0){
for (int s = 0; s < fastafileNames.size(); s++) {
for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear();
if (m->control_pressed) { MPI_File_close(&inMPI); return 0; }
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
numSeqs += num;
//send file positions to all processes
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastafileNames[s], processors);
+ vector<unsigned long int> positions = m->divideFile(fastafileNames[s], processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
MPI_Comm_rank(MPI_COMM_WORLD, &pid);
- if(trump != '*' || isTrue(vertical) || soft != 0){
+ if(trump != '*' || m->isTrue(vertical) || soft != 0){
if (pid == 0) { //only one process should output the filter
if (pid == 0) { //only one process should output the filter
#endif
+
F.setNumSeqs(numSeqs);
- if(isTrue(vertical) == 1) { F.doVertical(); }
+ if(m->isTrue(vertical) == 1) { F.doVertical(); }
if(soft != 0) { F.doSoft(); }
filterString = F.getFilter();
try {
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
in.seekg(filePos->start);
if (m->control_pressed) { in.close(); return 1; }
- Sequence seq(in); gobble(in);
+ Sequence seq(in); m->gobble(in);
if (seq.getName() != "") {
if (seq.getAligned().length() != alignmentLength) { m->mothurOut("Sequences are not all the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
if(trump != '*') { F.doTrump(seq); }
- if(isTrue(vertical) || soft != 0) { F.getFreqs(seq); }
+ if(m->isTrue(vertical) || soft != 0) { F.getFreqs(seq); }
cout.flush();
count++;
}
if (seq.getAligned().length() != alignmentLength) { cout << "Alignment length is " << alignmentLength << " and sequence " << seq.getName() << " has length " << seq.getAligned().length() << ", please correct." << endl; exit(1); }
if(trump != '*'){ F.doTrump(seq); }
- if(isTrue(vertical) || soft != 0){ F.getFreqs(seq); }
+ if(m->isTrue(vertical) || soft != 0){ F.getFreqs(seq); }
cout.flush();
//report progress
//write out filter counts to file
filename += toString(getpid()) + "filterValues.temp";
ofstream out;
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
out << num << endl;
out << F.getFilter() << endl;
for (int i = 0; i < processIDS.size(); i++) {
string tempFilename = filename + toString(processIDS[i]) + "filterValues.temp";
ifstream in;
- openInputFile(tempFilename, in);
+ m->openInputFile(tempFilename, in);
int temp, tempNum;
string tempFilterString;
- in >> tempNum; gobble(in); num += tempNum;
+ in >> tempNum; m->gobble(in); num += tempNum;
in >> tempFilterString;
F.mergeFilter(tempFilterString);
- for (int k = 0; k < alignmentLength; k++) { in >> temp; F.a[k] += temp; } gobble(in);
- for (int k = 0; k < alignmentLength; k++) { in >> temp; F.t[k] += temp; } gobble(in);
- for (int k = 0; k < alignmentLength; k++) { in >> temp; F.g[k] += temp; } gobble(in);
- for (int k = 0; k < alignmentLength; k++) { in >> temp; F.c[k] += temp; } gobble(in);
- for (int k = 0; k < alignmentLength; k++) { in >> temp; F.gap[k] += temp; } gobble(in);
+ for (int k = 0; k < alignmentLength; k++) { in >> temp; F.a[k] += temp; } m->gobble(in);
+ for (int k = 0; k < alignmentLength; k++) { in >> temp; F.t[k] += temp; } m->gobble(in);
+ for (int k = 0; k < alignmentLength; k++) { in >> temp; F.g[k] += temp; } m->gobble(in);
+ for (int k = 0; k < alignmentLength; k++) { in >> temp; F.c[k] += temp; } m->gobble(in);
+ for (int k = 0; k < alignmentLength; k++) { in >> temp; F.gap[k] += temp; } m->gobble(in);
in.close();
remove(tempFilename.c_str());
/***********************************************************************/
FormatColumnMatrix::FormatColumnMatrix(string df) : filename(df){
- openInputFile(filename, fileHandle);
+ m->openInputFile(filename, fileHandle);
}
/***********************************************************************/
ofstream out;
string tempOutFile = filename + ".temp";
- openOutputFile(tempOutFile, out);
+ m->openOutputFile(tempOutFile, out);
while(fileHandle && lt == 1){ //let's assume it's a triangular matrix...
reading->update(itA->second * nseqs / 2);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
out.close();
fileHandle.close();
}else{ squareFile = tempOutFile; }
//sort file by first column so the distances for each row are together
- string outfile = getRootName(squareFile) + "sorted.dist.temp";
+ string outfile = m->getRootName(squareFile) + "sorted.dist.temp";
//use the unix sort
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//output to new file distance for each row and save positions in file where new row begins
ifstream in;
- openInputFile(outfile, in);
+ m->openInputFile(outfile, in);
distFile = outfile + ".rowFormatted";
- openOutputFile(distFile, out);
+ m->openOutputFile(distFile, out);
rowPos.resize(nseqs, -1);
int currentRow;
if (m->control_pressed) { in.close(); out.close(); remove(distFile.c_str()); remove(tempOutFile.c_str()); remove(outfile.c_str()); delete reading; return 0; }
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (first != currentRow) {
//save position in file of each new row
/***********************************************************************/
FormatPhylipMatrix::FormatPhylipMatrix(string df) : filename(df) {
- openInputFile(filename, fileHandle);
+ m->openInputFile(filename, fileHandle);
}
/***********************************************************************/
//not using nameMap
fileHandle.close(); //reset file
//open and get through numSeqs, code below formats rest of file
- openInputFile(filename, fileHandle);
- fileHandle >> nseqs; gobble(fileHandle);
+ m->openInputFile(filename, fileHandle);
+ fileHandle >> nseqs; m->gobble(fileHandle);
distFile = filename + ".rowFormatted";
- openOutputFile(distFile, out);
+ m->openOutputFile(distFile, out);
break;
}
if(d == '\n'){
ofstream outTemp;
string tempFile = filename + ".temp";
- openOutputFile(tempFile, outTemp);
+ m->openOutputFile(tempFile, outTemp);
//convert to square column matrix
for(int i=1;i<nseqs;i++){
//format from square column to rowFormatted
//sort file by first column so the distances for each row are together
- string outfile = getRootName(tempFile) + "sorted.dist.temp";
+ string outfile = m->getRootName(tempFile) + "sorted.dist.temp";
//use the unix sort
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//output to new file distance for each row and save positions in file where new row begins
ifstream in;
- openInputFile(outfile, in);
+ m->openInputFile(outfile, in);
distFile = outfile + ".rowFormatted";
- openOutputFile(distFile, out);
+ m->openOutputFile(distFile, out);
rowPos.resize(nseqs, -1);
int currentRow;
while(!in.eof()) {
if (m->control_pressed) { in.close(); out.close(); remove(tempFile.c_str()); remove(distFile.c_str()); remove(outfile.c_str()); delete reading; return 0; }
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (first != currentRow) {
//save position in file of each new row
reading->update(index);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
//save position in file of each new row
rowPos[i] = out.tellp();
if (abort == false) {
//open shared file
sharedfile = globaldata->getSharedFile();
- openInputFile(sharedfile, in);
+ m->openInputFile(sharedfile, in);
//open output file
- if (outputDir == "") { outputDir += hasPath(sharedfile); }
- outputFile = outputDir + getRootName(getSimpleName(sharedfile)) + "bootGroups";
- openOutputFile(outputFile, out);
+ if (outputDir == "") { outputDir += m->hasPath(sharedfile); }
+ outputFile = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "bootGroups";
+ m->openOutputFile(outputFile, out);
}
}
filename = globaldata->inputFileName;
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
string label;
int numBins = 0;
int count = -1;
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
void GetListCountCommand::process(ListVector* list) {
try {
string binnames;
- if (outputDir == "") { outputDir += hasPath(listfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + list->getLabel() + ".otu";
- openOutputFile(outputFileName, out);
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
+ m->openOutputFile(outputFileName, out);
outputNames.push_back(outputFileName);
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
out << i+1 << '\t' << binnames << endl;
}else{ //sort = name
vector<string> names;
- splitAtComma(binnames, names);
+ m->splitAtComma(binnames, names);
for (int j = 0; j < names.size(); j++) {
out << names[j] << '\t' << i+1 << endl;
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; allLines = 1; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
m->mothurOut("You must provide a groupfile to use groups."); m->mothurOutEndLine();
abort = true;
}else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
}
}
globaldata->Groups = Groups;
string temp = validParameter.validFile(parameters, "large", false); if (temp == "not found") { temp = "F"; }
- large = isTrue(temp);
+ large = m->isTrue(temp);
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
convert(temp, precision);
delete nameMap;
//openfile for getMap to use
- openInputFile(distFile, inRow);
+ m->openInputFile(distFile, inRow);
if (m->control_pressed) { inRow.close(); remove(distFile.c_str()); return 0; }
}
names.clear();
binnames = globaldata->gListVector->get(i);
- splitAtComma(binnames, names);
+ m->splitAtComma(binnames, names);
for (int j = 0; j < names.size(); j++) {
nameToIndex[names[j]] = i;
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
void GetOTURepCommand::readNamesFile() {
try {
vector<string> dupNames;
- openInputFile(namefile, inNames);
+ m->openInputFile(namefile, inNames);
string name, names, sequence;
dupNames.clear();
//parse names into vector
- splitAtComma(names, dupNames);
+ m->splitAtComma(names, dupNames);
//store names in fasta map
sequence = fasta->getSequence(name);
fasta->push_back(dupNames[i], sequence);
}
- gobble(inNames);
+ m->gobble(inNames);
}
inNames.close();
string nameRep;
//create output file
- if (outputDir == "") { outputDir += hasPath(listfile); }
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
ofstream newNamesOutput;
string outputNamesFile;
map<string, ofstream*> filehandles;
if (Groups.size() == 0) { //you don't want to use groups
- outputNamesFile = outputDir + getRootName(getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
- openOutputFile(outputNamesFile, newNamesOutput);
+ outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
+ m->openOutputFile(outputNamesFile, newNamesOutput);
outputNames.push_back(outputNamesFile);
outputNameFiles[outputNamesFile] = processList->getLabel();
}else{ //you want to use groups
for (int i=0; i<Groups.size(); i++) {
temp = new ofstream;
filehandles[Groups[i]] = temp;
- outputNamesFile = outputDir + getRootName(getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".rep.names";
+ outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".rep.names";
- openOutputFile(outputNamesFile, *(temp));
+ m->openOutputFile(outputNamesFile, *(temp));
outputNames.push_back(outputNamesFile);
outputNameFiles[outputNamesFile] = processList->getLabel() + "." + Groups[i];
}
string temp = processList->get(i);
vector<string> namesInBin;
- splitAtComma(temp, namesInBin);
+ m->splitAtComma(temp, namesInBin);
if (Groups.size() == 0) {
nameRep = findRep(namesInBin);
if (thisgroup == "not found") { m->mothurOut(namesInBin[j] + " is not in your groupfile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
- if (inUsersGroups(thisgroup, Groups)) { //add this name to correct group
+ if (m->inUsersGroups(thisgroup, Groups)) { //add this name to correct group
NamesInGroup[thisgroup].push_back(namesInBin[j]);
}
}
try{
//create output file
- if (outputDir == "") { outputDir += hasPath(listfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + label + ".rep.fasta";
- openOutputFile(outputFileName, out);
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + label + ".rep.fasta";
+ m->openOutputFile(outputFileName, out);
vector<repStruct> reps;
outputNames.push_back(outputFileName);
ofstream out2;
string tempNameFile = filename + ".temp";
- openOutputFile(tempNameFile, out2);
+ m->openOutputFile(tempNameFile, out2);
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
int i = 0;
while (!in.eof()) {
string rep, binnames;
- in >> i >> rep >> binnames; gobble(in);
+ in >> i >> rep >> binnames; m->gobble(in);
out2 << rep << '\t' << binnames << endl;
vector<string> names;
- splitAtComma(binnames, names);
+ m->splitAtComma(binnames, names);
int binsize = names.size();
//if you have a groupfile
//if the user changes the output directory command factory will send this info to us in the output parameter
string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
string temp;
temp = validParameter.validFile(parameters, "sorted", false); if (temp == "not found") { temp = "T"; }
- sorted = isTrue(temp);
+ sorted = m->isTrue(temp);
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
}
if (abort == false) {
- filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "rabund";
- openOutputFile(filename, out);
+ filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "rabund";
+ m->openOutputFile(filename, out);
}
}
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
if (groups == "not found") { groups = ""; pickedGroups = false; }
else {
pickedGroups = true;
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
if (abort == true) { return 0; }
- string outputFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "relabund";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "relabund";
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
read = new ReadOTUFile(globaldata->inputFileName);
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
//if the user changes the output directory command factory will send this info to us in the output parameter
string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
}
if (abort == false) {
- filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "sabund";
- openOutputFile(filename, out);
+ filename = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "sabund";
+ m->openOutputFile(filename, out);
}
}
userLabels.erase(order->getLabel());
}
- if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = order->getLabel();
delete order;
it = parameters.find("alignreport");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("accnos");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["accnos"] = inputDir + it->second; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
}
string usedDups = "true";
string temp = validParameter.validFile(parameters, "dups", false); if (temp == "not found") { temp = "false"; usedDups = ""; }
- dups = isTrue(temp);
+ dups = m->isTrue(temp);
if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy or listfile."); m->mothurOutEndLine(); abort = true; }
//**********************************************************************************************************************
int GetSeqsCommand::readFasta(){
try {
- if (outputDir == "") { outputDir += hasPath(fastafile); }
- string outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + "pick" + getExtension(fastafile);
+ if (outputDir == "") { outputDir += m->hasPath(fastafile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
string name;
bool wroteSomething = false;
currSeq.printSequence(out);
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int GetSeqsCommand::readList(){
try {
- if (outputDir == "") { outputDir += hasPath(listfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + "pick" + getExtension(listfile);
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(listfile, in);
+ m->openInputFile(listfile, in);
bool wroteSomething = false;
newList.print(out);
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int GetSeqsCommand::readName(){
try {
- if (outputDir == "") { outputDir += hasPath(namefile); }
- string outputFileName = outputDir + getRootName(getSimpleName(namefile)) + "pick" + getExtension(namefile);
+ if (outputDir == "") { outputDir += m->hasPath(namefile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string name, firstCol, secondCol;
bool wroteSomething = false;
}
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int GetSeqsCommand::readGroup(){
try {
- if (outputDir == "") { outputDir += hasPath(groupfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(groupfile)) + "pick" + getExtension(groupfile);
+ if (outputDir == "") { outputDir += m->hasPath(groupfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(groupfile, in);
+ m->openInputFile(groupfile, in);
string name, group;
bool wroteSomething = false;
out << name << '\t' << group << endl;
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int GetSeqsCommand::readTax(){
try {
- if (outputDir == "") { outputDir += hasPath(taxfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(taxfile)) + "pick" + getExtension(taxfile);
+ if (outputDir == "") { outputDir += m->hasPath(taxfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(taxfile, in);
+ m->openInputFile(taxfile, in);
string name, tax;
bool wroteSomething = false;
out << name << '\t' << tax << endl;
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name
int GetSeqsCommand::readAlign(){
try {
- if (outputDir == "") { outputDir += hasPath(alignfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(alignfile)) + "pick.align.report";
+ if (outputDir == "") { outputDir += m->hasPath(alignfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(alignfile, in);
+ m->openInputFile(alignfile, in);
string name, junk;
bool wroteSomething = false;
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
try {
ifstream in;
- openInputFile(accnosfile, in);
+ m->openInputFile(accnosfile, in);
string name;
while(!in.eof()){
names.insert(name);
- gobble(in);
+ m->gobble(in);
}
in.close();
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
if (groups == "not found") { groups = ""; }
else {
userGroups = "unique." + groups;
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
if (groups == "not found") { groups = ""; }
else {
userGroups = groups;
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
unique = false;
}
if (fastafile != "") {
ifstream inFasta;
- openInputFile(fastafile, inFasta);
+ m->openInputFile(fastafile, inFasta);
while(!inFasta.eof()) {
if (m->control_pressed) { inFasta.close(); delete groupMap; return 0; }
- Sequence seq(inFasta); gobble(inFasta);
+ Sequence seq(inFasta); m->gobble(inFasta);
if (seq.getName() != "") { seqs.push_back(seq); }
}
inFasta.close();
set<string> userLabels = labels;
ifstream in;
- openInputFile(listfile, in);
+ m->openInputFile(listfile, in);
//as long as you are not at the end of the file or done wih the lines you want
while((!in.eof()) && ((allLines == 1) || (userLabels.size() != 0))) {
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
m->mothurOut(lastlist->getLabel());
ofstream outNames;
string outputFileNames;
- if (outputDir == "") { outputDir += hasPath(listfile); }
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
if (output != "accnos") {
- outputFileNames = outputDir + getRootName(getSimpleName(listfile)) + shared->getLabel() + userGroups + ".shared.seqs";
+ outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".shared.seqs";
}else {
- outputFileNames = outputDir + getRootName(getSimpleName(listfile)) + shared->getLabel() + userGroups + ".accnos";
+ outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".accnos";
}
- openOutputFile(outputFileNames, outNames);
+ m->openOutputFile(outputFileNames, outNames);
bool wroteSomething = false;
int num = 0;
//if fasta file provided output new fasta file
if ((fastafile != "") && wroteSomething) {
- if (outputDir == "") { outputDir += hasPath(fastafile); }
- string outputFileFasta = outputDir + getRootName(getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta";
+ if (outputDir == "") { outputDir += m->hasPath(fastafile); }
+ string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta";
ofstream outFasta;
- openOutputFile(outputFileFasta, outFasta);
+ m->openOutputFile(outputFileFasta, outFasta);
outputNames.push_back(outputFileFasta);
for (int k = 0; k < seqs.size(); k++) {
GroupMap::GroupMap(string filename) {
m = MothurOut::getInstance();
groupFileName = filename;
- openInputFile(filename, fileHandle);
+ m->openInputFile(filename, fileHandle);
index = 0;
}
int error = 0;
while(fileHandle){
- fileHandle >> seqName; gobble(fileHandle); //read from first column
+ fileHandle >> seqName; m->gobble(fileHandle); //read from first column
fileHandle >> seqGroup; //read from second column
if (m->control_pressed) { fileHandle.close(); return 1; }
groupmap[seqName] = seqGroup; //store data in map
seqsPerGroup[seqGroup]++; //increment number of seqs in that group
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
fileHandle.close();
return error;
}
if (method != "average") {
- openInputFile(distfile, filehandle);
+ m->openInputFile(distfile, filehandle);
}else{
processFile();
}
//get entry
while (!filehandle.eof()) {
- filehandle >> firstName >> secondName >> distance; gobble(filehandle);
+ filehandle >> firstName >> secondName >> distance; m->gobble(filehandle);
//save first one
if (prevDistance == -1) { prevDistance = distance; }
vector<seqDist> sameSeqs;
prevDistance = -1;
- openInputFile(distfile, filehandle, "no error");
+ m->openInputFile(distfile, filehandle, "no error");
//is the smallest value in mergedMin or the distfile?
float mergedMinDist = 10000;
if (mergedMin.size() > 0) { mergedMinDist = mergedMin[0].dist; }
if (!filehandle.eof()) {
- filehandle >> firstName >> secondName >> distance; gobble(filehandle);
+ filehandle >> firstName >> secondName >> distance; m->gobble(filehandle);
//save first one
if (prevDistance == -1) { prevDistance = distance; }
if (distance != -1) { //-1 means skip me
//get entry
while (!filehandle.eof()) {
- filehandle >> firstName >> secondName >> distance; gobble(filehandle);
+ filehandle >> firstName >> secondName >> distance; m->gobble(filehandle);
if (prevDistance == -1) { prevDistance = distance; }
string tempDistFile = distfile + ".temp";
ofstream out;
- openOutputFile(tempDistFile, out);
+ m->openOutputFile(tempDistFile, out);
//FILE* in;
//in = fopen(distfile.c_str(), "rb");
ifstream in;
- openInputFile(distfile, in);
+ m->openInputFile(distfile, in);
int first, second;
float dist;
//since file is sorted and mergedMin is sorted
//you can put the smallest distance from each through the code below and keep the file sorted
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (m->control_pressed) { in.close(); out.close(); remove(tempDistFile.c_str()); return 0; }
if ((buffer[index] == 10) || (buffer[index] == 13)) { //newline in unix or windows
gotDist = true;
- //gobble space
+ //m->gobble space
while (index < size) {
if (isspace(buffer[index])) { index++; }
else { break; }
float distance;
ifstream in;
- openInputFile(distfile, in);
+ m->openInputFile(distfile, in);
ofstream out;
string outTemp = distfile + ".temp";
- openOutputFile(outTemp, out);
+ m->openOutputFile(outTemp, out);
//get entry
while (!in.eof()) {
if (m->control_pressed) { in.close(); out.close(); remove(outTemp.c_str()); return 0; }
- in >> firstName >> secondName >> distance; gobble(in);
+ in >> firstName >> secondName >> distance; m->gobble(in);
map<string,int>::iterator itA = nameMap->find(firstName);
map<string,int>::iterator itB = nameMap->find(secondName);
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
convert(temp, precision);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; }
- hard = isTrue(temp);
+ hard = m->isTrue(temp);
temp = validParameter.validFile(parameters, "cutoff", false);
if (temp == "not found") { temp = "10"; }
sort = validParameter.validFile(parameters, "sorted", false);
if (sort == "not found") { sort = "F"; }
- sorted = isTrue(sort);
+ sorted = m->isTrue(sort);
timing = validParameter.validFile(parameters, "timing", false);
if (timing == "not found") { timing = "F"; }
if (abort == false) {
- if (outputDir == "") { outputDir += hasPath(distfile); }
- fileroot = outputDir + getRootName(getSimpleName(distfile));
+ if (outputDir == "") { outputDir += m->hasPath(distfile); }
+ fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
if (method == "furthest") { tag = "fn"; }
else if (method == "nearest") { tag = "nn"; }
else { tag = "an"; }
- openOutputFile(fileroot+ tag + ".sabund", sabundFile);
- openOutputFile(fileroot+ tag + ".rabund", rabundFile);
- openOutputFile(fileroot+ tag + ".list", listFile);
+ m->openOutputFile(fileroot+ tag + ".sabund", sabundFile);
+ m->openOutputFile(fileroot+ tag + ".rabund", rabundFile);
+ m->openOutputFile(fileroot+ tag + ".list", listFile);
outputNames.push_back(fileroot+ tag + ".sabund");
outputNames.push_back(fileroot+ tag + ".rabund");
float rndDist;
if (hard) {
- rndDist = ceilDist(seqs[i].dist, precision);
+ rndDist = m->ceilDist(seqs[i].dist, precision);
}else{
- rndDist = roundDist(seqs[i].dist, precision);
+ rndDist = m->roundDist(seqs[i].dist, precision);
}
void HClusterCommand::printData(string label){
try {
- if (isTrue(timing)) {
+ if (m->isTrue(timing)) {
m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins())
+ "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
}
start = time(NULL);
oldRAbund.setLabel(label);
- if (isTrue(showabund)) {
+ if (m->isTrue(showabund)) {
oldRAbund.getSAbundVector().print(cout);
}
oldRAbund.print(rabundFile);
}
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + rabund->getLabel() + ".heatmap.bin.svg";
- openOutputFile(filenamesvg, outsvg);
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + rabund->getLabel() + ".heatmap.bin.svg";
+ m->openOutputFile(filenamesvg, outsvg);
//svg image
outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((rabund->getNumBins()*5 + 120)) + "\">\n";
}
}
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
- openOutputFile(filenamesvg, outsvg);
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
+ m->openOutputFile(filenamesvg, outsvg);
//svg image
outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((lookup[0]->getNumBins()*5 + 120)) + "\">\n";
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
userLabels.erase(rabund->getLabel());
}
- if ((anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = rabund->getLabel();
delete rabund;
if (m->control_pressed) { return outputNames; }
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + calcs[k]->getName() + ".heatmap.sim.svg";
- openOutputFile(filenamesvg, outsvg);
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + calcs[k]->getName() + ".heatmap.sim.svg";
+ m->openOutputFile(filenamesvg, outsvg);
outputNames.push_back(filenamesvg);
//svg image
vector<double> sims;
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "heatmap.sim.svg";
- openOutputFile(filenamesvg, outsvg);
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "heatmap.sim.svg";
+ m->openOutputFile(filenamesvg, outsvg);
//svg image
outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString((dists.size() * 150) + 160) + " " + toString((dists.size() * 150) + 160) + "\">\n";
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
phylipfile = validParameter.validFile(parameters, "phylip", true);
if (phylipfile == "not open") { abort = true; }
else if (phylipfile == "not found") { phylipfile = ""; }
- else { format = "phylip"; if (outputDir == "") { outputDir += hasPath(phylipfile); } }
+ else { format = "phylip"; if (outputDir == "") { outputDir += m->hasPath(phylipfile); } }
columnfile = validParameter.validFile(parameters, "column", true);
if (columnfile == "not open") { abort = true; }
else if (columnfile == "not found") { columnfile = ""; }
- else { format = "column"; if (outputDir == "") { outputDir += hasPath(columnfile); } }
+ else { format = "column"; if (outputDir == "") { outputDir += m->hasPath(columnfile); } }
namefile = validParameter.validFile(parameters, "name", true);
if (namefile == "not open") { abort = true; }
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
if (format == "shared") {
- if (outputDir == "") { outputDir += hasPath(globaldata->getSharedFile()); }
+ if (outputDir == "") { outputDir += m->hasPath(globaldata->getSharedFile()); }
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "jest-thetayc"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
}
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
//read distance file and create distance vector and names vector
if (format == "phylip") {
//read phylip file
- openInputFile(phylipfile, in);
+ m->openInputFile(phylipfile, in);
string name;
int numSeqs;
if (m->control_pressed) { return 0; }
for(int j=0;j<numSeqs;j++) { in >> matrix[i][j]; }
- gobble(in);
+ m->gobble(in);
}
}else {
double dist;
in >> dist;
matrix[i][j] = dist; matrix[j][i] = dist;
}
- gobble(in);
+ m->gobble(in);
}
}
in.close();
//read column file
string first, second;
double dist;
- openInputFile(columnfile, in);
+ m->openInputFile(columnfile, in);
while (!in.eof()) {
- in >> first >> second >> dist; gobble(in);
+ in >> first >> second >> dist; m->gobble(in);
if (m->control_pressed) { return 0; }
InputData::InputData(string fName, string f) : format(f){
m = MothurOut::getInstance();
- openInputFile(fName, fileHandle);
+ m->openInputFile(fName, fileHandle);
filename = fName;
}
try {
m = MothurOut::getInstance();
ifstream ofHandle;
- openInputFile(orderFileName, ofHandle);
+ m->openInputFile(orderFileName, ofHandle);
string name;
int count = 0;
ofHandle >> name;
orderMap[name] = count;
count++;
- gobble(ofHandle);
+ m->gobble(ofHandle);
}
ofHandle.close();
- openInputFile(fName, fileHandle);
+ m->openInputFile(fName, fileHandle);
}
catch(exception& e) {
m->errorOut(e, "InputData", "InputData");
list = new ListVector(fileHandle);
}else{ list = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return list;
}
else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete list; }
- gobble(in);
+ m->gobble(in);
}
}else{ list = NULL; }
while (fileHandle.eof() != true) {
- list = new ListVector(fileHandle); gobble(fileHandle);
+ list = new ListVector(fileHandle); m->gobble(fileHandle);
thisLabel = list->getLabel();
//if you are at the last label
SharedList = new SharedListVector(fileHandle);
}else{ SharedList = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return SharedList;
}
else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete SharedList; }
- gobble(in);
+ m->gobble(in);
}
}else{ SharedList = NULL; }
SharedOrder = new SharedOrderVector(fileHandle);
}else{ SharedOrder = NULL; }
- gobble(fileHandle);
+ m->gobble(fileHandle);
return SharedOrder;
}else{
try {
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete SharedOrder; }
- gobble(in);
+ m->gobble(in);
}
}else{ SharedOrder = NULL; }
input = new SAbundVector(fileHandle);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
output = new OrderVector();
*output = (input->getOrderVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if((format == "list") || (format == "listorder")) {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
return SharedList->getSharedRAbundVector();
}
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
//this is created to signal to calling function that the input file is at eof
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (format == "sharedfile") {
delete SharedRAbund;
}
}else{ break; }
- gobble(in);
+ m->gobble(in);
}
}else if (format == "shared") {
delete SharedList;
}
}else{ break; }
- gobble(in);
+ m->gobble(in);
}
input = new SAbundVector(fileHandle);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
sabund = new SAbundVector();
*sabund = (input->getSAbundVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (format == "list") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
input = new SAbundVector(fileHandle);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
rabund = new RAbundVector();
*rabund = (input->getRAbundVector());
ifstream in;
string thisLabel;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
if(in){
if (format == "list") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
else if (format == "shared") {
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
}
if (thisLabel == label) { break; }
//so you don't loose this memory
else { delete input; }
- gobble(in);
+ m->gobble(in);
}
/***********************************************************************/
void Jackknife::getAMatrix(void){
try {
- vector<vector<double> > B = binomial(maxOrder);
+ vector<vector<double> > B = m->binomial(maxOrder);
aMat.resize(maxOrder+1);
try {
ofstream kmerFile; // once we have the kmerLocations folder print it out
- openOutputFile(kmerDBName, kmerFile); // to a file
+ m->openOutputFile(kmerDBName, kmerFile); // to a file
//output version
kmerFile << m->getVersion() << endl;
kmerDBFile.seekg(0); // start at the beginning of the file
//read version
- string line = getline(kmerDBFile); gobble(kmerDBFile);
+ string line = m->getline(kmerDBFile); m->gobble(kmerDBFile);
string seqName;
int seqNumber;
try {
outDistName = s;
ofstream outDistance;
- openOutputFile(outDistName, outDistance);
+ m->openOutputFile(outDistName, outDistance);
outDistance << "Name\tBestMatch\tDistance" << endl;
outDistance.close();
}
//use database to find closest seq
vector<int> closest = database->findClosestSequences(seq, num);
- if (search == "distance") { ofstream outDistance; openOutputFileAppend(outDistName, outDistance); outDistance << seq->getName() << '\t' << database->getName(closest[0]) << '\t' << database->getSearchScore() << endl; outDistance.close(); }
+ if (search == "distance") { ofstream outDistance; m->openOutputFileAppend(outDistName, outDistance); outDistance << seq->getName() << '\t' << database->getName(closest[0]) << '\t' << database->getSearchScore() << endl; outDistance.close(); }
if (m->control_pressed) { return tax; }
//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 += hasPath(globaldata->getPhylipFile()); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->getPhylipFile()); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.dist command
if (groups == "not found") { groups = ""; savegroups = groups; }
else {
savegroups = groups;
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
try {
ofstream outCov;
- summaryFile = outputDir + getRootName(getSimpleName(globaldata->getPhylipFile())) + "libshuff.coverage";
- openOutputFile(summaryFile, outCov);
+ summaryFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getPhylipFile())) + "libshuff.coverage";
+ m->openOutputFile(summaryFile, outCov);
outputNames.push_back(summaryFile);
outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
//cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
try {
ofstream outSum;
- summaryFile = outputDir + getRootName(getSimpleName(globaldata->getPhylipFile())) + "libshuff.summary";
- openOutputFile(summaryFile, outSum);
+ summaryFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getPhylipFile())) + "libshuff.summary";
+ m->openOutputFile(summaryFile, outSum);
outputNames.push_back(summaryFile);
outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
it = parameters.find("alignreport");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
}
//sort in alphabetical order
sort(names.begin(), names.end());
- if (outputDir == "") { outputDir += hasPath(inputFileName); }
+ if (outputDir == "") { outputDir += m->hasPath(inputFileName); }
- string outputFileName = outputDir + getRootName(getSimpleName(inputFileName)) + "accnos";
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + "accnos";
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
//output to .accnos file
for (int i = 0; i < names.size(); i++) {
try {
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
string name;
while(!in.eof()){
if (name != "") { names.push_back(name); }
- gobble(in);
+ m->gobble(in);
}
in.close();
int ListSeqsCommand::readList(){
try {
ifstream in;
- openInputFile(listfile, in);
+ m->openInputFile(listfile, in);
if(!in.eof()){
//read in list vector
try {
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string name, firstCol, secondCol;
while(!in.eof()){
//get name after last ,
names.push_back(secondCol);
- gobble(in);
+ m->gobble(in);
}
in.close();
return 0;
try {
ifstream in;
- openInputFile(groupfile, in);
+ m->openInputFile(groupfile, in);
string name, group;
while(!in.eof()){
names.push_back(name);
- gobble(in);
+ m->gobble(in);
}
in.close();
return 0;
try {
ifstream in;
- openInputFile(alignfile, in);
+ m->openInputFile(alignfile, in);
string name, junk;
//read column headers
names.push_back(name);
- gobble(in);
+ m->gobble(in);
}
in.close();
try {
ifstream in;
- openInputFile(taxfile, in);
+ m->openInputFile(taxfile, in);
string name, firstCol, secondCol;
while(!in.eof()){
names.push_back(firstCol);
- gobble(in);
+ m->gobble(in);
}
in.close();
try {
for(int i=0;i<data.size();i++){
if(data[i] != ""){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
numBins = i+1;
if(binSize > maxRank) { maxRank = binSize; }
numSeqs += binSize;
set(i, inputData);
}
- gobble(f);
+ m->gobble(f);
}
catch(exception& e) {
m->errorOut(e, "ListVector", "ListVector");
void ListVector::set(int binNumber, string seqNames){
try {
- int nNames_old = getNumNames(data[binNumber]);
+ int nNames_old = m->getNumNames(data[binNumber]);
data[binNumber] = seqNames;
- int nNames_new = getNumNames(seqNames);
+ int nNames_new = m->getNumNames(seqNames);
if(nNames_old == 0) { numBins++; }
if(nNames_new == 0) { numBins--; }
void ListVector::push_back(string seqNames){
try {
data.push_back(seqNames);
- int nNames = getNumNames(seqNames);
+ int nNames = m->getNumNames(seqNames);
numBins++;
RAbundVector rav;
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
rav.push_back(binSize);
}
SAbundVector sav(maxRank+1);
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
sav.set(binSize, sav.get(binSize) + 1);
}
sav.set(0, 0);
OrderVector ov;
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
for(int j=0;j<binSize;j++){
ov.push_back(i);
}
fastaFileName = validParameter.validFile(parameters, "fasta", false);
if (fastaFileName == "not found") { m->mothurOut("fasta is a required parameter for the make.group command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(fastaFileName, fastaFileNames);
+ m->splitAtDash(fastaFileName, fastaFileNames);
//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 = hasPath(fastaFileNames[i]);
+ 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 = openInputFile(fastaFileNames[i], in, "noerror");
+ 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() + getSimpleName(fastaFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
fastaFileNames[i] = tryPath;
}
}
//erase from file list
fastaFileNames.erase(fastaFileNames.begin()+i);
i--;
- }else{ filename += getRootName(getSimpleName(fastaFileNames[i])); }
+ }else{ filename += m->getRootName(m->getSimpleName(fastaFileNames[i])); }
}
filename += "groups";
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { m->mothurOut("groups is a required parameter for the make.group command."); m->mothurOutEndLine(); abort = true; }
- else { splitAtDash(groups, groupsNames); }
+ else { m->splitAtDash(groups, groupsNames); }
if (groupsNames.size() != fastaFileNames.size()) { m->mothurOut("You do not have the same number of valid fastfile files as groups. This could be because we could not open a fastafile."); m->mothurOutEndLine(); abort = true; }
}
if (abort == true) { return 0; }
ofstream out;
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
for (int i = 0; i < fastaFileNames.size(); i++) {
if (m->control_pressed) { out.close(); remove(filename.c_str()); return 0; }
ifstream in;
- openInputFile(fastaFileNames[i], in);
+ m->openInputFile(fastaFileNames[i], in);
while (!in.eof()) {
- Sequence seq(in, "no align"); gobble(in);
+ Sequence seq(in, "no align"); m->gobble(in);
if (m->control_pressed) { in.close(); out.close(); remove(filename.c_str()); return 0; }
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
else {
if (calc == "default") { calc = "jclass-thetayc"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
if (abort == false) {
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
}
- exportFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist";
- openOutputFile(exportFileName, out);
+ exportFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + "." + output + ".dist";
+ m->openOutputFile(exportFileName, out);
outputNames.push_back(exportFileName);
printSims(out);
string fileList = validParameter.validFile(parameters, "input", false);
if(fileList == "not found") { m->mothurOut("you must enter two or more file names"); m->mothurOutEndLine(); abort=true; }
- else{ splitAtDash(fileList, fileNames); }
+ else{ m->splitAtDash(fileList, fileNames); }
//if the user changes the output directory command factory will send this info to us in the output parameter
string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found") { outputDir = ""; }
else{
for(int i=0;i<numInputFiles;i++){
if (inputDir != "") {
- string path = hasPath(fileNames[i]);
+ 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]; }
}
- if(openInputFile(fileNames[i], testFile)){ abort = true; }
+ if(m->openInputFile(fileNames[i], testFile)){ abort = true; }
testFile.close();
}
}
outputFileName = validParameter.validFile(parameters, "output", false);
if (outputFileName == "not found") { m->mothurOut("you must enter an output file name"); m->mothurOutEndLine(); abort=true; }
- else if (outputDir != "") { outputFileName = outputDir + getSimpleName(outputFileName); }
+ else if (outputDir != "") { outputFileName = outputDir + m->getSimpleName(outputFileName); }
}
}
if (abort == true) { return 0; }
ofstream outputFile;
- openOutputFile(outputFileName, outputFile);
+ m->openOutputFile(outputFileName, outputFile);
char c;
for(int i=0;i<numInputFiles;i++){
ifstream inputFile; //declaration must be inside for loop of windows throws an error
- openInputFile(fileNames[i], inputFile);
+ m->openInputFile(fileNames[i], inputFile);
while(!inputFile.eof()){
if (m->control_pressed) { inputFile.close(); outputFile.close(); remove(outputFileName.c_str()); return 0; }
it = parameters.find("blast");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["blast"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = 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 = "";
- outputDir += hasPath(blastfile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(blastfile); //if user entered a file with a path then preserve it
}
namefile = validParameter.validFile(parameters, "name", true);
convert(temp, penalty);
temp = validParameter.validFile(parameters, "min", false); if (temp == "not found") { temp = "true"; }
- minWanted = isTrue(temp);
+ minWanted = m->isTrue(temp);
temp = validParameter.validFile(parameters, "merge", false); if (temp == "not found") { temp = "true"; }
- merge = isTrue(temp);
+ merge = m->isTrue(temp);
temp = validParameter.validFile(parameters, "hcluster", false); if (temp == "not found") { temp = "false"; }
- hclusterWanted = isTrue(temp);
+ hclusterWanted = m->isTrue(temp);
temp = validParameter.validFile(parameters, "hard", false); if (temp == "not found") { temp = "F"; }
- hard = isTrue(temp);
+ hard = m->isTrue(temp);
}
}
nameMap->readMap();
}else{ nameMap= new NameAssignment(); }
- string fileroot = outputDir + getRootName(getSimpleName(blastfile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(blastfile));
string tag = "";
time_t start;
float previousDist = 0.00000;
else { tag = "an"; }
//open output files
- openOutputFile(fileroot+ tag + ".list", listFile);
- openOutputFile(fileroot+ tag + ".rabund", rabundFile);
- openOutputFile(fileroot+ tag + ".sabund", sabundFile);
+ m->openOutputFile(fileroot+ tag + ".list", listFile);
+ m->openOutputFile(fileroot+ tag + ".rabund", rabundFile);
+ m->openOutputFile(fileroot+ tag + ".sabund", sabundFile);
if (m->control_pressed) {
delete nameMap; delete read; delete list; delete rabund;
float dist = distMatrix->getSmallDist();
float rndDist;
if (hard) {
- rndDist = ceilDist(dist, precision);
+ rndDist = m->ceilDist(dist, precision);
}else{
- rndDist = roundDist(dist, precision);
+ rndDist = m->roundDist(dist, precision);
}
if(previousDist <= 0.0000 && dist != previousDist){
vector<seqDist> seqs; seqs.resize(1); // to start loop
//ifstream inHcluster;
- //openInputFile(distFile, inHcluster);
+ //m->openInputFile(distFile, inHcluster);
if (m->control_pressed) {
delete nameMap; delete list; delete rabund; delete hcluster;
float rndDist;
if (hard) {
- rndDist = ceilDist(seqs[i].dist, precision);
+ rndDist = m->ceilDist(seqs[i].dist, precision);
}else{
- rndDist = roundDist(seqs[i].dist, precision);
+ rndDist = m->roundDist(seqs[i].dist, precision);
}
if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
int count = 0;
if (hclusterWanted) {
- openInputFile(overlapFile, inOverlap);
+ m->openInputFile(overlapFile, inOverlap);
if (inOverlap.eof()) { done = true; }
}else { if (overlapMatrix.size() == 0) { done = true; } }
if (!inOverlap.eof()) {
string firstName, secondName;
float overlapDistance;
- inOverlap >> firstName >> secondName >> overlapDistance; gobble(inOverlap);
+ inOverlap >> firstName >> secondName >> overlapDistance; m->gobble(inOverlap);
//commented out because we check this in readblast already
//map<string,int>::iterator itA = nameMap->find(firstName);
void MGClusterCommand::sortHclusterFiles(string unsortedDist, string unsortedOverlap) {
try {
//sort distFile
- string sortedDistFile = sortFile(unsortedDist, outputDir);
+ string sortedDistFile = m->sortFile(unsortedDist, outputDir);
remove(unsortedDist.c_str()); //delete unsorted file
distFile = sortedDistFile;
//sort overlap file
- string sortedOverlapFile = sortFile(unsortedOverlap, outputDir);
+ string sortedOverlapFile = m->sortFile(unsortedOverlap, outputDir);
remove(unsortedOverlap.c_str()); //delete unsorted file
overlapFile = sortedOverlapFile;
}
if (lastChar != "\\") { temp += "\\"; }
#endif
- temp = getFullPathName(temp);
+ temp = m->getFullPathName(temp);
m->setDefaultPath(temp);
m->mothurOutJustToLog("Using default file location " + temp);
}else {
ofstream outNewLog;
- openOutputFileAppend(newlogFileName, outNewLog);
+ m->openOutputFileAppend(newlogFileName, outNewLog);
outNewLog << endl << endl << "*********************************************************************************" << endl << endl;
outNewLog.close();
- appendFiles(logFileName, newlogFileName);
+ m->appendFiles(logFileName, newlogFileName);
remove(logFileName.c_str());
}
}else{
};
//**********************************************************************************************************************
-
template<typename T>
-inline void convert(const string& s, T& x, bool failIfLeftoverChars = true){
- istringstream i(s);
- char c;
- if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
- throw BadConversion(s);
+void convert(const string& s, T& x, bool failIfLeftoverChars = true){
+
+ istringstream i(s);
+ char c;
+ if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
+ throw BadConversion(s);
+
}
//**********************************************************************************************************************
template<typename T>
-inline bool convertTestFloat(const string& s, T& x, bool failIfLeftoverChars = true){
- istringstream i(s);
- char c;
- if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
- {
- return false;
- }
- return true;
+bool convertTestFloat(const string& s, T& x, bool failIfLeftoverChars = true){
+
+ istringstream i(s);
+ char c;
+ if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
+ {
+ return false;
+ }
+ return true;
+
}
//**********************************************************************************************************************
template<typename T>
-inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
- istringstream i(s);
- char c;
- if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
- {
- cout << "unable to be converted into an integer.\n" << endl;
- return false;
- }
- return true;
+bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
+
+ istringstream i(s);
+ char c;
+ if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
+ {
+ return false;
+ }
+ return true;
+
}
-
//**********************************************************************************************************************
-
template<typename T>
string toString(const T&x){
- stringstream output;
- output << x;
- return output.str();
+
+ stringstream output;
+ output << x;
+ return output.str();
+
}
//**********************************************************************************************************************
template<typename T>
string toHex(const T&x){
- stringstream output;
- output << hex << x;
+ stringstream output;
+
+ output << hex << x;
- return output.str();
+ return output.str();
+
}
//**********************************************************************************************************************
template<typename T>
string toString(const T&x, int i){
- stringstream output;
-
- output.precision(i);
- output << fixed << x;
-
- return output.str();
-}
-/***********************************************************************/
-inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
-
- fileHandle.open(fileName.c_str(), ios::app);
- if(!fileHandle) {
- cout << "Error: Could not open " << fileName << endl;
- return 1;
- }
- else {
- return 0;
- }
-
-}
-/***********************************************************************/
-
-inline void gobble(istream& f){
-
- char d;
- while(isspace(d=f.get())) {;}
- f.putback(d);
-
-}
-/***********************************************************************/
-
-inline void gobble(istringstream& f){
-
- char d;
- while(isspace(d=f.get())) {;}
- f.putback(d);
-
-}
-
-/***********************************************************************/
-
-inline string getline(istringstream& fileHandle) {
- try {
-
- string line = "";
-
- while (!fileHandle.eof()) {
- //get next character
- char c = fileHandle.get();
-
- //are you at the end of the line
- if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
- else { line += c; }
- }
-
- return line;
-
- }
- catch(exception& e) {
- cout << "Error in mothur function getline" << endl;
- exit(1);
- }
-}
-/***********************************************************************/
-
-inline string getline(ifstream& fileHandle) {
- try {
- string line = "";
+ stringstream output;
- while (!fileHandle.eof()) {
- //get next character
- char c = fileHandle.get();
-
- //are you at the end of the line
- if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
- else { line += c; }
- }
+ output.precision(i);
+ output << fixed << x;
- return line;
-
- }
- catch(exception& e) {
- cout << "Error in mothur function getline" << endl;
- exit(1);
- }
-}
-/***********************************************************************/
-
-inline bool isTrue(string f){
-
- if ((f == "TRUE") || (f == "T") || (f == "true") || (f == "t")) { return true; }
- else { return false; }
-}
-
-/***********************************************************************/
-
-inline float roundDist(float dist, int precision){
-
- return int(dist * precision + 0.5)/float(precision);
-
-}
-/***********************************************************************/
-
-inline float ceilDist(float dist, int precision){
-
- return int(ceil(dist * precision))/float(precision);
-
-}
-
-/***********************************************************************/
-
-inline int getNumNames(string names){
-
- int count = 0;
-
- if(names != ""){
- count = 1;
- for(int i=0;i<names.size();i++){
- if(names[i] == ','){
- count++;
- }
- }
- }
-
- return count;
-
-}
-
-/**************************************************************************************************/
-
-inline vector<vector<double> > binomial(int maxOrder){
-
- vector<vector<double> > binomial(maxOrder+1);
-
- for(int i=0;i<=maxOrder;i++){
- binomial[i].resize(maxOrder+1);
- binomial[i][0]=1;
- binomial[0][i]=0;
- }
- binomial[0][0]=1;
-
- binomial[1][0]=1;
- binomial[1][1]=1;
-
- for(int i=2;i<=maxOrder;i++){
- binomial[1][i]=0;
- }
-
- for(int i=2;i<=maxOrder;i++){
- for(int j=1;j<=maxOrder;j++){
- if(i==j){ binomial[i][j]=1; }
- if(j>i) { binomial[i][j]=0; }
- else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; }
- }
- }
-
- return binomial;
-}
-
-/***********************************************************************/
-
-inline string getRootName(string longName){
-
- string rootName = longName;
-
- if(longName.find_last_of(".") != longName.npos){
- int pos = longName.find_last_of('.')+1;
- rootName = longName.substr(0, pos);
- }
-
- return rootName;
-}
-/***********************************************************************/
-
-inline string getSimpleName(string longName){
-
- string simpleName = longName;
-
- size_t found;
- found=longName.find_last_of("/\\");
-
- if(found != longName.npos){
- simpleName = longName.substr(found+1);
- }
-
- //if(longName.find_last_of("/") != longName.npos){
- // int pos = longName.find_last_of('/')+1;
- // simpleName = longName.substr(pos, longName.length());
- //}
-
- return simpleName;
-}
-
-/***********************************************************************/
-
-inline int factorial(int num){
- int total = 1;
-
- for (int i = 1; i <= num; i++) {
- total *= i;
- }
-
- return total;
-}
-/**************************************************************************************************
-
-double min(double x, double y)
-{
- if(x<y){ return x; }
- else { return y; }
-}
-
-/***********************************************************************/
-
-inline string getPathName(string longName){
-
- string rootPathName = longName;
-
- if(longName.find_last_of("/\\") != longName.npos){
- int pos = longName.find_last_of("/\\")+1;
- rootPathName = longName.substr(0, pos);
- }
-
- return rootPathName;
-}
-/***********************************************************************/
-
-inline string hasPath(string longName){
-
- string path = "";
-
- size_t found;
- found=longName.find_last_of("~/\\");
-
- if(found != longName.npos){
- path = longName.substr(0, found+1);
- }
-
- return path;
-}
-
-/***********************************************************************/
-
-inline string getExtension(string longName){
-
- string extension = longName;
+ return output.str();
- if(longName.find_last_of('.') != longName.npos){
- int pos = longName.find_last_of('.');
- extension = longName.substr(pos, longName.length());
- }
-
- return extension;
-}
-/***********************************************************************/
-inline bool isBlank(string fileName){
-
- ifstream fileHandle;
- fileHandle.open(fileName.c_str());
- if(!fileHandle) {
- cout << "Error: Could not open " << fileName << endl;
- return false;
- }else {
- //check for blank file
- gobble(fileHandle);
- if (fileHandle.eof()) { fileHandle.close(); return true; }
- }
- return false;
-}
-/***********************************************************************/
-
-inline string getFullPathName(string fileName){
- try{
-
- string path = hasPath(fileName);
- string newFileName;
- int pos;
-
- if (path == "") { return fileName; } //its a simple name
- else { //we need to complete the pathname
- // ex. ../../../filename
- // cwd = /user/work/desktop
-
- string cwd;
- //get current working directory
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
-
- if (path.find("~") != -1) { //go to home directory
- string homeDir = getenv ("HOME");
- newFileName = homeDir + fileName.substr(fileName.find("~")+1);
- return newFileName;
- }else { //find path
- if (path.rfind("./") == -1) { return fileName; } //already complete name
- else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
-
- char* cwdpath = new char[1024];
-
- size_t size;
- cwdpath=getcwd(cwdpath,size);
-
- cwd = cwdpath;
-
- //rip off first '/'
- string simpleCWD;
- if (cwd.length() > 0) { simpleCWD = cwd.substr(1); }
-
- //break apart the current working directory
- vector<string> dirs;
- while (simpleCWD.find_first_of('/') != -1) {
- string dir = simpleCWD.substr(0,simpleCWD.find_first_of('/'));
- simpleCWD = simpleCWD.substr(simpleCWD.find_first_of('/')+1, simpleCWD.length());
- dirs.push_back(dir);
- }
- //get last one // ex. ../../../filename = /user/work/desktop/filename
- dirs.push_back(simpleCWD); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
-
-
- int index = dirs.size()-1;
-
- while((pos = path.rfind("./")) != -1) { //while you don't have a complete path
- if (pos == 0) { break; //you are at the end
- }else if (path[(pos-1)] == '.') { //you want your parent directory ../
- path = path.substr(0, pos-1);
- index--;
- if (index == 0) { break; }
- }else if (path[(pos-1)] == '/') { //you want the current working dir ./
- path = path.substr(0, pos);
- }else if (pos == 1) { break; //you are at the end
- }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
- }
-
- for (int i = index; i >= 0; i--) {
- newFileName = dirs[i] + "/" + newFileName;
- }
-
- newFileName = "/" + newFileName;
- return newFileName;
- }
- #else
- if (path.find("~") != -1) { //go to home directory
- string homeDir = getenv ("HOMEPATH");
- newFileName = homeDir + fileName.substr(fileName.find("~")+1);
- return newFileName;
- }else { //find path
- if (path.rfind(".\\") == -1) { return fileName; } //already complete name
- else { newFileName = fileName.substr(fileName.rfind(".\\")+2); } //save the complete part of the name
-
- char *cwdpath = NULL;
- cwdpath = getcwd(NULL, 0); // or _getcwd
- if ( cwdpath != NULL) { cwd = cwdpath; }
- else { cwd = ""; }
-
- //break apart the current working directory
- vector<string> dirs;
- while (cwd.find_first_of('\\') != -1) {
- string dir = cwd.substr(0,cwd.find_first_of('\\'));
- cwd = cwd.substr(cwd.find_first_of('\\')+1, cwd.length());
- dirs.push_back(dir);
-
- }
- //get last one
- dirs.push_back(cwd); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
-
- int index = dirs.size()-1;
-
- while((pos = path.rfind(".\\")) != -1) { //while you don't have a complete path
- if (pos == 0) { break; //you are at the end
- }else if (path[(pos-1)] == '.') { //you want your parent directory ../
- path = path.substr(0, pos-1);
- index--;
- if (index == 0) { break; }
- }else if (path[(pos-1)] == '\\') { //you want the current working dir ./
- path = path.substr(0, pos);
- }else if (pos == 1) { break; //you are at the end
- }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
- }
-
- for (int i = index; i >= 0; i--) {
- newFileName = dirs[i] + "\\" + newFileName;
- }
-
- return newFileName;
- }
-
- #endif
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function getFullPathName. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
}
-/***********************************************************************/
-
-inline int openInputFile(string fileName, ifstream& fileHandle, string m){
-
- //get full path name
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str());
- if(!fileHandle) {
- return 1;
- }else {
- //check for blank file
- gobble(fileHandle);
- return 0;
- }
-}
-/***********************************************************************/
-
-inline int openInputFile(string fileName, ifstream& fileHandle){
-
- //get full path name
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str());
- if(!fileHandle) {
- cout << "Error: Could not open " << completeFileName << endl;
- return 1;
- }
- else {
- //check for blank file
- gobble(fileHandle);
- if (fileHandle.eof()) { cout << completeFileName << " is blank. Please correct." << endl; }
-
- return 0;
- }
-
-}
-/***********************************************************************/
-
-inline int renameFile(string oldName, string newName){
-
- ifstream inTest;
- int exist = openInputFile(newName, inTest, "");
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if (exist == 0) { //you could open it so you want to delete it
- inTest.close();
- string command = "rm " + newName;
- system(command.c_str());
- }
-
- string command = "mv " + oldName + " " + newName;
- system(command.c_str());
-#else
- remove(newName.c_str());
- int renameOk = rename(oldName.c_str(), newName.c_str());
-#endif
- return 0;
-}
-
-/***********************************************************************/
-
-inline int openOutputFile(string fileName, ofstream& fileHandle){
-
- string completeFileName = getFullPathName(fileName);
-
- fileHandle.open(completeFileName.c_str(), ios::trunc);
- if(!fileHandle) {
- cout << "Error: Could not open " << completeFileName << endl;
- return 1;
- }
- else {
- return 0;
- }
-
-}
-
-/***********************************************************************/
-
-inline int getNumSeqs(ifstream& file){
-
- int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
- file.seekg(0);
- return numSeqs;
-
-}
-/***********************************************************************/
-inline void getNumSeqs(ifstream& file, int& numSeqs){
-
- string input;
- numSeqs = 0;
- while(!file.eof()){
- input = getline(file);
- if (input.length() != 0) {
- if(input[0] == '>'){ numSeqs++; }
- }
- }
-}
-
-/***********************************************************************/
-
-inline bool inVector(string member, vector<string> group){
-
- for (int i = 0; i < group.size(); i++) {
- if (group[i] == member) { return true; }
- }
-
- return false;
-}
-/***********************************************************************/
-
-//This function parses the estimator options and puts them in a vector
-inline void splitAtChar(string& estim, vector<string>& container, char symbol) {
- try {
- string individual;
-
- while (estim.find_first_of(symbol) != -1) {
- individual = estim.substr(0,estim.find_first_of(symbol));
- if ((estim.find_first_of(symbol)+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of(symbol)+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-
-//This function parses the estimator options and puts them in a vector
-inline void splitAtDash(string& estim, vector<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/***********************************************************************/
-//This function parses the label options and puts them in a set
-inline void splitAtDash(string& estim, set<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- container.insert(individual);
- }
- }
- //get last one
- container.insert(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-//This function parses the line options and puts them in a set
-inline void splitAtDash(string& estim, set<int>& container) {
- try {
- string individual;
- int lineNum;
-
- while (estim.find_first_of('-') != -1) {
- individual = estim.substr(0,estim.find_first_of('-'));
- if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
- estim = estim.substr(estim.find_first_of('-')+1, estim.length());
- convert(individual, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- }
- //get last one
- convert(estim, lineNum); //convert the string to int
- container.insert(lineNum);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtDash. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-//This function parses the a string and puts peices in a vector
-inline void splitAtComma(string& estim, vector<string>& container) {
- try {
- string individual;
-
- while (estim.find_first_of(',') != -1) {
- individual = estim.substr(0,estim.find_first_of(','));
- if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
- estim = estim.substr(estim.find_first_of(',')+1, estim.length());
- container.push_back(individual);
- }
- }
- //get last one
- container.push_back(estim);
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-
-//This function splits up the various option parameters
-inline void splitAtComma(string& prefix, string& suffix){
- try {
- prefix = suffix.substr(0,suffix.find_first_of(','));
- if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
- suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
- string space = " ";
- while(suffix.at(0) == ' ')
- suffix = suffix.substr(1, suffix.length());
- }
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtComma. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-
-//This function separates the key value from the option value i.e. dist=96_...
-inline void splitAtEquals(string& key, string& value){
- try {
- if(value.find_first_of('=') != -1){
- key = value.substr(0,value.find_first_of('='));
- if ((value.find_first_of('=')+1) <= value.length()) {
- value = value.substr(value.find_first_of('=')+1, value.length());
- }
- }else{
- key = value;
- value = 1;
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function splitAtEquals. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/**************************************************************************************************/
-
-inline bool inUsersGroups(string groupname, vector<string> Groups) {
- try {
- for (int i = 0; i < Groups.size(); i++) {
- if (groupname == Groups[i]) { return true; }
- }
- return false;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/**************************************************************************************************/
-//returns true if any of the strings in first vector are in second vector
-inline bool inUsersGroups(vector<string> groupnames, vector<string> Groups) {
- try {
-
- for (int i = 0; i < groupnames.size(); i++) {
- if (inUsersGroups(groupnames[i], Groups)) { return true; }
- }
- return false;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function inUsersGroups. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/***********************************************************************/
-//this function determines if the user has given us labels that are smaller than the given label.
-//if so then it returns true so that the calling function can run the previous valid distance.
-//it's a "smart" distance function. It also checks for invalid labels.
-inline bool anyLabelsToProcess(string label, set<string>& userLabels, string errorOff) {
- try {
-
- set<string>::iterator it;
- vector<float> orderFloat;
- map<string, float> userMap; //the conversion process removes trailing 0's which we need to put back
- map<string, float>::iterator it2;
- float labelFloat;
- bool smaller = false;
-
- //unique is the smallest line
- if (label == "unique") { return false; }
- else {
- if (convertTestFloat(label, labelFloat)) {
- convert(label, labelFloat);
- }else { //cant convert
- return false;
- }
- }
-
- //go through users set and make them floats
- for(it = userLabels.begin(); it != userLabels.end(); ++it) {
-
- float temp;
- if ((*it != "unique") && (convertTestFloat(*it, temp) == true)){
- convert(*it, temp);
- orderFloat.push_back(temp);
- userMap[*it] = temp;
- }else if (*it == "unique") {
- orderFloat.push_back(-1.0);
- userMap["unique"] = -1.0;
- }else {
- if (errorOff == "") { cout << *it << " is not a valid label." << endl; }
- userLabels.erase(*it);
- it--;
- }
- }
-
- //sort order
- sort(orderFloat.begin(), orderFloat.end());
-
- /*************************************************/
- //is this label bigger than any of the users labels
- /*************************************************/
-
- //loop through order until you find a label greater than label
- for (int i = 0; i < orderFloat.size(); i++) {
- if (orderFloat[i] < labelFloat) {
- smaller = true;
- if (orderFloat[i] == -1) {
- if (errorOff == "") { cout << "Your file does not include the label unique." << endl; }
- userLabels.erase("unique");
- }
- else {
- if (errorOff == "") { cout << "Your file does not include the label " << endl; }
- string s = "";
- for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {
- if (it2->second == orderFloat[i]) {
- s = it2->first;
- //remove small labels
- userLabels.erase(s);
- break;
- }
- }
- if (errorOff == "") {cout << s << ". I will use the next smallest distance. " << endl; }
- }
- //since they are sorted once you find a bigger one stop looking
- }else { break; }
- }
-
- return smaller;
-
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function anyLabelsToProcess. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/**************************************************************************************************/
-inline void appendFiles(string temp, string filename) {
- try{
- ofstream output;
- ifstream input;
-
- //open output file in append mode
- openOutputFileAppend(filename, output);
- int ableToOpen = openInputFile(temp, input, "no error");
-
- if (ableToOpen == 0) { //you opened it
- while(char c = input.get()){
- if(input.eof()) { break; }
- else { output << c; }
- }
- input.close();
- }
-
- output.close();
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function appendFiles. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-
-/**************************************************************************************************/
-inline string sortFile(string distFile, string outputDir){
- try {
-
- //if (outputDir == "") { outputDir += hasPath(distFile); }
- string outfile = getRootName(distFile) + "sorted.dist";
-
-
- //if you can, use the unix sort since its been optimized for years
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- string command = "sort -n -k +3 " + distFile + " -o " + outfile;
- system(command.c_str());
- #else //you are stuck with my best attempt...
- //windows sort does not have a way to specify a column, only a character in the line
- //since we cannot assume that the distance will always be at the the same character location on each line
- //due to variable sequence name lengths, I chose to force the distance into first position, then sort and then put it back.
-
- //read in file line by file and put distance first
- string tempDistFile = distFile + ".temp";
- ifstream input;
- ofstream output;
- openInputFile(distFile, input);
- openOutputFile(tempDistFile, output);
-
- string firstName, secondName;
- float dist;
- while (input) {
- input >> firstName >> secondName >> dist;
- output << dist << '\t' << firstName << '\t' << secondName << endl;
- gobble(input);
- }
- input.close();
- output.close();
-
-
- //sort using windows sort
- string tempOutfile = outfile + ".temp";
- string command = "sort " + tempDistFile + " /O " + tempOutfile;
- system(command.c_str());
-
- //read in sorted file and put distance at end again
- ifstream input2;
- openInputFile(tempOutfile, input2);
- openOutputFile(outfile, output);
-
- while (input2) {
- input2 >> dist >> firstName >> secondName;
- output << firstName << '\t' << secondName << '\t' << dist << endl;
- gobble(input2);
- }
- input2.close();
- output.close();
-
- //remove temp files
- remove(tempDistFile.c_str());
- remove(tempOutfile.c_str());
- #endif
-
- return outfile;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function sortfile. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/**************************************************************************************************/
-inline vector<unsigned long int> setFilePosFasta(string filename, int& num) {
-
- vector<unsigned long int> positions;
- ifstream inFASTA;
- openInputFile(filename, inFASTA);
-
- string input;
- while(!inFASTA.eof()){
- input = getline(inFASTA);
- if (input.length() != 0) {
- if(input[0] == '>'){ unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
- }
- gobble(inFASTA); //has to be here since windows line endings are 2 characters and mess up the positions
- }
- inFASTA.close();
-
- num = positions.size();
-
- /*FILE * pFile;
- long size;
-
- //get num bytes in file
- pFile = fopen (filename.c_str(),"rb");
- if (pFile==NULL) perror ("Error opening file");
- else{
- fseek (pFile, 0, SEEK_END);
- size=ftell (pFile);
- fclose (pFile);
- }*/
-
- unsigned long int size = positions[(positions.size()-1)];
- ifstream in;
- openInputFile(filename, in);
-
- in.seekg(size);
-
- while(char c = in.get()){
- if(in.eof()) { break; }
- else { size++; }
- }
- in.close();
-
- positions.push_back(size);
-
- return positions;
-}
-/**************************************************************************************************/
-inline vector<unsigned long int> setFilePosEachLine(string filename, int& num) {
-
- vector<unsigned long int> positions;
- ifstream in;
- openInputFile(filename, in);
-
- string input;
- while(!in.eof()){
- unsigned long int lastpos = in.tellg();
- input = getline(in);
- if (input.length() != 0) {
- unsigned long int pos = in.tellg();
- if (pos != -1) { positions.push_back(pos - input.length() - 1); }
- else { positions.push_back(lastpos); }
- }
- gobble(in); //has to be here since windows line endings are 2 characters and mess up the positions
- }
- in.close();
-
- num = positions.size();
-
- FILE * pFile;
- unsigned long int size;
-
- //get num bytes in file
- pFile = fopen (filename.c_str(),"rb");
- if (pFile==NULL) perror ("Error opening file");
- else{
- fseek (pFile, 0, SEEK_END);
- size=ftell (pFile);
- fclose (pFile);
- }
-
- positions.push_back(size);
-
- return positions;
-}
-/**************************************************************************************************/
-
-inline vector<unsigned long int> divideFile(string filename, int& proc) {
- try{
-
- vector<unsigned long int> filePos;
- filePos.push_back(0);
-
- FILE * pFile;
- unsigned long int size;
-
- //get num bytes in file
- pFile = fopen (filename.c_str(),"rb");
- if (pFile==NULL) perror ("Error opening file");
- else{
- fseek (pFile, 0, SEEK_END);
- size=ftell (pFile);
- fclose (pFile);
- }
-
- //estimate file breaks
- unsigned long int chunkSize = 0;
- chunkSize = size / proc;
-
- //file to small to divide by processors
- if (chunkSize == 0) { proc = 1; filePos.push_back(size); return filePos; }
-
- //for each process seekg to closest file break and search for next '>' char. make that the filebreak
- for (int i = 0; i < proc; i++) {
- unsigned long int spot = (i+1) * chunkSize;
-
- ifstream in;
- openInputFile(filename, in);
- in.seekg(spot);
-
- //look for next '>'
- unsigned long int newSpot = spot;
- while (!in.eof()) {
- char c = in.get();
- if (c == '>') { in.putback(c); newSpot = in.tellg(); break; }
- }
-
- //there was not another sequence before the end of the file
- unsigned long int sanityPos = in.tellg();
- if (sanityPos == -1) { break; }
- else { filePos.push_back(newSpot); }
-
- in.close();
- }
-
- //save end pos
- filePos.push_back(size);
-
- //sanity check filePos
- for (int i = 0; i < (filePos.size()-1); i++) {
- if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; }
- }
-
- proc = (filePos.size() - 1);
-
- return filePos;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function divideFile. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/**************************************************************************************************/
-inline bool checkReleaseVersion(ifstream& file, string version) {
- try {
-
- bool good = true;
-
- string line = getline(file);
+//**********************************************************************************************************************
- //before we added this check
- if (line[0] != '#') { good = false; }
- else {
- //rip off #
- line = line.substr(1);
-
- vector<string> versionVector;
- splitAtChar(version, versionVector, '.');
-
- //check file version
- vector<string> linesVector;
- splitAtChar(line, linesVector, '.');
-
- if (versionVector.size() != linesVector.size()) { good = false; }
- else {
- for (int j = 0; j < versionVector.size(); j++) {
- int num1, num2;
- convert(versionVector[j], num1);
- convert(linesVector[j], num2);
-
- //if mothurs version is newer than this files version, then we want to remake it
- if (num1 > num2) { good = false; break; }
- }
- }
-
- }
-
- if (!good) { file.close(); }
- else { file.seekg(0); }
-
- return good;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the mothur.h function checkReleaseVersion. Please contact Pat Schloss at mothur.bugs@gmail.com." << "\n";
- exit(1);
- }
-}
-/**************************************************************************************************/
#endif
-/*\r
- * m->mothurOut.cpp\r
- * Mothur\r
- *\r
- * Created by westcott on 2/25/10.\r
- * Copyright 2010 Schloss Lab. All rights reserved.\r
- *\r
- */\r
-\r
-#include "mothurout.h"\r
-\r
-/******************************************************/\r
-MothurOut* MothurOut::getInstance() {\r
- if( _uniqueInstance == 0) {\r
- _uniqueInstance = new MothurOut();\r
- }\r
- return _uniqueInstance;\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::setFileName(string filename) {\r
- try {\r
- logFileName = filename;\r
- \r
- #ifdef USE_MPI\r
- int pid;\r
- MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
- \r
- if (pid == 0) { //only one process should output to screen\r
- #endif\r
- \r
- openOutputFile(filename, out);\r
- \r
- #ifdef USE_MPI\r
- }\r
- #endif\r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "setFileName");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::setDefaultPath(string pathname) {\r
- try {\r
- \r
- //add / to name if needed\r
- string lastChar = pathname.substr(pathname.length()-1);\r
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)\r
- if (lastChar != "/") { pathname += "/"; }\r
- #else\r
- if (lastChar != "\\") { pathname += "\\"; } \r
- #endif\r
- \r
- defaultPath = pathname;\r
- \r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "setDefaultPath");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::closeLog() {\r
- try {\r
- \r
- #ifdef USE_MPI\r
- int pid;\r
- MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
- \r
- if (pid == 0) { //only one process should output to screen\r
- #endif\r
- \r
- out.close();\r
- \r
- #ifdef USE_MPI\r
- }\r
- #endif\r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "closeLog");\r
- exit(1);\r
- }\r
-}\r
-\r
-/*********************************************************************************************/\r
-MothurOut::~MothurOut() {\r
- try {\r
- _uniqueInstance = 0;\r
- \r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "MothurOut");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::mothurOut(string output) {\r
- try {\r
- \r
- #ifdef USE_MPI\r
- int pid;\r
- MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
- \r
- if (pid == 0) { //only one process should output to screen\r
- #endif\r
- \r
- cout << output;\r
- out << output;\r
- \r
- #ifdef USE_MPI\r
- }\r
- #endif\r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "MothurOut");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::mothurOutEndLine() {\r
- try {\r
- #ifdef USE_MPI\r
- int pid;\r
- MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
- \r
- if (pid == 0) { //only one process should output to screen\r
- #endif\r
- \r
- cout << endl;\r
- out << endl;\r
- \r
- #ifdef USE_MPI\r
- }\r
- #endif\r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "MothurOutEndLine");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::mothurOutJustToLog(string output) {\r
- try {\r
- #ifdef USE_MPI\r
- int pid;\r
- MPI_Comm_rank(MPI_COMM_WORLD, &pid); \r
- \r
- if (pid == 0) { //only one process should output to screen\r
- #endif\r
- \r
- out << output;\r
- \r
- #ifdef USE_MPI\r
- }\r
- #endif\r
- }\r
- catch(exception& e) {\r
- errorOut(e, "MothurOut", "MothurOutJustToLog");\r
- exit(1);\r
- }\r
-}\r
-/*********************************************************************************************/\r
-void MothurOut::errorOut(exception& e, string object, string function) {\r
- double vm, rss;\r
- //mem_usage(vm, rss);\r
- \r
- mothurOut("Error: ");\r
- mothurOut(toString(e.what()));\r
- mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");\r
- mothurOutEndLine();\r
-}\r
-/*********************************************************************************************/\r
-//The following was originally from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c \r
-// process_mem_usage(double &, double &) - takes two doubles by reference,\r
-// attempts to read the system-dependent data for a process' virtual memory\r
-// size and resident set size, and return the results in KB.\r
-//\r
-// On failure, returns 0.0, 0.0\r
-int MothurOut::mem_usage(double& vm_usage, double& resident_set) {\r
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)\r
- \r
- vm_usage = 0.0;\r
- resident_set = 0.0;\r
-\r
- // 'file' stat seems to give the most reliable results\r
- //\r
- ifstream stat_stream("/proc/self/stat",ios_base::in);\r
-\r
- // dummy vars for leading entries in stat that we don't care about\r
- //\r
- string pid, comm, state, ppid, pgrp, session, tty_nr;\r
- string tpgid, flags, minflt, cminflt, majflt, cmajflt;\r
- string utime, stime, cutime, cstime, priority, nice;\r
- string O, itrealvalue, starttime;\r
-\r
- // the two fields we want\r
- //\r
- unsigned long vsize;\r
- long rss;\r
-\r
- stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr\r
- >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt\r
- >> utime >> stime >> cutime >> cstime >> priority >> nice\r
- >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest\r
-\r
- long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages\r
- vm_usage = vsize / 1024.0;\r
- resident_set = rss * page_size_kb;\r
- \r
- mothurOut("Memory Usage: vm = " + toString(vm_usage) + " rss = " + toString(resident_set) + "\n");\r
- return 0;\r
-\r
- #else\r
-/* //windows memory usage\r
- // Get the list of process identifiers.\r
- DWORD aProcesses[1024], cbNeeded, cProcesses;\r
- \r
- if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ){ return 1; }\r
-\r
- // Calculate how many process identifiers were returned.\r
- cProcesses = cbNeeded / sizeof(DWORD);\r
-\r
- // Print the memory usage for each process\r
- for (int i = 0; i < cProcesses; i++ ) {\r
- DWORD processID = aProcesses[i];\r
- \r
- PROCESS_MEMORY_COUNTERS pmc;\r
-\r
- HANDLE hProcess = OpenProcess((PROCESS_QUERY_INFORMATION | PROCESS_VM_READ), FALSE, processID);\r
-\r
- // Print the process identifier.\r
- printf( "\nProcess ID: %u\n", processID);\r
- \r
- if (NULL != hProcess) {\r
-\r
- if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) ) {\r
- printf( "\tPageFaultCount: 0x%08X\n", pmc.PageFaultCount );\r
- printf( "\tPeakWorkingSetSize: 0x%08X\n", pmc.PeakWorkingSetSize );\r
- printf( "\tWorkingSetSize: 0x%08X\n", pmc.WorkingSetSize );\r
- printf( "\tQuotaPeakPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakPagedPoolUsage );\r
- printf( "\tQuotaPagedPoolUsage: 0x%08X\n", pmc.QuotaPagedPoolUsage );\r
- printf( "\tQuotaPeakNonPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakNonPagedPoolUsage );\r
- printf( "\tQuotaNonPagedPoolUsage: 0x%08X\n", pmc.QuotaNonPagedPoolUsage );\r
- printf( "\tPagefileUsage: 0x%08X\n", pmc.PagefileUsage ); \r
- printf( "\tPeakPagefileUsage: 0x%08X\n", pmc.PeakPagefileUsage );\r
- }\r
- CloseHandle(hProcess);\r
- }\r
- }\r
-*/\r
- return 0;\r
-\r
- #endif\r
-}\r
-/*********************************************************************************************/\r
-\r
-\r
-\r
-\r
-\r
-\r
+/*
+ * mothurOut.cpp
+ * Mothur
+ *
+ * Created by westcott on 2/25/10.
+ * Copyright 2010 Schloss Lab. All rights reserved.
+ *
+ */
+
+#include "mothurout.h"
+
+/******************************************************/
+MothurOut* MothurOut::getInstance() {
+ if( _uniqueInstance == 0) {
+ _uniqueInstance = new MothurOut();
+ }
+ return _uniqueInstance;
+}
+/*********************************************************************************************/
+void MothurOut::setFileName(string filename) {
+ try {
+ logFileName = filename;
+
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+ #endif
+
+ openOutputFile(filename, out);
+
+ #ifdef USE_MPI
+ }
+ #endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setFileName");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::setDefaultPath(string pathname) {
+ try {
+
+ //add / to name if needed
+ string lastChar = pathname.substr(pathname.length()-1);
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ if (lastChar != "/") { pathname += "/"; }
+ #else
+ if (lastChar != "\\") { pathname += "\\"; }
+ #endif
+
+ defaultPath = pathname;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setDefaultPath");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::closeLog() {
+ try {
+
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+ #endif
+
+ out.close();
+
+ #ifdef USE_MPI
+ }
+ #endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "closeLog");
+ exit(1);
+ }
+}
+
+/*********************************************************************************************/
+MothurOut::~MothurOut() {
+ try {
+ _uniqueInstance = 0;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOut");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::mothurOut(string output) {
+ try {
+
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+ #endif
+
+ cout << output;
+ out << output;
+
+ #ifdef USE_MPI
+ }
+ #endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOut");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::mothurOutEndLine() {
+ try {
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+ #endif
+
+ cout << endl;
+ out << endl;
+
+ #ifdef USE_MPI
+ }
+ #endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOutEndLine");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::mothurOutJustToLog(string output) {
+ try {
+ #ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+ #endif
+
+ out << output;
+
+ #ifdef USE_MPI
+ }
+ #endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOutJustToLog");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
+void MothurOut::errorOut(exception& e, string object, string function) {
+ //double vm, rss;
+ //mem_usage(vm, rss);
+
+ mothurOut("[ERROR]: ");
+ mothurOut(toString(e.what()));
+ mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");
+ mothurOutEndLine();
+}
+/*********************************************************************************************/
+//The following was originally from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c
+// process_mem_usage(double &, double &) - takes two doubles by reference,
+// attempts to read the system-dependent data for a process' virtual memory
+// size and resident set size, and return the results in KB.
+//
+// On failure, returns 0.0, 0.0
+int MothurOut::mem_usage(double& vm_usage, double& resident_set) {
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+
+ vm_usage = 0.0;
+ resident_set = 0.0;
+
+ // 'file' stat seems to give the most reliable results
+ //
+ ifstream stat_stream("/proc/self/stat",ios_base::in);
+
+ // dummy vars for leading entries in stat that we don't care about
+ //
+ string pid, comm, state, ppid, pgrp, session, tty_nr;
+ string tpgid, flags, minflt, cminflt, majflt, cmajflt;
+ string utime, stime, cutime, cstime, priority, nice;
+ string O, itrealvalue, starttime;
+
+ // the two fields we want
+ //
+ unsigned long vsize;
+ long rss;
+
+ stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
+ >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
+ >> utime >> stime >> cutime >> cstime >> priority >> nice
+ >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest
+
+ long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages
+ vm_usage = vsize / 1024.0;
+ resident_set = rss * page_size_kb;
+
+ mothurOut("Memory Usage: vm = " + toString(vm_usage) + " rss = " + toString(resident_set) + "\n");
+ return 0;
+
+ #else
+/* //windows memory usage
+ // Get the list of process identifiers.
+ DWORD aProcesses[1024], cbNeeded, cProcesses;
+
+ if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ){ return 1; }
+
+ // Calculate how many process identifiers were returned.
+ cProcesses = cbNeeded / sizeof(DWORD);
+
+ // Print the memory usage for each process
+ for (int i = 0; i < cProcesses; i++ ) {
+ DWORD processID = aProcesses[i];
+
+ PROCESS_MEMORY_COUNTERS pmc;
+
+ HANDLE hProcess = OpenProcess((PROCESS_QUERY_INFORMATION | PROCESS_VM_READ), FALSE, processID);
+
+ // Print the process identifier.
+ printf( "\nProcess ID: %u\n", processID);
+
+ if (NULL != hProcess) {
+
+ if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) ) {
+ printf( "\tPageFaultCount: 0x%08X\n", pmc.PageFaultCount );
+ printf( "\tPeakWorkingSetSize: 0x%08X\n", pmc.PeakWorkingSetSize );
+ printf( "\tWorkingSetSize: 0x%08X\n", pmc.WorkingSetSize );
+ printf( "\tQuotaPeakPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakPagedPoolUsage );
+ printf( "\tQuotaPagedPoolUsage: 0x%08X\n", pmc.QuotaPagedPoolUsage );
+ printf( "\tQuotaPeakNonPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakNonPagedPoolUsage );
+ printf( "\tQuotaNonPagedPoolUsage: 0x%08X\n", pmc.QuotaNonPagedPoolUsage );
+ printf( "\tPagefileUsage: 0x%08X\n", pmc.PagefileUsage );
+ printf( "\tPeakPagefileUsage: 0x%08X\n", pmc.PeakPagefileUsage );
+ }
+ CloseHandle(hProcess);
+ }
+ }
+*/
+ return 0;
+
+ #endif
+}
+
+
+/***********************************************************************/
+int MothurOut::openOutputFileAppend(string fileName, ofstream& fileHandle){
+ try {
+ fileHandle.open(fileName.c_str(), ios::app);
+ if(!fileHandle) {
+ mothurOut("[ERROR]: Could not open " + fileName); mothurOutEndLine();
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "openOutputFileAppend");
+ exit(1);
+ }
+}
+/***********************************************************************/
+void MothurOut::gobble(istream& f){
+ try {
+ char d;
+ while(isspace(d=f.get())) {;}
+ f.putback(d);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "gobble");
+ exit(1);
+ }
+}
+/***********************************************************************/
+void MothurOut::gobble(istringstream& f){
+ try {
+ char d;
+ while(isspace(d=f.get())) {;}
+ f.putback(d);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "gobble");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+string MothurOut::getline(istringstream& fileHandle) {
+ try {
+
+ string line = "";
+
+ while (!fileHandle.eof()) {
+ //get next character
+ char c = fileHandle.get();
+
+ //are you at the end of the line
+ if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
+ else { line += c; }
+ }
+
+ return line;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getline");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+string MothurOut::getline(ifstream& fileHandle) {
+ try {
+
+ string line = "";
+
+ while (!fileHandle.eof()) {
+ //get next character
+ char c = fileHandle.get();
+
+ //are you at the end of the line
+ if ((c == '\n') || (c == '\r') || (c == '\f')){ break; }
+ else { line += c; }
+ }
+
+ return line;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getline");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+string MothurOut::getRootName(string longName){
+ try {
+
+ string rootName = longName;
+
+ if(longName.find_last_of(".") != longName.npos){
+ int pos = longName.find_last_of('.')+1;
+ rootName = longName.substr(0, pos);
+ }
+
+ return rootName;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRootName");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+string MothurOut::getSimpleName(string longName){
+ try {
+ string simpleName = longName;
+
+ size_t found;
+ found=longName.find_last_of("/\\");
+
+ if(found != longName.npos){
+ simpleName = longName.substr(found+1);
+ }
+
+ return simpleName;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getSimpleName");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+string MothurOut::getPathName(string longName){
+ try {
+ string rootPathName = longName;
+
+ if(longName.find_last_of("/\\") != longName.npos){
+ int pos = longName.find_last_of("/\\")+1;
+ rootPathName = longName.substr(0, pos);
+ }
+
+ return rootPathName;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getPathName");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+
+string MothurOut::hasPath(string longName){
+ try {
+ string path = "";
+
+ size_t found;
+ found=longName.find_last_of("~/\\");
+
+ if(found != longName.npos){
+ path = longName.substr(0, found+1);
+ }
+
+ return path;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "hasPath");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+string MothurOut::getExtension(string longName){
+ try {
+ string extension = longName;
+
+ if(longName.find_last_of('.') != longName.npos){
+ int pos = longName.find_last_of('.');
+ extension = longName.substr(pos, longName.length());
+ }
+
+ return extension;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getExtension");
+ exit(1);
+ }
+}
+/***********************************************************************/
+bool MothurOut::isBlank(string fileName){
+ try {
+ ifstream fileHandle;
+ fileHandle.open(fileName.c_str());
+ if(!fileHandle) {
+ mothurOut("[ERROR]: Could not open " + fileName); mothurOutEndLine();
+ return false;
+ }else {
+ //check for blank file
+ gobble(fileHandle);
+ if (fileHandle.eof()) { fileHandle.close(); return true; }
+ }
+ return false;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "isBlank");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+string MothurOut::getFullPathName(string fileName){
+ try{
+
+ string path = hasPath(fileName);
+ string newFileName;
+ int pos;
+
+ if (path == "") { return fileName; } //its a simple name
+ else { //we need to complete the pathname
+ // ex. ../../../filename
+ // cwd = /user/work/desktop
+
+ string cwd;
+ //get current working directory
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+
+ if (path.find("~") != -1) { //go to home directory
+ string homeDir = getenv ("HOME");
+ newFileName = homeDir + fileName.substr(fileName.find("~")+1);
+ return newFileName;
+ }else { //find path
+ if (path.rfind("./") == -1) { return fileName; } //already complete name
+ else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
+
+ char* cwdpath = new char[1024];
+
+ size_t size;
+ cwdpath=getcwd(cwdpath,size);
+
+ cwd = cwdpath;
+
+ //rip off first '/'
+ string simpleCWD;
+ if (cwd.length() > 0) { simpleCWD = cwd.substr(1); }
+
+ //break apart the current working directory
+ vector<string> dirs;
+ while (simpleCWD.find_first_of('/') != -1) {
+ string dir = simpleCWD.substr(0,simpleCWD.find_first_of('/'));
+ simpleCWD = simpleCWD.substr(simpleCWD.find_first_of('/')+1, simpleCWD.length());
+ dirs.push_back(dir);
+ }
+ //get last one // ex. ../../../filename = /user/work/desktop/filename
+ dirs.push_back(simpleCWD); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
+
+
+ int index = dirs.size()-1;
+
+ while((pos = path.rfind("./")) != -1) { //while you don't have a complete path
+ if (pos == 0) { break; //you are at the end
+ }else if (path[(pos-1)] == '.') { //you want your parent directory ../
+ path = path.substr(0, pos-1);
+ index--;
+ if (index == 0) { break; }
+ }else if (path[(pos-1)] == '/') { //you want the current working dir ./
+ path = path.substr(0, pos);
+ }else if (pos == 1) { break; //you are at the end
+ }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
+ }
+
+ for (int i = index; i >= 0; i--) {
+ newFileName = dirs[i] + "/" + newFileName;
+ }
+
+ newFileName = "/" + newFileName;
+ return newFileName;
+ }
+ #else
+ if (path.find("~") != -1) { //go to home directory
+ string homeDir = getenv ("HOMEPATH");
+ newFileName = homeDir + fileName.substr(fileName.find("~")+1);
+ return newFileName;
+ }else { //find path
+ if (path.rfind(".\\") == -1) { return fileName; } //already complete name
+ else { newFileName = fileName.substr(fileName.rfind(".\\")+2); } //save the complete part of the name
+
+ char *cwdpath = NULL;
+ cwdpath = getcwd(NULL, 0); // or _getcwd
+ if ( cwdpath != NULL) { cwd = cwdpath; }
+ else { cwd = ""; }
+
+ //break apart the current working directory
+ vector<string> dirs;
+ while (cwd.find_first_of('\\') != -1) {
+ string dir = cwd.substr(0,cwd.find_first_of('\\'));
+ cwd = cwd.substr(cwd.find_first_of('\\')+1, cwd.length());
+ dirs.push_back(dir);
+
+ }
+ //get last one
+ dirs.push_back(cwd); //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
+
+ int index = dirs.size()-1;
+
+ while((pos = path.rfind(".\\")) != -1) { //while you don't have a complete path
+ if (pos == 0) { break; //you are at the end
+ }else if (path[(pos-1)] == '.') { //you want your parent directory ../
+ path = path.substr(0, pos-1);
+ index--;
+ if (index == 0) { break; }
+ }else if (path[(pos-1)] == '\\') { //you want the current working dir ./
+ path = path.substr(0, pos);
+ }else if (pos == 1) { break; //you are at the end
+ }else { cout << "cannot resolve path for " << fileName << endl; return fileName; }
+ }
+
+ for (int i = index; i >= 0; i--) {
+ newFileName = dirs[i] + "\\" + newFileName;
+ }
+
+ return newFileName;
+ }
+
+ #endif
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getFullPathName");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){
+ try {
+ //get full path name
+ string completeFileName = getFullPathName(fileName);
+
+ fileHandle.open(completeFileName.c_str());
+ if(!fileHandle) {
+ return 1;
+ }else {
+ //check for blank file
+ gobble(fileHandle);
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "openInputFile - no Error");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+int MothurOut::openInputFile(string fileName, ifstream& fileHandle){
+ try {
+ //get full path name
+ string completeFileName = getFullPathName(fileName);
+
+ fileHandle.open(completeFileName.c_str());
+ if(!fileHandle) {
+ mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
+ return 1;
+ }
+ else {
+ //check for blank file
+ gobble(fileHandle);
+ if (fileHandle.eof()) { mothurOut("[ERROR]: " + completeFileName + " is blank. Please correct."); mothurOutEndLine(); }
+
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "openInputFile");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+int MothurOut::renameFile(string oldName, string newName){
+ try {
+ ifstream inTest;
+ int exist = openInputFile(newName, inTest, "");
+
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ if (exist == 0) { //you could open it so you want to delete it
+ inTest.close();
+ string command = "rm " + newName;
+ system(command.c_str());
+ }
+
+ string command = "mv " + oldName + " " + newName;
+ system(command.c_str());
+ #else
+ remove(newName.c_str());
+ int renameOk = rename(oldName.c_str(), newName.c_str());
+ #endif
+ return 0;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "renameFile");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+int MothurOut::openOutputFile(string fileName, ofstream& fileHandle){
+ try {
+
+ string completeFileName = getFullPathName(fileName);
+
+ fileHandle.open(completeFileName.c_str(), ios::trunc);
+ if(!fileHandle) {
+ mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "openOutputFile");
+ exit(1);
+ }
+
+}
+
+/**************************************************************************************************/
+void MothurOut::appendFiles(string temp, string filename) {
+ try{
+ ofstream output;
+ ifstream input;
+
+ //open output file in append mode
+ openOutputFileAppend(filename, output);
+ int ableToOpen = openInputFile(temp, input, "no error");
+
+ if (ableToOpen == 0) { //you opened it
+ while(char c = input.get()){
+ if(input.eof()) { break; }
+ else { output << c; }
+ }
+ input.close();
+ }
+
+ output.close();
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "appendFiles");
+ exit(1);
+ }
+}
+
+/**************************************************************************************************/
+string MothurOut::sortFile(string distFile, string outputDir){
+ try {
+
+ //if (outputDir == "") { outputDir += hasPath(distFile); }
+ string outfile = getRootName(distFile) + "sorted.dist";
+
+
+ //if you can, use the unix sort since its been optimized for years
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ string command = "sort -n -k +3 " + distFile + " -o " + outfile;
+ system(command.c_str());
+ #else //you are stuck with my best attempt...
+ //windows sort does not have a way to specify a column, only a character in the line
+ //since we cannot assume that the distance will always be at the the same character location on each line
+ //due to variable sequence name lengths, I chose to force the distance into first position, then sort and then put it back.
+
+ //read in file line by file and put distance first
+ string tempDistFile = distFile + ".temp";
+ ifstream input;
+ ofstream output;
+ openInputFile(distFile, input);
+ openOutputFile(tempDistFile, output);
+
+ string firstName, secondName;
+ float dist;
+ while (input) {
+ input >> firstName >> secondName >> dist;
+ output << dist << '\t' << firstName << '\t' << secondName << endl;
+ gobble(input);
+ }
+ input.close();
+ output.close();
+
+
+ //sort using windows sort
+ string tempOutfile = outfile + ".temp";
+ string command = "sort " + tempDistFile + " /O " + tempOutfile;
+ system(command.c_str());
+
+ //read in sorted file and put distance at end again
+ ifstream input2;
+ openInputFile(tempOutfile, input2);
+ openOutputFile(outfile, output);
+
+ while (input2) {
+ input2 >> dist >> firstName >> secondName;
+ output << firstName << '\t' << secondName << '\t' << dist << endl;
+ gobble(input2);
+ }
+ input2.close();
+ output.close();
+
+ //remove temp files
+ remove(tempDistFile.c_str());
+ remove(tempOutfile.c_str());
+ #endif
+
+ return outfile;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "sortFile");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+vector<unsigned long int> MothurOut::setFilePosFasta(string filename, int& num) {
+ try {
+ vector<unsigned long int> positions;
+ ifstream inFASTA;
+ openInputFile(filename, inFASTA);
+
+ string input;
+ while(!inFASTA.eof()){
+ input = getline(inFASTA);
+ if (input.length() != 0) {
+ if(input[0] == '>'){ unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
+ }
+ gobble(inFASTA); //has to be here since windows line endings are 2 characters and mess up the positions
+ }
+ inFASTA.close();
+
+ num = positions.size();
+
+ /*FILE * pFile;
+ long size;
+
+ //get num bytes in file
+ pFile = fopen (filename.c_str(),"rb");
+ if (pFile==NULL) perror ("Error opening file");
+ else{
+ fseek (pFile, 0, SEEK_END);
+ size=ftell (pFile);
+ fclose (pFile);
+ }*/
+
+ unsigned long int size = positions[(positions.size()-1)];
+ ifstream in;
+ openInputFile(filename, in);
+
+ in.seekg(size);
+
+ while(char c = in.get()){
+ if(in.eof()) { break; }
+ else { size++; }
+ }
+ in.close();
+
+ positions.push_back(size);
+
+ return positions;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setFilePosFasta");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+vector<unsigned long int> MothurOut::setFilePosEachLine(string filename, int& num) {
+ try {
+
+ vector<unsigned long int> positions;
+ ifstream in;
+ openInputFile(filename, in);
+
+ string input;
+ while(!in.eof()){
+ unsigned long int lastpos = in.tellg();
+ input = getline(in);
+ if (input.length() != 0) {
+ unsigned long int pos = in.tellg();
+ if (pos != -1) { positions.push_back(pos - input.length() - 1); }
+ else { positions.push_back(lastpos); }
+ }
+ gobble(in); //has to be here since windows line endings are 2 characters and mess up the positions
+ }
+ in.close();
+
+ num = positions.size();
+
+ FILE * pFile;
+ unsigned long int size;
+
+ //get num bytes in file
+ pFile = fopen (filename.c_str(),"rb");
+ if (pFile==NULL) perror ("Error opening file");
+ else{
+ fseek (pFile, 0, SEEK_END);
+ size=ftell (pFile);
+ fclose (pFile);
+ }
+
+ positions.push_back(size);
+
+ return positions;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "setFilePosEachLine");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+
+vector<unsigned long int> MothurOut::divideFile(string filename, int& proc) {
+ try{
+
+ vector<unsigned long int> filePos;
+ filePos.push_back(0);
+
+ FILE * pFile;
+ unsigned long int size;
+
+ //get num bytes in file
+ pFile = fopen (filename.c_str(),"rb");
+ if (pFile==NULL) perror ("Error opening file");
+ else{
+ fseek (pFile, 0, SEEK_END);
+ size=ftell (pFile);
+ fclose (pFile);
+ }
+
+ //estimate file breaks
+ unsigned long int chunkSize = 0;
+ chunkSize = size / proc;
+
+ //file to small to divide by processors
+ if (chunkSize == 0) { proc = 1; filePos.push_back(size); return filePos; }
+
+ //for each process seekg to closest file break and search for next '>' char. make that the filebreak
+ for (int i = 0; i < proc; i++) {
+ unsigned long int spot = (i+1) * chunkSize;
+
+ ifstream in;
+ openInputFile(filename, in);
+ in.seekg(spot);
+
+ //look for next '>'
+ unsigned long int newSpot = spot;
+ while (!in.eof()) {
+ char c = in.get();
+ if (c == '>') { in.putback(c); newSpot = in.tellg(); break; }
+ }
+
+ //there was not another sequence before the end of the file
+ unsigned long int sanityPos = in.tellg();
+ if (sanityPos = -1) { break; }
+ else { filePos.push_back(newSpot); }
+
+ in.close();
+ }
+
+ //save end pos
+ filePos.push_back(size);
+
+ //sanity check filePos
+ for (int i = 0; i < (filePos.size()-1); i++) {
+ if (filePos[(i+1)] <= filePos[i]) { filePos.erase(filePos.begin()+(i+1)); i--; }
+ }
+
+ proc = (filePos.size() - 1);
+
+ return filePos;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "divideFile");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+bool MothurOut::isTrue(string f){
+ try {
+
+ for (int i = 0; i < f.length(); i++) { f[i] = toupper(f[i]); }
+
+ if ((f == "TRUE") || (f == "T")) { return true; }
+ else { return false; }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "isTrue");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+float MothurOut::roundDist(float dist, int precision){
+ try {
+ return int(dist * precision + 0.5)/float(precision);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "roundDist");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+float MothurOut::ceilDist(float dist, int precision){
+ try {
+ return int(ceil(dist * precision))/float(precision);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "ceilDist");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+int MothurOut::getNumNames(string names){
+ try {
+ int count = 0;
+
+ if(names != ""){
+ count = 1;
+ for(int i=0;i<names.size();i++){
+ if(names[i] == ','){
+ count++;
+ }
+ }
+ }
+
+ return count;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getNumNames");
+ exit(1);
+ }
+}
+
+/**************************************************************************************************/
+
+vector<vector<double> > MothurOut::binomial(int maxOrder){
+ try {
+ vector<vector<double> > binomial(maxOrder+1);
+
+ for(int i=0;i<=maxOrder;i++){
+ binomial[i].resize(maxOrder+1);
+ binomial[i][0]=1;
+ binomial[0][i]=0;
+ }
+ binomial[0][0]=1;
+
+ binomial[1][0]=1;
+ binomial[1][1]=1;
+
+ for(int i=2;i<=maxOrder;i++){
+ binomial[1][i]=0;
+ }
+
+ for(int i=2;i<=maxOrder;i++){
+ for(int j=1;j<=maxOrder;j++){
+ if(i==j){ binomial[i][j]=1; }
+ if(j>i) { binomial[i][j]=0; }
+ else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; }
+ }
+ }
+
+ return binomial;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "binomial");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+int MothurOut::factorial(int num){
+ try {
+ int total = 1;
+
+ for (int i = 1; i <= num; i++) {
+ total *= i;
+ }
+
+ return total;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "factorial");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+int MothurOut::getNumSeqs(ifstream& file){
+ try {
+ int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
+ file.seekg(0);
+ return numSeqs;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getNumSeqs");
+ exit(1);
+ }
+}
+/***********************************************************************/
+void MothurOut::getNumSeqs(ifstream& file, int& numSeqs){
+ try {
+ string input;
+ numSeqs = 0;
+ while(!file.eof()){
+ input = getline(file);
+ if (input.length() != 0) {
+ if(input[0] == '>'){ numSeqs++; }
+ }
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getNumSeqs");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+//This function parses the estimator options and puts them in a vector
+void MothurOut::splitAtChar(string& estim, vector<string>& container, char symbol) {
+ try {
+ string individual;
+
+ while (estim.find_first_of(symbol) != -1) {
+ individual = estim.substr(0,estim.find_first_of(symbol));
+ if ((estim.find_first_of(symbol)+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of(symbol)+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtChar");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+
+//This function parses the estimator options and puts them in a vector
+void MothurOut::splitAtDash(string& estim, vector<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtDash");
+ exit(1);
+ }
+}
+
+/***********************************************************************/
+//This function parses the label options and puts them in a set
+void MothurOut::splitAtDash(string& estim, set<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ container.insert(individual);
+ }
+ }
+ //get last one
+ container.insert(estim);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtDash");
+ exit(1);
+ }
+}
+/***********************************************************************/
+//This function parses the line options and puts them in a set
+void MothurOut::splitAtDash(string& estim, set<int>& container) {
+ try {
+ string individual;
+ int lineNum;
+
+ while (estim.find_first_of('-') != -1) {
+ individual = estim.substr(0,estim.find_first_of('-'));
+ if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
+ estim = estim.substr(estim.find_first_of('-')+1, estim.length());
+ convert(individual, lineNum); //convert the string to int
+ container.insert(lineNum);
+ }
+ }
+ //get last one
+ convert(estim, lineNum); //convert the string to int
+ container.insert(lineNum);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtDash");
+ exit(1);
+ }
+}
+/***********************************************************************/
+//This function parses the a string and puts peices in a vector
+void MothurOut::splitAtComma(string& estim, vector<string>& container) {
+ try {
+ string individual;
+
+ while (estim.find_first_of(',') != -1) {
+ individual = estim.substr(0,estim.find_first_of(','));
+ if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
+ estim = estim.substr(estim.find_first_of(',')+1, estim.length());
+ container.push_back(individual);
+ }
+ }
+ //get last one
+ container.push_back(estim);
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtComma");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+//This function splits up the various option parameters
+void MothurOut::splitAtComma(string& prefix, string& suffix){
+ try {
+ prefix = suffix.substr(0,suffix.find_first_of(','));
+ if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string
+ suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
+ string space = " ";
+ while(suffix.at(0) == ' ')
+ suffix = suffix.substr(1, suffix.length());
+ }
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtComma");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+//This function separates the key value from the option value i.e. dist=96_...
+void MothurOut::splitAtEquals(string& key, string& value){
+ try {
+ if(value.find_first_of('=') != -1){
+ key = value.substr(0,value.find_first_of('='));
+ if ((value.find_first_of('=')+1) <= value.length()) {
+ value = value.substr(value.find_first_of('=')+1, value.length());
+ }
+ }else{
+ key = value;
+ value = 1;
+ }
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "splitAtEquals");
+ exit(1);
+ }
+}
+
+/**************************************************************************************************/
+
+bool MothurOut::inUsersGroups(string groupname, vector<string> Groups) {
+ try {
+ for (int i = 0; i < Groups.size(); i++) {
+ if (groupname == Groups[i]) { return true; }
+ }
+ return false;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "inUsersGroups");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+//returns true if any of the strings in first vector are in second vector
+bool MothurOut::inUsersGroups(vector<string> groupnames, vector<string> Groups) {
+ try {
+
+ for (int i = 0; i < groupnames.size(); i++) {
+ if (inUsersGroups(groupnames[i], Groups)) { return true; }
+ }
+ return false;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "inUsersGroups");
+ exit(1);
+ }
+}
+/***********************************************************************/
+//this function determines if the user has given us labels that are smaller than the given label.
+//if so then it returns true so that the calling function can run the previous valid distance.
+//it's a "smart" distance function. It also checks for invalid labels.
+bool MothurOut::anyLabelsToProcess(string label, set<string>& userLabels, string errorOff) {
+ try {
+
+ set<string>::iterator it;
+ vector<float> orderFloat;
+ map<string, float> userMap; //the conversion process removes trailing 0's which we need to put back
+ map<string, float>::iterator it2;
+ float labelFloat;
+ bool smaller = false;
+
+ //unique is the smallest line
+ if (label == "unique") { return false; }
+ else {
+ if (convertTestFloat(label, labelFloat)) {
+ convert(label, labelFloat);
+ }else { //cant convert
+ return false;
+ }
+ }
+
+ //go through users set and make them floats
+ for(it = userLabels.begin(); it != userLabels.end(); ++it) {
+
+ float temp;
+ if ((*it != "unique") && (convertTestFloat(*it, temp) == true)){
+ convert(*it, temp);
+ orderFloat.push_back(temp);
+ userMap[*it] = temp;
+ }else if (*it == "unique") {
+ orderFloat.push_back(-1.0);
+ userMap["unique"] = -1.0;
+ }else {
+ if (errorOff == "") { cout << *it << " is not a valid label." << endl; }
+ userLabels.erase(*it);
+ it--;
+ }
+ }
+
+ //sort order
+ sort(orderFloat.begin(), orderFloat.end());
+
+ /*************************************************/
+ //is this label bigger than any of the users labels
+ /*************************************************/
+
+ //loop through order until you find a label greater than label
+ for (int i = 0; i < orderFloat.size(); i++) {
+ if (orderFloat[i] < labelFloat) {
+ smaller = true;
+ if (orderFloat[i] == -1) {
+ if (errorOff == "") { cout << "Your file does not include the label unique." << endl; }
+ userLabels.erase("unique");
+ }
+ else {
+ if (errorOff == "") { cout << "Your file does not include the label " << endl; }
+ string s = "";
+ for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {
+ if (it2->second == orderFloat[i]) {
+ s = it2->first;
+ //remove small labels
+ userLabels.erase(s);
+ break;
+ }
+ }
+ if (errorOff == "") {cout << s << ". I will use the next smallest distance. " << endl; }
+ }
+ //since they are sorted once you find a bigger one stop looking
+ }else { break; }
+ }
+
+ return smaller;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "anyLabelsToProcess");
+ exit(1);
+ }
+}
+
+/**************************************************************************************************/
+bool MothurOut::checkReleaseVersion(ifstream& file, string version) {
+ try {
+
+ bool good = true;
+
+ string line = getline(file);
+
+ //before we added this check
+ if (line[0] != '#') { good = false; }
+ else {
+ //rip off #
+ line = line.substr(1);
+
+ vector<string> versionVector;
+ splitAtChar(version, versionVector, '.');
+
+ //check file version
+ vector<string> linesVector;
+ splitAtChar(line, linesVector, '.');
+
+ if (versionVector.size() != linesVector.size()) { good = false; }
+ else {
+ for (int j = 0; j < versionVector.size(); j++) {
+ int num1, num2;
+ convert(versionVector[j], num1);
+ convert(linesVector[j], num2);
+
+ //if mothurs version is newer than this files version, then we want to remake it
+ if (num1 > num2) { good = false; break; }
+ }
+ }
+
+ }
+
+ if (!good) { file.close(); }
+ else { file.seekg(0); }
+
+ return good;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "checkReleaseVersion");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
+
+
+
+
+
void setReleaseDate(string r) { releaseDate = r; }
string getVersion() { return version; }
void setVersion(string r) { version = r; }
-
+
+ //functions from mothur.h
+ //file operations
+ vector<unsigned long int> divideFile(string, int&);
+ vector<unsigned long int> setFilePosEachLine(string, int&);
+ vector<unsigned long int> setFilePosFasta(string, int&);
+ string sortFile(string, string);
+ void appendFiles(string, string);
+ int renameFile(string, string); //oldname, newname
+ string getFullPathName(string);
+ string hasPath(string);
+ string getExtension(string);
+ string getPathName(string);
+ string getSimpleName(string);
+ string getRootName(string);
+ bool isBlank(string);
+ int openOutputFile(string, ofstream&);
+ int openOutputFileAppend(string, ofstream&);
+ int openInputFile(string, ifstream&);
+ int openInputFile(string, ifstream&, string); //no error given
+ string getline(ifstream&);
+ string getline(istringstream&);
+ void gobble(istream&);
+ void gobble(istringstream&);
+
+ //searchs and checks
+ bool checkReleaseVersion(ifstream&, string);
+ bool anyLabelsToProcess(string, set<string>&, string);
+ bool inUsersGroups(vector<string>, vector<string>);
+ bool inUsersGroups(string, vector<string>);
+ void getNumSeqs(ifstream&, int&);
+ int getNumSeqs(ifstream&);
+ int getNumNames(string);
+ bool isTrue(string);
+
+
+ //string manipulation
+ void splitAtEquals(string&, string&);
+ void splitAtComma(string&, string&);
+ void splitAtComma(string&, vector<string>&);
+ void splitAtDash(string&, set<int>&);
+ void splitAtDash(string&, set<string>&);
+ void splitAtDash(string&, vector<string>&);
+ void splitAtChar(string&, vector<string>&, char);
+
+ //math operation
+ int factorial(int num);
+ vector<vector<double> > binomial(int);
+ float ceilDist(float, int);
+ float roundDist(float, int);
int control_pressed;
bool executing;
NameAssignment::NameAssignment(string nameMapFile){
m = MothurOut::getInstance();
- openInputFile(nameMapFile, fileHandle);
+ m->openInputFile(nameMapFile, fileHandle);
}
}else{ m->mothurOut(firstCol + " is already in namesfile. I will use first definition."); m->mothurOutEndLine(); }
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
fileHandle.close();
/******************************************************************************************************************/
NastReport::NastReport() {
- output = "";
+ try {
+ m = MothurOut::getInstance();
+ output = "";
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "NastReport");
+ exit(1);
+ }
}
/******************************************************************************************************************/
string NastReport::getHeaders() {
- output = "";
-
- output += "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
- output += "SearchMethod\tSearchScore\t";
- output += "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
- output += "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
- output += "LongestInsert\t";
- output += "SimBtwnQuery&Template\n";
-
- return output;
+ try {
+ output = "";
+
+ output += "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
+ output += "SearchMethod\tSearchScore\t";
+ output += "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
+ output += "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
+ output += "LongestInsert\t";
+ output += "SimBtwnQuery&Template\n";
+
+ return output;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "getHeaders");
+ exit(1);
+ }
}
/******************************************************************************************************************/
NastReport::NastReport(string candidateReportFName) {
- openOutputFile(candidateReportFName, candidateReportFile);
-
- candidateReportFile << "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
- candidateReportFile << "SearchMethod\tSearchScore\t";
- candidateReportFile << "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
- candidateReportFile << "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
- candidateReportFile << "LongestInsert\t";
- candidateReportFile << "SimBtwnQuery&Template" << endl;
+ try {
+ m = MothurOut::getInstance();
+ m->openOutputFile(candidateReportFName, candidateReportFile);
+
+ candidateReportFile << "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
+ candidateReportFile << "SearchMethod\tSearchScore\t";
+ candidateReportFile << "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
+ candidateReportFile << "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
+ candidateReportFile << "LongestInsert\t";
+ candidateReportFile << "SimBtwnQuery&Template" << endl;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "NastReport");
+ exit(1);
+ }
}
/******************************************************************************************************************/
NastReport::~NastReport() {
- candidateReportFile.close();
+ try {
+ candidateReportFile.close();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "~NastReport");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::print(){
-
- candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
- candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
-
- candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
- candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
- candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
- candidateReportFile << longestInsert << '\t';
- candidateReportFile << setprecision(2) << similarityToTemplate;
-
- candidateReportFile << endl;
- candidateReportFile.flush();
+ try {
+ candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
+ candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
+
+ candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
+ candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
+ candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
+ candidateReportFile << longestInsert << '\t';
+ candidateReportFile << setprecision(2) << similarityToTemplate;
+
+ candidateReportFile << endl;
+ candidateReportFile.flush();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "print");
+ exit(1);
+ }
}
/******************************************************************************************************************/
string NastReport::getReport(){
-
- output = "";
-
- output += queryName + '\t' + toString(queryLength) + '\t' + templateName + '\t' + toString(templateLength) + '\t';
-
- string temp = toString(searchScore);
- int pos = temp.find_last_of('.'); //find deicmal point if their is one
-
- //if there is a decimal
- if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
- else{ temp += ".00"; }
-
- output += searchMethod + '\t' + temp + '\t';
- output += alignmentMethod + '\t' + toString(candidateStartPosition) + "\t" + toString(candidateEndPosition) + '\t';
- output += toString(templateStartPosition) + "\t" + toString(templateEndPosition) + '\t';
- output += toString(pairwiseAlignmentLength) + '\t' + toString(totalGapsInQuery) + '\t' + toString(totalGapsInTemplate) + '\t';
- output += toString(longestInsert) + '\t';
-
- temp = toString(similarityToTemplate);
- pos = temp.find_last_of('.'); //find deicmal point if their is one
-
- //if there is a decimal
- if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
- else{ temp += ".00"; }
-
- output += temp + '\n';
-
- return output;
+ try {
+ output = "";
+
+ output += queryName + '\t' + toString(queryLength) + '\t' + templateName + '\t' + toString(templateLength) + '\t';
+
+ string temp = toString(searchScore);
+ int pos = temp.find_last_of('.'); //find deicmal point if their is one
+
+ //if there is a decimal
+ if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
+ else{ temp += ".00"; }
+
+ output += searchMethod + '\t' + temp + '\t';
+ output += alignmentMethod + '\t' + toString(candidateStartPosition) + "\t" + toString(candidateEndPosition) + '\t';
+ output += toString(templateStartPosition) + "\t" + toString(templateEndPosition) + '\t';
+ output += toString(pairwiseAlignmentLength) + '\t' + toString(totalGapsInQuery) + '\t' + toString(totalGapsInTemplate) + '\t';
+ output += toString(longestInsert) + '\t';
+
+ temp = toString(similarityToTemplate);
+ pos = temp.find_last_of('.'); //find deicmal point if their is one
+
+ //if there is a decimal
+ if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
+ else{ temp += ".00"; }
+
+ output += temp + '\n';
+
+ return output;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "getReport");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::setCandidate(Sequence* candSeq){
- queryName = candSeq->getName();
- queryLength = candSeq->getNumBases();
+ try {
+ queryName = candSeq->getName();
+ queryLength = candSeq->getNumBases();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "setCandidate");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::setTemplate(Sequence* tempSeq){
- templateName = tempSeq->getName();
- templateLength = tempSeq->getNumBases();
+ try {
+ templateName = tempSeq->getName();
+ templateLength = tempSeq->getNumBases();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "setTemplate");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::setSearchParameters(string method, float score){
- searchMethod = method;
- searchScore = score;
+ try {
+ searchMethod = method;
+ searchScore = score;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "setSearchParameters");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::setAlignmentParameters(string method, Alignment* align){
- alignmentMethod = method;
-
- candidateStartPosition = align->getCandidateStartPos();
- candidateEndPosition = align->getCandidateEndPos();
- templateStartPosition = align->getTemplateStartPos();
- templateEndPosition = align->getTemplateEndPos();
- pairwiseAlignmentLength = align->getPairwiseLength();
-
- totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
- totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
+ try {
+ alignmentMethod = method;
+
+ candidateStartPosition = align->getCandidateStartPos();
+ candidateEndPosition = align->getCandidateEndPos();
+ templateStartPosition = align->getTemplateStartPos();
+ templateEndPosition = align->getTemplateEndPos();
+ pairwiseAlignmentLength = align->getPairwiseLength();
+
+ totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
+ totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "setAlignmentParameters");
+ exit(1);
+ }
}
/******************************************************************************************************************/
void NastReport::setNastParameters(Nast nast){
-
- longestInsert = nast.getMaxInsertLength();
- similarityToTemplate = nast.getSimilarityScore();
-
+ try {
+
+ longestInsert = nast.getMaxInsertLength();
+ similarityToTemplate = nast.getSimilarityScore();
+ }
+ catch(exception& e) {
+ m->errorOut(e, "NastReport", "setNastParameters");
+ exit(1);
+ }
}
/******************************************************************************************************************/
int totalGapsInQuery, totalGapsInTemplate;
float similarityToTemplate;
ofstream candidateReportFile;
+ MothurOut* m;
};
/******************************************************************************************************************/
string key, value;
//reads in parameters and values
while((option.find_first_of(',') != -1)) { //while there are parameters
- splitAtComma(value, option);
- splitAtEquals(key, value);
+ m->splitAtComma(value, option);
+ m->splitAtEquals(key, value);
parameters[key] = value;
}
//in case there is no comma and to get last parameter after comma
- splitAtEquals(key, option);
+ m->splitAtEquals(key, option);
parameters[key] = option;
}
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = 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 = "";
- outputDir += hasPath(listFile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(listFile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { m->mothurOut("label is a required parameter for the otu.hierarchy command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(label, labels);
+ m->splitAtDash(label, labels);
if (labels.size() != 2) { m->mothurOut("You must provide 2 labels."); m->mothurOutEndLine(); abort = true; }
}
}
ofstream out;
- string outputFileName = outputDir + getRootName(getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + ".otu.hierarchy";
- openOutputFile(outputFileName, out);
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + ".otu.hierarchy";
+ m->openOutputFile(outputFileName, out);
//go through each bin in "big" otu and output the bins in "little" otu which created it
for (int i = 0; i < lists[1].getNumBins(); i++) {
//open file
ifstream in;
- openInputFile(listFile, in);
+ m->openInputFile(listFile, in);
//get first list vector in file
ListVector* list = NULL;
pos = in.tellg();
lastPos = pos;
list = new ListVector(in);
- gobble(in);
+ m->gobble(in);
lastLabel = list->getLabel();
}
}
//you have a label the user want that is smaller than this label and the last label has not already been processed
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
int savePos = in.tellg();
if (!in.eof()) {
pos = in.tellg();
list = new ListVector(in);
- gobble(in);
+ m->gobble(in);
}else { list = NULL; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; allLines = 1; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
}
if (abort == true) { return 0; }
//set fileroot
- string fileroot = outputDir + getRootName(getSimpleName(listfile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
vector<string> outputNames;
//fill filehandles with neccessary ofstreams
string filename = fileroot + groupMap->namesOfGroups[i] + ".list";
outputNames.push_back(filename);
- openOutputFile(filename, *temp);
+ m->openOutputFile(filename, *temp);
}
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
string bin = list->get(i);
vector<string> names;
- splitAtComma(bin, names); //parses bin into individual sequence names
+ m->splitAtComma(bin, names); //parses bin into individual sequence names
//parse bin into list of sequences in each group
for (int j = 0; j < names.size(); j++) {
it = parameters.find("sff");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["sff"] = inputDir + it->second; }
}
it = parameters.find("oligos");
//user has given an oligos file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["oligos"] = inputDir + it->second; }
}
outputDir = validParameter.validFile(parameters, "outputdir", false);
if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(sffFile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(sffFile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
if (abort == true) { return 0; }
ifstream inSFF;
- openInputFile(sffFile, inSFF);
+ m->openInputFile(sffFile, inSFF);
cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
getOligos(flowFileNames);
}
else{
- flowFileNames.push_back(new ofstream((outputDir + getRootName(getSimpleName(sffFile)) + "flow").c_str(), ios::ate));
- outputNames.push_back((outputDir + getRootName(getSimpleName(sffFile)) + "flow"));
+ flowFileNames.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow").c_str(), ios::ate));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + "flow"));
}
for(int i=0;i<flowFileNames.size();i++){
if (m->control_pressed) { for(int i=0;i<flowFileNames.size();i++){ flowFileNames[i]->close(); } return 0; }
// ofstream fastaFile;
-// openOutputFile(getRootName(sffFile) + "fasta", fastaFile);
+// m->openOutputFile(m->getRootName(sffFile) + "fasta", fastaFile);
// ofstream qualFile;
-// openOutputFile(getRootName(sffFile) + "qual", qualFile);
+// m->openOutputFile(m->getRootName(sffFile) + "qual", qualFile);
- string commonHeader = getline(inSFF);
- string magicNumber = getline(inSFF);
- string version = getline(inSFF);
- string indexOffset = getline(inSFF);
- string indexLength = getline(inSFF);
+ string commonHeader = m->getline(inSFF);
+ string magicNumber = m->getline(inSFF);
+ string version = m->getline(inSFF);
+ string indexOffset = m->getline(inSFF);
+ string indexLength = m->getline(inSFF);
int numReads = parseHeaderLineToInt(inSFF);
- string headerLength = getline(inSFF);
- string keyLength = getline(inSFF);
+ string headerLength = m->getline(inSFF);
+ string keyLength = m->getline(inSFF);
int numFlows = parseHeaderLineToInt(inSFF);
- string flowgramCode = getline(inSFF);
- string flowChars = getline(inSFF);
- string keySequence = getline(inSFF);
- gobble(inSFF);
+ string flowgramCode = m->getline(inSFF);
+ string flowChars = m->getline(inSFF);
+ string keySequence = m->getline(inSFF);
+ m->gobble(inSFF);
string seqName;
bool good = 0;
inSFF >> seqName;
seqName = seqName.substr(1);
- gobble(inSFF);
+ m->gobble(inSFF);
string runPrefix = parseHeaderLineToString(inSFF);
string regionNumber = parseHeaderLineToString(inSFF);
string xyLocation = parseHeaderLineToString(inSFF);
- gobble(inSFF);
+ m->gobble(inSFF);
string runName = parseHeaderLineToString(inSFF);
string analysisName = parseHeaderLineToString(inSFF);
string fullPath = parseHeaderLineToString(inSFF);
- gobble(inSFF);
+ m->gobble(inSFF);
string readHeaderLen = parseHeaderLineToString(inSFF);
string nameLength = parseHeaderLineToString(inSFF);
int clipQualRight = parseHeaderLineToInt(inSFF);
string clipAdapLeft = parseHeaderLineToString(inSFF);
string clipAdapRight = parseHeaderLineToString(inSFF);
- gobble(inSFF);
+ m->gobble(inSFF);
vector<float> flowVector = parseHeaderLineToFloatVector(inSFF, numFlows);
vector<int> flowIndices = parseHeaderLineToIntVector(inSFF, numBases);
string bases = parseHeaderLineToString(inSFF);
string qualityScores = parseHeaderLineToString(inSFF);
- gobble(inSFF);
+ m->gobble(inSFF);
try {
ifstream inOligos;
- openInputFile(oligoFile, inOligos);
+ m->openInputFile(oligoFile, inOligos);
string type, oligo, group;
while(!inOligos.eof()){
inOligos >> type;
- if(type[0] == '#'){ getline(inOligos); } // get rest of line if there's any crap there
+ if(type[0] == '#'){ m->getline(inOligos); } // get rest of line if there's any crap there
else{
inOligos >> oligo;
barcodes[oligo]=index++;
groupVector.push_back(group);
- outSFFFlowVec.push_back(new ofstream((outputDir + getRootName(getSimpleName(sffFile)) + group + ".flow").c_str(), ios::ate));
- outputNames.push_back((outputDir + getRootName(getSimpleName(sffFile)) + group + "flow"));
+ outSFFFlowVec.push_back(new ofstream((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + ".flow").c_str(), ios::ate));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(sffFile)) + group + "flow"));
}
}
- gobble(inOligos);
+ m->gobble(inOligos);
}
inOligos.close();
}
}
- gobble(file);
+ m->gobble(file);
return number;
}
char c = file.get();
if (c == ':'){
- gobble(file);
- text = getline(file);
+ m->gobble(file);
+ text = m->getline(file);
break;
}
}
- gobble(file);
+ m->gobble(file);
return text;
}
break;
}
}
- gobble(file);
+ m->gobble(file);
return floatVector;
}
break;
}
}
- gobble(file);
+ m->gobble(file);
return intVector;
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; globaldata->Groups.clear(); }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
T = globaldata->gTree;
tmap = globaldata->gTreemap;
- if(outputDir == "") { outputDir += hasPath(globaldata->getTreeFile()); }
- output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + ".parsimony", itersString);
- outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + ".parsimony");
+ if(outputDir == "") { outputDir += m->hasPath(globaldata->getTreeFile()); }
+ output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".parsimony", itersString);
+ outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".parsimony");
- sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".psummary";
- openOutputFile(sumFile, outSum);
+ sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".psummary";
+ m->openOutputFile(sumFile, outSum);
outputNames.push_back(sumFile);
}else { //user wants random distribution
savetmap = globaldata->gTreemap;
getUserInput();
- if(outputDir == "") { outputDir += hasPath(randomtree); }
- output = new ColumnFile(outputDir+ getSimpleName(randomtree), itersString);
- outputNames.push_back(outputDir+ getSimpleName(randomtree));
+ if(outputDir == "") { outputDir += m->hasPath(randomtree); }
+ output = new ColumnFile(outputDir+ m->getSimpleName(randomtree), itersString);
+ outputNames.push_back(outputDir+ m->getSimpleName(randomtree));
}
//set users groups to analyze
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = 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 = "";
- outputDir += hasPath(phylipfile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(phylipfile); //if user entered a file with a path then preserve it
}
//error checking on files
vector<string> names;
vector<vector<double> > D;
- fbase = outputDir + getRootName(getSimpleName(filename));
+ fbase = outputDir + m->getRootName(m->getSimpleName(filename));
read(filename, names, D);
void PCACommand::read(string fname, vector<string>& names, vector<vector<double> >& D){
try {
ifstream f;
- openInputFile(fname, f);
+ m->openInputFile(fname, f);
//check whether matrix is square
char d;
- int m = 1;
+ int q = 1;
int numSeqs;
string name;
//is d a number meaning its square
if(isalnum(d)){
- m = 1;
+ q = 1;
break;
}
//is d a line return meaning its lower triangle
if(d == '\n'){
- m = 2;
+ q = 2;
break;
}
}
f.close();
//reopen to get back to beginning
- openInputFile(fname, f);
- read_phylip(f, m, names, D);
+ m->openInputFile(fname, f);
+ read_phylip(f, q, names, D);
}
catch(exception& e) {
m->errorOut(e, "PCACommand", "read");
}
//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 = hasPath(globaldata->getTreeFile()); }
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(globaldata->getTreeFile()); }
if (globaldata->gTree.size() == 0) {//no trees were read
m->mothurOut("You must execute the read.tree command, before you may execute the phylo.diversity command."); m->mothurOutEndLine(); abort = true; }
convert(temp, iters);
temp = validParameter.validFile(parameters, "rarefy", false); if (temp == "not found") { temp = "F"; }
- rarefy = isTrue(temp);
+ rarefy = m->isTrue(temp);
if (!rarefy) { iters = 1; }
temp = validParameter.validFile(parameters, "summary", false); if (temp == "not found") { temp = "T"; }
- summary = isTrue(temp);
+ summary = m->isTrue(temp);
temp = validParameter.validFile(parameters, "scale", false); if (temp == "not found") { temp = "F"; }
- scale = isTrue(temp);
+ scale = m->isTrue(temp);
temp = validParameter.validFile(parameters, "collect", false); if (temp == "not found") { temp = "F"; }
- collect = isTrue(temp);
+ collect = m->isTrue(temp);
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; Groups = globaldata->gTreemap->namesOfGroups; globaldata->Groups = Groups; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
ofstream outSum, outRare, outCollect;
- string outSumFile = outputDir + getRootName(getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv.summary";
- string outRareFile = outputDir + getRootName(getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv.rarefaction";
- string outCollectFile = outputDir + getRootName(getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv";
+ string outSumFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv.summary";
+ string outRareFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv.rarefaction";
+ string outCollectFile = outputDir + m->getRootName(m->getSimpleName(globaldata->getTreeFile())) + toString(i+1) + ".phylodiv";
- if (summary) { openOutputFile(outSumFile, outSum); outputNames.push_back(outSumFile); }
- if (rarefy) { openOutputFile(outRareFile, outRare); outputNames.push_back(outRareFile); }
- if (collect) { openOutputFile(outCollectFile, outCollect); outputNames.push_back(outCollectFile); }
+ if (summary) { m->openOutputFile(outSumFile, outSum); outputNames.push_back(outSumFile); }
+ if (rarefy) { m->openOutputFile(outRareFile, outRare); outputNames.push_back(outRareFile); }
+ if (collect) { m->openOutputFile(outCollectFile, outCollect); outputNames.push_back(outCollectFile); }
int numLeafNodes = trees[i]->getNumLeaves();
//create a vector containing indexes of leaf nodes, randomize it, select nodes to send to calculator
vector<int> randomLeaf;
for (int j = 0; j < numLeafNodes; j++) {
- if (inUsersGroups(trees[i]->tree[j].getGroup(), globaldata->Groups) == true) { //is this a node from the group the user selected.
+ if (m->inUsersGroups(trees[i]->tree[j].getGroup(), globaldata->Groups) == true) { //is this a node from the group the user selected.
randomLeaf.push_back(j);
}
}
try {
ifstream in;
- openInputFile(userTfile, in);
+ m->openInputFile(userTfile, in);
//read in users taxonomy file and add sequences to tree
string name, tax;
while(!in.eof()){
- in >> name >> tax; gobble(in);
+ in >> name >> tax; m->gobble(in);
addSeqToTree(name, tax);
try {
//read version
- string line = getline(in); gobble(in);
+ string line = m->getline(in); m->gobble(in);
int num;
- in >> num; gobble(in);
+ in >> num; m->gobble(in);
tree.resize(num);
- in >> maxLevel; gobble(in);
+ in >> maxLevel; m->gobble(in);
//read the tree file
for (int i = 0; i < tree.size(); i++) {
tree[i].total = 0;
- gobble(in);
+ m->gobble(in);
//if (tree[i].level > maxLevel) { maxLevel = tree[i].level; }
}
delete buffer;
//read version
- getline(iss); gobble(iss);
+ m->getline(iss); m->gobble(iss);
- iss >> numNodes; gobble(iss);
+ iss >> numNodes; m->gobble(iss);
tree.resize(numNodes);
for (int i = 0; i < tree.size(); i++) {
- iss >> tree[i].name >> tree[i].level >> tree[i].parent; gobble(iss);
+ iss >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(iss);
}
//read genus nodes
int numGenus = 0;
- iss >> numGenus; gobble(iss);
+ iss >> numGenus; m->gobble(iss);
int gnode, gsize;
totals.clear();
for (int i = 0; i < numGenus; i++) {
- iss >> gnode >> gsize; gobble(iss);
+ iss >> gnode >> gsize; m->gobble(iss);
uniqueTaxonomies[gnode] = gnode;
totals.push_back(gsize);
#else
//read version
- string line = getline(in); gobble(in);
+ string line = m->getline(in); m->gobble(in);
- in >> numNodes; gobble(in);
+ in >> numNodes; m->gobble(in);
tree.resize(numNodes);
for (int i = 0; i < tree.size(); i++) {
- in >> tree[i].name >> tree[i].level >> tree[i].parent; gobble(in);
+ in >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(in);
}
//read genus nodes
int numGenus = 0;
- in >> numGenus; gobble(in);
+ in >> numGenus; m->gobble(in);
int gnode, gsize;
totals.clear();
for (int i = 0; i < numGenus; i++) {
- in >> gnode >> gsize; gobble(in);
+ in >> gnode >> gsize; m->gobble(in);
uniqueTaxonomies[gnode] = gnode;
totals.push_back(gsize);
MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer
if (pid == 0) {
- positions = setFilePosEachLine(tfile, num);
+ positions = m->setFilePosEachLine(tfile, num);
//send file positions to all processes
for(int i = 1; i < processors; i++) {
#else
ifstream in;
- openInputFile(tfile, in);
+ m->openInputFile(tfile, in);
//read in users taxonomy file and add sequences to tree
while(!in.eof()){
- in >> name >> tax; gobble(in);
+ in >> name >> tax; m->gobble(in);
addSeqToTree(name, tax);
}
try {
ofstream out;
- openOutputFile(file, out);
+ m->openOutputFile(file, out);
map<string, int>::iterator itBin;
map<string, int>::iterator childPointer;
#endif
ofstream outTree;
- openOutputFile(treefilename, outTree);
+ m->openOutputFile(treefilename, outTree);
//output mothur version
outTree << "#" << m->getVersion() << endl;
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = 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 = "";
- outputDir += hasPath(taxonomyFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(taxonomyFileName); //if user entered a file with a path then preserve it
}
string temp = validParameter.validFile(parameters, "cutoff", false);
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; allLines = 1; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
if (m->control_pressed) { delete tree; return 0; }
- string fileroot = outputDir + getRootName(getSimpleName(taxonomyFileName));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(taxonomyFileName));
ofstream outList;
string outputListFile = fileroot + "tx.list";
- openOutputFile(outputListFile, outList);
+ m->openOutputFile(outputListFile, outList);
ofstream outSabund;
string outputSabundFile = fileroot + "tx.sabund";
- openOutputFile(outputSabundFile, outSabund);
+ m->openOutputFile(outputSabundFile, outSabund);
ofstream outRabund;
string outputRabundFile = fileroot + "tx.rabund";
- openOutputFile(outputRabundFile, outRabund);
+ m->openOutputFile(outputRabundFile, outRabund);
outputNames.push_back(outputListFile);
outputNames.push_back(outputSabundFile);
try {
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string first, second;
map<string, string>::iterator itNames;
while(!in.eof()) {
- in >> first >> second; gobble(in);
+ in >> first >> second; m->gobble(in);
itNames = namemap.find(first);
if (itNames == namemap.end()) {
m->mothurOut("Getting conservation... "); cout.flush();
if (consfile == "") {
m->mothurOut("Calculating probability of conservation for your template sequences. This can take a while... I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command. Providing the .freq file will improve speed. "); cout.flush();
- probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + getSimpleName(templateFileName));
+ probabilityProfile = decalc->calcFreq(templateSeqs, outputDir + m->getSimpleName(templateFileName));
if (m->control_pressed) { return 0; }
m->mothurOut("Done."); m->mothurOutEndLine();
}else { probabilityProfile = readFreq(); m->mothurOut("Done."); }
string noOutliers, outliers;
if ((!filter) && (seqMask == "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.quan";
+ noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.quan";
}else if ((!filter) && (seqMask != "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.masked.quan";
+ noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.masked.quan";
}else if ((filter) && (seqMask != "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "masked.quan";
+ noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan";
}else if ((filter) && (seqMask == "")) {
- noOutliers = outputDir + getRootName(getSimpleName(templateFileName)) + "pintail.filtered." + getSimpleName(getRootName(fastafile)) + "quan";
+ noOutliers = outputDir + m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan";
}
decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size());
istringstream iss (tempBuf,istringstream::in);
//read version
- string line = getline(iss); gobble(iss);
+ string line = m->getline(iss); m->gobble(iss);
while(!iss.eof()) {
iss >> pos >> num;
prob.push_back(Pi);
}
- gobble(iss);
+ m->gobble(iss);
}
MPI_File_close(&inMPI);
#else
ifstream in;
- openInputFile(consfile, in);
+ m->openInputFile(consfile, in);
//read version
- string line = getline(in); gobble(in);
+ string line = m->getline(in); m->gobble(in);
while(!in.eof()){
prob.push_back(Pi);
}
- gobble(in);
+ m->gobble(in);
}
in.close();
//write out data to file so parent can read it
ofstream out;
string s = toString(getpid()) + ".temp";
- openOutputFile(s, out);
+ m->openOutputFile(s, out);
//output observed distances
for (int i=0;i<processors;i++) {
ifstream in;
string s = toString(processIDS[i]) + ".temp";
- openInputFile(s, in);
+ m->openInputFile(s, in);
vector< vector<float> > quan;
quan.resize(100);
int num;
in >> num;
- gobble(in);
+ m->gobble(in);
vector<float> q; float w;
for (int j = 0; j < num; j++) {
}
quan[h] = q;
- gobble(in);
+ m->gobble(in);
}
delete buffer;
//read version
- string line = getline(iss); gobble(iss);
+ string line = m->getline(iss); m->gobble(iss);
while(!iss.eof()) {
iss >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine;
quan.push_back(temp);
- gobble(iss);
+ m->gobble(iss);
}
MPI_File_close(&inMPI);
#else
ifstream in;
- openInputFile(quanfile, in);
+ m->openInputFile(quanfile, in);
//read version
- string line = getline(in); gobble(in);
+ string line = m->getline(in); m->gobble(in);
while(!in.eof()){
quan.push_back(temp);
- gobble(in);
+ m->gobble(in);
}
in.close();
#endif
//delete FileName;
#else
ofstream outQuan;
- openOutputFile(file, outQuan);
+ m->openOutputFile(file, outQuan);
outQuan << outputString;
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = 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 = "";
- outputDir += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
if (numSeqs == 0) { m->mothurOut("Error reading fasta file...please correct."); m->mothurOutEndLine(); return 0; }
if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); return 0; }
- string fileroot = outputDir + getRootName(getSimpleName(fastafile));
- string newFastaFile = fileroot + "precluster" + getExtension(fastafile);
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
+ string newFastaFile = fileroot + "precluster" + m->getExtension(fastafile);
string newNamesFile = fileroot + "precluster.names";
ofstream outFasta;
ofstream outNames;
- openOutputFile(newFastaFile, outFasta);
- openOutputFile(newNamesFile, outNames);
+ m->openOutputFile(newFastaFile, outFasta);
+ m->openOutputFile(newNamesFile, outNames);
//sort seqs by number of identical seqs
alignSeqs.sort(comparePriority);
//ifstream inNames;
ifstream inFasta;
- //openInputFile(namefile, inNames);
- openInputFile(fastafile, inFasta);
+ //m->openInputFile(namefile, inNames);
+ m->openInputFile(fastafile, inFasta);
//string firstCol, secondCol, nameString;
length = 0;
//inNames >> firstCol >> secondCol;
//nameString = secondCol;
- //gobble(inNames);
+ //m->gobble(inNames);
//int size = 1;
//while (secondCol.find_first_of(',') != -1) {
// size++;
// secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
//}
- Sequence seq(inFasta); gobble(inFasta);
+ Sequence seq(inFasta); m->gobble(inFasta);
if (seq.getName() != "") { //can get "" if commented line is at end of fasta file
if (namefile != "") {
void PreClusterCommand::readNameFile(){
try {
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string firstCol, secondCol;
while (!in.eof()) {
- in >> firstCol >> secondCol; gobble(in);
+ in >> firstCol >> secondCol; m->gobble(in);
names[firstCol] = secondCol;
int size = 1;
int score;
//string line;
- //getline(qFile, line);
+ //m->getline(qFile, line);
//istringstream nameStream(line);
qFile >> seqName;
while (!qFile.eof()) { char c = qFile.get(); if (c == 10 || c == 13 || c == -1){ break; } } // get rest of line
- gobble(qFile);
+ m->gobble(qFile);
if (seqName == "") { m->mothurOut("Error reading quality file, name blank at position, " + toString(qFile.tellg())); m->mothurOutEndLine(); }
else {
seqName = seqName.substr(1);
}
- //getline(qFile, line);
+ //m->getline(qFile, line);
//istringstream qualStream(line);
//while(qualStream){
qFile >> score;
qScores.push_back(score);
}
- gobble(qFile);
+ m->gobble(qFile);
}
catch(exception& e) {
class RareCalc {
public:
- RareCalc(RAbundVector* b) : bins(b), numSeqs(b->getNumSeqs()), maxRank(b->getMaxRank()), numBins(b->getNumBins()) { bMatrix = binomial(numSeqs+1); m = MothurOut::getInstance(); }
+ RareCalc(RAbundVector* b) : bins(b), numSeqs(b->getNumSeqs()), maxRank(b->getMaxRank()), numBins(b->getNumBins()) { m = MothurOut::getInstance(); bMatrix = m->binomial(numSeqs+1); }
EstOutput getValues(int);
string getName() { return "rarecalc"; }
private:
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//make sure the user has already run the read.otu command
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sobs"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; }
for (int p = 0; p < inputFileNames.size(); p++) {
- string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
globaldata->inputFileName = inputFileNames[p];
if (m->control_pressed) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } return 0; }
userLabels.erase(order->getLabel());
}
- if ((anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = order->getLabel();
delete order;
input = globaldata->ginput;
vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
- string sharedFileRoot = getRootName(filename);
+ string sharedFileRoot = m->getRootName(filename);
//clears file before we start to write to it below
for (int i=0; i<lookup.size(); i++) {
for (int i = 0; i < lookup.size(); i++) {
RAbundVector rav = lookup[i]->getRAbundVector();
- openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
+ m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
rav.print(*(filehandles[lookup[i]->getGroup()]));
(*(filehandles[lookup[i]->getGroup()])).close();
}
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sharedobserved"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
}
globaldata->Groups = Groups;
convert(temp, nIters);
temp = validParameter.validFile(parameters, "jumble", false); if (temp == "not found") { temp = "T"; }
- if (isTrue(temp)) { jumble = true; }
+ if (m->isTrue(temp)) { jumble = true; }
else { jumble = false; }
globaldata->jumble = jumble;
if (abort == false) {
- string fileNameRoot = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName));
// format = globaldata->getFormat();
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
if (m->control_pressed) { return 0; }
ifstream fileHandle;
- openInputFile(blastfile, fileHandle);
+ m->openInputFile(blastfile, fileHandle);
string firstName, secondName, eScore, currentRow;
string repeatName = "";
if (!hclusterWanted) {
matrix = new SparseMatrix();
}else{
- overlapFile = getRootName(blastfile) + "overlap.dist";
- distFile = getRootName(blastfile) + "hclusterDists.dist";
+ overlapFile = m->getRootName(blastfile) + "overlap.dist";
+ distFile = m->getRootName(blastfile) + "hclusterDists.dist";
- openOutputFile(overlapFile, outOverlap);
- openOutputFile(distFile, outDist);
+ m->openOutputFile(overlapFile, outOverlap);
+ m->openOutputFile(distFile, outDist);
}
if (m->control_pressed) {
if (!fileHandle.eof()) {
//read in line from file
fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
- gobble(fileHandle);
+ m->gobble(fileHandle);
currentRow = firstName;
lengthThisSeq = numBases;
//read in line from file
fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
//cout << firstName << '\t' << secondName << '\t' << percentId << '\t' << numBases << '\t' << mismatch << '\t' << gap << '\t' << startQuery << '\t' << endQuery << '\t' << startRef << '\t' << endRef << '\t' << eScore << '\t' << score << endl;
- gobble(fileHandle);
+ m->gobble(fileHandle);
string temp = firstName + secondName; //to check if this file has repeat lines, ie. is this a blast instead of a blscreen file
int num = 1;
ifstream in;
- openInputFile(blastfile, in);
+ m->openInputFile(blastfile, in);
//ofstream outName;
- //openOutputFile((blastfile + ".tempOutNames"), outName);
+ //m->openOutputFile((blastfile + ".tempOutNames"), outName);
//read first line
in >> prevName;
for (int i = 0; i < 11; i++) { in >> hold; }
- gobble(in);
+ m->gobble(in);
//save name in nameMap
nameMap->push_back(prevName);
in >> name;
for (int i = 0; i < 11; i++) { in >> hold; }
- gobble(in);
+ m->gobble(in);
//is this a new name?
if (name != prevName) {
in.close();
//write out names file
- //string outNames = getRootName(blastfile) + "names";
+ //string outNames = m->getRootName(blastfile) + "names";
//ofstream out;
- //openOutputFile(outNames, out);
+ //m->openOutputFile(outNames, out);
//nameMap->print(out);
//out.close();
if (m->control_pressed) { return 0; }
- if (sortWanted) { OutPutFile = sortFile(distFile, outputDir); }
+ if (sortWanted) { OutPutFile = m->sortFile(distFile, outputDir); }
else { OutPutFile = distFile; } //for use by clusters splitMatrix to convert a phylip matrix to column
return 0;
ofstream out;
string tempFile = distFile + ".column.temp";
- openInputFile(distFile, in); gobble(in);
- openOutputFile(tempFile, out);
+ m->openInputFile(distFile, in); m->gobble(in);
+ m->openOutputFile(tempFile, out);
float distance;
int square, nseqs;
ifstream in2;
ofstream out2;
- string outputFile = getRootName(distFile) + "column.dist";
- openInputFile(tempFile, in2);
- openOutputFile(outputFile, out2);
+ string outputFile = m->getRootName(distFile) + "column.dist";
+ m->openInputFile(tempFile, in2);
+ m->openOutputFile(outputFile, out2);
int first, second;
float dist;
in2 >> first >> second >> dist;
out2 << rowToName[first] << '\t' << rowToName[second] << '\t' << dist << endl;
- gobble(in2);
+ m->gobble(in2);
}
in2.close();
out2.close();
ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){
- successOpen = openInputFile(distFile, fileHandle);
+ successOpen = m->openInputFile(distFile, fileHandle);
}
}
reading->update(itA->second * nseqs);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
if(lt == 0){ // oops, it was square
fileHandle.close(); //let's start over
D->clear(); //let's start over
- openInputFile(distFile, fileHandle); //let's start over
+ m->openInputFile(distFile, fileHandle); //let's start over
while(fileHandle){
fileHandle >> firstName >> secondName >> distance;
reading->update(itA->second * nseqs);
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
}
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
convert(temp, precision);
temp = validParameter.validFile(parameters, "sim", false); if (temp == "not found") { temp = "F"; }
- sim = isTrue(temp);
+ sim = m->isTrue(temp);
globaldata->sim = sim;
temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; }
if (format == "matrix") {
ifstream in;
- openInputFile(distFileName, in);
+ m->openInputFile(distFileName, in);
matrix = new FullMatrix(in); //reads the matrix file
in.close();
if (matrix->getNumSeqs() < groupMap->getNumSeqs()) {
m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences."); m->mothurOutEndLine();
//create new group file
- if(outputDir == "") { outputDir += hasPath(groupfile); }
+ if(outputDir == "") { outputDir += m->hasPath(groupfile); }
- string newGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "editted.groups";
+ string newGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "editted.groups";
outputNames.push_back(newGroupFile);
ofstream outGroups;
- openOutputFile(newGroupFile, outGroups);
+ m->openOutputFile(newGroupFile, outGroups);
for (int i = 0; i < matrix->getNumSeqs(); i++) {
if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); remove(newGroupFile.c_str()); return 0; }
ReadOTUFile::ReadOTUFile(string pf): philFile(pf){
m = MothurOut::getInstance();
- //openInputFile(philFile, fileHandle);
+ //m->openInputFile(philFile, fileHandle);
}
/***********************************************************************/
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("order");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["order"] = inputDir + it->second; }
}
it = parameters.find("shared");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["shared"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("sabund");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["sabund"] = inputDir + it->second; }
}
it = parameters.find("rabund");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["rabund"] = inputDir + it->second; }
}
it = parameters.find("ordergroup");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["ordergroup"] = inputDir + it->second; }
}
it = parameters.find("relabund");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["relabund"] = inputDir + it->second; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
globaldata->labels = labels;
}
ReadPhylipMatrix::ReadPhylipMatrix(string distFile){
- successOpen = openInputFile(distFile, fileHandle);
+ successOpen = m->openInputFile(distFile, fileHandle);
}
int ReadTree::readSpecialChar(istream& f, char c, string name) {
try {
- gobble(f);
+ m->gobble(f);
char d = f.get();
if(d == EOF){
exit(1);
}
if(d == ')' && f.peek() == '\n'){
- gobble(f);
+ m->gobble(f);
}
return d;
}
int ReadTree::readNodeChar(istream& f) {
try {
// while(isspace(d=f.get())) {;}
- gobble(f);
+ m->gobble(f);
char d = f.get();
if(d == EOF){
m->mothurOut("Error: Missing branch length in input tree.\n");
exit(1);
}
- gobble(f);
+ m->gobble(f);
return b;
}
catch(exception& e) {
//save trees for later commands
globaldata->gTree.push_back(T);
- gobble(filehandle);
+ m->gobble(filehandle);
}
//if you are a nexus file
}else if ((c = filehandle.peek()) == '#') {
class ReadNewickTree : public ReadTree {
public:
- ReadNewickTree(string file) : treeFile(file) { openInputFile(file, filehandle); readOk = 0; }
+ ReadNewickTree(string file) : treeFile(file) { m->openInputFile(file, filehandle); readOk = 0; }
~ReadNewickTree() {};
int read();
it = parameters.find("tree");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["tree"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
globaldata->names.clear();
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string first, second;
map<string, string>::iterator itNames;
while(!in.eof()) {
- in >> first >> second; gobble(in);
+ in >> first >> second; m->gobble(in);
itNames = globaldata->names.find(first);
if (itNames == globaldata->names.end()) {
//we need a list of names in your namefile to use above when removing extra seqs above so we don't remove them
vector<string> dupNames;
- splitAtComma(second, dupNames);
+ m->splitAtComma(second, dupNames);
for (int i = 0; i < dupNames.size(); i++) { nameMap[dupNames[i]] = dupNames[i]; }
}else { m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); globaldata->names.clear(); return 1; }
it = parameters.find("alignreport");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//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("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("accnos");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["accnos"] = inputDir + it->second; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("taxonomy");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["taxonomy"] = inputDir + it->second; }
}
string usedDups = "true";
- string temp = validParameter.validFile(parameters, "dups", false); if (temp == "not found") { temp = "false"; usedDups = ""; }
- dups = isTrue(temp);
+ string temp = validParameter.validFile(parameters, "dups", false);
+ if (temp == "not found") {
+ if (namefile != "") { temp = "true"; }
+ else { temp = "false"; usedDups = ""; }
+ }
+ dups = m->isTrue(temp);
if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide at least one of the following: fasta, name, group, taxonomy, alignreport or list."); m->mothurOutEndLine(); abort = true; }
m->mothurOut("The remove.seqs command reads an .accnos file and at least one of the following file types: fasta, name, group, list, taxonomy or alignreport file.\n");
m->mothurOut("It outputs a file containing the sequences NOT in the .accnos file.\n");
m->mothurOut("The remove.seqs command parameters are accnos, fasta, name, group, list, taxonomy, alignreport and dups. You must provide accnos and at least one of the file parameters.\n");
- m->mothurOut("The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=false. \n");
+ m->mothurOut("The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=true. \n");
m->mothurOut("The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
m->mothurOut("Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
m->mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
//**********************************************************************************************************************
int RemoveSeqsCommand::readFasta(){
try {
- if (outputDir == "") { outputDir += hasPath(fastafile); }
- string outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + "pick" + getExtension(fastafile);
+ if (outputDir == "") { outputDir += m->hasPath(fastafile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
string name;
bool wroteSomething = false;
currSeq.printSequence(out);
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int RemoveSeqsCommand::readList(){
try {
- if (outputDir == "") { outputDir += hasPath(listfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + "pick" + getExtension(listfile);
+ if (outputDir == "") { outputDir += m->hasPath(listfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" + m->getExtension(listfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(listfile, in);
+ m->openInputFile(listfile, in);
bool wroteSomething = false;
newList.print(out);
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int RemoveSeqsCommand::readName(){
try {
- if (outputDir == "") { outputDir += hasPath(namefile); }
- string outputFileName = outputDir + getRootName(getSimpleName(namefile)) + "pick" + getExtension(namefile);
+ if (outputDir == "") { outputDir += m->hasPath(namefile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
string name, firstCol, secondCol;
bool wroteSomething = false;
name = secondCol.substr(0,secondCol.find_first_of(','));
secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
parsedNames.push_back(name);
-
}
//get name after last ,
}
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int RemoveSeqsCommand::readGroup(){
try {
- if (outputDir == "") { outputDir += hasPath(groupfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(groupfile)) + "pick" + getExtension(groupfile);
+ if (outputDir == "") { outputDir += m->hasPath(groupfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(groupfile, in);
+ m->openInputFile(groupfile, in);
string name, group;
bool wroteSomething = false;
out << name << '\t' << group << endl;
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//**********************************************************************************************************************
int RemoveSeqsCommand::readTax(){
try {
- if (outputDir == "") { outputDir += hasPath(taxfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(taxfile)) + "pick" + getExtension(taxfile);
+ if (outputDir == "") { outputDir += m->hasPath(taxfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(taxfile, in);
+ m->openInputFile(taxfile, in);
string name, tax;
bool wroteSomething = false;
out << name << '\t' << tax << endl;
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
//alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name
int RemoveSeqsCommand::readAlign(){
try {
- if (outputDir == "") { outputDir += hasPath(alignfile); }
- string outputFileName = outputDir + getRootName(getSimpleName(alignfile)) + "pick.align.report";
+ if (outputDir == "") { outputDir += m->hasPath(alignfile); }
+ string outputFileName = outputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
ofstream out;
- openOutputFile(outputFileName, out);
+ m->openOutputFile(outputFileName, out);
ifstream in;
- openInputFile(alignfile, in);
+ m->openInputFile(alignfile, in);
string name, junk;
bool wroteSomething = false;
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
out.close();
try {
ifstream in;
- openInputFile(accnosfile, in);
+ m->openInputFile(accnosfile, in);
string name;
while(!in.eof()){
names.insert(name);
- gobble(in);
+ m->gobble(in);
}
in.close();
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = 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 = "";
- outputDir += hasPath(fasta); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fasta); //if user entered a file with a path then preserve it
}
}
if (abort == true) { return 0; }
ifstream inFASTA;
- openInputFile(fasta, inFASTA);
+ m->openInputFile(fasta, inFASTA);
ofstream outFASTA;
- string reverseFile = outputDir + getRootName(getSimpleName(fasta)) + "rc" + getExtension(fasta);
- openOutputFile(reverseFile, outFASTA);
+ string reverseFile = outputDir + m->getRootName(m->getSimpleName(fasta)) + "rc" + m->getExtension(fasta);
+ m->openOutputFile(reverseFile, outFASTA);
while(!inFASTA.eof()){
if (m->control_pressed) { inFASTA.close(); outFASTA.close(); remove(reverseFile.c_str()); return 0; }
- Sequence currSeq(inFASTA); gobble(inFASTA);
+ Sequence currSeq(inFASTA); m->gobble(inFASTA);
if (currSeq.getName() != "") {
currSeq.reverseComplement();
currSeq.printSequence(outFASTA);
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
it = parameters.find("alignreport");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["alignreport"] = 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 = "";
- outputDir += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
if (abort == true) { return 0; }
- string goodSeqFile = outputDir + getRootName(getSimpleName(fastafile)) + "good" + getExtension(fastafile);
- string badSeqFile = outputDir + getRootName(getSimpleName(fastafile)) + "bad" + getExtension(fastafile);
- string badAccnosFile = outputDir + getRootName(getSimpleName(fastafile)) + "bad.accnos";
+ string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "good" + m->getExtension(fastafile);
+ string badAccnosFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
int numFastaSeqs = 0;
set<string> badSeqNames;
MPI_File inMPI;
MPI_File outMPIGood;
- MPI_File outMPIBad;
MPI_File outMPIBadAccnos;
int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
char outGoodFilename[1024];
strcpy(outGoodFilename, goodSeqFile.c_str());
- char outBadFilename[1024];
- strcpy(outBadFilename, badSeqFile.c_str());
-
char outBadAccnosFilename[1024];
strcpy(outBadAccnosFilename, badAccnosFile.c_str());
MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer
MPI_File_open(MPI_COMM_WORLD, outGoodFilename, outMode, MPI_INFO_NULL, &outMPIGood);
- MPI_File_open(MPI_COMM_WORLD, outBadFilename, outMode, MPI_INFO_NULL, &outMPIBad);
MPI_File_open(MPI_COMM_WORLD, outBadAccnosFilename, outMode, MPI_INFO_NULL, &outMPIBadAccnos);
- if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBad); MPI_File_close(&outMPIBadAccnos); return 0; }
+ if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBadAccnos); return 0; }
if (pid == 0) { //you are the root process
- MPIPos = setFilePosFasta(fastafile, numFastaSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastafile, numFastaSeqs); //fills MPIPos, returns numSeqs
//send file positions to all processes
for(int i = 1; i < processors; i++) {
if(pid == (processors - 1)){ numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor; }
//align your part
- driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBad, outMPIBadAccnos, MPIPos, badSeqNames);
+ driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBadAccnos, MPIPos, badSeqNames);
- if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBadAccnos); MPI_File_close(&outMPIBad); return 0; }
+ if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBadAccnos); return 0; }
for (int i = 1; i < processors; i++) {
if(pid == (processors - 1)){ numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor; }
//align your part
- driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBad, outMPIBadAccnos, MPIPos, badSeqNames);
+ driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBadAccnos, MPIPos, badSeqNames);
- if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBad); MPI_File_close(&outMPIBadAccnos); return 0; }
+ if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBadAccnos); return 0; }
//send bad list
int badSize = badSeqNames.size();
//close files
MPI_File_close(&inMPI);
MPI_File_close(&outMPIGood);
- MPI_File_close(&outMPIBad);
MPI_File_close(&outMPIBadAccnos);
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastafile, processors);
+ vector<unsigned long int> positions = m->divideFile(fastafile, processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
if(processors == 1){
- numFastaSeqs = driver(lines[0], goodSeqFile, badSeqFile, badAccnosFile, fastafile, badSeqNames);
+ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames);
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
}else{
processIDS.resize(0);
- numFastaSeqs = createProcesses(goodSeqFile, badSeqFile, badAccnosFile, fastafile, badSeqNames);
+ numFastaSeqs = createProcesses(goodSeqFile, badAccnosFile, fastafile, badSeqNames);
rename((goodSeqFile + toString(processIDS[0]) + ".temp").c_str(), goodSeqFile.c_str());
- rename((badSeqFile + toString(processIDS[0]) + ".temp").c_str(), badSeqFile.c_str());
rename((badAccnosFile + toString(processIDS[0]) + ".temp").c_str(), badAccnosFile.c_str());
//append alignment and report files
for(int i=1;i<processors;i++){
- appendFiles((goodSeqFile + toString(processIDS[i]) + ".temp"), goodSeqFile);
+ m->appendFiles((goodSeqFile + toString(processIDS[i]) + ".temp"), goodSeqFile);
remove((goodSeqFile + toString(processIDS[i]) + ".temp").c_str());
-
- appendFiles((badSeqFile + toString(processIDS[i]) + ".temp"), badSeqFile);
- remove((badSeqFile + toString(processIDS[i]) + ".temp").c_str());
-
- appendFiles((badAccnosFile + toString(processIDS[i]) + ".temp"), badAccnosFile);
+
+ m->appendFiles((badAccnosFile + toString(processIDS[i]) + ".temp"), badAccnosFile);
remove((badAccnosFile + toString(processIDS[i]) + ".temp").c_str());
}
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
//read badSeqs in because root process doesnt know what other "bad" seqs the children found
ifstream inBad;
- int ableToOpen = openInputFile(badAccnosFile, inBad, "no error");
+ int ableToOpen = m->openInputFile(badAccnosFile, inBad, "no error");
if (ableToOpen == 0) {
badSeqNames.clear();
string tempName;
while (!inBad.eof()) {
- inBad >> tempName; gobble(inBad);
+ inBad >> tempName; m->gobble(inBad);
badSeqNames.insert(tempName);
}
inBad.close();
}
}
#else
- numFastaSeqs = driver(lines[0], goodSeqFile, badSeqFile, badAccnosFile, fastafile, badSeqNames);
+ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames);
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
#endif
badSeqNames.clear();
string tempName;
while (!iss.eof()) {
- iss >> tempName; gobble(iss);
+ iss >> tempName; m->gobble(iss);
badSeqNames.insert(tempName);
}
#endif
if(namefile != "" && groupfile != "") {
screenNameGroupFile(badSeqNames);
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
}else if(namefile != "") {
screenNameGroupFile(badSeqNames);
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
}else if(groupfile != "") { screenGroupFile(badSeqNames); } // this screens just the group
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
if(alignreport != "") { screenAlignReport(badSeqNames); }
- if (m->control_pressed) { remove(goodSeqFile.c_str()); remove(badSeqFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodSeqFile.c_str()); return 0; }
#ifdef USE_MPI
}
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
m->mothurOut(goodSeqFile); m->mothurOutEndLine();
- m->mothurOut(badSeqFile); m->mothurOutEndLine();
m->mothurOut(badAccnosFile); m->mothurOutEndLine();
for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
m->mothurOutEndLine();
int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
try {
ifstream inputNames;
- openInputFile(namefile, inputNames);
+ m->openInputFile(namefile, inputNames);
set<string> badSeqGroups;
string seqName, seqList, group;
set<string>::iterator it;
- string goodNameFile = outputDir + getRootName(getSimpleName(namefile)) + "good" + getExtension(namefile);
- string badNameFile = outputDir + getRootName(getSimpleName(namefile)) + "bad" + getExtension(namefile);
-
- outputNames.push_back(goodNameFile); outputNames.push_back(badNameFile);
+ string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + "good" + m->getExtension(namefile);
+ outputNames.push_back(goodNameFile);
- ofstream goodNameOut; openOutputFile(goodNameFile, goodNameOut);
- ofstream badNameOut; openOutputFile(badNameFile, badNameOut);
+ ofstream goodNameOut; m->openOutputFile(goodNameFile, goodNameOut);
while(!inputNames.eof()){
- if (m->control_pressed) { goodNameOut.close(); badNameOut.close(); inputNames.close(); remove(goodNameFile.c_str()); remove(badNameFile.c_str()); return 0; }
+ if (m->control_pressed) { goodNameOut.close(); inputNames.close(); remove(goodNameFile.c_str()); return 0; }
inputNames >> seqName >> seqList;
it = badSeqNames.find(seqName);
if(it != badSeqNames.end()){
badSeqNames.erase(it);
- badNameOut << seqName << '\t' << seqList << endl;
+
if(namefile != ""){
int start = 0;
for(int i=0;i<seqList.length();i++){
else{
goodNameOut << seqName << '\t' << seqList << endl;
}
- gobble(inputNames);
+ m->gobble(inputNames);
}
inputNames.close();
goodNameOut.close();
- badNameOut.close();
//we were unable to remove some of the bad sequences
if (badSeqNames.size() != 0) {
if(groupfile != ""){
ifstream inputGroups;
- openInputFile(groupfile, inputGroups);
+ m->openInputFile(groupfile, inputGroups);
- string goodGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "good" + getExtension(groupfile);
- string badGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "bad" + getExtension(groupfile);
-
- outputNames.push_back(goodGroupFile); outputNames.push_back(badGroupFile);
+ string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
+ outputNames.push_back(goodGroupFile);
- ofstream goodGroupOut; openOutputFile(goodGroupFile, goodGroupOut);
- ofstream badGroupOut; openOutputFile(badGroupFile, badGroupOut);
+ ofstream goodGroupOut; m->openOutputFile(goodGroupFile, goodGroupOut);
while(!inputGroups.eof()){
- if (m->control_pressed) { goodGroupOut.close(); badGroupOut.close(); inputGroups.close(); remove(goodNameFile.c_str()); remove(badNameFile.c_str()); remove(goodGroupFile.c_str()); remove(badGroupFile.c_str()); return 0; }
+ if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodNameFile.c_str()); remove(goodGroupFile.c_str()); return 0; }
inputGroups >> seqName >> group;
if(it != badSeqGroups.end()){
badSeqGroups.erase(it);
- badGroupOut << seqName << '\t' << group << endl;
}
else{
goodGroupOut << seqName << '\t' << group << endl;
}
- gobble(inputGroups);
+ m->gobble(inputGroups);
}
inputGroups.close();
goodGroupOut.close();
- badGroupOut.close();
//we were unable to remove some of the bad sequences
if (badSeqGroups.size() != 0) {
for (it = badSeqGroups.begin(); it != badSeqGroups.end(); it++) {
- m->mothurOut("Your namefile does not include the sequence " + *it + " please correct.");
+ m->mothurOut("Your groupfile does not include the sequence " + *it + " please correct.");
m->mothurOutEndLine();
}
}
int ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
try {
ifstream inputGroups;
- openInputFile(groupfile, inputGroups);
+ m->openInputFile(groupfile, inputGroups);
string seqName, group;
set<string>::iterator it;
- string goodGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "good" + getExtension(groupfile);
- string badGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "bad" + getExtension(groupfile);
-
- outputNames.push_back(goodGroupFile); outputNames.push_back(badGroupFile);
-
- ofstream goodGroupOut; openOutputFile(goodGroupFile, goodGroupOut);
- ofstream badGroupOut; openOutputFile(badGroupFile, badGroupOut);
+ string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
+ outputNames.push_back(goodGroupFile);
+ ofstream goodGroupOut; m->openOutputFile(goodGroupFile, goodGroupOut);
while(!inputGroups.eof()){
- if (m->control_pressed) { goodGroupOut.close(); badGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); remove(badGroupFile.c_str()); return 0; }
+ if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); return 0; }
inputGroups >> seqName >> group;
it = badSeqNames.find(seqName);
if(it != badSeqNames.end()){
badSeqNames.erase(it);
- badGroupOut << seqName << '\t' << group << endl;
}
else{
goodGroupOut << seqName << '\t' << group << endl;
}
- gobble(inputGroups);
+ m->gobble(inputGroups);
}
- if (m->control_pressed) { goodGroupOut.close(); badGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); remove(badGroupFile.c_str()); return 0; }
+ if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); remove(goodGroupFile.c_str()); return 0; }
//we were unable to remove some of the bad sequences
if (badSeqNames.size() != 0) {
inputGroups.close();
goodGroupOut.close();
- badGroupOut.close();
- if (m->control_pressed) { remove(goodGroupFile.c_str()); remove(badGroupFile.c_str()); }
-
+ if (m->control_pressed) { remove(goodGroupFile.c_str()); }
return 0;
int ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
try {
ifstream inputAlignReport;
- openInputFile(alignreport, inputAlignReport);
+ m->openInputFile(alignreport, inputAlignReport);
string seqName, group;
set<string>::iterator it;
- string goodAlignReportFile = outputDir + getRootName(getSimpleName(alignreport)) + "good" + getExtension(alignreport);
- string badAlignReportFile = outputDir + getRootName(getSimpleName(alignreport)) + "bad" + getExtension(alignreport);
-
- outputNames.push_back(goodAlignReportFile); outputNames.push_back(badAlignReportFile);
-
- ofstream goodAlignReportOut; openOutputFile(goodAlignReportFile, goodAlignReportOut);
- ofstream badAlignReportOut; openOutputFile(badAlignReportFile, badAlignReportOut);
+ string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + "good" + m->getExtension(alignreport);
+ outputNames.push_back(goodAlignReportFile);
+ ofstream goodAlignReportOut; m->openOutputFile(goodAlignReportFile, goodAlignReportOut);
while (!inputAlignReport.eof()) { // need to copy header
char c = inputAlignReport.get();
goodAlignReportOut << c;
- badAlignReportOut << c;
if (c == 10 || c == 13){ break; }
}
while(!inputAlignReport.eof()){
- if (m->control_pressed) { goodAlignReportOut.close(); badAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); remove(badAlignReportFile.c_str()); return 0; }
+ if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); return 0; }
inputAlignReport >> seqName;
it = badSeqNames.find(seqName);
if(it != badSeqNames.end()){
badSeqNames.erase(it);
- badAlignReportOut << seqName << '\t' << line;
}
else{
goodAlignReportOut << seqName << '\t' << line;
}
- gobble(inputAlignReport);
+ m->gobble(inputAlignReport);
}
- if (m->control_pressed) { goodAlignReportOut.close(); badAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); remove(badAlignReportFile.c_str()); return 0; }
+ if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); remove(goodAlignReportFile.c_str()); return 0; }
//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 file does not include the sequence " + *it + " please correct.");
+ m->mothurOut("Your alignreport file does not include the sequence " + *it + " please correct.");
m->mothurOutEndLine();
}
}
inputAlignReport.close();
goodAlignReportOut.close();
- badAlignReportOut.close();
- if (m->control_pressed) { remove(goodAlignReportFile.c_str()); remove(badAlignReportFile.c_str()); return 0; }
+ if (m->control_pressed) { remove(goodAlignReportFile.c_str()); return 0; }
return 0;
}
//**********************************************************************************************************************
-int ScreenSeqsCommand::driver(linePair* filePos, string goodFName, string badFName, string badAccnosFName, string filename, set<string>& badSeqNames){
+int ScreenSeqsCommand::driver(linePair* filePos, string goodFName, string badAccnosFName, string filename, set<string>& badSeqNames){
try {
ofstream goodFile;
- openOutputFile(goodFName, goodFile);
-
- ofstream badFile;
- openOutputFile(badFName, badFile);
+ m->openOutputFile(goodFName, goodFile);
ofstream badAccnosFile;
- openOutputFile(badAccnosFName, badAccnosFile);
+ m->openOutputFile(badAccnosFName, badAccnosFile);
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
if (m->control_pressed) { return 0; }
- Sequence currSeq(inFASTA); gobble(inFASTA);
+ Sequence currSeq(inFASTA); m->gobble(inFASTA);
if (currSeq.getName() != "") {
bool goodSeq = 1; // innocent until proven guilty
if(goodSeq == 1 && startPos != -1 && startPos < currSeq.getStartPos()) { goodSeq = 0; }
currSeq.printSequence(goodFile);
}
else{
- currSeq.printSequence(badFile);
badAccnosFile << currSeq.getName() << endl;
badSeqNames.insert(currSeq.getName());
}
goodFile.close();
inFASTA.close();
- badFile.close();
badAccnosFile.close();
return count;
}
//**********************************************************************************************************************
#ifdef USE_MPI
-int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& goodFile, MPI_File& badFile, MPI_File& badAccnosFile, vector<unsigned long int>& MPIPos, set<string>& badSeqNames){
+int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& goodFile, MPI_File& badAccnosFile, vector<unsigned long int>& MPIPos, set<string>& badSeqNames){
try {
string outputString = "";
MPI_Status statusGood;
- MPI_Status statusBad;
MPI_Status statusBadAccnos;
MPI_Status status;
int pid;
delete buf2;
}
else{
- outputString = ">" + currSeq.getName() + "\n" + currSeq.getAligned() + "\n";
-
- //print bad seq to fasta
- length = outputString.length();
- char* buf2 = new char[length];
- memcpy(buf2, outputString.c_str(), length);
-
- MPI_File_write_shared(badFile, buf2, length, MPI_CHAR, &statusBad);
- delete buf2;
badSeqNames.insert(currSeq.getName());
#endif
/**************************************************************************************************/
-int ScreenSeqsCommand::createProcesses(string goodFileName, string badFileName, string badAccnos, string filename, set<string>& badSeqNames) {
+int ScreenSeqsCommand::createProcesses(string goodFileName, string badAccnos, string filename, set<string>& badSeqNames) {
try {
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
int process = 0;
processIDS.push_back(pid); //create map from line number to pid so you can append files in correct order later
process++;
}else if (pid == 0){
- num = driver(lines[process], goodFileName + toString(getpid()) + ".temp", badFileName + toString(getpid()) + ".temp", badAccnos + toString(getpid()) + ".temp", filename, badSeqNames);
+ num = driver(lines[process], goodFileName + toString(getpid()) + ".temp", badAccnos + toString(getpid()) + ".temp", filename, badSeqNames);
//pass numSeqs to parent
ofstream out;
string tempFile = filename + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
out.close();
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = filename + toString(processIDS[i]) + ".num.temp";
- openInputFile(tempFile, in);
+ m->openInputFile(tempFile, in);
if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
in.close(); remove(tempFile.c_str());
}
int screenGroupFile(set<string>);
int screenAlignReport(set<string>);
- int driver(linePair*, string, string, string, string, set<string>&);
- int createProcesses(string, string, string, string, set<string>&);
+ int driver(linePair*, string, string, string, set<string>&);
+ int createProcesses(string, string, string, set<string>&);
#ifdef USE_MPI
- int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&, set<string>&);
+ int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long int>&, set<string>&);
#endif
bool abort;
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("map");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["map"] = 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 = "";
- outputDir += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
}
readMap();
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
ofstream out;
- string outfile = outputDir + getRootName(getSimpleName(fastafile)) + "align.check";
- openOutputFile(outfile, out);
+ string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "align.check";
+ m->openOutputFile(outfile, out);
out << "name" << '\t' << "pound" << '\t' << "dash" << '\t' << "plus" << '\t' << "equal" << '\t';
out << "loop" << '\t' << "tilde" << '\t' << "total" << endl;
while(!in.eof()){
if (m->control_pressed) { in.close(); out.close(); remove(outfile.c_str()); return 0; }
- Sequence seq(in); gobble(in);
+ Sequence seq(in); m->gobble(in);
if (seq.getName() != "") {
statData data = getStats(seq.getAligned());
structMap.resize(1, 0);
ifstream in;
- openInputFile(mapfile, in);
+ m->openInputFile(mapfile, in);
while(!in.eof()){
int position;
in >> position;
structMap.push_back(position);
- gobble(in);
+ m->gobble(in);
}
in.close();
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
outputDir = validParameter.validFile(parameters, "outputdir", false);
if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(listFile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(listFile); //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...
temp = validParameter.validFile(parameters, "hard", false);
if (temp == "not found"){ hard = 0; }
- else if(!isTrue(temp)) { hard = 0; }
- else if(isTrue(temp)) { hard = 1; }
+ else if(!m->isTrue(temp)) { hard = 0; }
+ else if(m->isTrue(temp)) { hard = 1; }
// temp = validParameter.validFile(parameters, "name", true);
// if (temp == "not found") { nameFile = ""; }
//probably need some checking to confirm that the names in the distance matrix are the same as those in the list file
ifstream inputListFile;
- openInputFile(listFile, inputListFile);
+ m->openInputFile(listFile, inputListFile);
string origCutoff = "";
bool getCutoff = 0;
}
seqMap[seqName] = i;
}
- gobble(inputListFile);
+ m->gobble(inputListFile);
int lNumSeqs = seqMap.size();
int pNumSeqs = 0;
ifstream phylipFile;
- openInputFile(distFile, phylipFile);
+ m->openInputFile(distFile, phylipFile);
phylipFile >> pNumSeqs;
if(pNumSeqs != lNumSeqs){ cout << "numSeq mismatch!" << endl; }
void SensSpecCommand::processColumn(){
try{
ifstream inputListFile;
- openInputFile(listFile, inputListFile);
+ m->openInputFile(listFile, inputListFile);
string origCutoff = "";
bool getCutoff = 0;
}
}
}
- gobble(inputListFile);
+ m->gobble(inputListFile);
int numDists = (numSeqs * (numSeqs-1) / 2);
ifstream columnFile;
- openInputFile(distFile, columnFile);
+ m->openInputFile(distFile, columnFile);
string seqNameA, seqNameB, seqPairString;
double distance;
seqPairSet.erase(it);
}
- gobble(columnFile);
+ m->gobble(columnFile);
}
falsePositives += seqPairSet.size();
void SensSpecCommand::setUpOutput(){
try{
ofstream sensSpecFile;
- openOutputFile(sensSpecFileName, sensSpecFile);
+ m->openOutputFile(sensSpecFileName, sensSpecFile);
sensSpecFile << "label\tcutoff\ttp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n";
if(nPrime == 0) { negativePredictiveValue = 0; matthewsCorrCoef = 0; }
ofstream sensSpecFile;
- openOutputFileAppend(sensSpecFileName, sensSpecFile);
+ m->openOutputFileAppend(sensSpecFileName, sensSpecFile);
sensSpecFile << label << '\t' << cutoff << '\t';
sensSpecFile << truePositives << '\t' << trueNegatives << '\t' << falsePositives << '\t' << falseNegatives << '\t';
it = parameters.find("query");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["query"] = inputDir + it->second; }
}
it = parameters.find("reference");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["reference"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
outputDir = validParameter.validFile(parameters, "outputdir", false);
if (outputDir == "not found"){
outputDir = "";
- outputDir += hasPath(queryFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(queryFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
convert(temp, threshold);
errorFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".errors";
- openOutputFile(errorFileName, errorFile);
+ m->openOutputFile(errorFileName, errorFile);
printErrorHeader();
}
}
if(namesFileName != ""){ weights = getWeights(); }
ifstream queryFile;
- openInputFile(queryFileName, queryFile);
+ m->openInputFile(queryFileName, queryFile);
int totalBases = 0;
int totalMatches = 0;
string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".count";
ofstream errorCountFile;
- openOutputFile(errorCountFileName, errorCountFile);
+ m->openOutputFile(errorCountFileName, errorCountFile);
m->mothurOut("Overall error rate:\t" + toString((double)(totalBases - totalMatches) / (double)totalBases) + "\n\n");
m->mothurOut("Errors\tSequences\n");
try {
ifstream referenceFile;
- openInputFile(referenceFileName, referenceFile);
+ m->openInputFile(referenceFileName, referenceFile);
while(referenceFile){
Sequence currentSeq(referenceFile);
currentSeq.removeAmbigBases();
}
referenceSeqs.push_back(currentSeq);
- gobble(referenceFile);
+ m->gobble(referenceFile);
}
numRefs = referenceSeqs.size();
map<string, int> SeqErrorCommand::getWeights(){
ifstream nameFile;
- openInputFile(namesFileName, nameFile);
+ m->openInputFile(namesFileName, nameFile);
string seqName;
string redundantSeqs;
while(nameFile){
nameFile >> seqName >> redundantSeqs;
- nameCountMap[seqName] = getNumNames(redundantSeqs);
- gobble(nameFile);
+ nameCountMap[seqName] = m->getNumNames(redundantSeqs);
+ m->gobble(nameFile);
}
return nameCountMap;
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = 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 = "";
- outputDir += hasPath(fastafile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it
}
string temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = "1"; }
if (abort == true) { return 0; }
- string summaryFile = outputDir + getSimpleName(fastafile) + ".summary";
+ string summaryFile = outputDir + m->getSimpleName(fastafile) + ".summary";
int numSeqs = 0;
MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &statusOut);
delete buf2;
- MPIPos = setFilePosFasta(fastafile, numSeqs); //fills MPIPos, returns numSeqs
+ MPIPos = m->setFilePosFasta(fastafile, numSeqs); //fills MPIPos, returns numSeqs
for(int i = 1; i < processors; i++) {
MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- vector<unsigned long int> positions = divideFile(fastafile, processors);
+ vector<unsigned long int> positions = m->divideFile(fastafile, processors);
for (int i = 0; i < (positions.size()-1); i++) {
lines.push_back(new linePair(positions[i], positions[(i+1)]));
rename((summaryFile + toString(processIDS[0]) + ".temp").c_str(), summaryFile.c_str());
//append files
for(int i=1;i<processors;i++){
- appendFiles((summaryFile + toString(processIDS[i]) + ".temp"), summaryFile);
+ m->appendFiles((summaryFile + toString(processIDS[i]) + ".temp"), summaryFile);
remove((summaryFile + toString(processIDS[i]) + ".temp").c_str());
}
}
try {
ofstream outSummary;
- openOutputFile(sumFile, outSummary);
+ m->openOutputFile(sumFile, outSummary);
//print header if you are process 0
if (filePos->start == 0) {
}
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
in.seekg(filePos->start);
if (m->control_pressed) { in.close(); outSummary.close(); return 1; }
- Sequence current(in); gobble(in);
+ Sequence current(in); m->gobble(in);
if (current.getName() != "") {
startPosition.push_back(current.getStartPos());
//pass numSeqs to parent
ofstream out;
string tempFile = fastafile + toString(getpid()) + ".num.temp";
- openOutputFile(tempFile, out);
+ m->openOutputFile(tempFile, out);
out << num << endl;
for (int k = 0; k < startPosition.size(); k++) { out << startPosition[k] << '\t'; } out << endl;
for (int i = 0; i < processIDS.size(); i++) {
string tempFilename = fastafile + toString(processIDS[i]) + ".num.temp";
ifstream in;
- openInputFile(tempFilename, in);
+ m->openInputFile(tempFilename, in);
int temp, tempNum;
- in >> tempNum; gobble(in); num += tempNum;
- for (int k = 0; k < tempNum; k++) { in >> temp; startPosition.push_back(temp); } gobble(in);
- for (int k = 0; k < tempNum; k++) { in >> temp; endPosition.push_back(temp); } gobble(in);
- for (int k = 0; k < tempNum; k++) { in >> temp; seqLength.push_back(temp); } gobble(in);
- for (int k = 0; k < tempNum; k++) { in >> temp; ambigBases.push_back(temp); } gobble(in);
- for (int k = 0; k < tempNum; k++) { in >> temp; longHomoPolymer.push_back(temp); } gobble(in);
+ in >> tempNum; m->gobble(in); num += tempNum;
+ for (int k = 0; k < tempNum; k++) { in >> temp; startPosition.push_back(temp); } m->gobble(in);
+ for (int k = 0; k < tempNum; k++) { in >> temp; endPosition.push_back(temp); } m->gobble(in);
+ for (int k = 0; k < tempNum; k++) { in >> temp; seqLength.push_back(temp); } m->gobble(in);
+ for (int k = 0; k < tempNum; k++) { in >> temp; ambigBases.push_back(temp); } m->gobble(in);
+ for (int k = 0; k < tempNum; k++) { in >> temp; longHomoPolymer.push_back(temp); } m->gobble(in);
in.close();
remove(tempFilename.c_str());
while(fastaFile){
letter=fastaFile.get();
if((letter == '\r') || (letter == '\n')){
- gobble(fastaFile); //in case its a \r\n situation
+ m->gobble(fastaFile); //in case its a \r\n situation
break;
}
}
while(fastaFile){
letter=fastaFile.get();
if((letter == '\r') || (letter == '\n')){
- gobble(fastaFile); //in case its a \r\n situation
+ m->gobble(fastaFile); //in case its a \r\n situation
break;
}
}
if (newSequence.getName() != "") { data.push_back(newSequence); }
//takes care of white space
- gobble(filehandle);
+ m->gobble(filehandle);
}
filehandle.close();
#endif
//test to make sure directory exists
- output = getFullPathName(output);
+ output = m->getFullPathName(output);
string outTemp = output + "temp";
ofstream out;
out.open(outTemp.c_str(), ios::trunc);
#endif
//test to make sure directory exists
- input = getFullPathName(input);
+ input = m->getFullPathName(input);
string inTemp = input + "temp";
ofstream in;
in.open(inTemp.c_str(), ios::trunc);
if (name == "not found") { m->mothurOut("name is a required parameter for the set.logfile command."); abort = true; }
string temp = validParameter.validFile(parameters, "append", false); if (temp == "not found") { temp = "F"; }
- append = isTrue(temp);
+ append = m->isTrue(temp);
}
}
catch(exception& e) {
sffFilename = validParameter.validFile(parameters, "sff", false);
if (sffFilename == "not found") { m->mothurOut("sff is a required parameter for the sffinfo command."); m->mothurOutEndLine(); abort = true; }
else {
- splitAtDash(sffFilename, filenames);
+ m->splitAtDash(sffFilename, filenames);
//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 = hasPath(filenames[i]);
+ 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 = openInputFile(filenames[i], in, "noerror");
+ 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() + getSimpleName(filenames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(filenames[i]);
m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
filenames[i] = tryPath;
}
}
if (accnosName == "not found") { accnosName = ""; }
else {
hasAccnos = true;
- splitAtDash(accnosName, accnosFileNames);
+ m->splitAtDash(accnosName, accnosFileNames);
//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 = hasPath(accnosFileNames[i]);
+ 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 = openInputFile(accnosFileNames[i], in, "noerror");
+ 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() + getSimpleName(accnosFileNames[i]);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(accnosFileNames[i]);
m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
accnosFileNames[i] = tryPath;
}
}
}
string temp = validParameter.validFile(parameters, "qfile", false); if (temp == "not found"){ temp = "T"; }
- qual = isTrue(temp);
+ qual = m->isTrue(temp);
temp = validParameter.validFile(parameters, "fasta", false); if (temp == "not found"){ temp = "T"; }
- fasta = isTrue(temp);
+ fasta = m->isTrue(temp);
temp = validParameter.validFile(parameters, "flow", false); if (temp == "not found"){ temp = "F"; }
- flow = isTrue(temp);
+ flow = m->isTrue(temp);
temp = validParameter.validFile(parameters, "trim", false); if (temp == "not found"){ temp = "T"; }
- trim = isTrue(temp);
+ trim = m->isTrue(temp);
temp = validParameter.validFile(parameters, "sfftxt", false); if (temp == "not found"){ temp = "F"; }
- sfftxt = isTrue(temp);
+ sfftxt = m->isTrue(temp);
}
}
catch(exception& e) {
int SffInfoCommand::extractSffInfo(string input, string accnos){
try {
- if (outputDir == "") { outputDir += hasPath(input); }
+ if (outputDir == "") { outputDir += m->hasPath(input); }
if (accnos != "") { readAccnosFile(accnos); }
else { seqNames.clear(); }
ofstream outSfftxt, outFasta, outQual, outFlow;
string outFastaFileName, outQualFileName;
- string sfftxtFileName = outputDir + getRootName(getSimpleName(input)) + "sff.txt";
- string outFlowFileName = outputDir + getRootName(getSimpleName(input)) + "flow";
+ string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "sff.txt";
+ string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "flow";
if (trim) {
- outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "fasta";
- outQualFileName = outputDir + getRootName(getSimpleName(input)) + "qual";
+ outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "fasta";
+ outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "qual";
}else{
- outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "raw.fasta";
- outQualFileName = outputDir + getRootName(getSimpleName(input)) + "raw.qual";
+ outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.fasta";
+ outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.qual";
}
- if (sfftxt) { openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint); outputNames.push_back(sfftxtFileName); }
- if (fasta) { openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); }
- if (qual) { openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); }
- if (flow) { openOutputFile(outFlowFileName, outFlow); outputNames.push_back(outFlowFileName); }
+ if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint); outputNames.push_back(sfftxtFileName); }
+ if (fasta) { m->openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); }
+ if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); }
+ if (flow) { m->openOutputFile(outFlowFileName, outFlow); outputNames.push_back(outFlowFileName); }
ifstream in;
in.open(input.c_str(), ios::binary);
seqNames.clear();
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
string name;
while(!in.eof()){
- in >> name; gobble(in);
+ in >> name; m->gobble(in);
seqNames.insert(name);
//getting output filename
filename = globaldata->inputFileName;
- if (outputDir == "") { outputDir += hasPath(filename); }
+ if (outputDir == "") { outputDir += m->hasPath(filename); }
- filename = outputDir + getRootName(getSimpleName(filename));
+ filename = outputDir + m->getRootName(m->getSimpleName(filename));
filename = filename + "shared";
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
pickedGroups = false;
groupMap = globaldata->gGroupmap;
}
//set fileroot
- fileroot = outputDir + getRootName(getSimpleName(globaldata->getListFile()));
+ fileroot = outputDir + m->getRootName(m->getSimpleName(globaldata->getListFile()));
//clears file before we start to write to it below
for (int i=0; i<groups.size(); i++) {
groups += globaldata->Groups[i] + ".";
}
- string newGroupFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + groups + "groups";
+ string newGroupFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + groups + "groups";
ofstream outGroups;
- openOutputFile(newGroupFile, outGroups);
+ m->openOutputFile(newGroupFile, outGroups);
vector<string> names = groupMap->getNamesSeqs();
string groupName;
userLabels.erase(SharedList->getLabel());
}
- if ((anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = SharedList->getLabel();
delete SharedList;
thislookup[i]->print(out);
RAbundVector rav = thislookup[i]->getRAbundVector();
- openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
+ m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
rav.print(*(filehandles[thislookup[i]->getGroup()]));
(*(filehandles[thislookup[i]->getGroup()])).close();
}
(myIt->second)->print(out);
RAbundVector rav = (myIt->second)->getRAbundVector();
- openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
+ m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
rav.print(*(filehandles[(myIt->second)->getGroup()]));
(*(filehandles[(myIt->second)->getGroup()])).close();
}else{
int SharedCommand::createMisMatchFile() {
try {
ofstream outMisMatch;
- string outputMisMatchName = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
+ string outputMisMatchName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName));
//you have sequences in your list file that are not in your group file
if (SharedList->getNumSeqs() > groupMap->getNumSeqs()) {
outputMisMatchName += "missing.group";
m->mothurOut("For a list of names that are in your list file and not in your group file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
- openOutputFile(outputMisMatchName, outMisMatch);
+ m->openOutputFile(outputMisMatchName, outMisMatch);
map<string, string> listNames;
map<string, string>::iterator itList;
map<string, string>::iterator itMatch;
- openOutputFile(outputMisMatchName, outMisMatch);
+ m->openOutputFile(outputMisMatchName, outMisMatch);
//loop through names in seqNames and if they aren't in namesIn list output them
for (int i = 0; i < seqNames.size(); i++) {
order.clear();
ifstream in;
- openInputFile(globaldata->getOrderGroupFile(), in);
+ m->openInputFile(globaldata->getOrderGroupFile(), in);
string thisGroup;
while(!in.eof()){
- in >> thisGroup; gobble(in);
+ in >> thisGroup; m->gobble(in);
order.push_back(thisGroup);
/***********************************************************************/
void SharedListVector::set(int binNumber, string seqNames){
try {
- int nNames_old = getNumNames(data[binNumber]);
+ int nNames_old = m->getNumNames(data[binNumber]);
data[binNumber] = seqNames;
- int nNames_new = getNumNames(seqNames);
+ int nNames_new = m->getNumNames(seqNames);
if(nNames_old == 0) { numBins++; }
if(nNames_new == 0) { numBins--; }
void SharedListVector::push_back(string seqNames){
try {
data.push_back(seqNames);
- int nNames = getNumNames(seqNames);
+ int nNames = m->getNumNames(seqNames);
numBins++;
RAbundVector rav;
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
rav.push_back(binSize);
}
SAbundVector sav(maxRank+1);
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
sav.set(binSize, sav.get(binSize) + 1);
}
sav.set(0, 0);
order->setLabel(label);
for(int i=0;i<numBins;i++){
- int binSize = getNumNames(get(i)); //find number of individual in given bin
+ int binSize = m->getNumNames(get(i)); //find number of individual in given bin
names = get(i);
while (names.find_first_of(',') != -1) {
name = names.substr(0,names.find_first_of(','));
finder[globaldata->gGroupmap->namesOfGroups[i]] = temp;
finder[globaldata->gGroupmap->namesOfGroups[i]]->setLabel(label);
finder[globaldata->gGroupmap->namesOfGroups[i]]->setGroup(globaldata->gGroupmap->namesOfGroups[i]);
- if (inVector(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups)) { //if this group is in user groups
+ if (m->inUsersGroups(globaldata->gGroupmap->namesOfGroups[i], globaldata->Groups)) { //if this group is in user groups
lookup.push_back(finder[globaldata->gGroupmap->namesOfGroups[i]]);
}
}
OrderVector ov;
for(int i=0;i<data.size();i++){
- int binSize = getNumNames(data[i]);
+ int binSize = m->getNumNames(data[i]);
for(int j=0;j<binSize;j++){
ov.push_back(i);
}
}
}
- gobble(f);
+ m->gobble(f);
if (f.eof() != true) { f >> nextLabel; }
}
}
- gobble(f);
+ m->gobble(f);
if (f.eof() != true) { f >> nextLabel; }
}
- gobble(f);
+ m->gobble(f);
if (f.eof() != true) { f >> nextLabel; }
lookup[count]->push_back(inputData, groupN); //abundance, bin, group
}
- gobble(f);
+ m->gobble(f);
if (f.eof() != true) { f >> nextLabel; }
}
it = parameters.find("list");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["list"] = inputDir + it->second; }
}
it = parameters.find("group");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["group"] = inputDir + it->second; }
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
if (groupfile != "") { Groups = groupMap->namesOfGroups; }
else { m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = ""; }
}else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
}
if ((groupfile == "") && (groups != "")) { m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = ""; Groups.clear(); }
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; allLines = 1; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
string temp = validParameter.validFile(parameters, "accnos", false); if (temp == "not found") { temp = "F"; }
- accnos = isTrue(temp);
+ accnos = m->isTrue(temp);
temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "0"; }
convert(temp, cutoff);
if (abort == true) { return 0; }
if (listfile != "") { //you are using a listfile to determine abundance
- if (outputDir == "") { outputDir = hasPath(listfile); }
+ if (outputDir == "") { outputDir = m->hasPath(listfile); }
//remove old files so you can append later....
- string fileroot = outputDir + getRootName(getSimpleName(listfile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
if (Groups.size() == 0) {
remove((fileroot + "rare.list").c_str());
remove((fileroot + "abund.list").c_str());
userLabels.erase(list->getLabel());
}
- if ((anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = list->getLabel();
delete list;
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
}else { //you are using the namefile to determine abundance
- if (outputDir == "") { outputDir = hasPath(namefile); }
+ if (outputDir == "") { outputDir = m->hasPath(namefile); }
splitNames();
writeNames();
string bin = thisList->get(i);
vector<string> names;
- splitAtComma(bin, names); //parses bin into individual sequence names
+ m->splitAtComma(bin, names); //parses bin into individual sequence names
int size = names.size();
if (size <= cutoff) {
ofstream aout;
ofstream rout;
- string rare = outputDir + getRootName(getSimpleName(listfile)) + "rare.list";
- openOutputFileAppend(rare, rout);
+ string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + "rare.list";
+ m->openOutputFileAppend(rare, rout);
outputNames.push_back(rare);
- string abund = outputDir + getRootName(getSimpleName(listfile)) + "abund.list";
- openOutputFileAppend(abund, aout);
+ string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + "abund.list";
+ m->openOutputFileAppend(abund, aout);
outputNames.push_back(abund);
if (rareNames.size() != 0) { rout << thisList->getLabel() << '\t' << numRareBins << '\t'; }
string bin = list->get(i);
- int size = getNumNames(bin);
+ int size = m->getNumNames(bin);
if (size <= cutoff) { rout << bin << '\t'; }
else { aout << bin << '\t'; }
aout.close();
}else{ //parse names by abundance and group
- string fileroot = outputDir + getRootName(getSimpleName(listfile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
ofstream* temp;
ofstream* temp2;
//map<string, bool> wroteFile;
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- openOutputFileAppend(fileroot + Groups[i] + ".rare.list", *(filehandles[Groups[i]+".rare"]));
- openOutputFileAppend(fileroot + Groups[i] + ".abund.list", *(filehandles[Groups[i]+".abund"]));
+ m->openOutputFileAppend(fileroot + Groups[i] + ".rare.list", *(filehandles[Groups[i]+".rare"]));
+ m->openOutputFileAppend(fileroot + Groups[i] + ".abund.list", *(filehandles[Groups[i]+".abund"]));
}
map<string, string> groupVector;
string bin = list->get(i);
vector<string> names;
- splitAtComma(bin, names); //parses bin into individual sequence names
+ m->splitAtComma(bin, names); //parses bin into individual sequence names
//parse bin into list of sequences in each group
for (int j = 0; j < names.size(); j++) {
string group = groupMap->getGroup(names[j]);
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
itGroup = groupBins.find(group+rareAbund);
if(itGroup == groupBins.end()) {
groupBins[group+rareAbund] = names[j]; //add first name
//open input file
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
while (!in.eof()) {
if (m->control_pressed) { break; }
string firstCol, secondCol;
- in >> firstCol >> secondCol; gobble(in);
+ in >> firstCol >> secondCol; m->gobble(in);
nameMap[firstCol] = secondCol;
- int size = getNumNames(secondCol);
+ int size = m->getNumNames(secondCol);
if (size <= cutoff) {
rareNames.insert(firstCol);
try {
//open input file
ifstream in;
- openInputFile(namefile, in);
+ m->openInputFile(namefile, in);
while (!in.eof()) {
if (m->control_pressed) { break; }
string firstCol, secondCol;
- in >> firstCol >> secondCol; gobble(in);
+ in >> firstCol >> secondCol; m->gobble(in);
nameMap[firstCol] = secondCol;
}
string bin = thisList->get(i);
vector<string> names;
- splitAtComma(bin, names); //parses bin into individual sequence names
+ m->splitAtComma(bin, names); //parses bin into individual sequence names
for (int j = 0; j < names.size(); j++) { nameMap[names[j]] = names[j]; }
}//end for
ofstream aout;
ofstream rout;
- string rare = outputDir + getRootName(getSimpleName(namefile)) + "rare.names";
- openOutputFile(rare, rout);
+ string rare = outputDir + m->getRootName(m->getSimpleName(namefile)) + "rare.names";
+ m->openOutputFile(rare, rout);
outputNames.push_back(rare);
- string abund = outputDir + getRootName(getSimpleName(namefile)) + "abund.names";
- openOutputFile(abund, aout);
+ string abund = outputDir + m->getRootName(m->getSimpleName(namefile)) + "abund.names";
+ m->openOutputFile(abund, aout);
outputNames.push_back(abund);
if (rareNames.size() != 0) {
aout.close();
}else{ //parse names by abundance and group
- string fileroot = outputDir + getRootName(getSimpleName(namefile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(namefile));
ofstream* temp;
ofstream* temp2;
map<string, ofstream*> filehandles;
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
- openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
+ m->openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
+ m->openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
}
for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {
vector<string> names;
- splitAtComma(itName->second, names); //parses bin into individual sequence names
+ m->splitAtComma(itName->second, names); //parses bin into individual sequence names
string rareAbund;
if (rareNames.count(itName->first) != 0) { //you are a rare name
string group = groupMap->getGroup(names[i]);
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
itout = outputStrings.find(group+rareAbund);
if (itout == outputStrings.end()) {
outputStrings[group+rareAbund] = names[i] + '\t' + names[i];
ofstream rout;
- string rare = outputDir + getRootName(getSimpleName(inputFile)) + tag + "rare.accnos";
- openOutputFile(rare, rout);
+ string rare = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag + "rare.accnos";
+ m->openOutputFile(rare, rout);
outputNames.push_back(rare);
for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
}
rout.close();
- string abund = outputDir + getRootName(getSimpleName(inputFile)) + tag + "abund.accnos";
- openOutputFile(abund, aout);
+ string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag + "abund.accnos";
+ m->openOutputFile(abund, aout);
outputNames.push_back(abund);
for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
aout.close();
}else{ //parse names by abundance and group
- string fileroot = outputDir + getRootName(getSimpleName(inputFile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(inputFile));
ofstream* temp;
ofstream* temp2;
map<string, ofstream*> filehandles;
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
- openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
}
//write rare
for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
string group = groupMap->getGroup(*itRare);
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
*(filehandles[group+".rare"]) << *itRare << endl;
}
}
for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
string group = groupMap->getGroup(*itAbund);
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
*(filehandles[group+".abund"]) << *itAbund << endl;
}
}
ofstream aout;
ofstream rout;
- string rare = outputDir + getRootName(getSimpleName(groupfile)) + tag + "rare.groups";
- openOutputFile(rare, rout);
+ string rare = outputDir + m->getRootName(m->getSimpleName(groupfile)) + tag + "rare.groups";
+ m->openOutputFile(rare, rout);
outputNames.push_back(rare);
- string abund = outputDir + getRootName(getSimpleName(groupfile)) + tag + "abund.groups";
- openOutputFile(abund, aout);
+ string abund = outputDir + m->getRootName(m->getSimpleName(groupfile)) + tag + "abund.groups";
+ m->openOutputFile(abund, aout);
outputNames.push_back(abund);
for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {
vector<string> names;
- splitAtComma(itName->second, names); //parses bin into individual sequence names
+ m->splitAtComma(itName->second, names); //parses bin into individual sequence names
for (int i = 0; i < names.size(); i++) {
aout.close();
}else{ //parse names by abundance and group
- string fileroot = outputDir + getRootName(getSimpleName(groupfile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(groupfile));
ofstream* temp;
ofstream* temp2;
map<string, ofstream*> filehandles;
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
- openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
}
for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {
vector<string> names;
- splitAtComma(itName->second, names); //parses bin into individual sequence names
+ m->splitAtComma(itName->second, names); //parses bin into individual sequence names
string rareAbund;
if (rareNames.count(itName->first) != 0) { //you are a rare name
string group = groupMap->getGroup(names[i]);
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
*(filehandles[group+rareAbund]) << names[i] << '\t' << group << endl;
}
}
ofstream aout;
ofstream rout;
- string rare = outputDir + getRootName(getSimpleName(fastafile)) + tag + "rare.fasta";
- openOutputFile(rare, rout);
+ string rare = outputDir + m->getRootName(m->getSimpleName(fastafile)) + tag + "rare.fasta";
+ m->openOutputFile(rare, rout);
outputNames.push_back(rare);
- string abund = outputDir + getRootName(getSimpleName(fastafile)) + tag + "abund.fasta";
- openOutputFile(abund, aout);
+ string abund = outputDir + m->getRootName(m->getSimpleName(fastafile)) + tag + "abund.fasta";
+ m->openOutputFile(abund, aout);
outputNames.push_back(abund);
//open input file
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
while (!in.eof()) {
if (m->control_pressed) { break; }
- Sequence seq(in); gobble(in);
+ Sequence seq(in); m->gobble(in);
if (seq.getName() != "") {
aout.close();
}else{ //parse names by abundance and group
- string fileroot = outputDir + getRootName(getSimpleName(fastafile));
+ string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
ofstream* temp;
ofstream* temp2;
map<string, ofstream*> filehandles;
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
- openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
+ m->openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
}
//open input file
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
while (!in.eof()) {
if (m->control_pressed) { break; }
- Sequence seq(in); gobble(in);
+ Sequence seq(in); m->gobble(in);
if (seq.getName() != "") {
map<string, string>::iterator itNames = nameMap.find(seq.getName());
m->mothurOut(seq.getName() + " is not in your namesfile, ignoring."); m->mothurOutEndLine();
}else{
vector<string> names;
- splitAtComma(itNames->second, names); //parses bin into individual sequence names
+ m->splitAtComma(itNames->second, names); //parses bin into individual sequence names
string rareAbund;
if (rareNames.count(itNames->first) != 0) { //you are a rare name
string group = groupMap->getGroup(seq.getName());
- if (inUsersGroups(group, Groups)) { //only add if this is in a group we want
+ if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
seq.printSequence(*(filehandles[group+rareAbund]));
}else if(group == "not found") {
m->mothurOut(seq.getName() + " is not in your groupfile. Ignoring."); m->mothurOutEndLine();
PhyloTree* phylo = new PhyloTree();
ifstream in;
- openInputFile(taxFile, in);
+ m->openInputFile(taxFile, in);
//read in users taxonomy file and add sequences to tree
string seqname, tax;
while(!in.eof()){
- in >> seqname >> tax; gobble(in);
+ in >> seqname >> tax; m->gobble(in);
phylo->addSeqToTree(seqname, tax);
}
in.close();
}
ifstream in;
- openInputFile(fastafile, in);
+ m->openInputFile(fastafile, in);
//parse fastafile
ofstream outFile;
while (!in.eof()) {
- Sequence query(in); gobble(in);
+ Sequence query(in); m->gobble(in);
if (query.getName() != "") {
it = seqGroup.find(query.getName());
if (namefile == "") { names.insert(query.getName()); }
if (it != seqGroup.end()) { //not singleton
- openOutputFileAppend((fastafile + "." + toString(it->second) + ".temp"), outFile);
+ m->openOutputFileAppend((fastafile + "." + toString(it->second) + ".temp"), outFile);
query.printSequence(outFile);
outFile.close();
singleton = namefile + ".extra.temp";
ofstream remainingNames;
- openOutputFile(singleton, remainingNames);
+ m->openOutputFile(singleton, remainingNames);
bool wroteExtra = false;
ifstream bigNameFile;
- openInputFile(namefile, bigNameFile);
+ m->openInputFile(namefile, bigNameFile);
string name, nameList;
while(!bigNameFile.eof()){
- bigNameFile >> name >> nameList; gobble(bigNameFile);
+ bigNameFile >> name >> nameList; m->gobble(bigNameFile);
//did this sequence get assigned a group
it = seqGroup.find(name);
if (it != seqGroup.end()) {
- openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
+ m->openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
outFile << name << '\t' << nameList << endl;
outFile.close();
}else{
for(int i=0;i<numGroups;i++){
string tempNameFile = namefile + "." + toString(i) + ".temp";
- string tempDistFile = outputDir + getRootName(getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "dist";
+ string tempDistFile = outputDir + m->getRootName(m->getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "dist";
//if there are valid distances
ifstream fileHandle;
fileHandle.open(tempDistFile.c_str());
if(fileHandle) {
- gobble(fileHandle);
+ m->gobble(fileHandle);
if (!fileHandle.eof()) { //check for blank file - this could occur if all dists in group are above cutoff
map<string, string> temp;
temp[tempDistFile] = tempNameFile;
dists.push_back(temp);
}else {
ifstream in;
- openInputFile(tempNameFile, in);
+ m->openInputFile(tempNameFile, in);
while(!in.eof()) {
- in >> name >> nameList; gobble(in);
+ in >> name >> nameList; m->gobble(in);
wroteExtra = true;
remainingNames << name << '\t' << nameList << endl;
}
map<string, int>::iterator it2;
ifstream dFile;
- openInputFile(distFile, dFile);
+ m->openInputFile(distFile, dFile);
ofstream outFile;
for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case
if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { remove((distFile + "." + toString(i) + ".temp").c_str()); } }
- dFile >> seqA >> seqB >> dist; gobble(dFile);
+ dFile >> seqA >> seqB >> dist; m->gobble(dFile);
//if both sequences are in the same group then they are within the cutoff
it = seqGroup.find(seqA);
if ((it != seqGroup.end()) && (it2 != seqGroup.end())) { //they are both not singletons
if (it->second == it2->second) { //they are from the same group so add the distance
if (numOutputs[it->second] > 30) {
- openOutputFileAppend((distFile + "." + toString(it->second) + ".temp"), outFile);
+ m->openOutputFileAppend((distFile + "." + toString(it->second) + ".temp"), outFile);
outFile << outputs[it->second] << seqA << '\t' << seqB << '\t' << dist << endl;
outFile.close();
outputs[it->second] = "";
//write out any remaining buffers
if (numOutputs[i] > 0) {
- openOutputFileAppend((distFile + "." + toString(i) + ".temp"), outFile);
+ m->openOutputFileAppend((distFile + "." + toString(i) + ".temp"), outFile);
outFile << outputs[i];
outFile.close();
outputs[i] = "";
}
ifstream bigNameFile;
- openInputFile(namefile, bigNameFile);
+ m->openInputFile(namefile, bigNameFile);
singleton = namefile + ".extra.temp";
ofstream remainingNames;
- openOutputFile(singleton, remainingNames);
+ m->openOutputFile(singleton, remainingNames);
bool wroteExtra = false;
string name, nameList;
while(!bigNameFile.eof()){
- bigNameFile >> name >> nameList; gobble(bigNameFile);
+ bigNameFile >> name >> nameList; m->gobble(bigNameFile);
//did this sequence get assigned a group
it = seqGroup.find(name);
if (it != seqGroup.end()) {
- openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
+ m->openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
outFile << name << '\t' << nameList << endl;
outFile.close();
}else{
dists.push_back(temp);
}else{
ifstream in;
- openInputFile(tempNameFile, in);
+ m->openInputFile(tempNameFile, in);
while(!in.eof()) {
- in >> name >> nameList; gobble(in);
+ in >> name >> nameList; m->gobble(in);
wroteExtra = true;
remainingNames << name << '\t' << nameList << endl;
}
ofstream outFile;
ifstream dFile;
- openInputFile(distFile, dFile);
+ m->openInputFile(distFile, dFile);
while(dFile){
string seqA, seqB;
}
}
}
- gobble(dFile);
+ m->gobble(dFile);
}
dFile.close();
while(bigNameFile){
bigNameFile >> name >> nameList;
nameMap[name] = nameList;
- gobble(bigNameFile);
+ m->gobble(bigNameFile);
}
bigNameFile.close();
int numGroups = 0;
ifstream dFile;
- openInputFile(distFile, dFile);
+ m->openInputFile(distFile, dFile);
while(dFile){
string seqA, seqB;
}
}
}
- gobble(dFile);
+ m->gobble(dFile);
}
dFile.close();
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "abund", false); if (temp == "not found") { temp = "10"; }
convert(temp, size);
temp = validParameter.validFile(parameters, "groupmode", false); if (temp == "not found") { temp = "F"; }
- groupMode = isTrue(temp);
+ groupMode = m->isTrue(temp);
}
numLines = 0;
numCols = 0;
- string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p])) + "summary";
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "summary";
globaldata->inputFileName = inputFileNames[p];
outputNames.push_back(fileNameRoot);
if (sumCalculators.size() == 0) { if (hadShared != "") { globaldata->setSharedFile(hadShared); globaldata->setFormat("sharedfile"); } return 0; }
ofstream outputFileHandle;
- openOutputFile(fileNameRoot, outputFileHandle);
+ m->openOutputFile(fileNameRoot, outputFileHandle);
outputFileHandle << "label";
read = new ReadOTUFile(globaldata->inputFileName);
numLines++;
}
- if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = sabund->getLabel();
delete sabund;
input = globaldata->ginput;
vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
- string sharedFileRoot = getRootName(filename);
+ string sharedFileRoot = m->getRootName(filename);
//clears file before we start to write to it below
for (int i=0; i<lookup.size(); i++) {
for (int i = 0; i < lookup.size(); i++) {
RAbundVector rav = lookup[i]->getRAbundVector();
- openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
+ m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
rav.print(*(filehandles[lookup[i]->getGroup()]));
(*(filehandles[lookup[i]->getGroup()])).close();
}
try {
ofstream out;
- string combineFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "groups.summary";
+ string combineFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "groups.summary";
//open combined file
- openOutputFile(combineFileName, out);
+ m->openOutputFile(combineFileName, out);
//open each groups summary file
string newLabel = "";
for (int i=0; i<outputNames.size(); i++) {
temp = new ifstream;
filehandles[outputNames[i]] = temp;
- openInputFile(outputNames[i], *(temp));
+ m->openInputFile(outputNames[i], *(temp));
//read through first line - labels
string tempLabel;
}
}else{ for (int j = 0; j < numCols+1; j++) { *(temp) >> tempLabel; } }
- gobble(*(temp));
+ m->gobble(*(temp));
}
//output label line to new file
}
out << endl;
- gobble(*(filehandles[outputNames[i]]));
+ m->gobble(*(filehandles[outputNames[i]]));
}
}
//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 += hasPath(globaldata->getSharedFile()); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->getSharedFile()); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
else {
if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
string temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; }
- all = isTrue(temp);
+ all = m->isTrue(temp);
if (abort == false) {
}
}
- outputFileName = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "shared.summary";
- openOutputFile(outputFileName, outputFileHandle);
+ outputFileName = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "shared.summary";
+ m->openOutputFile(outputFileName, outputFileHandle);
outputNames.push_back(outputFileName);
mult = false;
//create file and put column headers for multiple groups file
if (mult == true) {
- outAllFileName = ((getRootName(globaldata->inputFileName)) + "sharedmultiple.summary");
- openOutputFile(outAllFileName, outAll);
+ outAllFileName = ((m->getRootName(globaldata->inputFileName)) + "sharedmultiple.summary");
+ m->openOutputFile(outAllFileName, outAll);
outputNames.push_back(outAllFileName);
outAll << "label" <<'\t' << "comparison" << '\t';
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
containsConfidence = false;
ifstream inTax;
- openInputFile(tfile, inTax);
+ m->openInputFile(tfile, inTax);
highestLevel = getHighestLevel(inTax);
inTax.close();
ifstream in;
- openInputFile(tfile, in);
+ m->openInputFile(tfile, in);
ofstream out;
- equalizedFile = outputDir + getRootName(getSimpleName(tfile)) + "equalized.taxonomy";
- openOutputFile(equalizedFile, out);
+ equalizedFile = outputDir + m->getRootName(m->getSimpleName(tfile)) + "equalized.taxonomy";
+ m->openOutputFile(equalizedFile, out);
string name, tax;
if (m->control_pressed) { break; }
- in >> name >> tax; gobble(in);
+ in >> name >> tax; m->gobble(in);
if (containsConfidence) { removeConfidences(tax); }
string name, tax;
while (in) {
- in >> name >> tax; gobble(in);
+ in >> name >> tax; m->gobble(in);
//count levels in this taxonomy
int thisLevel = 0;
if (itNames == globaldata->names.end()) { m->mothurOut(name + " is not in your name file, please correct."); m->mothurOutEndLine(); exit(1); }
else {
vector<string> dupNames;
- splitAtComma(globaldata->names[name], dupNames);
+ m->splitAtComma(globaldata->names[name], dupNames);
map<string, int>::iterator itCounts;
int maxPars = 1;
//loop through nodes groups removing the ones the user doesn't want
for(it=tree[lc].pGroups.begin();it!=tree[lc].pGroups.end();){
- if (inUsersGroups(it->first, g) != true) {
+ if (m->inUsersGroups(it->first, g) != true) {
tree[lc].pGroups.erase(it++);
}else { it++; }
}
//loop through nodes groups removing the ones the user doesn't want
for(it=tree[rc].pGroups.begin();it!=tree[rc].pGroups.end();){
- if (inUsersGroups(it->first, g) != true) {
+ if (m->inUsersGroups(it->first, g) != true) {
tree[rc].pGroups.erase(it++);
}else { it++; }
}
//if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them.
bool treez, treei;
- treez = inUsersGroups(tree[z].getGroup(), g);
- treei = inUsersGroups(tree[i].getGroup(), g);
+ treez = m->inUsersGroups(tree[z].getGroup(), g);
+ treei = m->inUsersGroups(tree[i].getGroup(), g);
if ((treez == true) && (treei == true)) {
//switches node i and node z's info.
void Tree::createNewickFile(string f) {
try {
int root = findRoot();
- //filename = getRootName(globaldata->getTreeFile()) + "newick";
+ //filename = m->getRootName(globaldata->getTreeFile()) + "newick";
filename = f;
- openOutputFile(filename, out);
+ m->openOutputFile(filename, out);
printBranch(root, out, "branch");
try {
string filename = globaldata->getTreeFile();
ifstream filehandle;
- openInputFile(filename, filehandle);
+ m->openInputFile(filename, filehandle);
int c, comment;
comment = 0;
int done = 1;
it = parameters.find("phylip");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["phylip"] = inputDir + it->second; }
}
it = parameters.find("column");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["column"] = inputDir + it->second; }
}
it = parameters.find("name");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["name"] = inputDir + it->second; }
}
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
else {
if (calc == "default") { calc = "jclass-thetayc"; }
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; }
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
if (m->control_pressed) { return 0; }
//create a new filename
- outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "tre";
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "tre";
outputNames.push_back(outputFile);
createTree();
userLabels.erase(lookup[0]->getLabel());
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
for (int g = 0; g < numGroups; g++) { index[g] = g; }
//create a new filename
- outputFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
+ outputFile = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";
outputNames.push_back(outputFile);
for (int k = 0; k < thisLookup.size(); k++) {
TreeMap::TreeMap(string filename) {
groupFileName = filename;
- openInputFile(filename, fileHandle);
+ m->openInputFile(filename, fileHandle);
}
/************************************************************/
seqsPerGroup[seqGroup]++;
}
- gobble(fileHandle);
+ m->gobble(fileHandle);
}
fileHandle.close();
}
it = parameters.find("fasta");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["fasta"] = inputDir + it->second; }
}
it = parameters.find("oligos");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ path = m->hasPath(it->second);
//if the user has not given a path then, add inputdir. else leave path alone.
if (path == "") { parameters["oligos"] = inputDir + it->second; }
}
it = parameters.find("qfile");
//user has given a template file
if(it != parameters.end()){
- path = hasPath(it->second);
+ 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; }
}
//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 += hasPath(fastaFile); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(fastaFile); //if user entered a file with a path then preserve it
}
string temp;
temp = validParameter.validFile(parameters, "flip", false);
if (temp == "not found"){ flip = 0; }
- else if(isTrue(temp)) { flip = 1; }
+ else if(m->isTrue(temp)) { flip = 1; }
temp = validParameter.validFile(parameters, "oligos", true);
if (temp == "not found"){ oligoFile = ""; }
convert(temp, qThreshold);
temp = validParameter.validFile(parameters, "qtrim", false); if (temp == "not found") { temp = "F"; }
- qtrim = isTrue(temp);
+ qtrim = m->isTrue(temp);
temp = validParameter.validFile(parameters, "rollaverage", false); if (temp == "not found") { temp = "0"; }
convert(temp, qRollAverage);
convert(temp, qAverage);
temp = validParameter.validFile(parameters, "allfiles", false); if (temp == "not found") { temp = "F"; }
- allFiles = isTrue(temp);
+ allFiles = m->isTrue(temp);
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found") { temp = "1"; }
convert(temp, processors);
numFPrimers = 0; //this needs to be initialized
numRPrimers = 0;
- string trimSeqFile = outputDir + getRootName(getSimpleName(fastaFile)) + "trim.fasta";
+ string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
outputNames.push_back(trimSeqFile);
- string scrapSeqFile = outputDir + getRootName(getSimpleName(fastaFile)) + "scrap.fasta";
+ string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.fasta";
outputNames.push_back(scrapSeqFile);
- string trimQualFile = outputDir + getRootName(getSimpleName(fastaFile)) + "trim.qual";
+ string trimQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual";
outputNames.push_back(trimQualFile);
- string scrapQualFile = outputDir + getRootName(getSimpleName(fastaFile)) + "scrap.qual";
+ string scrapQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.qual";
outputNames.push_back(scrapQualFile);
- string groupFile = outputDir + getRootName(getSimpleName(fastaFile)) + "groups";
+ string groupFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "groups";
vector<string> fastaFileNames;
vector<string> qualFileNames;
//append files
for(int i=1;i<processors;i++){
- appendFiles((trimSeqFile + toString(processIDS[i]) + ".temp"), trimSeqFile);
+ m->appendFiles((trimSeqFile + toString(processIDS[i]) + ".temp"), trimSeqFile);
remove((trimSeqFile + toString(processIDS[i]) + ".temp").c_str());
- appendFiles((scrapSeqFile + toString(processIDS[i]) + ".temp"), scrapSeqFile);
+ m->appendFiles((scrapSeqFile + toString(processIDS[i]) + ".temp"), scrapSeqFile);
remove((scrapSeqFile + toString(processIDS[i]) + ".temp").c_str());
- appendFiles((trimQualFile + toString(processIDS[i]) + ".temp"), trimQualFile);
+ m->appendFiles((trimQualFile + toString(processIDS[i]) + ".temp"), trimQualFile);
remove((trimQualFile + toString(processIDS[i]) + ".temp").c_str());
- appendFiles((scrapQualFile + toString(processIDS[i]) + ".temp"), scrapQualFile);
+ m->appendFiles((scrapQualFile + toString(processIDS[i]) + ".temp"), scrapQualFile);
remove((scrapQualFile + toString(processIDS[i]) + ".temp").c_str());
- appendFiles((groupFile + toString(processIDS[i]) + ".temp"), groupFile);
+ m->appendFiles((groupFile + toString(processIDS[i]) + ".temp"), groupFile);
remove((groupFile + toString(processIDS[i]) + ".temp").c_str());
for (int j = 0; j < fastaFileNames.size(); j++) {
- appendFiles((fastaFileNames[j] + toString(processIDS[i]) + ".temp"), fastaFileNames[j]);
+ m->appendFiles((fastaFileNames[j] + toString(processIDS[i]) + ".temp"), fastaFileNames[j]);
remove((fastaFileNames[j] + toString(processIDS[i]) + ".temp").c_str());
}
if(qFileName != ""){
for (int j = 0; j < qualFileNames.size(); j++) {
- appendFiles((qualFileNames[j] + toString(processIDS[i]) + ".temp"), qualFileNames[j]);
+ m->appendFiles((qualFileNames[j] + toString(processIDS[i]) + ".temp"), qualFileNames[j]);
remove((qualFileNames[j] + toString(processIDS[i]) + ".temp").c_str());
}
}
for(int i=0;i<fastaFileNames.size();i++){
- if (isBlank(fastaFileNames[i])) { remove(fastaFileNames[i].c_str()); }
+ if (m->isBlank(fastaFileNames[i])) { remove(fastaFileNames[i].c_str()); }
else if (filesToRemove.count(fastaFileNames[i]) > 0) { remove(fastaFileNames[i].c_str()); }
else {
ifstream inFASTA;
string seqName;
- openInputFile(fastaFileNames[i], inFASTA);
+ m->openInputFile(fastaFileNames[i], inFASTA);
ofstream outGroups;
- string outGroupFilename = outputDir + getRootName(getSimpleName(fastaFileNames[i])) + "groups";
- openOutputFile(outGroupFilename, outGroups);
+ string outGroupFilename = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "groups";
+ m->openOutputFile(outGroupFilename, outGroups);
outputNames.push_back(outGroupFilename);
string thisGroup = "";
if(qFileName != ""){
for(int i=0;i<qualFileNames.size();i++){
- if (isBlank(qualFileNames[i])) { remove(qualFileNames[i].c_str()); }
+ if (m->isBlank(qualFileNames[i])) { remove(qualFileNames[i].c_str()); }
else if (filesToRemove.count(qualFileNames[i]) > 0) { remove(qualFileNames[i].c_str()); }
else {
ifstream inQual;
string seqName;
- openInputFile(qualFileNames[i], inQual);
+ m->openInputFile(qualFileNames[i], inQual);
// ofstream outGroups;
//
// string thisGroup = "";
try {
ofstream outFASTA;
- int able = openOutputFile(trimFile, outFASTA);
+ int able = m->openOutputFile(trimFile, outFASTA);
ofstream scrapFASTA;
- openOutputFile(scrapFile, scrapFASTA);
+ m->openOutputFile(scrapFile, scrapFASTA);
ofstream outQual;
ofstream scrapQual;
if(qFileName != ""){
- openOutputFile(trimQFile, outQual);
- openOutputFile(scrapQFile, scrapQual);
+ m->openOutputFile(trimQFile, outQual);
+ m->openOutputFile(scrapQFile, scrapQual);
}
ofstream outGroups;
if (oligoFile != "") {
- openOutputFile(groupFile, outGroups);
+ m->openOutputFile(groupFile, outGroups);
for (int i = 0; i < fastaNames.size(); i++) {
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
fastaFileNames.push_back(new ofstream((fastaNames[i] + toString(getpid()) + ".temp").c_str(), ios::ate));
}
ifstream inFASTA;
- openInputFile(filename, inFASTA);
+ m->openInputFile(filename, inFASTA);
inFASTA.seekg(line->start);
ifstream qFile;
- if(qFileName != "") { openInputFile(qFileName, qFile); qFile.seekg(qline->start); }
+ if(qFileName != "") { m->openInputFile(qFileName, qFile); qFile.seekg(qline->start); }
bool done = false;
int count = 0;
int success = 1;
- Sequence currSeq(inFASTA); gobble(inFASTA);
+ Sequence currSeq(inFASTA); m->gobble(inFASTA);
QualityScores currQual;
if(qFileName != ""){
- currQual = QualityScores(qFile, currSeq.getNumBases()); gobble(qFile);
+ currQual = QualityScores(qFile, currSeq.getNumBases()); m->gobble(qFile);
}
string origSeq = currSeq.getUnaligned();
try {
//set file positions for fasta file
- fastaFilePos = divideFile(filename, processors);
+ fastaFilePos = m->divideFile(filename, processors);
if (qfilename == "") { return processors; }
map<string, int> firstSeqNames;
for (int i = 0; i < (fastaFilePos.size()-1); i++) {
ifstream in;
- openInputFile(filename, in);
+ m->openInputFile(filename, in);
in.seekg(fastaFilePos[i]);
Sequence temp(in);
//seach for filePos of each first name in the qfile and save in qfileFilePos
ifstream inQual;
- openInputFile(qfilename, inQual);
+ m->openInputFile(qfilename, inQual);
string input;
while(!inQual.eof()){
- input = getline(inQual);
+ input = m->getline(inQual);
if (input.length() != 0) {
if(input[0] == '>'){ //this is a sequence name line
void TrimSeqsCommand::getOligos(vector<string>& outFASTAVec, vector<string>& outQualVec){
try {
ifstream inOligos;
- openInputFile(oligoFile, inOligos);
+ m->openInputFile(oligoFile, inOligos);
ofstream test;
groupVector.push_back(group);
if(allFiles){
- outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
+ outFASTAVec.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
if(qFileName != ""){
- outQualVec.push_back((outputDir + getRootName(getSimpleName(qFileName)) + group + ".qual"));
+ outQualVec.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
}
if (group == "") { //if there is not a group for this primer, then this file will not get written to, but we add it to keep the indexes correct
- filesToRemove.insert((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
+ filesToRemove.insert((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
if(qFileName != ""){
- filesToRemove.insert((outputDir + getRootName(getSimpleName(qFileName)) + group + ".qual"));
+ filesToRemove.insert((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
}
}else {
- outputNames.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
if(qFileName != ""){
- outputNames.push_back((outputDir + getRootName(getSimpleName(qFileName)) + group + ".qual"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
}
}
}
groupVector.push_back(group);
if(allFiles){
- outputNames.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
- outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + group + ".fasta"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
+ outFASTAVec.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + group + ".fasta"));
if(qFileName != ""){
- outQualVec.push_back((outputDir + getRootName(getSimpleName(qFileName)) + group + ".qual"));
- outputNames.push_back((outputDir + getRootName(getSimpleName(qFileName)) + group + ".qual"));
+ outQualVec.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + group + ".qual"));
}
}
}else{ m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine(); }
}
- gobble(inOligos);
+ m->gobble(inOligos);
}
inOligos.close();
for (map<string, int>::iterator itBar = barcodes.begin(); itBar != barcodes.end(); itBar++) {
for (map<string, int>::iterator itPrime = primers.begin(); itPrime != primers.end(); itPrime++) {
if (groupVector[itPrime->second] != "") { //there is a group for this primer
- outputNames.push_back((outputDir + getRootName(getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
- outFASTAVec.push_back((outputDir + getRootName(getSimpleName(fastaFile)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
+ outFASTAVec.push_back((outputDir + m->getRootName(m->getSimpleName(fastaFile)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".fasta"));
combos[(groupVector[itBar->second] + "." + groupVector[itPrime->second])] = outFASTAVec.size()-1;
if(qFileName != ""){
- outQualVec.push_back((outputDir + getRootName(getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
- outputNames.push_back((outputDir + getRootName(getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
+ outQualVec.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
+ outputNames.push_back((outputDir + m->getRootName(m->getSimpleName(qFileName)) + groupVector[itBar->second] + "." + groupVector[itPrime->second] + ".qual"));
}
}
}
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
convert(itersString, iters);
string temp = validParameter.validFile(parameters, "distance", false); if (temp == "not found") { temp = "false"; }
- phylip = isTrue(temp);
+ phylip = m->isTrue(temp);
temp = validParameter.validFile(parameters, "random", false); if (temp == "not found") { temp = "true"; }
- random = isTrue(temp);
+ random = m->isTrue(temp);
if (!random) { iters = 0; } //turn off random calcs
//if user selects distance = true and no groups it won't calc the pairwise
if ((phylip) && (Groups.size() == 0)) {
groups = "all";
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
if (abort == false) {
T = globaldata->gTree;
tmap = globaldata->gTreemap;
- sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
+ sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
outputNames.push_back(sumFile);
- openOutputFile(sumFile, outSum);
+ m->openOutputFile(sumFile, outSum);
util = new SharedUtil();
util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze
counter = 0;
if (random) {
- output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted", itersString);
- outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted");
+ output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted", itersString);
+ outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted");
}
/***********************************************************/
void UnifracUnweightedCommand::createPhylipFile(int i) {
try {
- string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted.dist";
+ string phylipFileName = outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".unweighted.dist";
outputNames.push_back(phylipFileName);
ofstream out;
- openOutputFile(phylipFileName, out);
+ m->openOutputFile(phylipFileName, out);
//output numSeqs
out << globaldata->Groups.size() << endl;
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
convert(itersString, iters);
string temp = validParameter.validFile(parameters, "distance", false); if (temp == "not found") { temp = "false"; }
- phylip = isTrue(temp);
+ phylip = m->isTrue(temp);
temp = validParameter.validFile(parameters, "random", false); if (temp == "not found") { temp = "true"; }
- random = isTrue(temp);
+ random = m->isTrue(temp);
if (!random) { iters = 0; } //turn off random calcs
if (abort == false) {
T = globaldata->gTree;
tmap = globaldata->gTreemap;
- sumFile = outputDir + getSimpleName(globaldata->getTreeFile()) + ".wsummary";
- openOutputFile(sumFile, outSum);
+ sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".wsummary";
+ m->openOutputFile(sumFile, outSum);
outputNames.push_back(sumFile);
util = new SharedUtil();
uScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
if (random) {
- output = new ColumnFile(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted", itersString);
- outputNames.push_back(outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted");
+ output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted", itersString);
+ outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted");
}
userData = weighted->getValues(T[i]); //userData[0] = weightedscore
//for each tree
for (int i = 0; i < T.size(); i++) {
- string phylipFileName = outputDir + getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted.dist";
+ string phylipFileName = outputDir + m->getSimpleName(globaldata->getTreeFile()) + toString(i+1) + ".weighted.dist";
outputNames.push_back(phylipFileName);
ofstream out;
- openOutputFile(phylipFileName, out);
+ m->openOutputFile(phylipFileName, out);
//output numSeqs
out << globaldata->Groups.size() << endl;
copyIpcount = t->tree[i].pcount;
for (it = copyIpcount.begin(); it != copyIpcount.end();) {
- if (inUsersGroups(it->first, groups) != true) {
+ if (m->inUsersGroups(it->first, groups) != true) {
copyIpcount.erase(it++);
}else { it++; }
}
copyIpcount = t->tree[i].pcount;
for (it = copyIpcount.begin(); it != copyIpcount.end();) {
- if (inUsersGroups(it->first, groups) != true) {
+ if (m->inUsersGroups(it->first, groups) != true) {
copyIpcount.erase(it++);
}else { it++; }
}
//This section adds in all lengths that are non leaf
copyIpcount = copyTree->tree[i].pcount;
for (it = copyIpcount.begin(); it != copyIpcount.end();) {
- if (inUsersGroups(it->first, groups) != true) {
+ if (m->inUsersGroups(it->first, groups) != true) {
copyIpcount.erase(it++);
}else { it++; }
}
copyIpcount = copyTree->tree[i].pcount;
for (it = copyIpcount.begin(); it != copyIpcount.end();) {
- if (inUsersGroups(it->first, groups) != true) {
+ if (m->inUsersGroups(it->first, groups) != true) {
copyIpcount.erase(it++);
}else { it++; }
}
vector<string> range = parameterRanges[parameter];
vector<string> values;
- splitAtDash(value, values);
+ m->splitAtDash(value, values);
for(int i = 0; i < values.size(); i++) {
value = values.at(i);
if (pid == 0) {
#endif
- ableToOpen = openInputFile(it->second, in, "noerror");
+ ableToOpen = m->openInputFile(it->second, 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() + getSimpleName(it->second);
+ string tryPath = m->getDefaultPath() + m->getSimpleName(it->second);
m->mothurOut("Unable to open " + it->second + ". Trying default " + tryPath); m->mothurOutEndLine();
- ableToOpen = openInputFile(tryPath, in, "noerror");
+ ableToOpen = m->openInputFile(tryPath, in, "noerror");
container[parameter] = tryPath;
}
}
vector<string> outputNames;
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
outputNames.push_back(filenamesvg);
- openOutputFile(filenamesvg, outsvg);
+ m->openOutputFile(filenamesvg, outsvg);
if (m->control_pressed) { outsvg.close(); return outputNames; }
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
outputNames.push_back(filenamesvg);
- openOutputFile(filenamesvg, outsvg);
+ m->openOutputFile(filenamesvg, outsvg);
if (m->control_pressed) { outsvg.close(); return outputNames; }
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
outputNames.push_back(filenamesvg);
- openOutputFile(filenamesvg, outsvg);
+ m->openOutputFile(filenamesvg, outsvg);
if (m->control_pressed) { outsvg.close(); return outputNames; }
//make a file for each calculator
for(int i=0;i<vCalcs.size();i++){
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
outputNames.push_back(filenamesvg);
- openOutputFile(filenamesvg, outsvg);
+ m->openOutputFile(filenamesvg, outsvg);
if (m->control_pressed) { outsvg.close(); return outputNames; }
if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups. It will be disregarded. "); m->mothurOutEndLine(); }
else{
- string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
+ string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
outputNames.push_back(filenamesvg);
- openOutputFile(filenamesvg, outsvg);
+ m->openOutputFile(filenamesvg, outsvg);
if (m->control_pressed) { outsvg.close(); return outputNames; }
//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 += hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
}
//check for optional parameter and set defaults
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; }
else {
- if(label != "all") { splitAtDash(label, labels); allLines = 0; }
+ if(label != "all") { m->splitAtDash(label, labels); allLines = 0; }
else { allLines = 1; }
}
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else {
- splitAtDash(groups, Groups);
+ m->splitAtDash(groups, Groups);
globaldata->Groups = Groups;
}
else { calc = "sharedsobs"; }
}
}
- splitAtDash(calc, Estimators);
+ m->splitAtDash(calc, Estimators);
string temp;
temp = validParameter.validFile(parameters, "abund", false); if (temp == "not found") { temp = "10"; }
for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]); } }
}
- if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = lookup[0]->getLabel();
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
userLabels.erase(sabund->getLabel());
}
- if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
string saveLabel = sabund->getLabel();
delete sabund;
}
//is this sum from a sequence which is in one of the users groups
- if (inUsersGroups(t->tree[v].getGroup(), globaldata->Groups) == true) {
+ if (m->inUsersGroups(t->tree[v].getGroup(), globaldata->Groups) == true) {
//is this sum from a sequence which is in this groupCombo
- if (inUsersGroups(t->tree[v].getGroup(), groups)) {
+ if (m->inUsersGroups(t->tree[v].getGroup(), groups)) {
int numSeqsInGroupI, numSeqsInGroupL;
map<string, int>::iterator it;
sum += abs(t->tree[index].getBranchLength());
}
- if (inUsersGroups(t->tree[v].getGroup(), groups)) {
+ if (m->inUsersGroups(t->tree[v].getGroup(), groups)) {
int numSeqsInGroupI, numSeqsInGroupL;
map<string, int>::iterator it;