From 1c122c538316b6f9035a207c6eb00b0534ab0acc Mon Sep 17 00:00:00 2001
From: Aaron <aaronquinlan@gmail.com>
Date: Thu, 19 Nov 2009 08:19:26 -0500
Subject: [PATCH] Version 2.3.1 (for real)

---
 RELEASE_HISTORY               |  4 ++++
 src/closestBed/closestBed.cpp | 14 ++++++++++----
 src/utils/version/version.h   |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/RELEASE_HISTORY b/RELEASE_HISTORY
index 50ca151e..c023e75b 100644
--- a/RELEASE_HISTORY
+++ b/RELEASE_HISTORY
@@ -1,3 +1,7 @@
+Version 2.3.1 (11/19/2009)
+Fixed a typo in closestBed that caused all nearby features to be returned instead of just the closest one.
+
+
 Version 2.3.0 (11/18/2009)
 1. Added four new tools:
 	- shuffleBed. 			Randomly permutes the locations of a BED file among a genome.  Useful for testing for significant overlap enrichments.
diff --git a/src/closestBed/closestBed.cpp b/src/closestBed/closestBed.cpp
index d1ecfded..0bf13267 100755
--- a/src/closestBed/closestBed.cpp
+++ b/src/closestBed/closestBed.cpp
@@ -129,17 +129,23 @@ void BedClosest::FindWindowOverlaps(BED &a, vector<BED> &hits) {
 					}
 				}
 				else if (h->end < a.start){
-					if ((a.start - h->end) <= minDistance) {
+					if ((a.start - h->end) < minDistance) {
 						closestB.clear();
 						closestB.push_back(*h);
 						minDistance = a.start - h->end;
-					}	
+					}
+					else if ((a.start - h->end) == minDistance) {
+						closestB.push_back(*h);
+					}
 				}
 				else {
-					if ((h->start - a.end) <= minDistance) {
+					if ((h->start - a.end) < minDistance) {
 						closestB.clear();
 						closestB.push_back(*h);
 						minDistance = h->start - a.end;
+					}
+					else if ((h->start - a.end) == minDistance) {
+						closestB.push_back(*h);
 					}	
 				}
 				
@@ -158,7 +164,7 @@ void BedClosest::FindWindowOverlaps(BED &a, vector<BED> &hits) {
 
 	if (numOverlaps > 0) {
 		
-		if (closestB.size() == 1) {
+		if (closestB.size() == 1) {		
 			bedA->reportBedTab(a); 
 			bedB->reportBedNewLine(closestB[0]);
 		}
diff --git a/src/utils/version/version.h b/src/utils/version/version.h
index c8144615..a5b04b37 100644
--- a/src/utils/version/version.h
+++ b/src/utils/version/version.h
@@ -3,6 +3,6 @@
 
 // define the version.  All tools in the 
 // suite carry the same version number.
-#define VERSION "2.3.0"
+#define VERSION "2.3.1"
 
 #endif /* VERSION_H */
-- 
GitLab