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

Added -S to subtractBed

parent 793ec9f3
No related branches found
No related tags found
No related merge requests found
......@@ -16,12 +16,13 @@
/*
Constructor
*/
BedSubtract::BedSubtract(string &bedAFile, string &bedBFile, float &overlapFraction, bool &forceStrand) {
BedSubtract::BedSubtract(string &bedAFile, string &bedBFile, float overlapFraction, bool sameStrand, bool diffStrand) {
_bedAFile = bedAFile;
_bedBFile = bedBFile;
_overlapFraction = overlapFraction;
_forceStrand = forceStrand;
_sameStrand = sameStrand;
_diffStrand = diffStrand;
_bedA = new BedFile(bedAFile);
_bedB = new BedFile(bedBFile);
......@@ -40,7 +41,7 @@ BedSubtract::~BedSubtract(void) {
void BedSubtract::FindAndSubtractOverlaps(BED &a, vector<BED> &hits) {
// find all of the overlaps between a and B.
_bedB->FindOverlapsPerBin(a.chrom, a.start, a.end, a.strand, hits, _forceStrand);
_bedB->FindOverlapsPerBin(a.chrom, a.start, a.end, a.strand, hits, _sameStrand, _diffStrand);
// is A completely spanned by an entry in B?
// if so, A should not be reported.
......
......@@ -27,7 +27,7 @@ class BedSubtract {
public:
// constructor
BedSubtract(string &bedAFile, string &bedBFile, float &overlapFraction, bool &forceStrand);
BedSubtract(string &bedAFile, string &bedBFile, float overlapFraction, bool sameStrand, bool diffStrand);
// destructor
~BedSubtract(void);
......@@ -38,7 +38,9 @@ private:
string _bedAFile;
string _bedBFile;
float _overlapFraction;
bool _forceStrand;
bool _sameStrand;
bool _diffStrand;
// instances of bed file class.
BedFile *_bedA, *_bedB;
......
......@@ -39,7 +39,8 @@ int main(int argc, char* argv[]) {
bool haveBedA = false;
bool haveBedB = false;
bool haveFraction = false;
bool forceStrand = false;
bool sameStrand = false;
bool diffStrand = false;
// check to see if we should print out some help
if(argc <= 1) showHelp = true;
......@@ -82,7 +83,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 {
cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl;
......@@ -95,10 +99,15 @@ int main(int argc, char* argv[]) {
cerr << endl << "*****" << endl << "*****ERROR: Need -a and -b files. " << endl << "*****" << endl;
showHelp = true;
}
if (sameStrand && diffStrand) {
cerr << endl << "*****" << endl << "*****ERROR: Request either -s OR -S, not both." << endl << "*****" << endl;
showHelp = true;
}
if (!showHelp) {
BedSubtract *bs = new BedSubtract(bedAFile, bedBFile, overlapFraction, forceStrand);
BedSubtract *bs = new BedSubtract(bedAFile, bedBFile, overlapFraction, sameStrand, diffStrand);
delete bs;
return 0;
}
......@@ -123,10 +132,13 @@ void ShowHelp(void) {
cerr << "\t\t- Default is 1E-9 (i.e., 1bp)." << endl;
cerr << "\t\t- (FLOAT) (e.g. 0.50)" << endl << endl;
cerr << "\t-s\t" << "Force strandedness. That is, only report hits in B that" << endl;
cerr << "\t\toverlap 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 same strandedness. That is, only subtract hits in B that" << endl;
cerr << "\t\toverlap A on the _same_ strand." << endl;
cerr << "\t\t- By default, overlaps are subtracted without respect to strand." << endl << endl;
cerr << "\t-S\t" << "Force strandedness. That is, only subtract hits in B that" << endl;
cerr << "\t\toverlap A on the _opposite_ strand." << endl;
cerr << "\t\t- By default, overlaps are subtracted without respect to strand." << endl << endl;
// end the program here
exit(1);
......
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