Skip to content
Snippets Groups Projects
Commit 80f29d23 authored by Aaron Quinlan's avatar Aaron Quinlan
Browse files

Updated mergeBed reporting logic

	1.  Changed the cout statements for the last entries for a chromosome.
	2.  I had forgotten to report the number of merged entries when -n is requested.
	3.  I also fixed a bug that occassionally caused the last entry for a chromosome
	    to report the chrom twice in the output.
parent 38d67119
No related branches found
No related tags found
No related merge requests found
//
// 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" #include "intersectBed.h"
/*
Constructor
*/
BedIntersect::BedIntersect(string &bedAFile, string &bedBFile, bool &anyHit, BedIntersect::BedIntersect(string &bedAFile, string &bedBFile, bool &anyHit,
bool &writeB, float &overlapFraction, bool &noHit, bool &writeCount) { bool &writeB, float &overlapFraction, bool &noHit, bool &writeCount) {
...@@ -16,12 +32,20 @@ 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); this->bedB = new BedFile(bedBFile);
} }
/*
Destructor
*/
BedIntersect::~BedIntersect(void) { BedIntersect::~BedIntersect(void) {
} }
/*
reportA
Writes the _original_ BED entry for A.
Works for BED3 - BED6.
*/
void BedIntersect::reportA(const BED &a) { void BedIntersect::reportA(const BED &a) {
if (bedA->bedType == 3) { if (bedA->bedType == 3) {
...@@ -39,11 +63,15 @@ void BedIntersect::reportA(const BED &a) { ...@@ -39,11 +63,15 @@ void BedIntersect::reportA(const BED &a) {
cout << a.chrom << "\t" << a.start << "\t" << a.end << "\t" cout << a.chrom << "\t" << a.start << "\t" << a.end << "\t"
<< a.name << "\t" << a.score << "\t" << a.strand; << 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) { void BedIntersect::reportAIntersect(const BED &a, int &start, int &end) {
if (bedA->bedType == 3) { if (bedA->bedType == 3) {
...@@ -64,6 +92,14 @@ void BedIntersect::reportAIntersect(const BED &a, int &start, int &end) { ...@@ -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) { void BedIntersect::reportB(const BED &b) {
if (bedB->bedType == 3) { if (bedB->bedType == 3) {
cout << b.chrom << "\t" << b.start << "\t" << b.end; cout << b.chrom << "\t" << b.start << "\t" << b.end;
......
...@@ -98,12 +98,21 @@ void BedMerge::MergeBed() { ...@@ -98,12 +98,21 @@ void BedMerge::MergeBed() {
// clean up based on the last entry for the current chromosome // clean up based on the last entry for the current chromosome
if (OIP) { 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 { 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;
}
} }
} }
} }
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