From 054fc8576a192086d718f81c929c587f02fe8dc2 Mon Sep 17 00:00:00 2001 From: Aaron <aaronquinlan@gmail.com> Date: Thu, 3 Nov 2011 15:50:00 -0400 Subject: [PATCH] Updated banner and help for multiIntersectBed. --- src/multiIntersectBed/multiIntersectBed.cpp | 14 +- .../multiIntersectBedMain.cpp | 134 +++++++++--------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/multiIntersectBed/multiIntersectBed.cpp b/src/multiIntersectBed/multiIntersectBed.cpp index a0738f61..e4eb5e10 100644 --- a/src/multiIntersectBed/multiIntersectBed.cpp +++ b/src/multiIntersectBed/multiIntersectBed.cpp @@ -123,14 +123,12 @@ void MultiIntersectBed::UpdateInformation(const IntervalItem &item) { case START: current_depth[item.source_index] = 1; current_non_zero_inputs++; - files_with_coverage[item.source_index] = true; break; case END: //Read the next interval from this file AddInterval(item.source_index); current_depth[item.source_index] = 0; current_non_zero_inputs--; - files_with_coverage.erase(item.source_index); break; default: assert(0); @@ -162,9 +160,15 @@ void MultiIntersectBed::AddInterval(int index) { void MultiIntersectBed::PrintHeader() { - output << "chrom\tstart\tend\tnum\tlist" ; - for (size_t i=0;i<titles.size();++i) - output << "\t" <<titles[i]; + output << "chrom\tstart\tend\tnum\tlist"; + if (titles.size() > 0) { + for (size_t i = 0; i < titles.size(); ++i) + output << "\t" << titles[i]; + } + else { + for (size_t i = 0;i < filenames.size(); ++i) + output << "\t" << filenames[i]; + } output << endl; } diff --git a/src/multiIntersectBed/multiIntersectBedMain.cpp b/src/multiIntersectBed/multiIntersectBedMain.cpp index 884af23c..5248315e 100644 --- a/src/multiIntersectBed/multiIntersectBedMain.cpp +++ b/src/multiIntersectBed/multiIntersectBedMain.cpp @@ -136,11 +136,11 @@ int main(int argc, char* argv[]) //Sanity checks if (inputFiles.empty() == true) { - cerr << "Error: missing BedGraph file names (-i) to combine." << endl; + cerr << "Error: missing file names (-i) to combine." << endl; exit(1); } if (inputFiles.size() == 1) { - cerr << "Error: Only a single BedGraph file was specified. Nothing to combine, exiting." << endl; + cerr << "Error: Only a single file was specified. Nothing to combine, exiting." << endl; exit(1); } if (printEmptyRegions && (genomeFile.empty() == true)) { @@ -162,15 +162,14 @@ void ShowHelp(void) { cerr << endl << "Program: " << PROGRAM_NAME << " (v" << VERSION << ")" << endl; - cerr << "Authors: Assaf Gordon, CSHL" << endl; - cerr << " Aaron Quinlan (aaronquinlan@gmail.com)" << endl << endl; + cerr << "Authors: Aaron Quinlan (aaronquinlan@gmail.com)" << endl; + cerr << " Assaf Gordon" << endl << endl; - cerr << "Summary: Combines multiple BedGraph files into a single file," << endl; - cerr << "\t allowing coverage comparisons between them." << endl << endl; + cerr << "Summary: Identifies common intervals among multiple" << endl; + cerr << "\t BED/GFF/VCF files." << endl << endl; cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -i FILE1 FILE2 .. FILEn" << endl; - cerr << "\t Assumes that each BedGraph file is sorted by chrom/start " << endl; - cerr << "\t and that the intervals in each are non-overlapping." << endl << endl; + cerr << "\t Requires that each interval file is sorted by chrom/start. " << endl << endl; cerr << "Options: " << endl; @@ -200,79 +199,77 @@ void ShowExamples() cerr << "Example usage:\n\n" \ "== Input files: ==\n" \ "\n" \ -" $ cat 1.bg\n" \ -" chr1 1000 1500 10\n" \ -" chr1 2000 2100 20\n" \ +" $ cat a.bed\n" \ +" chr1 6 12\n" \ +" chr1 10 20\n" \ +" chr1 22 27\n" \ +" chr1 24 30\n" \ "\n" \ -" $ cat 2.bg\n" \ -" chr1 900 1600 60\n" \ -" chr1 1700 2050 50\n" \ +" $ cat b.bed\n" \ +" chr1 12 32\n" \ +" chr1 14 30\n" \ "\n" \ -" $ cat 3.bg\n" \ -" chr1 1980 2070 80\n" \ -" chr1 2090 2100 20\n" \ +" $ cat c.bed\n" \ +" chr1 8 15\n" \ +" chr1 10 14\n" \ +" chr1 32 34\n" \ "\n" \ " $ cat sizes.txt\n" \ " chr1 5000\n" \ "\n" \ -"== Union/combine the files: ==\n" \ +"== Multi-intersect the files: ==\n" \ "\n" \ -" $ unionBedGraphs -i 1.bg 2.bg 3.bg\n" \ -" chr1 900 1000 0 60 0\n" \ -" chr1 1000 1500 10 60 0\n" \ -" chr1 1500 1600 0 60 0\n" \ -" chr1 1700 1980 0 50 0\n" \ -" chr1 1980 2000 0 50 80\n" \ -" chr1 2000 2050 20 50 80\n" \ -" chr1 2050 2070 20 0 80\n" \ -" chr1 2070 2090 20 0 0\n" \ -" chr1 2090 2100 20 0 20\n" \ +" $ multiIntersectBed -i a.bed b.bed c.bed\n" \ +"chr1 6 8 1 1 1 0 0\n" \ +"chr1 8 12 2 1,3 1 0 1\n" \ +"chr1 12 15 3 1,2,3 1 1 1\n" \ +"chr1 15 20 2 1,2 1 1 0\n" \ +"chr1 20 22 1 2 0 1 0\n" \ +"chr1 22 30 2 1,2 1 1 0\n" \ +"chr1 30 32 1 2 0 1 0\n" \ +"chr1 32 34 1 3 0 0 1\n" \ "\n" \ -"== Union/combine the files, with a header line (titles are the file names): ==\n" \ +"== Multi-intersect the files, with a header line (titles are the file names): ==\n" \ "\n" \ -" $ unionBedGraphs -header -i 1.bg 2.bg 3.bg\n" \ -" chrom start end 1 2 3\n" \ -" chr1 900 1000 0 60 0\n" \ -" chr1 1000 1500 10 60 0\n" \ -" chr1 1500 1600 0 60 0\n" \ -" chr1 1700 1980 0 50 0\n" \ -" chr1 1980 2000 0 50 80\n" \ -" chr1 2000 2050 20 50 80\n" \ -" chr1 2050 2070 20 0 80\n" \ -" chr1 2070 2090 20 0 0\n" \ -" chr1 2090 2100 20 0 20\n" \ +" $ multiIntersectBed -header -i a.bed b.bed c.bed\n" \ +" chrom start end num list a.bed b.bed c.bed\n" \ +" chr1 6 8 1 1 1 0 0\n" \ +" chr1 8 12 2 1,3 1 0 1\n" \ +" chr1 12 15 3 1,2,3 1 1 1\n" \ +" chr1 15 20 2 1,2 1 1 0\n" \ +" chr1 20 22 1 2 0 1 0\n" \ +" chr1 22 30 2 1,2 1 1 0\n" \ +" chr1 30 32 1 2 0 1 0\n" \ +" chr1 32 34 1 3 0 0 1\n" \ "\n" \ -"== Union/combine the files, with a header line and custom names: ==\n" \ +"== Multi-intersect the files, with a header line and custom names: ==\n" \ "\n" \ -" $ unionBedGraphs -header -i 1.bg 2.bg 3.bg -names WT-1 WT-2 KO-1\n" \ -" chrom start end WT-1 WT-2 KO-1\n" \ -" chr1 900 1000 0 60 0\n" \ -" chr1 1000 1500 10 60 0\n" \ -" chr1 1500 1600 0 60 0\n" \ -" chr1 1700 1980 0 50 0\n" \ -" chr1 1980 2000 0 50 80\n" \ -" chr1 2000 2050 20 50 80\n" \ -" chr1 2050 2070 20 0 80\n" \ -" chr1 2070 2090 20 0 0\n" \ -" chr1 2090 2100 20 0 20\n" \ +" $ multiIntersectBed -header -i a.bed b.bed c.bed -names A B C\n" \ +" chrom start end num list A B C\n" \ +" chr1 6 8 1 A 1 0 0\n" \ +" chr1 8 12 2 A,C 1 0 1\n" \ +" chr1 12 15 3 A,B,C 1 1 1\n" \ +" chr1 15 20 2 A,B 1 1 0\n" \ +" chr1 20 22 1 B 0 1 0\n" \ +" chr1 22 30 2 A,B 1 1 0\n" \ +" chr1 30 32 1 B 0 1 0\n" \ +" chr1 32 34 1 C 0 0 1\n" \ "\n" \ -"== Union/combine, showing empty regions (note, requires -g): ==\n" \ -"\n" \ -" $ unionBedGraphs -header -empty -g sizes.TXT -i 1.bg 2.bg 3.bg\n" \ -" chrom start end 1 2 3\n" \ -" chr1 0 900 0 0 0\n" \ -" chr1 900 1000 0 60 0\n" \ -" chr1 1000 1500 10 60 0\n" \ -" chr1 1500 1600 0 60 0\n" \ -" chr1 1600 1700 0 0 0\n" \ -" chr1 1700 1980 0 50 0\n" \ -" chr1 1980 2000 0 50 80\n" \ -" chr1 2000 2050 20 50 80\n" \ -" chr1 2050 2070 20 0 80\n" \ -" chr1 2070 2090 20 0 0\n" \ -" chr1 2090 2100 20 0 20\n" \ -" chr1 2100 5000 0 0 0\n" \ +"== Multi-intersect the files, showing empty regions (note, requires -g): ==\n" \ "\n" \ +" $ multiIntersectBed -header -i a.bed b.bed c.bed -names A B C -empty -g sizes.txt\n" \ +" chrom start end num list A B C\n" \ +" chr1 0 6 0 none 0 0 0\n" \ +" chr1 6 8 1 A 1 0 0\n" \ +" chr1 8 12 2 A,C 1 0 1\n" \ +" chr1 12 15 3 A,B,C 1 1 1\n" \ +" chr1 15 20 2 A,B 1 1 0\n" \ +" chr1 20 22 1 B 0 1 0\n" \ +" chr1 22 30 2 A,B 1 1 0\n" \ +" chr1 30 32 1 B 0 1 0\n" \ +" chr1 32 34 1 C 0 0 1\n" \ +" chr1 34 5000 0 none 0 0 0\n" \ +"\n" ; } @@ -291,4 +288,3 @@ std::string stl_basename(const std::string& path) return result; } - -- GitLab