From 54a6cb0ef32b761ebd7ae35f1e60947edf44d699 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 15 Jun 2010 12:05:46 +0000 Subject: [PATCH] final commit before testing 1.11 --- removeseqscommand.cpp | 6 +++--- seqsummarycommand.cpp | 3 ++- sequence.cpp | 46 ++++++++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp index 35d9bea..5816cfd 100644 --- a/removeseqscommand.cpp +++ b/removeseqscommand.cpp @@ -334,7 +334,7 @@ int RemoveSeqsCommand::readName(){ string name, firstCol, secondCol; bool wroteSomething = false; - int numSeqsInNames = 0; + while(!in.eof()){ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } @@ -359,7 +359,7 @@ int RemoveSeqsCommand::readName(){ validSecond.push_back(parsedNames[i]); } } - numSeqsInNames += parsedNames.size(); + if ((dups) && (validSecond.size() != parsedNames.size())) { //if dups is true and we want to get rid of anyone, get rid of everyone for (int i = 0; i < parsedNames.size(); i++) { names.insert(parsedNames[i]); } }else { @@ -394,7 +394,7 @@ int RemoveSeqsCommand::readName(){ } in.close(); out.close(); -cout << "your names file contains " << numSeqsInNames << endl; + if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine(); remove(outputFileName.c_str()); diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index f225d50..d613391 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -230,7 +230,7 @@ int SeqSummaryCommand::execute(){ openInputFile(fastafile, inFASTA); numSeqs=count(istreambuf_iterator(inFASTA),istreambuf_iterator(), '>'); inFASTA.close(); - + cout << numSeqs << endl; lines.push_back(new linePair(0, numSeqs)); driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, summaryFile, lines[0]); @@ -334,6 +334,7 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vectorcontrol_pressed) { in.close(); outSummary.close(); return 1; } Sequence current(in); + if (current.getName() != "") { startPosition.push_back(current.getStartPos()); endPosition.push_back(current.getEndPos()); diff --git a/sequence.cpp b/sequence.cpp index 71dd3a9..0afe3a9 100644 --- a/sequence.cpp +++ b/sequence.cpp @@ -129,31 +129,37 @@ Sequence::Sequence(ifstream& fastaFile){ m = MothurOut::getInstance(); initialize(); fastaFile >> name; - name = name.substr(1); - string sequence; + + if (name.length() != 0) { - //read comments - while ((name[0] == '#') && fastaFile) { - while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there - sequence = getCommentString(fastaFile); + name = name.substr(1); - if (fastaFile) { - fastaFile >> name; - name = name.substr(1); - }else { - name = ""; - break; - } - } + string sequence; - //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 + //read comments + while ((name[0] == '#') && fastaFile) { + while (!fastaFile.eof()) { char c = fastaFile.get(); if (c == 10 || c == 13){ break; } } // get rest of line if there's any crap there + sequence = getCommentString(fastaFile); + + if (fastaFile) { + fastaFile >> name; + name = name.substr(1); + }else { + name = ""; + break; + } + } + + //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 + + sequence = getSequenceString(fastaFile); - sequence = getSequenceString(fastaFile); + setAligned(sequence); + //setUnaligned removes any gap characters for us + setUnaligned(sequence); + } - setAligned(sequence); - //setUnaligned removes any gap characters for us - setUnaligned(sequence); } catch(exception& e) { m->errorOut(e, "Sequence", "Sequence"); -- 2.39.2