Skip to content
Snippets Groups Projects
Commit ee63ec3b authored by Aaron's avatar Aaron
Browse files

Updated mergeBed and bedFile.cpp

	1. Revised usage to 80 chars
	2. GPL headers
	3. Added new stdin logic
	4. Changes logo.
	5. Updated bedFile.cpp's loadBedIntoMapNoBin.  Bug in stdin logic.
parent 787d9678
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -102,11 +102,10 @@ int main(int argc, char* argv[]) { ...@@ -102,11 +102,10 @@ int main(int argc, char* argv[]) {
void ShowHelp(void) { void ShowHelp(void) {
cerr << "===============================================" << endl; cerr << endl << "PROGRAM: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl << endl;
cerr << " " <<PROGRAM_NAME << " v" << VERSION << endl ;
cerr << " Aaron Quinlan, Ph.D. (aaronquinlan@gmail.com) " << endl ; cerr << "AUTHOR: Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl ;
cerr << " Hall Laboratory, University of Virginia" << endl;
cerr << "===============================================" << endl << endl;
cerr << "SUMMARY: For each feature in BED A, finds the closest " << endl; cerr << "SUMMARY: For each feature in BED A, finds the closest " << endl;
cerr << "\t feature (upstream or downstream) in BED B." << endl << endl; cerr << "\t feature (upstream or downstream) in BED B." << endl << endl;
......
...@@ -151,11 +151,10 @@ int main(int argc, char* argv[]) { ...@@ -151,11 +151,10 @@ int main(int argc, char* argv[]) {
void ShowHelp(void) { void ShowHelp(void) {
cerr << "===============================================" << endl; cerr << endl << "PROGRAM: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl << endl;
cerr << " " <<PROGRAM_NAME << " v" << VERSION << endl ;
cerr << " Aaron Quinlan, Ph.D. (aaronquinlan@gmail.com) " << endl ; cerr << "AUTHOR: Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl ;
cerr << " Hall Laboratory, University of Virginia" << endl;
cerr << "===============================================" << endl << endl;
cerr << "SUMMARY: Report overlaps between a.bed and b.bed." << endl << endl; cerr << "SUMMARY: Report overlaps between a.bed and b.bed." << endl << endl;
cerr << "USAGE: " << PROGRAM_NAME << " [OPTIONS] -a <a.bed> -b <b.bed>" << endl << endl; cerr << "USAGE: " << PROGRAM_NAME << " [OPTIONS] -a <a.bed> -b <b.bed>" << endl << endl;
...@@ -176,7 +175,8 @@ void ShowHelp(void) { ...@@ -176,7 +175,8 @@ void ShowHelp(void) {
cerr << "\t- Similar to \"grep -v.\"" << endl << endl; cerr << "\t- Similar to \"grep -v.\"" << endl << endl;
cerr << " " << "-f\t" << "Minimum overlap required as a fraction of A." << endl; cerr << " " << "-f\t" << "Minimum overlap required as a fraction of A." << endl;
cerr << "\t- Default is 1E-9 (i.e., 1bp)." << endl << endl; cerr << "\t- Default is 1E-9 (i.e., 1bp)." << endl;
cerr << "\t- FLOAT (e.g. 0.50)" << endl << endl;
cerr << " " << "-r\t" << "Require that the fraction overlap be reciprocal for A and B." << endl; cerr << " " << "-r\t" << "Require that the fraction overlap be reciprocal for A and B." << endl;
cerr << "\t- In other words, if -f is 0.90 and -r is used, this requires" << endl; cerr << "\t- In other words, if -f is 0.90 and -r is used, this requires" << endl;
......
chr1 10 20 a
chr1 15 25 b
// /*****************************************************************************
// mergeBed.cpp mergeBed.cpp
// BEDTools
// (c) 2009 - Aaron Quinlan
// Created by Aaron Quinlan Spring 2009. Hall Laboratory
// Copyright 2009 Aaron Quinlan. All rights reserved. Department of Biochemistry and Molecular Genetics
// University of Virginia
// Summary: Combines overlapping BED entries into a single entry. aaronquinlan@gmail.com
//
Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/
#include "lineFileUtilities.h" #include "lineFileUtilities.h"
#include "mergeBed.h" #include "mergeBed.h"
...@@ -22,7 +24,6 @@ BedMerge::BedMerge(string &bedFile, bool &numEntries, int &maxDistance, bool &fo ...@@ -22,7 +24,6 @@ BedMerge::BedMerge(string &bedFile, bool &numEntries, int &maxDistance, bool &fo
this->reportNames = reportNames; this->reportNames = reportNames;
this->bed = new BedFile(bedFile); this->bed = new BedFile(bedFile);
} }
......
/*****************************************************************************
mergeBed.h
(c) 2009 - Aaron Quinlan
Hall Laboratory
Department of Biochemistry and Molecular Genetics
University of Virginia
aaronquinlan@gmail.com
Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/
#include "bedFile.h" #include "bedFile.h"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
......
/*****************************************************************************
mergeMain.cpp
(c) 2009 - Aaron Quinlan
Hall Laboratory
Department of Biochemistry and Molecular Genetics
University of Virginia
aaronquinlan@gmail.com
Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/
#include "mergeBed.h" #include "mergeBed.h"
#include "version.h" #include "version.h"
...@@ -64,7 +75,7 @@ int main(int argc, char* argv[]) { ...@@ -64,7 +75,7 @@ int main(int argc, char* argv[]) {
else if (PARAMETER_CHECK("-s", 2, parameterLength)) { else if (PARAMETER_CHECK("-s", 2, parameterLength)) {
forceStrand = true; forceStrand = true;
} }
else if (PARAMETER_CHECK("-names", 6, parameterLength)) { else if (PARAMETER_CHECK("-nms", 4, parameterLength)) {
reportNames = true; reportNames = true;
} }
else { else {
...@@ -97,25 +108,29 @@ int main(int argc, char* argv[]) { ...@@ -97,25 +108,29 @@ int main(int argc, char* argv[]) {
void ShowHelp(void) { void ShowHelp(void) {
cerr << "===============================================" << endl; cerr << endl << "PROGRAM: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl << endl;
cerr << " " <<PROGRAM_NAME << " v" << VERSION << endl ;
cerr << " Aaron Quinlan, Ph.D. (aaronquinlan@gmail.com) " << endl ; cerr << "AUTHOR: Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl ;
cerr << " Hall Laboratory, University of Virginia" << endl;
cerr << "===============================================" << endl << endl; cerr << "SUMMARY: Merges overlapping BED entries into a single interval." << endl << endl;
cerr << "Description: Merges overlapping bed entries into a single interval." << endl << endl;
cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i <input.bed>" << endl << endl; cerr << "USAGE: " << PROGRAM_NAME << " [OPTIONS] -i <input.bed>" << endl << endl;
cerr << "OPTIONS: " << endl; cerr << "OPTIONS: " << endl;
cerr << "\t" << "-s\t\t" << "Force strandedness. Only report hits in B that overlap A on the same strand." << endl << "\t\t\tBy default, overlaps are reported without respect to strand." << endl << endl; cerr << " " << "-s\t" << "Force strandedness. That is, only merge features" << endl;
cerr << "\t" << "-n\t\t" << "Report the number of BED entries that were merged. (=1 if no merging occured)" << endl << endl; cerr << "\tthat are the same strand." << endl;
cerr << "\t" << "-d\t\t" << "Maximum distance between features allowed for features to be merged. (Default=0)" << endl << endl; cerr << "\t- By default, merging is done without respect to strand." << endl << endl;
cerr << "\t" << "-names\t\t" << "Report the names of the merged features separated by semicolons." << endl << endl;
cerr << "NOTES: " << endl; cerr << " " << "-n\t" << "Report the number of BED entries that were merged." << endl;
cerr << "\t" << "-i stdin\t" << "Allows BED file A to be read from stdin. E.g.: cat a.bed | mergeBed -a stdin -b B.bed" << endl << endl; cerr << "\t- Note: \"1\" is reported if no merging occured." << endl << endl;
cerr << "\t***Only tab-delimited BED3 - BED6 formats allowed.***"<< endl << endl;
cerr << " " << "-d\t" << "Maximum distance between features allowed for features to be merged." << endl;
cerr << "\t- Def. 0. That is, overlapping and/or book-ended features are merged." << endl;
cerr << "\t- INTEGER" << endl << endl;
cerr << " " << "-nms\t" << "Report the names of the merged features separated by semicolons." << endl << endl;
// end the program here // end the program here
exit(1); exit(1);
......
...@@ -107,11 +107,10 @@ int main(int argc, char* argv[]) { ...@@ -107,11 +107,10 @@ int main(int argc, char* argv[]) {
void ShowHelp(void) { void ShowHelp(void) {
cerr << "===============================================" << endl; cerr << endl << "PROGRAM: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl << endl;
cerr << " " <<PROGRAM_NAME << " v" << VERSION << endl ;
cerr << " Aaron Quinlan, Ph.D. (aaronquinlan@gmail.com) " << endl ; cerr << "AUTHOR: Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl ;
cerr << " Hall Laboratory, University of Virginia" << endl;
cerr << "===============================================" << endl << endl;
cerr << "SUMMARY: Removes the portion(s) of an interval that is overlapped" << endl; cerr << "SUMMARY: Removes the portion(s) of an interval that is overlapped" << endl;
cerr << "\t by another feature(s)." << endl << endl; cerr << "\t by another feature(s)." << endl << endl;
...@@ -119,7 +118,8 @@ void ShowHelp(void) { ...@@ -119,7 +118,8 @@ void ShowHelp(void) {
cerr << "OPTIONS: " << endl; cerr << "OPTIONS: " << endl;
cerr << " " << "-f\t" << "Minimum overlap required as a fraction of A." << endl; cerr << " " << "-f\t" << "Minimum overlap required as a fraction of A." << endl;
cerr << "\t- Default is 1E-9 (i.e., 1bp)." << endl << endl; cerr << "\t- Default is 1E-9 (i.e., 1bp)." << endl;
cerr << "\t- FLOAT (e.g. 0.50)" << endl << endl;
cerr << " " << "-s\t" << "Force strandedness. That is, only report hits in B that" << endl; cerr << " " << "-s\t" << "Force strandedness. That is, only report hits in B that" << endl;
cerr << "\toverlap A on the same strand." << endl; cerr << "\toverlap A on the same strand." << endl;
......
...@@ -545,20 +545,19 @@ void BedFile::loadBedFileIntoMapNoBin() { ...@@ -545,20 +545,19 @@ void BedFile::loadBedFileIntoMapNoBin() {
} }
// Case 2: STDIN. // Case 2: STDIN.
else { else {
while (getline(cin, bedLine)) { while (getline(cin, bedLine)) {
if ((bedLine.find("track") != string::npos) || (bedLine.find("browser") != string::npos)) { if ((bedLine.find("track") != string::npos) || (bedLine.find("browser") != string::npos)) {
continue; continue;
} }
else { else {
vector<string> bedFields;
Tokenize(bedLine,bedFields); Tokenize(bedLine,bedFields);
lineNum++; lineNum++;
if (parseLine(bedEntry, bedFields, lineNum)) { if (parseLine(bedEntry, bedFields, lineNum)) {
bedEntry.count = 0; bedEntry.count = 0;
bedEntry.minOverlapStart = INT_MAX;
this->bedMapNoBin[bedEntry.chrom].push_back(bedEntry); this->bedMapNoBin[bedEntry.chrom].push_back(bedEntry);
} }
bedFields.clear(); bedFields.clear();
......
...@@ -162,11 +162,10 @@ int main(int argc, char* argv[]) { ...@@ -162,11 +162,10 @@ int main(int argc, char* argv[]) {
void ShowHelp(void) { void ShowHelp(void) {
cerr << "===============================================" << endl; cerr << endl << "PROGRAM: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl << endl;
cerr << " " <<PROGRAM_NAME << " v" << VERSION << endl ;
cerr << " Aaron Quinlan, Ph.D. (aaronquinlan@gmail.com) " << endl ; cerr << "AUTHOR: Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl ;
cerr << " Hall Laboratory, University of Virginia" << endl;
cerr << "===============================================" << endl << endl;
cerr << "SUMMARY: Examines a \"window\" around each feature in A and" << endl; cerr << "SUMMARY: Examines a \"window\" around each feature in A and" << endl;
cerr << "\t reports all features in B that overlap the window. For each" << endl; cerr << "\t reports all features in B that overlap the window. For each" << endl;
cerr << "\t overlap the entire entry in A and B are reported." << endl << endl; cerr << "\t overlap the entire entry in A and B are reported." << endl << endl;
...@@ -177,17 +176,20 @@ void ShowHelp(void) { ...@@ -177,17 +176,20 @@ void ShowHelp(void) {
cerr << " " << "-w\t" << "Base pairs added upstream and downstream of each entry" << endl; cerr << " " << "-w\t" << "Base pairs added upstream and downstream of each entry" << endl;
cerr << "\tin A when searching for overlaps in B." << endl; cerr << "\tin A when searching for overlaps in B." << endl;
cerr << "\t- Creates symterical \"windows\" around A." << endl; cerr << "\t- Creates symterical \"windows\" around A." << endl;
cerr << "\t- Default is 1000 bp." << endl << endl; cerr << "\t- Default is 1000 bp." << endl;
cerr << "\t- INTEGER" << endl << endl;
cerr << " " << "-l\t" << "Base pairs added upstream (left of) of each entry" << endl; cerr << " " << "-l\t" << "Base pairs added upstream (left of) of each entry" << endl;
cerr << "\tin A when searching for overlaps in B." << endl; cerr << "\tin A when searching for overlaps in B." << endl;
cerr << "\t- Allows one to define assymterical \"windows\"." << endl; cerr << "\t- Allows one to define assymterical \"windows\"." << endl;
cerr << "\t- Default is 1000 bp." << endl << endl; cerr << "\t- Default is 1000 bp." << endl;
cerr << "\t- INTEGER" << endl << endl;
cerr << " " << "-r\t" << "Base pairs added downstream (right of) of each entry" << endl; cerr << " " << "-r\t" << "Base pairs added downstream (right of) of each entry" << endl;
cerr << "\tin A when searching for overlaps in B." << endl; cerr << "\tin A when searching for overlaps in B." << endl;
cerr << "\t- Allows one to define assymterical \"windows\"." << endl; cerr << "\t- Allows one to define assymterical \"windows\"." << endl;
cerr << "\t- Default is 1000 bp." << endl << endl; cerr << "\t- Default is 1000 bp." << endl;
cerr << "\t- INTEGER" << endl << endl;
cerr << " " << "-sw\t" << "Define -l and -r based on strand. For example if used, -l 500" << endl; cerr << " " << "-sw\t" << "Define -l and -r based on strand. For example if used, -l 500" << endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment