From 939d5390d94154f792b3c1edb167f7fb1005cdd0 Mon Sep 17 00:00:00 2001
From: Aaron <aaronquinlan@gmail.com>
Date: Mon, 16 Aug 2010 16:51:16 -0400
Subject: [PATCH] Cleaned up groupBy and unionBedFiles.

---
 Makefile                      |  1 +
 src/groupBy/groupBy.cpp       | 29 ++++++++++++-------------
 src/utils/bedFile/bedFile.cpp | 41 -----------------------------------
 3 files changed, 15 insertions(+), 56 deletions(-)

diff --git a/Makefile b/Makefile
index 6cb24583..363fbd1b 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,7 @@ SUBDIRS = $(SRC_DIR)/bamToBed \
 
 UTIL_SUBDIRS =  $(SRC_DIR)/utils/lineFileUtilities \
                 $(SRC_DIR)/utils/bedFile \
+                $(SRC_DIR)/utils/bedGraphFile \
                 $(SRC_DIR)/utils/tabFile \
                 $(SRC_DIR)/utils/genomeFile \
                 $(SRC_DIR)/utils/gzstream \
diff --git a/src/groupBy/groupBy.cpp b/src/groupBy/groupBy.cpp
index 000e0687..6396af95 100644
--- a/src/groupBy/groupBy.cpp
+++ b/src/groupBy/groupBy.cpp
@@ -185,27 +185,26 @@ void ShowHelp(void) {
 	
 	cerr << "\t-grp\t"	    << "Specify the columns (1-based) for the grouping." << endl;
 	cerr 					<< "\t\tThe columns must be comma separated." << endl;
-	cerr					<< "\t\tDefault: 1,2,3" << endl << endl;	
+	cerr					<< "\t\t- Default: 1,2,3" << endl << endl;	
 
-	cerr << "\t-opCol\t"	<< "Specify the column (1-based) that should be summarized." << endl;
-	cerr 					<< "\t\tRequired." << endl << endl;
+	cerr << "\t-opCols\t"	<< "Specify the column (1-based) that should be summarized." << endl;
+	cerr 					<< "\t\t- Required." << endl << endl;
 
-	cerr << "\t-op\t"	    << "Specify the operation that should be applied to opCol." << endl;
+	cerr << "\t-ops\t"	    << "Specify the operation that should be applied to opCol." << endl;
 	cerr 					<< "\t\tValid operations: sum, count, min, max, mean, median," << endl;
-    cerr                    << "\t\tmode, antimode, stdev, collapse (i.e., print a comma separated list)" << endl;
-    cerr                    << "\t\tDefault: sum" << endl;
+    cerr                    << "\t\tmode, antimode, stdev, sstdev (sample standard dev.), and" << endl;
+    cerr                    << "\t\tcollapse (i.e., print a comma separated list)" << endl;
+    cerr                    << "\t\t- Default: sum" << endl << endl;
 
 	cerr << "Examples: " << endl;
-	cerr << "\t$ cat test.out" << endl;
-	cerr << "\tchr1	10	20	A	chr1	15	25	1000" << endl;
-	cerr << "\tchr1	10	20	A	chr1	25	35	10000" << endl << endl;
-	cerr << "\t$ cat test.out | groupBy -i stdin -grp 1,2,3,4 -opCol 8 -op sum" << endl;
+	cerr << "\t$ cat ex1.out" << endl;
+	cerr << "\tchr1	10	20	A	chr1	15	25	B.1 1000" << endl;
+	cerr << "\tchr1	10	20	A	chr1	25	35	B.2 10000" << endl << endl;
+	cerr << "\t$ groupBy -i ex1.out -grp 1,2,3,4 -opCols 9 -ops sum" << endl;
 	cerr << "\tchr1	10	20	A	11000" << endl << endl;
-	cerr << "\t$ cat test.out | groupBy -i stdin -grp 1,2,3,4 -opCol 8 -op max" << endl;
-	cerr << "\tchr1	10	20	A	1000" << endl << endl;
-	cerr << "\t$ cat test.out | groupBy -i stdin -grp 1,2,3,4 -opCol 8 -op mean" << endl;
-	cerr << "\tchr1	10	20	A	5500" << endl << endl;
-	cerr << "\t$ cat test.out | groupBy -i stdin -grp 1,2,3,4 -opCol 8 -op collapse" << endl;
+	cerr << "\t$ groupBy -i ex1.out -grp 1,2,3,4 -opCols 9,9 -ops sum,max" << endl;
+	cerr << "\tchr1	10	20	A	11000	10000" << endl << endl;
+	cerr << "\t$ groupBy -i ex1.out -grp 1,2,3,4 -opCols 8,9 -ops collapse,mean" << endl;
 	cerr << "\tchr1	10	20	A	1000,10000," << endl << endl;
 	
 	cerr << "Notes: " << endl;
diff --git a/src/utils/bedFile/bedFile.cpp b/src/utils/bedFile/bedFile.cpp
index ab612c90..7610a15a 100644
--- a/src/utils/bedFile/bedFile.cpp
+++ b/src/utils/bedFile/bedFile.cpp
@@ -163,47 +163,6 @@ void BedFile::Open(void) {
         cerr << "Error: Unexpected file type (" << bedFile << "). Exiting!" << endl;
         exit(1);
     }
-    
-    // Old method.
-	/*
-	else {
-		size_t foundPos;
-	  	foundPos = bedFile.find_last_of(".gz");
-		// is this a GZIPPED BED file?
-		if (foundPos == bedFile.size() - 1) {
-			igzstream beds(bedFile.c_str(), ios::in);
-			if ( !beds ) {
-				cerr << "Error: The requested bed file (" << bedFile << ") could not be opened. Exiting!" << endl;
-				exit (1);
-			}
-			else {
-				// if so, close it (this was just a test)
-				beds.close();		
-				// now set a pointer to the stream so that we
-				// can read the file later on.
-				// Thank God for Josuttis, p. 631!
-				_bedStream = new igzstream(bedFile.c_str(), ios::in);
-			}
-		}  
-		// not GZIPPED.
-		else {
-		
-			ifstream beds(bedFile.c_str(), ios::in);
-			// can we open the file?
-			if ( !beds ) {
-				cerr << "Error: The requested bed file (" << bedFile << ") could not be opened. Exiting!" << endl;
-				exit (1);
-			}
-			else {
-				// if so, close it (this was just a test)
-				beds.close();		
-				// now set a pointer to the stream so that we
-				// can read the file later on.
-				// Thank God for Josuttis, p. 631!
-				_bedStream = new ifstream(bedFile.c_str(), ios::in);
-			}
-		}
-	}*/
 }
 
 
-- 
GitLab