diff --git a/src/intersectBed/intersectBed.cpp b/src/intersectBed/intersectBed.cpp index cdce4da22ba998199e95c0561e2c289e60a22a56..c6b7dafe218d6d40766727cc610f7ce937683c10 100755 --- a/src/intersectBed/intersectBed.cpp +++ b/src/intersectBed/intersectBed.cpp @@ -1,6 +1,22 @@ +// +// intersectBed.cpp +// BEDTools +// +// Created by Aaron Quinlan Spring 2009. +// Copyright 2009 Aaron Quinlan. All rights reserved. +// +// Summary: Looks for overlaps between features in two BED files. +// + +/* + Includes +*/ #include "intersectBed.h" +/* + Constructor +*/ BedIntersect::BedIntersect(string &bedAFile, string &bedBFile, bool &anyHit, bool &writeB, float &overlapFraction, bool &noHit, bool &writeCount) { @@ -16,12 +32,20 @@ bool &writeB, float &overlapFraction, bool &noHit, bool &writeCount) { this->bedB = new BedFile(bedBFile); } - - +/* + Destructor +*/ BedIntersect::~BedIntersect(void) { } + +/* + reportA + + Writes the _original_ BED entry for A. + Works for BED3 - BED6. +*/ void BedIntersect::reportA(const BED &a) { if (bedA->bedType == 3) { @@ -39,11 +63,15 @@ void BedIntersect::reportA(const BED &a) { cout << a.chrom << "\t" << a.start << "\t" << a.end << "\t" << a.name << "\t" << a.score << "\t" << a.strand; } - } - +/* + reportAIntersect + + Writes the base-pair _overlap_ for a BED entry in A. + Works for BED3 - BED6. +*/ void BedIntersect::reportAIntersect(const BED &a, int &start, int &end) { if (bedA->bedType == 3) { @@ -64,6 +92,14 @@ void BedIntersect::reportAIntersect(const BED &a, int &start, int &end) { } + + +/* + reportB + + Writes the _original_ BED entry for B. + Works for BED3 - BED6. +*/ void BedIntersect::reportB(const BED &b) { if (bedB->bedType == 3) { cout << b.chrom << "\t" << b.start << "\t" << b.end; diff --git a/src/mergeBed/mergeBed.cpp b/src/mergeBed/mergeBed.cpp index 499db70296d60f196afd669e2a36389773a5657b..76906f48544aef32e9c8143b42f225d1072235dd 100755 --- a/src/mergeBed/mergeBed.cpp +++ b/src/mergeBed/mergeBed.cpp @@ -98,12 +98,21 @@ void BedMerge::MergeBed() { // clean up based on the last entry for the current chromosome if (OIP) { - cout << bedList[i-1].chrom << "\t" << minStart << "\t" << maxEnd << endl; + if (this->numEntries) { + cout << bedList[i-1].chrom << "\t" << minStart << "\t" << maxEnd << "\t" << mergeCount << endl; + } + else { + cout << bedList[i-1].chrom << "\t" << minStart << "\t" << maxEnd << endl; + } } else { - cout << m->first << "\t" << bedList[i-1].chrom << "\t" << bedList[i-1].start << "\t" << bedList[i-1].end << endl; + if (this->numEntries) { + cout << bedList[i-1].chrom << "\t" << bedList[i-1].start << "\t" << bedList[i-1].end << "\t" << mergeCount << endl; + } + else { + cout << bedList[i-1].chrom << "\t" << bedList[i-1].start << "\t" << bedList[i-1].end << endl; + } } - } }