From ac4d6a2ac10c8feb043aa11582a769b6093c5941 Mon Sep 17 00:00:00 2001
From: Sarah Westcott <mothur.westcott@gmail.com>
Date: Fri, 14 Dec 2012 07:21:44 -0500
Subject: [PATCH] fixed outputName creator, added debugging to readblast

---
 command.hpp   |  9 +++++++--
 readblast.cpp | 11 +++++++----
 readblast.h   |  6 +++---
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/command.hpp b/command.hpp
index 2ba35ab..7ed03f1 100644
--- a/command.hpp
+++ b/command.hpp
@@ -74,8 +74,13 @@ class Command {
                                         m->mothurOut("[ERROR]: Did not provide variable for " + pieces[i] + ".\n"); m->control_pressed = true;
                                     }else {
                                         if (it->second != "") {
-                                            if (it->first != "[filename]") { filename += it->second + "."; }
-                                            else { filename += it->second; }
+                                            if (it->first == "[filename]") { filename += it->second; }
+                                            else if (it->first == "[extension]") { 
+                                                if (filename.length() > 0) { //rip off last "."
+                                                    filename = filename.substr(0, filename.length()-1);
+                                                }
+                                                filename += it->second + "."; 
+                                            }else { filename += it->second + "."; }
                                         }
                                     }
                                 }else {
diff --git a/readblast.cpp b/readblast.cpp
index 5f24415..e98b69c 100644
--- a/readblast.cpp
+++ b/readblast.cpp
@@ -110,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()){  
 		
@@ -193,6 +194,7 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                         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;
 								}
@@ -324,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;
@@ -349,6 +351,7 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
 			if (name != prevName) {
 				prevName = name;
 				nameMap->push_back(name);
+                outName << name << '\t' << name << endl;
 				num++;
 			}
 		}
diff --git a/readblast.h b/readblast.h
index ef5ff9a..97ce6c7 100644
--- a/readblast.h
+++ b/readblast.h
@@ -27,9 +27,9 @@ public:
 	
 	int read(NameAssignment*);
 	SparseDistanceMatrix* getDistMatrix()		{	return matrix;		}
-	vector<seqDist> getOverlapMatrix()	{	return overlap;		}
-	string getOverlapFile()				{	return overlapFile;	}
-	string getDistFile()				{	return distFile;	}
+	vector<seqDist> getOverlapMatrix()          {	return overlap;		}
+	string getOverlapFile()                     {	return overlapFile;	}
+	string getDistFile()                        {	return distFile;	}
 	
 private:
 	string blastfile, overlapFile, distFile;
-- 
2.39.5