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

nucBed now obeys strand'

parent 7b9c84ac
No related branches found
No related tags found
No related merge requests found
......@@ -13,13 +13,15 @@
#include "nucBed.h"
NucBed::NucBed(string &dbFile, string &bedFile, bool printSeq, bool hasPattern, const string &pattern) {
NucBed::NucBed(string &dbFile, string &bedFile, bool printSeq,
bool hasPattern, const string &pattern, bool forceStrand) {
_dbFile = dbFile;
_bedFile = bedFile;
_printSeq = printSeq;
_hasPattern = hasPattern;
_pattern = pattern;
_forceStrand = forceStrand;
_bed = new BedFile(_bedFile);
......@@ -129,7 +131,10 @@ void NucBed::ProfileDNA() {
// grab the dna at this interval
int length = bed.end - bed.start;
// report the sequence's content
ReportDnaProfile(bed, fr.getSubSequence(bed.chrom, bed.start, length), length);
string dna = fr.getSubSequence(bed.chrom, bed.start, length);
if ((_forceStrand == true) && (bed.strand == "-"))
reverseComplement(dna);
ReportDnaProfile(bed, dna, length);
bed = nullBed;
}
else
......
......@@ -29,7 +29,9 @@ class NucBed {
public:
// constructor
NucBed(string &dbFile, string &bedFile, bool printSeq, bool hasPattern, const string &pattern);
NucBed(string &dbFile, string &bedFile, bool printSeq,
bool hasPattern, const string &pattern,
bool forceStrand);
// destructor
~NucBed(void);
......@@ -42,6 +44,7 @@ private:
bool _printSeq;
bool _hasPattern;
string _pattern;
bool _forceStrand;
// instance of a bed file class.
BedFile *_bed;
......
......@@ -39,6 +39,7 @@ int main(int argc, char* argv[]) {
bool haveBed = false;
bool printSeq = false;
bool hasPattern = false;
bool forceStrand = false;
// check to see if we should print out some help
if(argc <= 1) showHelp = true;
......@@ -76,6 +77,9 @@ int main(int argc, char* argv[]) {
else if(PARAMETER_CHECK("-seq", 4, parameterLength)) {
printSeq = true;
}
else if(PARAMETER_CHECK("-s", 2, parameterLength)) {
forceStrand = true;
}
else if(PARAMETER_CHECK("-pattern", 8, parameterLength)) {
if ((i+1) < argc) {
hasPattern = true;
......@@ -95,7 +99,7 @@ int main(int argc, char* argv[]) {
if (!showHelp) {
NucBed *nuc = new NucBed(fastaDbFile, bedFile, printSeq, hasPattern, pattern);
NucBed *nuc = new NucBed(fastaDbFile, bedFile, printSeq, hasPattern, pattern, forceStrand);
delete nuc;
return 0;
......@@ -118,6 +122,7 @@ void ShowHelp(void) {
cerr << "Options: " << endl;
cerr << "\t-fi\tInput FASTA file" << endl << endl;
cerr << "\t-bed\tBED/GFF/VCF file of ranges to extract from -fi" << endl << endl;
cerr << "\t-s\tProfile the sequence according to strand." << endl << endl;
cerr << "\t-seq\tPrint the extracted sequence" << endl << endl;
cerr << "\t-pattern\tReport the number of times a user-defined sequence is observed (case-insensitive)." << 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