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

Added -f to tagBam.

parent 0b3f2511
No related branches found
No related tags found
No related merge requests found
......@@ -14,12 +14,13 @@
// build
TagBam::TagBam(const string &bamFile, const vector<string> &annoFileNames,
const vector<string> &annoLables, bool forceStrand) :
const vector<string> &annoLables, bool forceStrand, float overlapFraction) :
_bamFile(bamFile),
_annoFileNames(annoFileNames),
_annoLabels(annoLables),
_forceStrand(forceStrand)
_forceStrand(forceStrand),
_overlapFraction(overlapFraction)
{}
......@@ -49,7 +50,7 @@ void TagBam::CloseAnnoFiles() {
bool TagBam::FindOneOrMoreOverlap(const BED &a, BedFile *bedFile) {
return bedFile->FindOneOrMoreOverlapsPerBin(a.chrom, a.start, a.end, a.strand,
_forceStrand, 0);
_forceStrand, _overlapFraction);
}
void TagBam::Tag() {
......
......@@ -40,7 +40,7 @@ public:
// constructor
TagBam(const string &bamFile, const vector<string> &annoFileNames,
const vector<string> &annoLabels, bool forceStrand);
const vector<string> &annoLabels, bool forceStrand, float overlapFraction);
// destructor
~TagBam(void);
......@@ -61,6 +61,7 @@ private:
// do we care about strandedness when tagging?
bool _forceStrand;
float _overlapFraction;
// private function for reporting coverage information
void ReportAnnotations();
......
......@@ -30,8 +30,10 @@ int main(int argc, char* argv[]) {
// input file
string bamFile;
float overlapFraction = 1E-9;
// parm flags
bool haveFraction = false;
bool forceStrand = false;
bool haveBam = false;
bool haveFiles = false;
......@@ -98,6 +100,13 @@ int main(int argc, char* argv[]) {
else if (PARAMETER_CHECK("-s", 2, parameterLength)) {
forceStrand = true;
}
else if(PARAMETER_CHECK("-f", 2, parameterLength)) {
if ((i+1) < argc) {
haveFraction = true;
overlapFraction = atof(argv[i + 1]);
i++;
}
}
else {
cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl;
showHelp = true;
......@@ -111,7 +120,7 @@ int main(int argc, char* argv[]) {
}
if (!showHelp) {
TagBam *ba = new TagBam(bamFile, inputFiles, inputLabels, forceStrand);
TagBam *ba = new TagBam(bamFile, inputFiles, inputLabels, forceStrand, overlapFraction);
ba->Tag();
delete ba;
return 0;
......@@ -137,5 +146,8 @@ void ShowHelp(void) {
cerr << "\t-s\t" << "Force strandedness. That is, only tag alignments that have the same" << endl;
cerr << "\t\tstrand as a feature in the annotation file(s)." << endl << endl;
cerr << "\t-f\t" << "Minimum overlap required as a fraction of the alignment." << endl;
cerr << "\t\t- Default is 1E-9 (i.e., 1bp)." << endl;
cerr << "\t\t- FLOAT (e.g. 0.50)" << endl << endl;
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