}
//check for necessary files
- string taxFileNameTest = refTfile.substr(0,refTfile.find_last_of(".")+1) + "tree.sum";
+ string taxFileNameTest = m->getFullPathName((refTfile.substr(0,refTfile.find_last_of(".")+1) + "tree.sum"));
ifstream FileTest(taxFileNameTest.c_str());
if (!FileTest) {
int PhyloSummary::summarize(string userTfile){
try {
-
- ifstream in;
- m->openInputFile(userTfile, in);
-
- //read in users taxonomy file and add sequences to tree
- string name, tax;
- int numSeqs = 0;
- while(!in.eof()){
- in >> name >> tax; m->gobble(in);
-
- addSeqToTree(name, tax);
+ map<string, string> temp;
+ m->readTax(userTfile, temp);
+
+ for (map<string, string>::iterator itTemp = temp.begin(); itTemp != temp.end();) {
+ addSeqToTree(itTemp->first, itTemp->second);
numSeqs++;
-
- if (m->control_pressed) { break; }
- }
- in.close();
-
- return numSeqs;
+ temp.erase(itTemp++);
+ }
+
+ return numSeqs;
}
catch(exception& e) {
m->errorOut(e, "PhyloSummary", "summarize");
int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
try {
+
numSeqs++;
map<string, int>::iterator childPointer;
int level = 0;
//are there confidence scores, if so remove them
- if (seqTaxonomy.find_first_of('(') != -1) { removeConfidences(seqTaxonomy); }
+ if (seqTaxonomy.find_first_of('(') != -1) { m->removeConfidences(seqTaxonomy); }
while (seqTaxonomy != "") {
//find out the sequences group
string group = groupmap->getGroup(seqName);
- if (group == "not found") { m->mothurOut(seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
+ if (group == "not found") { m->mothurOut("[WARNING]: " + seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
//do you have a count for this group?
map<string, int>::iterator itGroup = tree[childPointer->second].groupCount.find(group);
//find out the sequences group
string group = groupmap->getGroup(seqName);
- if (group == "not found") { m->mothurOut(seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
+ if (group == "not found") { m->mothurOut("[WARNING]: " + seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
//do you have a count for this group?
map<string, int>::iterator itGroup = tree[index].groupCount.find(group);
int level = 0;
//are there confidence scores, if so remove them
- if (seqTaxonomy.find_first_of('(') != -1) { removeConfidences(seqTaxonomy); }
+ if (seqTaxonomy.find_first_of('(') != -1) { m->removeConfidences(seqTaxonomy); }
while (seqTaxonomy != "") {
//find out the sequences group
string group = groupmap->getGroup(names[k]);
- if (group == "not found") { m->mothurOut(names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
+ if (group == "not found") { m->mothurOut("[WARNING]: " + names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
else {
containsGroup[group] = true;
}
//find out the sequences group
string group = groupmap->getGroup(names[k]);
- if (group == "not found") { m->mothurOut(names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
+ if (group == "not found") { m->mothurOut("[WARNING]: " + names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
else {
containsGroup[group] = true;
}
}
}
/**************************************************************************************************/
-void PhyloSummary::removeConfidences(string& tax) {
- try {
-
- string taxon;
- string newTax = "";
-
- while (tax.find_first_of(';') != -1) {
- //get taxon
- taxon = tax.substr(0,tax.find_first_of(';'));
-
- int pos = taxon.find_first_of('(');
- if (pos != -1) {
- taxon = taxon.substr(0, pos); //rip off confidence
- }
-
- taxon += ";";
-
- tax = tax.substr(tax.find_first_of(';')+1, tax.length());
- newTax += taxon;
- }
-
- tax = newTax;
- }
- catch(exception& e) {
- m->errorOut(e, "PhyloSummary", "removeConfidences");
- exit(1);
- }
-}
-/**************************************************************************************************/