]> git.donarmstrong.com Git - mothur.git/blobdiff - readblast.cpp
added kruskwalliscommand to Xcode project and fixed parameter issues.
[mothur.git] / readblast.cpp
index 2d4947745be0a52fafba4c33f38fb6504ede2288..e98b69c68bfdb8f90fa841429cf4d607ba6fe1c3 100644 (file)
@@ -54,7 +54,8 @@ int ReadBlast::read(NameAssignment* nameMap) {
                
                //create objects needed for read
                if (!hclusterWanted) {
-                       matrix = new SparseMatrix();
+                       matrix = new SparseDistanceMatrix();
+            matrix->resize(nseqs);
                }else{
                        overlapFile = m->getRootName(blastfile) + "overlap.dist";
                        distFile = m->getRootName(blastfile) + "hclusterDists.dist";
@@ -109,8 +110,9 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                }
                        }
                }else { m->mothurOut("Error in your blast file, cannot read."); m->mothurOutEndLine(); exit(1); }
-
-                               
+string outDistFilem = "../kathryn/blastDist.dist";
+        ofstream outMDist;
+        m->openOutputFile(outDistFilem, outMDist);
                //read file
                while(!fileHandle.eof()){  
                
@@ -185,8 +187,14 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                                        //is this distance below cutoff
                                                        if (distance < cutoff) {
                                                                if (!hclusterWanted) {
-                                                                       PCell value(itA->second, it->first, distance);
-                                                                       matrix->addCell(value);
+                                    if (itA->second < it->first) {
+                                        PDistCell value(it->first, distance);
+                                        matrix->addCell(itA->second, value);
+                                    }else {
+                                        PDistCell value(itA->second, distance);
+                                        matrix->addCell(it->first, value);
+                                    }
+                                    outMDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl;
                                                                }else{
                                                                        outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl;
                                                                }
@@ -252,8 +260,13 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                //is this distance below cutoff
                                if (distance < cutoff) {
                                        if (!hclusterWanted) {
-                                               PCell value(itA->second, it->first, distance);
-                                               matrix->addCell(value);
+                                               if (itA->second < it->first) {
+                            PDistCell value(it->first, distance);
+                            matrix->addCell(itA->second, value);
+                        }else {
+                            PDistCell value(itA->second, distance);
+                            matrix->addCell(it->first, value);
+                        }
                                        }else{
                                                outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl;
                                        }
@@ -313,8 +326,8 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
                ifstream in;
                m->openInputFile(blastfile, in);
                
-               //ofstream outName;
-               //m->openOutputFile((blastfile + ".tempOutNames"), outName);
+               ofstream outName;
+               m->openOutputFile((blastfile + ".tempOutNames"), outName);
                
                //read first line
                in >> prevName;
@@ -338,6 +351,7 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
                        if (name != prevName) {
                                prevName = name;
                                nameMap->push_back(name);
+                outName << name << '\t' << name << endl;
                                num++;
                        }
                }