From: westcott Date: Fri, 17 Sep 2010 16:55:59 +0000 (+0000) Subject: bug fixes X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=8c616f2509abd2fb9485a38607c1b439d243b85c bug fixes --- diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 0f03784..c59b637 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -786,8 +786,8 @@ A7DA207D113FECD400BF472F /* heatmapsimcommand.h */, A7DA207E113FECD400BF472F /* helpcommand.cpp */, A7DA207F113FECD400BF472F /* helpcommand.h */, - A7DA208D113FECD400BF472F /* libshuffcommand.cpp */, A7DA208E113FECD400BF472F /* libshuffcommand.h */, + A7DA208D113FECD400BF472F /* libshuffcommand.cpp */, A7DA2090113FECD400BF472F /* listseqscommand.h */, A7DA208F113FECD400BF472F /* listseqscommand.cpp */, A703FE931194645F002C397E /* makegroupcommand.h */, diff --git a/aligncommand.cpp b/aligncommand.cpp index 5aabeef..877e7c7 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -488,7 +488,7 @@ int AlignCommand::driver(linePair* filePos, string alignFName, string reportFNam if (m->control_pressed) { return 0; } Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA); - + int origNumBases = candidateSeq->getNumBases(); string originalUnaligned = candidateSeq->getUnaligned(); int numBasesNeeded = origNumBases * threshold; @@ -565,8 +565,12 @@ int AlignCommand::driver(linePair* filePos, string alignFName, string reportFNam } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index 6a1904f..753bc9a 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -423,8 +423,12 @@ int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string fi } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index 4d99aa4..1855439 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -394,8 +394,12 @@ int ChimeraCheckCommand::driver(linePair* filePos, string outputFName, string fi } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index 398d37a..7c3b24b 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -494,8 +494,12 @@ int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 8a80d4d..996843b 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -439,8 +439,12 @@ int ChimeraSlayerCommand::driver(linePair* filePos, string outputFName, string f } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/classifyotucommand.cpp b/classifyotucommand.cpp index 0e23461..b724a68 100644 --- a/classifyotucommand.cpp +++ b/classifyotucommand.cpp @@ -245,7 +245,7 @@ int ClassifyOtuCommand::readNamesFile() { string name, names; - while(inNames){ + while(!inNames.eof()){ inNames >> name; //read from first column A inNames >> names; //read from second column A,B,C,D m->gobble(inNames); @@ -313,9 +313,10 @@ string ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList, size = 0; for (int i = 0; i < names.size(); i++) { - + //if namesfile include the names if (namefile != "") { + //is this sequence in the name file - namemap maps seqName -> repSeqName it2 = nameMap.find(names[i]); @@ -327,7 +328,8 @@ string ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList, it = taxMap.find(it2->second); if (it == taxMap.end()) { //this name is not in taxonomy file, skip it - if (names[i] != it->second) { m->mothurOut(names[i] + " is represented by " + it2->second + " and is not in your taxonomy file. I will not include it in the consensus."); m->mothurOutEndLine(); } + + if (names[i] != it2->second) { m->mothurOut(names[i] + " is represented by " + it2->second + " and is not in your taxonomy file. I will not include it in the consensus."); m->mothurOutEndLine(); } else { m->mothurOut(names[i] + " is not in your taxonomy file. I will not include it in the consensus."); m->mothurOutEndLine(); } }else{ @@ -426,8 +428,9 @@ int ClassifyOtuCommand::process(ListVector* processList) { //for each bin in the list vector for (int i = 0; i < processList->getNumBins(); i++) { + conTax = findConsensusTaxonomy(i, processList, size); - + if (m->control_pressed) { out.close(); return 0; } //output to new names file diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index e934d9d..33f49e5 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -767,8 +767,12 @@ int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempT } delete candidateSeq; - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index 1b3b3cf..addc5f3 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -485,8 +485,12 @@ int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string i count++; } - unsigned long int pos = in.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = in.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (in.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } @@ -786,8 +790,12 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair* count++; } - unsigned long int pos = in.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = in.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (in.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } diff --git a/groupmap.cpp b/groupmap.cpp index 0e0be0e..f6705e5 100644 --- a/groupmap.cpp +++ b/groupmap.cpp @@ -46,6 +46,32 @@ int GroupMap::readMap() { fileHandle.close(); return error; } +/************************************************************/ +int GroupMap::readDesignMap() { + string seqName, seqGroup; + int error = 0; + + while(fileHandle){ + fileHandle >> seqName; m->gobble(fileHandle); //read from first column + fileHandle >> seqGroup; //read from second column + + if (m->control_pressed) { fileHandle.close(); return 1; } + + setNamesOfGroups(seqGroup); + + it = groupmap.find(seqName); + + if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 group named " + seqName + ", group names must be unique. Please correct."); m->mothurOutEndLine(); } + else { + groupmap[seqName] = seqGroup; //store data in map + seqsPerGroup[seqGroup]++; //increment number of seqs in that group + } + m->gobble(fileHandle); + } + fileHandle.close(); + return error; +} + /************************************************************/ int GroupMap::getNumGroups() { return namesOfGroups.size(); } /************************************************************/ diff --git a/groupmap.h b/groupmap.h index 8a1cfff..d0e43c5 100644 --- a/groupmap.h +++ b/groupmap.h @@ -21,6 +21,7 @@ public: GroupMap(string); ~GroupMap(); int readMap(); + int readDesignMap(); int getNumGroups(); bool isValidGroup(string); //return true if string is a valid group string getGroup(string); diff --git a/makefile b/makefile index 44f5484..92c2013 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,7 @@ CXXFLAGS += -O3 MOTHUR_FILES = "\"../Release\"" -RELEASE_DATE = "\"9/9/2010\"" +RELEASE_DATE = "\"9/17/2010\"" VERSION = "\"1.13.0\"" CXXFLAGS += -DRELEASE_DATE=${RELEASE_DATE} -DVERSION=${VERSION} diff --git a/mothurout.cpp b/mothurout.cpp index 0c3ef3d..1231700 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -276,8 +276,9 @@ int MothurOut::openOutputFileAppend(string fileName, ofstream& fileHandle){ /***********************************************************************/ void MothurOut::gobble(istream& f){ try { + char d; - while(isspace(d=f.get())) {;} + while(isspace(d=f.get())) { ;} f.putback(d); } catch(exception& e) { @@ -984,7 +985,7 @@ vector MothurOut::divideFile(string filename, int& proc) { //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; } @@ -1002,7 +1003,7 @@ vector MothurOut::divideFile(string filename, int& proc) { 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(); @@ -1017,7 +1018,7 @@ vector MothurOut::divideFile(string filename, int& proc) { //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--; } + if (filePos[(i+1)] <= filePos[i]) { cout << "erasing " << (i+1) << endl; filePos.erase(filePos.begin()+(i+1)); i--; } } proc = (filePos.size() - 1); diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 5f5d22f..581264c 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -662,8 +662,12 @@ int ScreenSeqsCommand::driver(linePair* filePos, string goodFName, string badAcc count++; } - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif //report progress if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine(); } diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index abef126..a47364a 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -343,8 +343,12 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vector= filePos->end)) { break; } + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = in.tellg(); + if ((pos == -1) || (pos >= filePos->end)) { break; } + #else + if (in.eof()) { break; } + #endif //report progress //if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } diff --git a/sequence.cpp b/sequence.cpp index 04f97a8..78fa266 100644 --- a/sequence.cpp +++ b/sequence.cpp @@ -74,14 +74,14 @@ Sequence::Sequence(istringstream& fastaString){ } } - while (!fastaString.eof()) { char c = fastaString.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there + while (!fastaString.eof()) { char c = fastaString.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there sequence = getSequenceString(fastaString); setAligned(sequence); //setUnaligned removes any gap characters for us setUnaligned(sequence); }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaString.tellg()) + ". Blank name."); m->mothurOutEndLine(); } - + } catch(exception& e) { m->errorOut(e, "Sequence", "Sequence"); @@ -116,13 +116,14 @@ Sequence::Sequence(istringstream& fastaString, string JustUnaligned){ } } - while (!fastaString.eof()) { char c = fastaString.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there + while (!fastaString.eof()) { char c = fastaString.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there sequence = getSequenceString(fastaString); //setUnaligned removes any gap characters for us setUnaligned(sequence); }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaString.tellg()) + ". Blank name."); m->mothurOutEndLine(); } + } catch(exception& e) { m->errorOut(e, "Sequence", "Sequence"); @@ -160,15 +161,15 @@ Sequence::Sequence(ifstream& fastaFile){ } //read real sequence - while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there + while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there sequence = getSequenceString(fastaFile); - + setAligned(sequence); //setUnaligned removes any gap characters for us setUnaligned(sequence); }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); } - + } catch(exception& e) { m->errorOut(e, "Sequence", "Sequence"); @@ -202,14 +203,14 @@ Sequence::Sequence(ifstream& fastaFile, string JustUnaligned){ } //read real sequence - while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there + while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there sequence = getSequenceString(fastaFile); //setUnaligned removes any gap characters for us setUnaligned(sequence); }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); } - + } catch(exception& e) { m->errorOut(e, "Sequence", "Sequence"); diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 320bc41..1d70fb1 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -571,9 +571,13 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string count++; } - unsigned long int pos = inFASTA.tellg(); - if ((pos == -1) || (pos >= line->end)) { break; } - + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + unsigned long int pos = inFASTA.tellg(); + if ((pos == -1) || (pos >= line->end)) { break; } + #else + if (inFASTA.eof()) { break; } + #endif + //report progress if((count) % 1000 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); }