X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mgclustercommand.cpp;h=9a1ac215388e09e6477fffa034e0542c38c208b1;hb=2df35fdeea85f574630d75b11fb5b08c39aec31a;hp=f8f3c78e6fc68c507bcc896bf0789a2ba2d7e373;hpb=3102812d94898439646131cecdb64fc542913c87;p=mothur.git diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp index f8f3c78..9a1ac21 100644 --- a/mgclustercommand.cpp +++ b/mgclustercommand.cpp @@ -208,7 +208,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; } - + //cluster using cluster classes while (distMatrix->getSmallDist() < cutoff && distMatrix->getNNodes() > 0){ @@ -227,7 +227,6 @@ int MGClusterCommand::execute(){ }else{ rndDist = roundDist(dist, precision); } - if(previousDist <= 0.0000 && dist != previousDist){ oldList.setLabel("unique"); @@ -235,7 +234,6 @@ int MGClusterCommand::execute(){ } else if(rndDist != rndPreviousDist){ if (merge) { - Seq2Bin = cluster->getSeqtoBin(); ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist); if (m->control_pressed) { @@ -252,11 +250,11 @@ int MGClusterCommand::execute(){ printData(&oldList); } } - + previousDist = dist; - cout << "prev distance = " << previousDist << " dist = " << dist << endl; rndPreviousDist = rndDist; oldList = *list; + Seq2Bin = cluster->getSeqtoBin(); oldSeq2Bin = Seq2Bin; } @@ -266,7 +264,6 @@ int MGClusterCommand::execute(){ } else if(rndPreviousDistgetSeqtoBin(); ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist); if (m->control_pressed) { @@ -359,7 +356,6 @@ int MGClusterCommand::execute(){ } else if((rndDist != rndPreviousDist)){ if (merge) { - Seq2Bin = hcluster->getSeqtoBin(); ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist); if (m->control_pressed) { @@ -382,6 +378,7 @@ int MGClusterCommand::execute(){ previousDist = seqs[i].dist; rndPreviousDist = rndDist; oldList = *list; + Seq2Bin = cluster->getSeqtoBin(); oldSeq2Bin = Seq2Bin; } } @@ -394,7 +391,6 @@ int MGClusterCommand::execute(){ } else if(rndPreviousDistgetSeqtoBin(); ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist); if (m->control_pressed) { @@ -415,8 +411,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 +471,7 @@ ListVector* MGClusterCommand::mergeOPFs(map binInfo, float dist){ try { //create new listvector so you don't overwrite the clustering ListVector* newList = new ListVector(oldList); + bool done = false; ifstream inOverlap; int count = 0; @@ -503,13 +500,16 @@ ListVector* MGClusterCommand::mergeOPFs(map binInfo, float dist){ float overlapDistance; inOverlap >> firstName >> secondName >> overlapDistance; gobble(inOverlap); - map::iterator itA = nameMap->find(firstName); - map::iterator itB = nameMap->find(secondName); - if(itA == nameMap->end()){ cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; exit(1); } - if(itB == nameMap->end()){ cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1); } + //commented out because we check this in readblast already + //map::iterator itA = nameMap->find(firstName); + //map::iterator itB = nameMap->find(secondName); + //if(itA == nameMap->end()){ cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; exit(1); } + //if(itB == nameMap->end()){ cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1); } - overlapNode.seq1 = itA->second; - overlapNode.seq2 = itB->second; + //overlapNode.seq1 = itA->second; + //overlapNode.seq2 = itB->second; + overlapNode.seq1 = nameMap->get(firstName); + overlapNode.seq2 = nameMap->get(secondName); overlapNode.dist = overlapDistance; }else { inOverlap.close(); break; } } @@ -520,21 +520,24 @@ ListVector* MGClusterCommand::mergeOPFs(map binInfo, float dist){ string name2 = nameMap->get(overlapNode.seq2); //use binInfo to find out if they are already in the same bin - map::iterator itBin1 = binInfo.find(name1); - map::iterator itBin2 = binInfo.find(name2); + //map::iterator itBin1 = binInfo.find(name1); + //map::iterator itBin2 = binInfo.find(name2); - 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); } + //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); } - int binKeep = itBin1->second; - int binRemove = itBin2->second; + //int binKeep = itBin1->second; + //int binRemove = itBin2->second; + int binKeep = binInfo[name1]; + int binRemove = binInfo[name2]; + //if not merge bins and update binInfo if(binKeep != binRemove) { //save names in old bin string names = newList->get(binRemove); - + //merge bins into name1s bin newList->set(binKeep, newList->get(binRemove)+','+newList->get(binKeep)); newList->set(binRemove, "");