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

Updated fastaFromBed

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