- // Returns index of toFind in sortedArray, or -1 if not found
- int low = 0;
- int high = closeness[i].size() - 1;
- int mid;
+ bool found = false;
+ if (closeness[i].count(toFind) != 0) { found = true; }
+ return found;
- int l = closeness[i][low];
- int h = closeness[i][high];
-
- while (l <= toFind && h >= toFind) {
- mid = (low + high)/2;
-
- int m = closeness[i][mid];
-
- if (m < toFind) {
- l = closeness[i][low = mid + 1];
- } elseif (m > toFind) {
- h = closeness[i][high = mid - 1];
- } else {
- returntrue;
- }
- }
-
- if (closeness[i][low] == toFind) {
- returntrue;
- }else{
- returnfalse; // Not found
- }
}
catch(exception& e) {
m->errorOut(e, "OptiMatrix", "isClose");
@@ -173,7 +150,7 @@ int OptiMatrix::readPhylip(){
if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ", quitting."); m->mothurOutEndLine(); exit(1); }
+ if(itA == nameAssignment.end()){ m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the name or count file, please correct\n"); exit(1); }
+ if(itB == nameAssignment.end()){ m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the name or count file, please correct\n"); exit(1); }
+
+ if (distance == -1) { distance = 1000000; }
+ elseif (sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert.
+
+ if(distance < cutoff){
+ int indexA = (itA->second);
+ int indexB = (itB->second);
+
+ int newB = singletonIndexSwap[indexB];
+ int newA = singletonIndexSwap[indexA];
+ closeness[newA].insert(newB);
+ closeness[newB].insert(newA);
+ }
+ }
+ in.close();
+ nameAssignment.clear();
+
if (namefile != "") {
+ map<string, string> names;
m->readNames(namefile, names);
//update nameMap
for (int i = 0; i < nameMap.size(); i++) {
@@ -381,40 +408,16 @@ int OptiMatrix::readColumn(){
names.clear();
}
- //nameMap will contain extra indexes and will be larger than closeness. This should be okay since we don't allow access to nameMap
- map<int, int> closenessIndexMap;
- for (int i = 0; i < temp.size(); i++) {
- if (temp[i].size() == 0) {
- singletons.push_back(nameMap[i]);
- }else {
- string newName = nameMap[i];
- int newIndex = closeness.size();
- nameMap[newIndex] = newName;
-
- vector<int> thisClose;
- for(map<int, string>:: iterator it = temp[i].begin(); it != temp[i].end(); it++) {
0 comments on commit
20a419b