-
- //get counts
- for (int j = 0; j < seqLength; j++) {
-
- if (m->control_pressed) { return consSeq; }
-
- vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
- int numDots = 0;
-
- for (int i = 0; i < seqs.size(); i++) {
-
- if (seqs[i][j] == '.') { numDots++; }
-
- char base = toupper(seqs[i][j]);
- if (base == 'A') { counts[0]++; }
- else if (base == 'T') { counts[1]++; }
- else if (base == 'G') { counts[2]++; }
- else if (base == 'C') { counts[3]++; }
- else { counts[4]++; }
- }
-
- char conBase = '.';
- if (numDots != seqs.size()) { conBase = getBase(counts); }
-
- consSeq += conBase;
-
- percentages[0][j] = counts[0] / (float) seqs.size();
- percentages[1][j] = counts[1] / (float) seqs.size();
- percentages[2][j] = counts[2] / (float) seqs.size();
- percentages[3][j] = counts[3] / (float) seqs.size();
- percentages[4][j] = counts[4] / (float) seqs.size();
-
+
+ if (countfile != "") {
+ //get counts
+ for (int j = 0; j < seqLength; j++) {
+
+ if (m->control_pressed) { return consSeq; }
+
+ vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
+ int numDots = 0;
+ totalSize = 0;
+ for (int i = 0; i < binNames.size(); i++) {
+ if (m->control_pressed) { return consSeq; }
+
+ string thisSeq = "";
+ map<string, string>::iterator itFasta = fastaMap.find(binNames[i]);
+ if (itFasta != fastaMap.end()) {
+ thisSeq = itFasta->second;
+ }else { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta file, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
+
+ int size = ct.getNumSeqs(binNames[i]);
+ if (size != 0) {
+ for (int k = 0; k < size; k++) {
+ if (thisSeq[j] == '.') { numDots++; }
+
+ char base = toupper(thisSeq[j]);
+ if (base == 'A') { counts[0]++; }
+ else if (base == 'T') { counts[1]++; }
+ else if (base == 'G') { counts[2]++; }
+ else if (base == 'C') { counts[3]++; }
+ else { counts[4]++; }
+ totalSize++;
+ }
+ }else { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your count file, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
+ }
+ char conBase = '.';
+ if (numDots != totalSize) { conBase = getBase(counts, totalSize); }
+
+ consSeq += conBase;
+
+ percentages[0][j] = counts[0] / (float) totalSize;
+ percentages[1][j] = counts[1] / (float) totalSize;
+ percentages[2][j] = counts[2] / (float) totalSize;
+ percentages[3][j] = counts[3] / (float) totalSize;
+ percentages[4][j] = counts[4] / (float) totalSize;
+ }
+
+ }else {
+
+ //get sequence strings for each name in the bin
+ vector<string> seqs;
+ for (int i = 0; i < binNames.size(); i++) {
+
+ map<string, string>::iterator it;
+ it = nameMap.find(binNames[i]);
+ if (it == nameMap.end()) {
+ if (namefile == "") { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta file, please correct."); m->mothurOutEndLine(); error = true; }
+ else { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta or name file, please correct."); m->mothurOutEndLine(); error = true; }
+ break;
+ }else {
+ //add sequence string to seqs vector to process below
+ map<string, string>::iterator itFasta = fastaMap.find(it->second);
+
+ if (itFasta != fastaMap.end()) {
+ string seq = itFasta->second;
+ seqs.push_back(seq);
+ }else { m->mothurOut("[ERROR]: file mismatch, aborting. \n"); }
+ }
+ }
+
+ if (error) { m->control_pressed = true; return consSeq; }
+ totalSize = seqs.size();
+ //get counts
+ for (int j = 0; j < seqLength; j++) {
+
+ if (m->control_pressed) { return consSeq; }
+
+ vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
+ int numDots = 0;
+
+ for (int i = 0; i < seqs.size(); i++) {
+
+ if (seqs[i][j] == '.') { numDots++; }
+
+ char base = toupper(seqs[i][j]);
+ if (base == 'A') { counts[0]++; }
+ else if (base == 'T') { counts[1]++; }
+ else if (base == 'G') { counts[2]++; }
+ else if (base == 'C') { counts[3]++; }
+ else { counts[4]++; }
+ }
+
+ char conBase = '.';
+ if (numDots != seqs.size()) { conBase = getBase(counts, seqs.size()); }
+
+ consSeq += conBase;
+
+ percentages[0][j] = counts[0] / (float) seqs.size();
+ percentages[1][j] = counts[1] / (float) seqs.size();
+ percentages[2][j] = counts[2] / (float) seqs.size();
+ percentages[3][j] = counts[3] / (float) seqs.size();
+ percentages[4][j] = counts[4] / (float) seqs.size();
+
+ }