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

complementBed now uses the GenomeFile class.

parent 98ed68a6
No related branches found
No related tags found
No related merge requests found
...@@ -10,14 +10,14 @@ BIN_DIR = ../../bin/ ...@@ -10,14 +10,14 @@ BIN_DIR = ../../bin/
# ------------------- # -------------------
# define our includes # define our includes
# ------------------- # -------------------
INCLUDES = -I$(UTILITIES_DIR)/bedFile/ -I$(UTILITIES_DIR)/lineFileUtilities/ -I$(UTILITIES_DIR)/version/ INCLUDES = -I$(UTILITIES_DIR)/bedFile/ -I$(UTILITIES_DIR)/genomeFile/ -I$(UTILITIES_DIR)/lineFileUtilities/ -I$(UTILITIES_DIR)/version/
# ---------------------------------- # ----------------------------------
# define our source and object files # define our source and object files
# ---------------------------------- # ----------------------------------
SOURCES= complementMain.cpp complementBed.cpp SOURCES= complementMain.cpp complementBed.cpp
OBJECTS= $(SOURCES:.cpp=.o) OBJECTS= $(SOURCES:.cpp=.o)
_EXT_OBJECTS=bedFile.o lineFileUtilities.o _EXT_OBJECTS=bedFile.o genomeFile.o lineFileUtilities.o
EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS)) EXT_OBJECTS=$(patsubst %,$(OBJ_DIR)/%,$(_EXT_OBJECTS))
BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS)) BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
PROGRAM= complementBed PROGRAM= complementBed
...@@ -37,6 +37,7 @@ $(BUILT_OBJECTS): $(SOURCES) ...@@ -37,6 +37,7 @@ $(BUILT_OBJECTS): $(SOURCES)
$(EXT_OBJECTS): $(EXT_OBJECTS):
@$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/bedFile/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/bedFile/
@$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/genomeFile/
@$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/lineFileUtilities/ @$(MAKE) --no-print-directory -C $(UTILITIES_DIR)/lineFileUtilities/
clean: clean:
......
...@@ -12,20 +12,16 @@ ...@@ -12,20 +12,16 @@
#include "lineFileUtilities.h" #include "lineFileUtilities.h"
#include "complementBed.h" #include "complementBed.h"
//==========================
// Constructor
//
BedComplement::BedComplement(string &bedFile, string &genomeFile) { BedComplement::BedComplement(string &bedFile, string &genomeFile) {
this->bedFile = bedFile; this->bedFile = bedFile;
this->genomeFile = genomeFile; this->genomeFile = genomeFile;
this->bed = new BedFile(bedFile);
this->bed = new BedFile(bedFile);
this->genome = new GenomeFile(genomeFile);
} }
//
// Destructor
//
BedComplement::~BedComplement(void) { BedComplement::~BedComplement(void) {
} }
...@@ -35,22 +31,6 @@ BedComplement::~BedComplement(void) { ...@@ -35,22 +31,6 @@ BedComplement::~BedComplement(void) {
// //
void BedComplement::ComplementBed() { void BedComplement::ComplementBed() {
// open the GENOME file for reading
ifstream genome(this->genomeFile.c_str(), ios::in);
if ( !genome ) {
cerr << "Error: The requested genome file (" <<this->genomeFile << ") could not be opened. Exiting!" << endl;
exit (1);
}
string chrom;
unsigned int size;
map<string, int, less<string> > chromSizes;
while (genome >> chrom >> size) {
chromSizes[chrom] = size;
}
// load the "B" bed file into a map so // load the "B" bed file into a map so
// that we can easily compare "A" to it for overlaps // that we can easily compare "A" to it for overlaps
bed->loadBedFileIntoMapNoBin(); bed->loadBedFileIntoMapNoBin();
...@@ -62,18 +42,20 @@ void BedComplement::ComplementBed() { ...@@ -62,18 +42,20 @@ void BedComplement::ComplementBed() {
for (masterBedMapNoBin::iterator m = bed->bedMapNoBin.begin(); m != bed->bedMapNoBin.end(); ++m) { for (masterBedMapNoBin::iterator m = bed->bedMapNoBin.begin(); m != bed->bedMapNoBin.end(); ++m) {
currChrom = m->first; currChrom = m->first;
int currChromSize = genome->getChromSize(currChrom);
// bedList is already sorted by start position. // bedList is already sorted by start position.
vector<BED> bedList = m->second; vector<BED> bedList = m->second;
// create a flag for every base on the chrom. // create a flag for every base on the chrom.
vector<short> chromMasks(chromSizes[currChrom], 0); vector<short> chromMasks(currChromSize, 0);
vector<BED>::const_iterator bIt = bedList.begin(); vector<BED>::const_iterator bIt = bedList.begin();
vector<BED>::const_iterator bEnd = bedList.end(); vector<BED>::const_iterator bEnd = bedList.end();
for ( ; bIt != bEnd; ++bIt) { for ( ; bIt != bEnd; ++bIt) {
// sanity check the end of the bed entry // sanity check the end of the bed entry
if (bIt->end > chromSizes[currChrom]) { if (bIt->end > currChromSize) {
cout << "End of BED entry exceeds chromosome length. Please correct." << endl; cout << "End of BED entry exceeds chromosome length. Please correct." << endl;
bed->reportBedNewLine(*bIt); bed->reportBedNewLine(*bIt);
exit(1); exit(1);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
Licenced under the GNU General Public License 2.0+ license. Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/ ******************************************************************************/
#include "bedFile.h" #include "bedFile.h"
#include "genomeFile.h"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
...@@ -42,5 +44,5 @@ private: ...@@ -42,5 +44,5 @@ private:
// instance of a bed file class. // instance of a bed file class.
BedFile *bed; BedFile *bed;
GenomeFile *genome;
}; };
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