]> git.donarmstrong.com Git - mothur.git/blobdiff - mgclustercommand.cpp
created blank accnos in chimera commands if no seqs are deemed chimeric. modified...
[mothur.git] / mgclustercommand.cpp
index f8f3c78e6fc68c507bcc896bf0789a2ba2d7e373..182e78dc31502fb6c9a75e1703c8f17ffe4ba0fb 100644 (file)
@@ -166,6 +166,13 @@ int MGClusterCommand::execute(){
                
                list = new ListVector(nameMap->getListVector());
                RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
+for (int i = 0; i < list->getNumBins(); i++) {
+string bin = list->get(i);
+if(bin == "") {
+cout << "bin " << i << " is blank."<< endl;
+}
+}
+cout << "after outputting blank bins." << endl;
                
                if (m->control_pressed) { delete nameMap; delete read; delete list; delete rabund; return 0; }
                
@@ -208,7 +215,7 @@ int MGClusterCommand::execute(){
                                listFile.close(); rabundFile.close(); sabundFile.close(); remove((fileroot+ tag + ".list").c_str()); remove((fileroot+ tag + ".rabund").c_str()); remove((fileroot+ tag + ".sabund").c_str());
                                return 0; 
                        }
-                       
+       int count = 0;          
                        //cluster using cluster classes
                        while (distMatrix->getSmallDist() < cutoff && distMatrix->getNNodes() > 0){
                                
@@ -227,11 +234,12 @@ int MGClusterCommand::execute(){
                                }else{
                                        rndDist = roundDist(dist, precision); 
                                }
-
+cout << "here " << count << '\t' << dist << endl;
                                
                                if(previousDist <= 0.0000 && dist != previousDist){
                                        oldList.setLabel("unique");
                                        printData(&oldList);
+                                       Seq2Bin = cluster->getSeqtoBin();
                                }
                                else if(rndDist != rndPreviousDist){
                                        if (merge) {
@@ -252,9 +260,9 @@ int MGClusterCommand::execute(){
                                                printData(&oldList);
                                        }
                                }
-                               
+       //cout << "after merge " << count << '\t' << dist << endl;      
+       count++;                
                                previousDist = dist;
-       cout << "prev distance = " << previousDist << " dist = " << dist << endl;
                                rndPreviousDist = rndDist;
                                oldList = *list;
                                oldSeq2Bin = Seq2Bin;
@@ -263,6 +271,7 @@ int MGClusterCommand::execute(){
                        if(previousDist <= 0.0000){
                                oldList.setLabel("unique");
                                printData(&oldList);
+                               Seq2Bin = cluster->getSeqtoBin();
                        }
                        else if(rndPreviousDist<cutoff){
                                if (merge) {
@@ -356,6 +365,7 @@ int MGClusterCommand::execute(){
                                                if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
                                                        oldList.setLabel("unique");
                                                        printData(&oldList);
+                                                       Seq2Bin = hcluster->getSeqtoBin();
                                                }
                                                else if((rndDist != rndPreviousDist)){
                                                        if (merge) {
@@ -415,8 +425,8 @@ int MGClusterCommand::execute(){
                        }
                        
                        delete hcluster;
-                       //remove(distFile.c_str());
-                       //remove(overlapFile.c_str());
+                       remove(distFile.c_str());
+                       remove(overlapFile.c_str());
                }
                
                delete list; 
@@ -475,6 +485,17 @@ ListVector* MGClusterCommand::mergeOPFs(map<string, int> binInfo, float dist){
        try {
                //create new listvector so you don't overwrite the clustering
                ListVector* newList = new ListVector(oldList);
+for (int i = 0; i < newList->getNumBins(); i++) {
+string bin = newList->get(i);
+if(bin == "") {
+cout << "bin " << i << " is blank."<< endl;
+for (map<string, int>::iterator itBin = binInfo.begin(); itBin != binInfo.end(); itBin++) {
+       if (itBin->second == i) { cout << itBin->first << " maps to an empty bin." << endl; }
+}
+}
+}
+cout << "after outputting blank bins." << endl;                
+
                bool done = false;
                ifstream inOverlap;
                int count = 0;
@@ -525,16 +546,17 @@ ListVector* MGClusterCommand::mergeOPFs(map<string, int> binInfo, float dist){
                                
                                if(itBin1 == binInfo.end()){  cerr << "AAError: Sequence '" << name1 << "' does not have any bin info.\n"; exit(1);  }
                                if(itBin2 == binInfo.end()){  cerr << "ABError: Sequence '" << name2 << "' does not have any bin info.\n"; exit(1);  }
-
+cout << overlapNode.dist << '\t' << dist << endl;
                                int binKeep = itBin1->second;
                                int binRemove = itBin2->second;
-                               
+                       
                                //if not merge bins and update binInfo
                                if(binKeep != binRemove) {
-               
+       cout << "bin keep = " << binKeep << " bin remove = " << binRemove << endl;              
                                        //save names in old bin
                                        string names = newList->get(binRemove);
-                                       
+                       cout << names << endl << endl << endl;  
+                       cout << newList->get(binKeep) << endl << endl << endl;  
                                        //merge bins into name1s bin
                                        newList->set(binKeep, newList->get(binRemove)+','+newList->get(binKeep));
                                        newList->set(binRemove, "");