- //look for sequence name in nameMap
- map<string, string>::iterator it = nameMap.find(seq.getName());
-
- if (it == nameMap.end()) { m->mothurOut("[ERROR]: Your namefile does not contain " + seq.getName() + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
- else {
- vector<string> names;
- m->splitAtComma(it->second, names);
-
- //output sequences
- for (int i = 0; i < names.size(); i++) {
- out << ">" << names[i] << endl;
- out << seq.getAligned() << endl;
- }
-
- //remove seq from name map so we can check for seqs in namefile not in fastafile later
- nameMap.erase(it);
- }
+ if (nameFile != "") {
+ //look for sequence name in nameMap
+ map<string, string>::iterator it = nameMap.find(seq.getName());
+
+ if (it == nameMap.end()) { m->mothurOut("[ERROR]: Your namefile does not contain " + seq.getName() + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
+ else {
+ vector<string> names;
+ m->splitAtComma(it->second, names);
+
+ //output sequences
+ for (int i = 0; i < names.size(); i++) {
+ out << ">" << names[i] << endl;
+ out << seq.getAligned() << endl;
+ }
+
+ //remove seq from name map so we can check for seqs in namefile not in fastafile later
+ nameMap.erase(it);
+ }
+ }else {
+ if (ct.hasGroupInfo()) {
+ vector<int> groupCounts = ct.getGroupCounts(seq.getName());
+ int count = 1;
+ for (int i = 0; i < groups.size(); i++) {
+ for (int j = 0; j < groupCounts[i]; j++) {
+ outGroup << seq.getName()+"_"+toString(count) << '\t' << groups[i] << endl; count++;
+ }
+ }
+
+ }
+
+ int numReps = ct.getNumSeqs(seq.getName()); //will report error and set m->control_pressed if not found
+ for (int i = 0; i < numReps; i++) {
+ out << ">" << seq.getName()+"_"+toString(i+1) << endl;
+ out << seq.getAligned() << endl;
+ }
+ }