diff --git a/src/maskFastaFromBed/maskFastaFromBed.cpp b/src/maskFastaFromBed/maskFastaFromBed.cpp index 654ff6dbcd28abb1c14babc67ca241864f4a46cf..2bab1226eabfa586cf4773b57d34853e7663a255 100644 --- a/src/maskFastaFromBed/maskFastaFromBed.cpp +++ b/src/maskFastaFromBed/maskFastaFromBed.cpp @@ -13,21 +13,17 @@ #include "maskFastaFromBed.h" -MaskFastaFromBed::MaskFastaFromBed(string &fastaInFile, string &bedFile, string &fastaOutFile, bool &softMask) { - - _softMask = false; - if (softMask) { - _softMask = true; - } - - _fastaInFile = fastaInFile; - _bedFile = bedFile; +MaskFastaFromBed::MaskFastaFromBed(const string &fastaInFile, const string &bedFile, + const string &fastaOutFile, bool softMask, char maskChar) { + _softMask = softMask; + _fastaInFile = fastaInFile; + _bedFile = bedFile; _fastaOutFile = fastaOutFile; - - _bed = new BedFile(_bedFile); + _maskChar = maskChar; + _bed = new BedFile(_bedFile); _bed->loadBedFileIntoMapNoBin(); - + // start masking. MaskFasta(); } @@ -102,7 +98,7 @@ void MaskFastaFromBed::MaskFasta() { currDNA.replace(start, length, replacement); } else { - string hardmask(length, 'N'); + string hardmask(length, _maskChar); currDNA.replace(start, length, hardmask); } } @@ -133,7 +129,7 @@ void MaskFastaFromBed::MaskFasta() { currDNA.replace(start, length, replacement); } else { - string hardmask(length, 'N'); + string hardmask(length, _maskChar); currDNA.replace(start, length, hardmask); } } diff --git a/src/maskFastaFromBed/maskFastaFromBed.h b/src/maskFastaFromBed/maskFastaFromBed.h index 1b7a3590b2722285ad11ae14eaaccb8dee2ed2ea..4cf68c84019fa7dca0336ca7567a0817ca48096a 100644 --- a/src/maskFastaFromBed/maskFastaFromBed.h +++ b/src/maskFastaFromBed/maskFastaFromBed.h @@ -28,7 +28,8 @@ class MaskFastaFromBed { public: // constructor - MaskFastaFromBed(string &fastaInFile, string &bedFile, string &fastaOutFile, bool &softMask); + MaskFastaFromBed(const string &fastaInFile, const string &bedFile, + const string &fastaOutFile, bool softMask, char maskChar); // destructor ~MaskFastaFromBed(void); @@ -41,6 +42,7 @@ private: string _fastaInFile; string _bedFile; string _fastaOutFile; + char _maskChar; // typically "N", but user's can choose something else, e.g., "X" // instance of a bed file class. BedFile *_bed; diff --git a/src/maskFastaFromBed/maskFastaFromBedMain.cpp b/src/maskFastaFromBed/maskFastaFromBedMain.cpp index 0978436d9d5e05f01dc3fe48aa2fcc5809bfa05b..7fce56bbbe913fca5384b19dba4e5fb86ad99e82 100644 --- a/src/maskFastaFromBed/maskFastaFromBedMain.cpp +++ b/src/maskFastaFromBed/maskFastaFromBedMain.cpp @@ -36,11 +36,12 @@ int main(int argc, char* argv[]) { // output files string fastaOutFile; - // checks for existence of parameters - bool haveFastaIn = false; - bool haveBed = false; + // defaults for parameters + bool haveFastaIn = false; + bool haveBed = false; bool haveFastaOut = false; - bool softMask = false; + bool softMask = false; + char maskChar = 'N'; // check to see if we should print out some help if(argc <= 1) showHelp = true; @@ -85,6 +86,19 @@ int main(int argc, char* argv[]) { else if(PARAMETER_CHECK("-soft", 5, parameterLength)) { softMask = true; } + else if(PARAMETER_CHECK("-mc", 3, parameterLength)) { + if ((i+1) < argc) { + string mask = argv[i + 1]; + if (mask.size() > 1) { + cerr << "*****ERROR: The mask character (-mc) should be a single character.*****" << endl << endl; + showHelp = true; + } + else { + maskChar = mask[0]; + } + i++; + } + } else { cerr << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl; showHelp = true; @@ -97,7 +111,7 @@ int main(int argc, char* argv[]) { if (!showHelp) { - MaskFastaFromBed *maskFasta = new MaskFastaFromBed(fastaInFile, bedFile, fastaOutFile, softMask); + MaskFastaFromBed *maskFasta = new MaskFastaFromBed(fastaInFile, bedFile, fastaOutFile, softMask, maskChar); delete maskFasta; return 0; } @@ -124,6 +138,7 @@ void ShowHelp(void) { cerr << "\t-fo\tOutput FASTA file" << endl; cerr << "\t-soft\tEnforce \"soft\" masking. That is, instead of masking with Ns," << endl; cerr << "\t\tmask with lower-case bases." << endl; + cerr << "\t-mc\tReplace masking character. That is, instead of masking with Ns, use another character." << endl; // end the program here exit(1);