m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file, and not in your namefile, please correct.");
m->mothurOutEndLine();
} else if (countfile != "") {
- int num = ct.getNumSeqs(seq.getName()); //checks to make sure seq is in table
- if (num != 0) { //its in the table
- ct.mergeCounts(itStrings->second.second, seq.getName()); //merges counts and saves in uniques name
- }
+ int num = ct.getNumSeqs(seq.getName()); //checks to make sure seq is in table
+ if (num != 0) { //its in the table
+ ct.mergeCounts(primary_seqname(itStrings->second.second), seq.getName()); //merges counts and saves in uniques name
+ }
}
itStrings->second.second += "," + seq.getName();
}
if (countfile == "") {
//get rep name
- int pos = (it->second.second).find_first_of(',');
-
- if (pos == string::npos) { // only reps itself
- outNames << it->second.second << '\t' << it->second.second << endl;
- }else {
- outNames << (it->second.second).substr(0, pos) << '\t' << it->second.second << endl;
- }
+ outNames << primary_seqname(it->second.second) << '\t' << it->second.second << endl;
} else {
//get rep name
- int pos = (it->second.second).find_first_of(',');
- if (pos == string::npos) { // only reps itself
- ct.printSeq(outNames, it->second.second);
- } else {
- m->mothurOut("Duplicate " + it->second.second + " " + (it->second.second).substr(0,pos) + "\n");
- ct.printSeq(outNames, (it->second.second).substr(0,pos));
- }
+ ct.printSeq(outNames,primary_seqname(it->second.second);
}
}
outNames.close();
fasta_file.seekg(cur_pos);
return seq_strings.end();
}
+
+
+string primary_seqname(string name) {
+ int pos = name.find_first_of(',');
+ if (pos == string::npos) {
+ return name;
+ }
+ return name.substr(0,pos);
+}