From: pschloss Date: Sun, 21 Jun 2009 13:47:29 +0000 (+0000) Subject: This is v.1.4.0 X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=163b300cfd7d4ca4e70c454be20f07b1d8346650 This is v.1.4.0 --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index e6a9c0c..1407154 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -1153,10 +1153,15 @@ isa = XCBuildConfiguration; buildSettings = { GCC_OPTIMIZATION_LEVEL = 3; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + GCC_WARN_PEDANTIC = NO; GCC_WARN_UNUSED_VARIABLE = YES; + OTHER_CPLUSPLUSFLAGS = ""; PREBINDING = NO; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + WARNING_CFLAGS = ""; }; name = Debug; }; @@ -1168,10 +1173,15 @@ i386, ); GCC_OPTIMIZATION_LEVEL = 3; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + GCC_WARN_PEDANTIC = NO; GCC_WARN_UNUSED_VARIABLE = YES; + OTHER_CPLUSPLUSFLAGS = ""; PREBINDING = NO; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; + WARNING_CFLAGS = ""; }; name = Release; }; diff --git a/aligncommand.cpp b/aligncommand.cpp index 064189b..4bf18d7 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -193,7 +193,7 @@ int AlignCommand::execute(){ while(!inFASTA.eof()){ char c = inFASTA.get(); - if(c == '>'){ positions.push_back(inFASTA.tellg()); } + if(c == '>'){ int pos = inFASTA.tellg(); positions.push_back(pos-1); } while (!inFASTA.eof()) { c = inFASTA.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there } inFASTA.close(); @@ -343,22 +343,15 @@ void AlignCommand::createProcesses(string alignFileName, string reportFileName) void AlignCommand::appendAlignFiles(string temp, string filename) { try{ - //open output file in append mode ofstream output; - openOutputFileAppend(filename, output); - - //open temp file for reading ifstream input; + openOutputFileAppend(filename, output); openInputFile(temp, input); - string line; - //read input file and write to output file - while(input.eof() != true) { - getline(input, line); //getline removes the newline char - if (line != "") { - output << line << endl; // Appending back newline char - } - } + while(char c = input.get()){ + if(input.eof()) { break; } + else { output << c; } + } input.close(); output.close(); @@ -378,23 +371,17 @@ void AlignCommand::appendAlignFiles(string temp, string filename) { void AlignCommand::appendReportFiles(string temp, string filename) { try{ - //open output file in append mode ofstream output; - openOutputFileAppend(filename, output); - - //open temp file for reading ifstream input; + openOutputFileAppend(filename, output); openInputFile(temp, input); + while (!input.eof()) { char c = input.get(); if (c == 10 || c == 13){ break; } } // get header line - - string line; - //read input file and write to output file - while(input.eof() != true) { - getline(input, line); //getline removes the newline char - if (line != "") { - output << line << endl; // Appending back newline char - } - } + + while(char c = input.get()){ + if(input.eof()) { break; } + else { output << c; } + } input.close(); output.close(); diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp index 1627b42..0ae5d9e 100644 --- a/binsequencecommand.cpp +++ b/binsequencecommand.cpp @@ -79,7 +79,7 @@ BinSeqCommand::BinSeqCommand(string option){ else if (groupfile == "not found") { groupfile = ""; } if (abort == false) { - openInputFile(fastafile, in); +// openInputFile(fastafile, in); fasta = new FastaMap(); if (groupfile != "") { groupMap = new GroupMap(groupfile); @@ -147,9 +147,8 @@ int BinSeqCommand::execute(){ int error = 0; //read fastafile - fasta->readFastaFile(in); + fasta->readFastaFile(fastafile); - in.close(); //set format to list so input can get listvector // globaldata->setFormat("list"); diff --git a/collect.cpp b/collect.cpp index 76481d1..ac4aa4d 100644 --- a/collect.cpp +++ b/collect.cpp @@ -193,4 +193,4 @@ void Collect::getGroupComb() { } -/**************************************************************************************/ \ No newline at end of file +/**************************************************************************************/ diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 86d5ffc..4d0306d 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -328,4 +328,3 @@ int CollectSharedCommand::execute(){ } /***********************************************************/ - diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index 2fe7a25..fba2d27 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -19,7 +19,7 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { else { //valid paramters for this command - string Array[] = {"fasta"}; + string Array[] = {"fasta", "name"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -33,10 +33,13 @@ DeconvoluteCommand::DeconvoluteCommand(string option) { } //check for required parameters - filename = validParameter.validFile(parameters, "fasta", true); - if (filename == "not open") { abort = true; } - else if (filename == "not found") { filename = ""; cout << "fasta is a required parameter for the unique.seqs command." << endl; abort = true; } + inFastaName = validParameter.validFile(parameters, "fasta", true); + if (inFastaName == "not open") { abort = true; } + else if (inFastaName == "not found") { inFastaName = ""; cout << "fasta is a required parameter for the unique.seqs command." << endl; abort = true; } + oldNameMapFName = validParameter.validFile(parameters, "name", true); + if (oldNameMapFName == "not open") { abort = true; } + else if (oldNameMapFName == "not found"){ oldNameMapFName = ""; } } } @@ -75,31 +78,19 @@ int DeconvoluteCommand::execute() { try { if (abort == true) { return 0; } - + //prepare filenames and open files - outputFileName = (getRootName(filename) + "names"); - outFastafile = (getRootName(filename) + "unique.fasta"); + string outNameFile = (getRootName(inFastaName) + "names"); + string outFastaFile = (getRootName(inFastaName) + "unique" + getExtension(inFastaName)); - openInputFile(filename, in); - openOutputFile(outputFileName, out); - openOutputFile(outFastafile, outFasta); - - //constructor reads in file and store internally - fastamap = new FastaMap(); + FastaMap fastamap; - //two columns separated by tabs sequence name and then sequence - fastamap->readFastaFile(in); + if(oldNameMapFName == "") { fastamap.readFastaFile(inFastaName); } + else { fastamap.readFastaFile(inFastaName, oldNameMapFName); } - //print out new names file - //file contains 2 columns separated by tabs. the first column is the groupname(name of first sequence found. - //the second column is the list of names of identical sequences separated by ','. - fastamap->printNamesFile(out); - fastamap->printCondensedFasta(outFasta); + fastamap.printCondensedFasta(outFastaFile); + fastamap.printNamesFile(outNameFile); - in.close(); - out.close(); - outFasta.close(); - return 0; } catch(exception& e) { diff --git a/deconvolutecommand.h b/deconvolutecommand.h index b6bda8f..635e53f 100644 --- a/deconvolutecommand.h +++ b/deconvolutecommand.h @@ -20,15 +20,12 @@ class DeconvoluteCommand : public Command { public: DeconvoluteCommand(string); - ~DeconvoluteCommand() { delete fastamap; }; + ~DeconvoluteCommand() { }; int execute(); void help(); private: - FastaMap* fastamap; - ifstream in; - ofstream out, outFasta; - string filename, outputFileName, outFastafile; + string inFastaName, oldNameMapFName; bool abort; }; diff --git a/dist.h b/dist.h index 6e42ae3..6a461f5 100644 --- a/dist.h +++ b/dist.h @@ -27,4 +27,4 @@ protected: /**************************************************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/distancecommand.cpp b/distancecommand.cpp index 0c9d011..67ad7be 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -309,18 +309,12 @@ void DistanceCommand::appendFiles(string temp, string filename) { //open output file in append mode openOutputFileAppend(filename, output); - - //open temp file for reading openInputFile(temp, input); - string line; - //read input file and write to output file - while(input.eof() != true) { - getline(input, line); //getline removes the newline char - if (line != "") { - output << line << endl; // Appending back newline char - } - } + while(char c = input.get()){ + if(input.eof()) { break; } + else { output << c; } + } input.close(); output.close(); @@ -334,4 +328,4 @@ void DistanceCommand::appendFiles(string temp, string filename) { exit(1); } } -/**************************************************************************************************/ \ No newline at end of file +/**************************************************************************************************/ diff --git a/engine.cpp b/engine.cpp index a2d5250..d2a4cad 100644 --- a/engine.cpp +++ b/engine.cpp @@ -301,4 +301,4 @@ string ScriptEngine::getNextCommand(string& commandString) { exit(1); } } -/***********************************************************************/ \ No newline at end of file +/***********************************************************************/ diff --git a/fastamap.cpp b/fastamap.cpp index a0652d9..9b2438f 100644 --- a/fastamap.cpp +++ b/fastamap.cpp @@ -12,43 +12,35 @@ /*******************************************************************************/ -void FastaMap::readFastaFile(ifstream& in) { +void FastaMap::readFastaFile(string inFileName) { try { + ifstream in; + openInputFile(inFileName, in); string name, sequence, line; sequence = ""; -// int c; string temp; - - - //read through file -// while ((c = in.get()) != EOF) { -// name = ""; sequence = ""; -// //is this a name -// if (c == '>') { -// name = readName(in); -// sequence = readSequence(in); -// }else { cout << "Error fasta in your file. Please correct." << endl; } - - //store info in map - //input sequence info into map + while(!in.eof()){ Sequence currSeq(in); name = currSeq.getName(); - sequence = currSeq.getUnaligned(); + + if(currSeq.getIsAligned()) { sequence = currSeq.getAligned(); } + else { sequence = currSeq.getUnaligned(); } + seqmap[name] = sequence; - it = data.find(sequence); + map::iterator it = data.find(sequence); if (it == data.end()) { //it's unique. data[sequence].groupname = name; //group name will be the name of the first duplicate sequence found. - data[sequence].groupnumber = 1; +// data[sequence].groupnumber = 1; data[sequence].names = name; }else { // its a duplicate. data[sequence].names += "," + name; - data[sequence].groupnumber++; +// data[sequence].groupnumber++; } gobble(in); } - + in.close(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function readFastaFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -62,46 +54,81 @@ void FastaMap::readFastaFile(ifstream& in) { /*******************************************************************************/ -string FastaMap::getGroupName(string seq) { //pass a sequence name get its group - return data[seq].groupname; +void FastaMap::readFastaFile(string inFastaFile, string oldNameFileName){ //prints data + + ifstream oldNameFile; + openInputFile(oldNameFileName, oldNameFile); + + map oldNameMap; + string name, list; + while(!oldNameFile.eof()){ + oldNameFile >> name >> list; + oldNameMap[name] = list; + gobble(oldNameFile); + } + oldNameFile.close(); + + ifstream inFASTA; + openInputFile(inFastaFile, inFASTA); + string sequence; + while(!inFASTA.eof()){ + Sequence currSeq(inFASTA); + name = currSeq.getName(); + + if(currSeq.getIsAligned()) { sequence = currSeq.getAligned(); } + else { sequence = currSeq.getUnaligned(); } + + seqmap[name] = sequence; + map::iterator it = data.find(sequence); + if (it == data.end()) { //it's unique. + data[sequence].groupname = name; //group name will be the name of the first duplicate sequence found. +// data[sequence].groupnumber = 1; + data[sequence].names = oldNameMap[name]; + }else { // its a duplicate. + data[sequence].names += "," + oldNameMap[name]; +// data[sequence].groupnumber++; + } + + gobble(inFASTA); + } + + + inFASTA.close(); } /*******************************************************************************/ -string FastaMap::getNames(string seq) { //pass a sequence get the string of names in the group separated by ','s. - return data[seq].names; +string FastaMap::getGroupName(string seq) { //pass a sequence name get its group + return data[seq].groupname; } /*******************************************************************************/ -int FastaMap::getGroupNumber(string seq) { //pass a sequence get the number of identical sequences. - return data[seq].groupnumber; +string FastaMap::getNames(string seq) { //pass a sequence get the string of names in the group separated by ','s. + return data[seq].names; } /*******************************************************************************/ string FastaMap::getSequence(string name) { - it2 = seqmap.find(name); - if (it2 == seqmap.end()) { //it's not found - return "not found"; - }else { // found it - return it2->second; - } + + map::iterator it = seqmap.find(name); + if (it == seqmap.end()) { return "not found"; } + else { return it->second; } + } /*******************************************************************************/ void FastaMap::push_back(string name, string seq) { - it = data.find(seq); + + map::iterator it = data.find(seq); if (it == data.end()) { //it's unique. data[seq].groupname = name; //group name will be the name of the first duplicate sequence found. - data[seq].groupnumber = 1; data[seq].names = name; }else { // its a duplicate. data[seq].names += "," + name; - data[seq].groupnumber++; } - seqmap[name] = seq; } @@ -113,12 +140,16 @@ int FastaMap::sizeUnique(){ //returns datas size which is the number of unique s /*******************************************************************************/ -void FastaMap::printNamesFile(ostream& out){ //prints data +void FastaMap::printNamesFile(string outFileName){ //prints data try { + ofstream outFile; + openOutputFile(outFileName, outFile); + // two column file created with groupname and them list of identical sequence names - for (it = data.begin(); it != data.end(); it++) { - out << it->second.groupname << '\t' << it->second.names << endl; + for (map::iterator it = data.begin(); it != data.end(); it++) { + outFile << it->second.groupname << '\t' << it->second.names << endl; } + outFile.close(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -132,13 +163,16 @@ void FastaMap::printNamesFile(ostream& out){ //prints data /*******************************************************************************/ -void FastaMap::printCondensedFasta(ostream& out){ //prints data +void FastaMap::printCondensedFasta(string outFileName){ //prints data try { + ofstream out; + openOutputFile(outFileName, out); //creates a fasta file - for (it = data.begin(); it != data.end(); it++) { + for (map::iterator it = data.begin(); it != data.end(); it++) { out << ">" << it->second.groupname << endl; out << it->first << endl; } + out.close(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; diff --git a/fastamap.h b/fastamap.h index 6051874..e628aed 100644 --- a/fastamap.h +++ b/fastamap.h @@ -25,29 +25,23 @@ public: ~FastaMap() {}; string getGroupName(string); //pass a sequence name get its group - int getGroupNumber(string); //pass a sequence name get number of sequence in its group string getNames(string); //pass a sequence get the string of names in the group separated by ','s. void push_back(string, string); //sequencename, sequence int sizeUnique(); //returns number of unique sequences - void printNamesFile(ostream&); //produces a 2 column file with the groupname in the first column and the names in the second column - a names file. - void printCondensedFasta(ostream&); //produces a fasta file. - void readFastaFile(ifstream&); + void printNamesFile(string); //produces a 2 column file with the groupname in the first column and the names in the second column - a names file. + void printCondensedFasta(string); //produces a fasta file. + void readFastaFile(string); + void readFastaFile(string, string); string getSequence(string); //pass it a name of a sequence, it returns the sequence. private: struct group { string groupname; //the group name for identical sequences, will be set to the first sequence found. - int groupnumber; //the number of sequence names with the same sequence. string names; //the names of the sequence separated by ','. }; map data; //sequence, groupinfo - condensed representation of file map seqmap; //name, sequence - uncondensed representation of file - map::iterator it; - map::iterator it2; - - string readName(ifstream&); - string readSequence(ifstream&); }; #endif diff --git a/fullmatrix.h b/fullmatrix.h index 95c472f..a669f70 100644 --- a/fullmatrix.h +++ b/fullmatrix.h @@ -51,4 +51,4 @@ private: GlobalData* globaldata; }; -#endif \ No newline at end of file +#endif diff --git a/getlabelcommand.h b/getlabelcommand.h index 326d894..3e18026 100644 --- a/getlabelcommand.h +++ b/getlabelcommand.h @@ -28,4 +28,4 @@ private: bool abort; }; -#endif \ No newline at end of file +#endif diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp index 65c1806..8008079 100644 --- a/getoturepcommand.cpp +++ b/getoturepcommand.cpp @@ -112,7 +112,7 @@ GetOTURepCommand::GetOTURepCommand(string option){ } }else { cout << "error, no listvector." << endl; } - openInputFile(fastafile, in); +// openInputFile(fastafile, in); fasta = new FastaMap(); } @@ -177,7 +177,7 @@ int GetOTURepCommand::execute(){ int error; //read fastafile - fasta->readFastaFile(in); + fasta->readFastaFile(fastafile); in.close(); diff --git a/mothur.h b/mothur.h index ec56c50..e5d1113 100644 --- a/mothur.h +++ b/mothur.h @@ -1,7 +1,6 @@ #ifndef MOTHUR_H #define MOTHUR_H -using namespace std; /* @@ -40,13 +39,24 @@ using namespace std; #include #include #include + +//misc +#include #include +#include + +using namespace std; #ifdef _WIN32 #define exp(x) (exp((double) x)) #define sqrt(x) (sqrt((double) x)) #define log10(x) (log10((double) x)) #define log2(x) (log10(x)/log10(2)) + #define isnan(x) ((x) != (x)) + #define isinf(x) (fabs(x) == std::numeric_limits::infinity()) +#else + #include + #include #endif diff --git a/nameassignment.cpp b/nameassignment.cpp index 21703e4..cf4e677 100644 --- a/nameassignment.cpp +++ b/nameassignment.cpp @@ -12,37 +12,33 @@ NameAssignment::NameAssignment(string nameMapFile){ //********************************************************************************************************************** -void NameAssignment::readMap(int colA, int colB){ +void NameAssignment::readMap(){ try{ string firstCol, secondCol, skip; // int index = 0; - int skipNCols = colB-colA-1; - - map data; +// map data; + int rowIndex = 0; + while(fileHandle){ fileHandle >> firstCol; //read from first column - - for(int i=0;i> skip; - } - fileHandle >> secondCol; //read from second column - - data[firstCol] = secondCol; //store data in map - + +// data[firstCol] = secondCol; //store data in map + + list.push_back(secondCol); //adds data's value to list + (*this)[firstCol] = rowIndex++; gobble(fileHandle); } fileHandle.close(); - int rowIndex = 0; - map::iterator it = data.begin(); - for(it;it!=data.end();it++){ - list.push_back(it->second); //adds data's value to list - (*this)[it->first] = rowIndex; - rowIndex++; - } +// map::iterator it = data.begin(); +// for(it;it!=data.end();it++){ +// cout << it->first << endl; +// (*this)[it->first] = rowIndex; +// rowIndex++; +// } } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the NameAssignment class Function readMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; diff --git a/nameassignment.hpp b/nameassignment.hpp index 93299cc..e36a763 100644 --- a/nameassignment.hpp +++ b/nameassignment.hpp @@ -7,7 +7,7 @@ class NameAssignment : public map { public: NameAssignment(string); - void readMap(int, int); + void readMap(); ListVector getListVector(); int get(string); void print(); diff --git a/parselistcommand.cpp b/parselistcommand.cpp index c12bd47..f040307 100644 --- a/parselistcommand.cpp +++ b/parselistcommand.cpp @@ -220,4 +220,4 @@ void ParseListCommand::process(SharedListVector* thisList) { cout << "An unknown error has occurred in the ParseListCommand class function process. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; exit(1); } -} \ No newline at end of file +} diff --git a/parsimony.h b/parsimony.h index a22f5bd..d4f71ab 100644 --- a/parsimony.h +++ b/parsimony.h @@ -34,4 +34,5 @@ class Parsimony : public TreeCalculator { }; /***********************************************************************/ -#endif \ No newline at end of file + +#endif diff --git a/readcolumn.cpp b/readcolumn.cpp index 59c3bd5..c03c37f 100644 --- a/readcolumn.cpp +++ b/readcolumn.cpp @@ -22,122 +22,109 @@ ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){ void ReadColumnMatrix::read(NameAssignment* nameMap){ try { + + string firstName, secondName; + float distance; + int nseqs = nameMap->size(); + + list = new ListVector(nameMap->getListVector()); - string firstName, secondName; - float distance; - int nseqs = nameMap->size(); + Progress* reading = new Progress("Reading matrix: ", nseqs * nseqs); - list = new ListVector(nameMap->getListVector()); - - Progress* reading = new Progress("Reading matrix: ", nseqs * nseqs); + int lt = 1; + int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose + int refCol = 0; //shows up later - Cell(refCol,refRow). If it does, then its a square matrix + + //need to see if this is a square or a triangular matrix... - int lt = 1; - int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose - int refCol = 0; //shows up later - Cell(refCol,refRow). If it does, then its a square matrix + while(fileHandle && lt == 1){ //let's assume it's a triangular matrix... + + fileHandle >> firstName >> secondName >> distance; // get the row and column names and distance - //need to see if this is a square or a triangular matrix... - while(fileHandle && lt == 1){ //let's assume it's a triangular matrix... + map::iterator itA = nameMap->find(firstName); + map::iterator itB = nameMap->find(secondName); - fileHandle >> firstName >> secondName >> distance; // get the row and column names and distance - - if(nameMap->count(firstName)==0){ - cerr << "AError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; - } - if(nameMap->count(secondName)==0){ - cerr << "AError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; - } - - if (distance == -1) { distance = 1000000; } - - if(distance < cutoff && nameMap->get(firstName) != nameMap->get(secondName)){ - if(nameMap->get(firstName) > nameMap->get(secondName)){ - PCell value(nameMap->get(firstName), nameMap->get(secondName), distance); - - if(refRow == refCol){ // in other words, if we haven't loaded refRow and refCol... - refRow = nameMap->get(firstName); - refCol = nameMap->get(secondName); - D->addCell(value); - } - else if(refRow == nameMap->get(firstName) && refCol == nameMap->get(secondName)){ - lt = 0; - } - else{ - D->addCell(value); - } - } - else if(nameMap->get(firstName) < nameMap->get(secondName)){ - PCell value(nameMap->get(secondName), nameMap->get(firstName), distance); - - if(refRow == refCol){ // in other words, if we haven't loaded refRow and refCol... - refRow = nameMap->get(firstName); - refCol = nameMap->get(secondName); - D->addCell(value); - } - else if(refRow == nameMap->get(secondName) && refCol == nameMap->get(firstName)){ - lt = 0; - } - else{ - D->addCell(value); - } - } - reading->update(nameMap->get(firstName) * nseqs); - } - gobble(fileHandle); + if(itA == nameMap->end()){ + cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; + } + if(itB == nameMap->end()){ + cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; } - 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 - - while(fileHandle){ - fileHandle >> firstName >> secondName >> distance; + if (distance == -1) { distance = 1000000; } + + if(distance < cutoff && itA != itB){ + if(itA->second > itB->second){ + PCell value(itA->second, itB->second, distance); - if(nameMap->count(firstName)==0){ - cerr << "BError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; + if(refRow == refCol){ // in other words, if we haven't loaded refRow and refCol... + refRow = itA->second; + refCol = itB->second; + D->addCell(value); } - if(nameMap->count(secondName)==0){ - cerr << "BError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; + else if(refRow == itA->second && refCol == itB->second){ + lt = 0; } - - if (distance == -1) { distance = 1000000; } - - if(distance < cutoff && nameMap->get(firstName) > nameMap->get(secondName)){ - PCell value(nameMap->get(firstName), nameMap->get(secondName), distance); + else{ D->addCell(value); - reading->update(nameMap->get(firstName) * nseqs); } + } + else if(itA->second < itB->second){ + PCell value(itB->second, itA->second, distance); - gobble(fileHandle); + if(refRow == refCol){ // in other words, if we haven't loaded refRow and refCol... + refRow = itA->second; + refCol = itB->second; + D->addCell(value); + } + else if(refRow == itB->second && refCol == itA->second){ + lt = 0; + } + else{ + D->addCell(value); + } } + reading->update(itA->second * nseqs); } - // else if(lt == 0){ - // while(fileHandle){ - // fileHandle >> firstName >> secondName >> distance; - // - // if(nameMap->count(firstName)==0){ - // cerr << "CError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; - // } - // if(nameMap->count(secondName)==0){ - // cerr << "CError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; - // } - // if (distance == -1) { distance = 1000000; } + 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 + + while(fileHandle){ + fileHandle >> firstName >> secondName >> distance; - // if(distance < cutoff && (*nameMap)[firstName].second < (*nameMap)[secondName].second){ - //// cout << (*nameMap)[secondName] << ' ' << (*nameMap)[firstName] << ' ' << distance << endl; - // D->addCell(Cell((*nameMap)[secondName].second, (*nameMap)[firstName].second, distance)); - // reading->update((*nameMap)[secondName].second * nseqs); - // } - // - // gobble(fileHandle); - // } - // } - reading->finish(); - fileHandle.close(); - - list->setLabel("0"); - + map::iterator itA = nameMap->find(firstName); + map::iterator itB = nameMap->find(secondName); + + if(itA == nameMap->end()){ + cerr << "BError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; + } + if(itB == nameMap->end()){ + cerr << "BError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; + } + + if (distance == -1) { distance = 1000000; } + + if(distance < cutoff && itA->second > itB->second){ + PCell value(itA->second, itB->second, distance); + D->addCell(value); + reading->update(itA->second * nseqs); + } + + gobble(fileHandle); + } + } + + reading->finish(); + fileHandle.close(); + + list->setLabel("0"); + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the ReadColumnMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; diff --git a/readcolumn.h b/readcolumn.h index 2e0120f..fea6f59 100644 --- a/readcolumn.h +++ b/readcolumn.h @@ -26,4 +26,4 @@ private: /******************************************************/ -#endif \ No newline at end of file +#endif diff --git a/readdistcommand.cpp b/readdistcommand.cpp index 392d12b..744a35d 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -61,7 +61,6 @@ ReadDistCommand::ReadDistCommand(string option){ if (namefile == "not open") { abort = true; } else if (namefile == "not found") { namefile = ""; } else { globaldata->setNameFile(namefile); } - //you are doing a list and group shared if ((phylipfile != "") && (groupfile != "")) { @@ -103,7 +102,7 @@ ReadDistCommand::ReadDistCommand(string option){ if(namefile != ""){ nameMap = new NameAssignment(namefile); - nameMap->readMap(1,2); + nameMap->readMap(); }else{ nameMap = NULL; } diff --git a/readotu.h b/readotu.h index b259733..399316d 100644 --- a/readotu.h +++ b/readotu.h @@ -43,4 +43,4 @@ private: }; -#endif \ No newline at end of file +#endif diff --git a/readphylip.h b/readphylip.h index eab0df4..9277338 100644 --- a/readphylip.h +++ b/readphylip.h @@ -26,4 +26,4 @@ private: /******************************************************/ -#endif \ No newline at end of file +#endif diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 70094f2..d0f0af0 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -156,9 +156,9 @@ int ScreenSeqsCommand::execute(){ } gobble(inFASTA); } - if(namefile != "") { screenNameGroupFile(badSeqNames); } - if(groupfile != "") { screenGroupFile(badSeqNames); } - if(alignreport != "") { screenAlignReport(badSeqNames); } + if(namefile != "" && groupfile != "") { screenNameGroupFile(badSeqNames); } // this screens both names and groups + else if(groupfile != "") { screenGroupFile(badSeqNames); } // this screens just the groups + if(alignreport != "") { screenAlignReport(badSeqNames); } goodSeqOut.close(); badSeqOut.close(); diff --git a/sharedanderbergs.h b/sharedanderbergs.h index 2460cfe..becfe7d 100644 --- a/sharedanderbergs.h +++ b/sharedanderbergs.h @@ -25,6 +25,4 @@ class Anderberg : public Calculator { /***********************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/sharedkulczynski.h b/sharedkulczynski.h index 58594c6..0bace81 100644 --- a/sharedkulczynski.h +++ b/sharedkulczynski.h @@ -26,6 +26,4 @@ private: /***********************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/sharedkulczynskicody.h b/sharedkulczynskicody.h index c09be3a..1df563a 100644 --- a/sharedkulczynskicody.h +++ b/sharedkulczynskicody.h @@ -27,6 +27,4 @@ private: /***********************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/sharedlennon.h b/sharedlennon.h index cd2ebf6..77eb629 100644 --- a/sharedlennon.h +++ b/sharedlennon.h @@ -27,6 +27,4 @@ private: /***********************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/sharedmarczewski.h b/sharedmarczewski.h index 40cc9a4..2bbd622 100644 --- a/sharedmarczewski.h +++ b/sharedmarczewski.h @@ -25,4 +25,4 @@ private: /***********************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/sharedmorisitahorn.cpp b/sharedmorisitahorn.cpp index eeb01d3..28ff4fe 100644 --- a/sharedmorisitahorn.cpp +++ b/sharedmorisitahorn.cpp @@ -59,4 +59,4 @@ EstOutput MorHorn::getValues(vector shared) { } } -/***********************************************************************/ \ No newline at end of file +/***********************************************************************/ diff --git a/sharedochiai.h b/sharedochiai.h index 99003e6..78ec0ae 100644 --- a/sharedochiai.h +++ b/sharedochiai.h @@ -26,4 +26,4 @@ private: /***********************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/sharedordervector.cpp b/sharedordervector.cpp index a009db1..218ed87 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -33,7 +33,7 @@ SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() { //reads in a if (globaldata->gGroupmap == NULL) { groupmap = new GroupMap(); } - int num, inputData, pos, count; + int num, inputData, count; count = 0; numSeqs = 0; string holdLabel, nextLabel, groupN; individual newguy; diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp index 6815d87..c0cc507 100644 --- a/sharedsobscollectsummary.cpp +++ b/sharedsobscollectsummary.cpp @@ -43,4 +43,4 @@ EstOutput SharedSobsCS::getValues(vector shared){ } } -/***********************************************************************/ \ No newline at end of file +/***********************************************************************/ diff --git a/sharedutilities.h b/sharedutilities.h index 75ecf23..f6b95e3 100644 --- a/sharedutilities.h +++ b/sharedutilities.h @@ -37,6 +37,4 @@ class SharedUtil { /**************************************************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 4006b2d..1a3ecf0 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -417,4 +417,4 @@ void SummarySharedCommand::process(vector thisLookup) { } } -/***********************************************************/ \ No newline at end of file +/***********************************************************/ diff --git a/treecalculator.h b/treecalculator.h index 35d061c..797c457 100644 --- a/treecalculator.h +++ b/treecalculator.h @@ -38,4 +38,4 @@ protected: /***********************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 88b1b46..83443d0 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -251,7 +251,7 @@ int TreeGroupCommand::execute(){ if(namefile != ""){ nameMap = new NameAssignment(namefile); - nameMap->readMap(1,2); + nameMap->readMap(); } else{ nameMap = NULL; diff --git a/unifracunweightedcommand.h b/unifracunweightedcommand.h index 7707df4..2fca41a 100644 --- a/unifracunweightedcommand.h +++ b/unifracunweightedcommand.h @@ -58,6 +58,4 @@ class UnifracUnweightedCommand : public Command { }; - - -#endif \ No newline at end of file +#endif diff --git a/unweighted.h b/unweighted.h index 8751469..007fef7 100644 --- a/unweighted.h +++ b/unweighted.h @@ -34,6 +34,4 @@ class Unweighted : public TreeCalculator { /***********************************************************************/ - - -#endif \ No newline at end of file +#endif diff --git a/venncommand.cpp b/venncommand.cpp index 343461a..6821e1d 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -358,4 +358,4 @@ int VennCommand::execute(){ } } -//********************************************************************************************************************** \ No newline at end of file +//********************************************************************************************************************** diff --git a/venncommand.h b/venncommand.h index 0b89143..79a22d9 100644 --- a/venncommand.h +++ b/venncommand.h @@ -51,4 +51,4 @@ private: -#endif \ No newline at end of file +#endif diff --git a/weighted.h b/weighted.h index 3fed6f5..3914ef2 100644 --- a/weighted.h +++ b/weighted.h @@ -35,4 +35,4 @@ class Weighted : public TreeCalculator { /***********************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/whittaker.cpp b/whittaker.cpp index 3b17911..4b66ec9 100644 --- a/whittaker.cpp +++ b/whittaker.cpp @@ -36,4 +36,4 @@ EstOutput Whittaker::getValues(vector shared){ } } -/***********************************************************************/ \ No newline at end of file +/***********************************************************************/ diff --git a/whittaker.h b/whittaker.h index bcd72fc..540dc0b 100644 --- a/whittaker.h +++ b/whittaker.h @@ -26,4 +26,4 @@ public: /***********************************************************************/ -#endif \ No newline at end of file +#endif