void parseFasta(SeqStream input_stream, string filename, SeqSet &data) { data.filename = filename; char ch; string temp = ""; string nm; unsigned size_guess = 10000; // Seems like it might speed things up // Enclose all of this in a while loop that goes to EOF: input_stream.get(ch); if(ch != '>') { throw("Not in FASTA format"); } bool inseq = false; bool linebreak = false; while(!input_stream.eof()) { SeqRecord rec; rec.reserve(size_guess); nm = ""; while (true && !inseq) { if(!input_stream.good()) { throw("Problem reading file"); } input_stream.get(ch); if (ch == '\n' || ch == '\r') inseq = true; nm += ch; } rec.setName(nm); temp = ""; while(inseq){ input_stream.get(ch); if(input_stream.eof()) break; // ">" after a linebreak means a new name if(ch == '>' && linebreak) { inseq = false; linebreak = false; continue; } // Ignore, but note linebreaks linebreak = false; if(ch == '\n' || ch == '\r') { linebreak = true; continue; } // Ignore whitespace if(ch == ' ' || ch == '\t') { continue; } temp += ch; } rec.append(temp); data.append(rec); size_guess = rec.getSeq().size(); } }