diff --git a/src/fastaFromBed/Makefile b/src/fastaFromBed/Makefile index 87bbf74d100b6c9555c49ea29a2fd0f5715b9177..3cd9e892da53c4c6fa6a91b9435ba037594657e2 100644 --- a/src/fastaFromBed/Makefile +++ b/src/fastaFromBed/Makefile @@ -6,12 +6,13 @@ BIN_DIR = ../../bin/ # define our includes # ------------------- INCLUDES = -I$(UTILITIES_DIR)/bedFile/ \ - -I$(UTILITIES_DIR)/sequenceUtilities/ \ - -I$(UTILITIES_DIR)/lineFileUtilities/ \ - -I$(UTILITIES_DIR)/version/ \ - -I$(UTILITIES_DIR)/gzstream/ \ - -I$(UTILITIES_DIR)/fileType/ \ - -I$(UTILITIES_DIR)/Fasta/ + -I$(UTILITIES_DIR)/version/ \ + -I$(UTILITIES_DIR)/gzstream/ \ + -I$(UTILITIES_DIR)/genomeFile/ \ + -I$(UTILITIES_DIR)/lineFileUtilities/ \ + -I$(UTILITIES_DIR)/sequenceUtilities/ \ + -I$(UTILITIES_DIR)/fileType/ \ + -I$(UTILITIES_DIR)/Fasta/ \ # ---------------------------------- # define our source and object files @@ -37,9 +38,9 @@ $(BUILT_OBJECTS): $(SOURCES) @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES) $(EXT_OBJECTS): + @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/bedFile/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/sequenceUtilities/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/lineFileUtilities/ - @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/bedFile/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/gzstream/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/fileType/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/Fasta/ diff --git a/src/fastaFromBed/fastaFromBed.cpp b/src/fastaFromBed/fastaFromBed.cpp index d34eed03e4e27bac7f327beb4c07ea2947644229..41ddebd82d2555ca9970c4bd30c70a031b09d14c 100644 --- a/src/fastaFromBed/fastaFromBed.cpp +++ b/src/fastaFromBed/fastaFromBed.cpp @@ -13,13 +13,10 @@ #include "fastaFromBed.h" -Bed2Fa::Bed2Fa(bool &useName, string &dbFile, string &bedFile, - string &fastaOutFile, bool &useFasta, bool &useStrand) { - - if (useName) { - _useName = true; - } +Bed2Fa::Bed2Fa(bool useName, const string &dbFile, const string &bedFile, + const string &fastaOutFile, bool useFasta, bool useStrand) { + _useName = useName; _dbFile = dbFile; _bedFile = bedFile; _fastaOutFile = fastaOutFile; @@ -102,9 +99,9 @@ void Bed2Fa::ExtractDNA() { } // open and memory-map genome file - FastaReference fr; + FastaReference *fr = new FastaReference; bool memmap = true; - fr.open(_dbFile, memmap); + fr->open(_dbFile, memmap); BED bed, nullBed; int lineNum = 0; @@ -116,14 +113,13 @@ void Bed2Fa::ExtractDNA() { if (bedStatus == BED_VALID) { // make sure we are extracting >= 1 bp if (bed.zeroLength == false) { - size_t seqLength = fr.sequenceLength(bed.chrom); + size_t seqLength = fr->sequenceLength(bed.chrom); // make sure this feature will not exceed the end of the chromosome. if ( (bed.start <= seqLength) && (bed.end <= seqLength) ) { int length = bed.end - bed.start; - sequence = fr.getSubSequence(bed.chrom, bed.start, length); + sequence = fr->getSubSequence(bed.chrom, bed.start, length); ReportDNA(bed, sequence); - bed = nullBed; } else { diff --git a/src/fastaFromBed/fastaFromBed.h b/src/fastaFromBed/fastaFromBed.h index 93ebd611d07374172e45cdcd115d56712e5a10bc..3f5f454be7c8ed40904780c3bbd79055dca5560d 100644 --- a/src/fastaFromBed/fastaFromBed.h +++ b/src/fastaFromBed/fastaFromBed.h @@ -29,8 +29,8 @@ class Bed2Fa { public: // constructor - Bed2Fa(bool &useName, string &dbFile, string &bedFile, string &fastaOutFile, - bool &useFasta, bool &useStrand); + Bed2Fa(bool useName, const string &dbFile, const string &bedFile, const string &fastaOutFile, + bool useFasta, bool useStrand); // destructor ~Bed2Fa(void); diff --git a/src/utils/Fasta/Fasta.cpp b/src/utils/Fasta/Fasta.cpp index bd0c70096805641dbc293af528891377e47c6f85..447eab8b94bb513858475796f6c1fdd666fd2df4 100644 --- a/src/utils/Fasta/Fasta.cpp +++ b/src/utils/Fasta/Fasta.cpp @@ -286,7 +286,7 @@ string FastaReference::sequenceNameStartingWith(string seqnameStart) { } } -string FastaReference::getSubSequence(string seqname, int start, int length) { +string FastaReference::getSubSequence(const string &seqname, int start, int length) { FastaIndexEntry entry = index->entry(seqname); if (start < 0 || length < 1) { cerr << "Error: cannot construct subsequence with negative offset or length < 1" << endl; @@ -318,7 +318,7 @@ string FastaReference::getSubSequence(string seqname, int start, int length) { return s; } -long unsigned int FastaReference::sequenceLength(string seqname) { +long unsigned int FastaReference::sequenceLength(const string &seqname) { FastaIndexEntry entry = index->entry(seqname); return entry.length; } diff --git a/src/utils/Fasta/Fasta.h b/src/utils/Fasta/Fasta.h index f9e3a7f5e3c1b6421d0912e55266f11cc71be215..9bebae04c0f41d966793b0ebbd6329064c2912f1 100644 --- a/src/utils/Fasta/Fasta.h +++ b/src/utils/Fasta/Fasta.h @@ -70,9 +70,9 @@ class FastaReference { string getSequence(string seqname); // potentially useful for performance, investigate // void getSequence(string seqname, string& sequence); - string getSubSequence(string seqname, int start, int length); + string getSubSequence(const string &seqname, int start, int length); string sequenceNameStartingWith(string seqnameStart); - long unsigned int sequenceLength(string seqname); + long unsigned int sequenceLength(const string &seqname); }; #endif