From d39c47623faf0dc1e271f3d50efa6b029b622b88 Mon Sep 17 00:00:00 2001
From: Sarah Westcott <mothur.westcott@gmail.com>
Date: Wed, 29 May 2013 14:16:43 -0400
Subject: [PATCH] get.seqs not renaming sequences correctly for dups=f.
 unique.seqs crash when count table had group data.

---
 clusterfragmentscommand.cpp | 2 +-
 createdatabasecommand.cpp   | 4 ++--
 deconvolutecommand.cpp      | 2 +-
 getseqscommand.cpp          | 8 ++++++--
 makefile                    | 4 ++--
 screenseqscommand.cpp       | 6 +++---
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/clusterfragmentscommand.cpp b/clusterfragmentscommand.cpp
index f17c11e..9c1408c 100644
--- a/clusterfragmentscommand.cpp
+++ b/clusterfragmentscommand.cpp
@@ -181,7 +181,7 @@ ClusterFragmentsCommand::ClusterFragmentsCommand(string option) {
             countfile = validParameter.validFile(parameters, "count", true);
 			if (countfile == "not open") { abort = true; countfile = ""; }	
 			else if (countfile == "not found") { countfile = ""; }
-			else { ct.readTable(countfile, false); m->setCountTableFile(countfile); }
+			else { ct.readTable(countfile, true); m->setCountTableFile(countfile); }
 			
             if ((countfile != "") && (namefile != "")) { m->mothurOut("When executing a cluster.fragments command you must enter ONLY ONE of the following: count or name."); m->mothurOutEndLine(); abort = true; }
 			
diff --git a/createdatabasecommand.cpp b/createdatabasecommand.cpp
index 58799e7..5296279 100644
--- a/createdatabasecommand.cpp
+++ b/createdatabasecommand.cpp
@@ -380,8 +380,8 @@ int CreateDatabaseCommand::execute(){
                 if (countfile == "") {
                     sort(binNames.begin(), binNames.end());
                     bin = "";
-                    for (int i = 0; i < binNames.size()-1; i++) {
-                        bin += binNames[i] + ',';
+                    for (int j = 0; j < binNames.size()-1; j++) {
+                        bin += binNames[j] + ',';
                     }
                     bin += binNames[binNames.size()-1];
                     map<string, string>::iterator it = repNames.find(bin);
diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp
index 8b73425..51fa43b 100644
--- a/deconvolutecommand.cpp
+++ b/deconvolutecommand.cpp
@@ -209,7 +209,7 @@ int DeconvoluteCommand::execute() {
         }
         CountTable ct;
         if (countfile != "")  {  
-            ct.readTable(countfile, false);
+            ct.readTable(countfile, true);
             if (countfile == outCountFile){
                 //prepare filenames and open files
                 map<string, string> mvariables;
diff --git a/getseqscommand.cpp b/getseqscommand.cpp
index 9538698..83fdf73 100644
--- a/getseqscommand.cpp
+++ b/getseqscommand.cpp
@@ -430,9 +430,11 @@ int GetSeqsCommand::readFasta(){
             
             if (!dups) {//adjust name if needed
                 map<string, string>::iterator it = uniqueMap.find(name);
-                if (it != uniqueMap.end()) { name = it->second; }
+                if (it != uniqueMap.end()) { currSeq.setName(it->second); }
             }
 			
+            name = currSeq.getName();
+            
 			if (name != "") {
 				//if this name is in the accnos file
 				if (names.count(name) != 0) {
@@ -710,7 +712,7 @@ int GetSeqsCommand::readName(){
 		
 			if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
 
-			in >> firstCol;				
+			in >> firstCol;			m->gobble(in);
 			in >> secondCol;
 			
 			string hold = "";
@@ -734,6 +736,7 @@ int GetSeqsCommand::readName(){
 				selectedCount += parsedNames.size();
                 if (m->debug) { sanity["name"].insert(firstCol); }
 			}else {
+                
 				selectedCount += validSecond.size();
 				
 				//if the name in the first column is in the set then print it and any other names in second column also in set
@@ -752,6 +755,7 @@ int GetSeqsCommand::readName(){
 				
 				//make first name in set you come to first column and then add the remaining names to second column
 				}else {
+                    
 					//you want part of this row
 					if (validSecond.size() != 0) {
 					
diff --git a/makefile b/makefile
index 25ef4d4..163db6b 100644
--- a/makefile
+++ b/makefile
@@ -15,8 +15,8 @@ USEREADLINE ?= yes
 CYGWIN_BUILD ?= no
 USECOMPRESSION ?= no
 MOTHUR_FILES="\"Enter_your_default_path_here\""
-RELEASE_DATE = "\"5/28/2013\""
-VERSION = "\"1.31.0\""
+RELEASE_DATE = "\"5/29/2013\""
+VERSION = "\"1.31.1\""
 FORTAN_COMPILER = gfortran
 FORTRAN_FLAGS = 
 
diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp
index 1d7cb8d..e7b2c6a 100644
--- a/screenseqscommand.cpp
+++ b/screenseqscommand.cpp
@@ -1820,7 +1820,6 @@ int ScreenSeqsCommand::getSummary(vector<unsigned long long>& positions){
 		vector<int> longHomoPolymer;
         vector<int> numNs;
 		
-        vector<unsigned long long> positions;
 #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
 		positions = m->divideFile(fastafile, processors);
 		for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); }	
@@ -1845,8 +1844,9 @@ int ScreenSeqsCommand::getSummary(vector<unsigned long long>& positions){
 		int pid;
 		MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
 		
-		if (pid == 0) { 
-			driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, numNs, fastafile, lines[0]);
+		if (pid == 0) {
+            linePair tempLine(0, positions[positions.size()-1]);
+			driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, numNs, fastafile, tempLine);
 #else
 		int numSeqs = 0;
 		//#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-- 
2.39.5