string tfileroot = tfile.substr(0,tfile.find_last_of(".")+1);
string tempfileroot = getRootName(getSimpleName(tempFile));
string phyloTreeName = tfileroot + "tree.train";
+ string phyloTreeSumName = tfileroot + "tree.sum";
string probFileName = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.prob";
string probFileName2 = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.numNonZero";
ifstream phyloTreeTest(phyloTreeName.c_str());
ifstream probFileTest2(probFileName2.c_str());
ifstream probFileTest(probFileName.c_str());
+ ifstream probFileTest3(phyloTreeSumName.c_str());
int start = time(NULL);
- if(probFileTest && probFileTest2 && phyloTreeTest){
+ if(probFileTest && probFileTest2 && phyloTreeTest && probFileTest3){
m->mothurOut("Reading template taxonomy... "); cout.flush();
phyloTree = new PhyloTree(phyloTreeTest, phyloTreeName);
//read in users taxonomy file and add sequences to tree
while(!in.eof()){
in >> name >> tax; gobble(in);
-
+
addSeqToTree(name, tax);
}
in.close();
#endif
-
+
assignHeirarchyIDs(0);
-
+
//create file for summary if needed
setUp(tfile);
}
if (pid == 0) { binUnclassified(taxFileNameTest); }
#else
- //create file needed for summary if it doesn't exist
- ifstream FileTest(taxFileNameTest.c_str());
-
- if (!FileTest) {
- binUnclassified(taxFileNameTest);
- }
+ binUnclassified(taxFileNameTest);
#endif
}
catch(exception& e) {
leafNodes[i] = i;
}
}
- //cout << "maxLevel = " << maxLevel << endl;
- int copyNodes = copy.size();
+ int copyNodes = copy.size();
+
//go through the seqs and if a sequence finest taxon is not the same level as the most finely defined taxon then classify it as unclassified where necessary
map<int, int>::iterator itLeaf;
for (itLeaf = leafNodes.begin(); itLeaf != leafNodes.end(); itLeaf++) {
/**************************************************************************************************/
void PhyloTree::fillOutTree(int index, vector<TaxNode>& copy) {
try {
+
map<string,int>::iterator it;
- if (copy[index].level < maxLevel) {
- it = copy[index].children.find("unclassified");
- if (it == copy[index].children.end()) { //no unclassified at this level
- string taxon = "unclassified";
- copy.push_back(TaxNode(taxon));
- copy[index].children[taxon] = copy.size()-1;
- copy[copy.size()-1].parent = index;
- copy[copy.size()-1].level = copy[index].level + 1;
- }
+ it = copy[index].children.find("unclassified");
+ if (it == copy[index].children.end()) { //no unclassified at this level
+ string taxon = "unclassified";
+ copy.push_back(TaxNode(taxon));
+ copy[index].children[taxon] = copy.size()-1;
+ copy[copy.size()-1].parent = index;
+ copy[copy.size()-1].level = copy[index].level + 1;
+ }
-
- for(it=copy[index].children.begin();it!=copy[index].children.end();it++){ //check your children
+ if (tree[index].level < maxLevel) {
+ for(it=tree[index].children.begin();it!=tree[index].children.end();it++){ //check your children
fillOutTree(it->second, copy);
}
-
}
-
+
}
catch(exception& e) {
m->errorOut(e, "PhyloTree", "fillOutTree");
try {
out << copy.size() << endl;
+ out << maxLevel << endl;
+
for (int i = 0; i < copy.size(); i++) {
out << copy[i].level << '\t'<< copy[i].name << '\t' << copy[i].children.size() << '\t';