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

Added -S to coverageBed

parent 8e72b209
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
#include "coverageBed.h"
// build
BedCoverage::BedCoverage(string &bedAFile, string &bedBFile, bool forceStrand,
BedCoverage::BedCoverage(string &bedAFile, string &bedBFile, bool sameStrand, bool diffStrand,
bool writeHistogram, bool bamInput, bool obeySplits,
bool eachBase, bool countsOnly) {
......@@ -23,7 +23,8 @@ BedCoverage::BedCoverage(string &bedAFile, string &bedBFile, bool forceStrand,
_bedA = new BedFile(bedAFile);
_bedB = new BedFile(bedBFile);
_forceStrand = forceStrand;
_sameStrand = sameStrand;
_diffStrand = diffStrand;
_obeySplits = obeySplits;
_eachBase = eachBase;
_writeHistogram = writeHistogram;
......@@ -60,7 +61,7 @@ void BedCoverage::CollectCoverageBed() {
if (bedStatus == BED_VALID) {
// process the BED entry as a single block
if (_obeySplits == false)
_bedB->countHits(a, _forceStrand, _countsOnly);
_bedB->countHits(a, _sameStrand, _diffStrand, _countsOnly);
// split the BED into discrete blocksand process each independently.
else {
bedVector bedBlocks;
......@@ -68,7 +69,7 @@ void BedCoverage::CollectCoverageBed() {
// use countSplitHits to avoid over-counting each split chunk
// as distinct read coverage.
_bedB->countSplitHits(bedBlocks, _forceStrand, _countsOnly);
_bedB->countSplitHits(bedBlocks, _sameStrand, _diffStrand, _countsOnly);
}
a = nullBed;
}
......@@ -112,7 +113,7 @@ void BedCoverage::CollectCoverageBam(string bamFile) {
a.strand = "+";
if (bam.IsReverseStrand()) a.strand = "-";
_bedB->countHits(a, _forceStrand, _countsOnly);
_bedB->countHits(a, _sameStrand, _diffStrand, _countsOnly);
}
// split the BAM alignment into discrete blocks and
// look for overlaps only within each block.
......@@ -124,7 +125,7 @@ void BedCoverage::CollectCoverageBam(string bamFile) {
getBamBlocks(bam, refs, bedBlocks, true);
// use countSplitHits to avoid over-counting each split chunk
// as distinct read coverage.
_bedB->countSplitHits(bedBlocks, _forceStrand, _countsOnly);
_bedB->countSplitHits(bedBlocks, _sameStrand, _diffStrand, _countsOnly);
}
}
}
......
......@@ -36,7 +36,7 @@ class BedCoverage {
public:
// constructor
BedCoverage(string &bedAFile, string &bedBFile, bool forceStrand, bool writeHistogram,
BedCoverage(string &bedAFile, string &bedBFile, bool sameStrand, bool diffStrand, bool writeHistogram,
bool bamInput, bool obeySplits, bool eachBase, bool countsOnly);
// destructor
......@@ -51,8 +51,9 @@ private:
// instance of a bed file class.
BedFile *_bedA, *_bedB;
// do we care about strandedness when counting coverage?
bool _forceStrand;
// do we care about same or opposite strandedness when counting coverage?
bool _sameStrand;
bool _diffStrand;
// should we write a histogram for each feature in B?
bool _writeHistogram;
......
......@@ -33,7 +33,8 @@ int main(int argc, char* argv[]) {
string bedBFile;
// parm flags
bool forceStrand = false;
bool sameStrand = false;
bool diffStrand = false;
bool writeHistogram = false;
bool eachBase = false;
bool obeySplits = false;
......@@ -84,7 +85,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("-hist", 5, parameterLength)) {
writeHistogram = true;
......@@ -109,9 +113,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) {
BedCoverage *bg = new BedCoverage(bedAFile, bedBFile, forceStrand, writeHistogram, bamInput, obeySplits, eachBase, countsOnly);
BedCoverage *bg = new BedCoverage(bedAFile, bedBFile, sameStrand, diffStrand,
writeHistogram, bamInput, obeySplits, eachBase, countsOnly);
delete bg;
return 0;
}
......@@ -135,9 +145,13 @@ void ShowHelp(void) {
cerr << "\t-abam\t" << "The A input file is in BAM format." << endl << endl;
cerr << "\t-s\t" << "Force strandedness. That is, only include hits in A that" << endl;
cerr << "\t\toverlap B on the same strand." << endl;
cerr << "\t\t- By default, hits are included without respect to strand." << endl << endl;
cerr << "\t-s\t" << "Require same strandedness. That is, only counts hits in A that" << endl;
cerr << "\t\toverlap B on the _same_ strand." << endl;
cerr << "\t\t- By default, overlaps are counted without respect to strand." << endl << endl;
cerr << "\t-S\t" << "Require different strandedness. That is, only report hits in A that" << endl;
cerr << "\t\toverlap B on the _opposite_ strand." << endl;
cerr << "\t\t- By default, overlaps are counted without respect to strand." << endl << endl;
cerr << "\t-hist\t" << "Report a histogram of coverage for each feature in B" << endl;
cerr << "\t\tas well as a summary histogram for _all_ features in B." << endl << 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