From f12f568c80c3201b84fc16d23ef9b6cd1bd270c4 Mon Sep 17 00:00:00 2001 From: Aaron <aaronquinlan@gmail.com> Date: Wed, 31 Aug 2011 11:48:07 -0400 Subject: [PATCH] Added -S to closestBed --- src/closestBed/closestBed.cpp | 8 +++++--- src/closestBed/closestBed.h | 5 +++-- src/closestBed/closestMain.cpp | 23 ++++++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/closestBed/closestBed.cpp b/src/closestBed/closestBed.cpp index 635bdf85..dcd44a1d 100644 --- a/src/closestBed/closestBed.cpp +++ b/src/closestBed/closestBed.cpp @@ -21,11 +21,13 @@ const int SLOPGROWTH = 2048000; /* Constructor */ -BedClosest::BedClosest(string &bedAFile, string &bedBFile, bool forceStrand, string &tieMode, bool reportDistance, bool ignoreOverlaps) +BedClosest::BedClosest(string &bedAFile, string &bedBFile, bool sameStrand, bool diffStrand, + string &tieMode, bool reportDistance, bool ignoreOverlaps) : _bedAFile(bedAFile) , _bedBFile(bedBFile) , _tieMode(tieMode) - , _forceStrand(forceStrand) + , _sameStrand(sameStrand) + , _diffStrand(diffStrand) , _reportDistance(reportDistance) , _ignoreOverlaps(ignoreOverlaps) { @@ -76,7 +78,7 @@ void BedClosest::FindWindowOverlaps(BED &a, vector<BED> &hits) { // THE HEAVY LIFTING // search for hits with the current slop added - _bedB->FindOverlapsPerBin(a.chrom, aFudgeStart, aFudgeEnd, a.strand, hits, _forceStrand); + _bedB->FindOverlapsPerBin(a.chrom, aFudgeStart, aFudgeEnd, a.strand, hits, _sameStrand, _diffStrand); vector<BED>::const_iterator h = hits.begin(); vector<BED>::const_iterator hitsEnd = hits.end(); diff --git a/src/closestBed/closestBed.h b/src/closestBed/closestBed.h index e5083003..0ee74d25 100644 --- a/src/closestBed/closestBed.h +++ b/src/closestBed/closestBed.h @@ -28,7 +28,7 @@ public: // constructor BedClosest(string &bedAFile, string &bedBFile, - bool forceStrand, string &tieMode, + bool sameStrand, bool diffStrand, string &tieMode, bool reportDistance, bool ignoreOverlaps); // destructor @@ -43,7 +43,8 @@ private: string _bedAFile; string _bedBFile; string _tieMode; - bool _forceStrand; + bool _sameStrand; + bool _diffStrand; bool _reportDistance; bool _ignoreOverlaps; diff --git a/src/closestBed/closestMain.cpp b/src/closestBed/closestMain.cpp index d34e01ff..d2f4fce7 100644 --- a/src/closestBed/closestMain.cpp +++ b/src/closestBed/closestMain.cpp @@ -36,7 +36,8 @@ int main(int argc, char* argv[]) { bool haveBedA = false; bool haveBedB = false; bool haveTieMode = false; - bool forceStrand = false; + bool sameStrand = false; + bool diffStrand = false; bool ignoreOverlaps = false; bool reportDistance = false; @@ -75,7 +76,10 @@ int main(int argc, char* argv[]) { } } else if (PARAMETER_CHECK("-s", 2, parameterLength)) { - forceStrand = true; + sameStrand = true; + } + else if (PARAMETER_CHECK("-S", 2, parameterLength)) { + diffStrand = true; } else if (PARAMETER_CHECK("-d", 2, parameterLength)) { reportDistance = true; @@ -108,8 +112,13 @@ int main(int argc, char* argv[]) { showHelp = true; } + if (sameStrand && diffStrand) { + cerr << endl << "*****" << endl << "*****ERROR: Request either -s OR -S, not both." << endl << "*****" << endl; + showHelp = true; + } + if (!showHelp) { - BedClosest *bc = new BedClosest(bedAFile, bedBFile, forceStrand, tieMode, reportDistance, ignoreOverlaps); + BedClosest *bc = new BedClosest(bedAFile, bedBFile, sameStrand, diffStrand, tieMode, reportDistance, ignoreOverlaps); delete bc; return 0; } @@ -131,8 +140,12 @@ void ShowHelp(void) { cerr << "Usage: " << PROGRAM_NAME << " [OPTIONS] -a <bed/gff/vcf> -b <bed/gff/vcf>" << endl << endl; cerr << "Options: " << endl; - cerr << "\t-s\t" << "Force strandedness. That is, find the closest feature in B" << endl; - cerr << "\t\tthat overlaps A on the same strand." << endl; + cerr << "\t-s\t" << "Require same strandedness. That is, find the closest feature in B" << endl; + cerr << "\t\tthat overlaps A on the _same_ strand." << endl; + cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; + + cerr << "\t-s\t" << "Require opposite strandedness. That is, find the closest feature in B" << endl; + cerr << "\t\tthat overlaps A on the _opposite_ strand." << endl; cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl; cerr << "\t-d\t" << "In addition to the closest feature in B, " << endl; -- GitLab