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

Added -Sm to windowBed

parent 39ce5531
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
*/
BedWindow::BedWindow(string bedAFile, string bedBFile, int leftSlop, int rightSlop,
bool anyHit, bool noHit, bool writeCount, bool strandWindows,
bool matchOnStrand, bool bamInput, bool bamOutput, bool isUncompressedBam) {
bool matchOnSameStrand, bool matchOnDiffStrand, bool bamInput, bool bamOutput, bool isUncompressedBam) {
_bedAFile = bedAFile;
_bedBFile = bedBFile;
......@@ -30,7 +30,8 @@ BedWindow::BedWindow(string bedAFile, string bedBFile, int leftSlop, int rightSl
_noHit = noHit;
_writeCount = writeCount;
_strandWindows = strandWindows;
_matchOnStrand = matchOnStrand;
_matchOnSameStrand = matchOnSameStrand;
_matchOnDiffStrand = matchOnDiffStrand;
_bamInput = bamInput;
_bamOutput = bamOutput;
_isUncompressedBam = isUncompressedBam;
......@@ -70,7 +71,7 @@ void BedWindow::FindWindowOverlaps(const BED &a, vector<BED> &hits) {
Now report the hits (if any) based on the window around a.
*/
// get the hits in B for the A feature
_bedB->FindOverlapsPerBin(a.chrom, aFudgeStart, aFudgeEnd, a.strand, hits, _matchOnStrand);
_bedB->FindOverlapsPerBin(a.chrom, aFudgeStart, aFudgeEnd, a.strand, hits, _matchOnSameStrand, _matchOnDiffStrand);
int numOverlaps = 0;
......@@ -114,7 +115,7 @@ bool BedWindow::FindOneOrMoreWindowOverlaps(const BED &a) {
CHRPOS aFudgeEnd;
AddWindow(a, aFudgeStart, aFudgeEnd);
bool overlapsFound = _bedB->FindOneOrMoreOverlapsPerBin(a.chrom, a.start, a.end, a.strand, _matchOnStrand);
bool overlapsFound = _bedB->FindOneOrMoreOverlapsPerBin(a.chrom, a.start, a.end, a.strand, _matchOnSameStrand, _matchOnDiffStrand);
return overlapsFound;
}
......
......@@ -34,7 +34,7 @@ public:
// constructor
BedWindow(string bedAFile, string bedBFile, int leftSlop, int rightSlop,
bool anyHit, bool noHit, bool writeCount, bool strandWindows,
bool matchOnStrand, bool bamInput, bool bamOutput, bool isUncompressedBam);
bool matchOnSameStrand, bool matchOnDiffStrand, bool bamInput, bool bamOutput, bool isUncompressedBam);
// destructor
~BedWindow(void);
......@@ -49,7 +49,8 @@ private:
int _rightSlop;
bool _noHit;
bool _strandWindows;
bool _matchOnStrand;
bool _matchOnSameStrand;
bool _matchOnDiffStrand;
bool _bamInput;
bool _bamOutput;
bool _isUncompressedBam;
......
......@@ -46,7 +46,8 @@ int main(int argc, char* argv[]) {
bool haveLeft = false;
bool haveRight = false;
bool strandWindows = false;
bool matchOnStrand = false;
bool matchOnSameStrand = false;
bool matchOnDiffStrand = false;
bool inputIsBam = false;
bool outputIsBam = true;
bool uncompressedBam = false;
......@@ -108,7 +109,10 @@ int main(int argc, char* argv[]) {
strandWindows = true;
}
else if (PARAMETER_CHECK("-sm", 3, parameterLength)) {
matchOnStrand = true;
matchOnSameStrand = true;
}
else if (PARAMETER_CHECK("-sm", 3, parameterLength)) {
matchOnDiffStrand = true;
}
else if (PARAMETER_CHECK("-w", 2, parameterLength)) {
if ((i+1) < argc) {
......@@ -177,9 +181,14 @@ int main(int argc, char* argv[]) {
showHelp = true;
}
if (matchOnSameStrand && matchOnDiffStrand) {
cerr << endl << "*****" << endl << "*****ERROR: Use either -sm or -Sm, not both." << endl << "*****" << endl;
showHelp = true;
}
if (!showHelp) {
BedWindow *bi = new BedWindow(bedAFile, bedBFile, leftSlop, rightSlop, anyHit,
noHit, writeCount, strandWindows, matchOnStrand,
noHit, writeCount, strandWindows, matchOnSameStrand, matchOnDiffStrand,
inputIsBam, outputIsBam, uncompressedBam);
delete bi;
return 0;
......@@ -233,7 +242,10 @@ void ShowHelp(void) {
cerr << "\t\tfor a negative-stranded feature will add 500 bp downstream." << endl;
cerr << "\t\t- Default = disabled." << endl << endl;
cerr << "\t-sm\t" << "Only report hits in B that overlap A on the same strand." << endl;
cerr << "\t-sm\t" << "Only report hits in B that overlap A on the _same_ strand." << endl;
cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl;
cerr << "\t-Sm\t" << "Only report hits in B that overlap A on the _opposite_ strand." << endl;
cerr << "\t\t- By default, overlaps are reported without respect to strand." << endl << endl;
cerr << "\t-u\t" << "Write the original A entry _once_ if _any_ overlaps found in B." << 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