Permalink
Browse files

Changed the search debugger into a singleton

  • Loading branch information...
1 parent cd99f35 commit 04bf829ebd8390eee26f5c28794c483107888baf @ctSkennerton committed Apr 25, 2012
Showing with 91 additions and 65 deletions.
  1. +9 −0 src/crass/SearchChecker.cpp
  2. +19 −16 src/crass/SearchChecker.h
  3. +0 −13 src/crass/WorkHorse.cpp
  4. +0 −3 src/crass/WorkHorse.h
  5. +13 −1 src/crass/crass.cpp
  6. +1 −12 src/crass/libcrispr.cpp
  7. +49 −20 src/crass/libcrispr.h
@@ -37,6 +37,15 @@
#include "SearchChecker.h"
#include "Exception.h"
+SearchChecker * SearchChecker::SC_instance = NULL;
+
+
+SearchChecker * SearchChecker::instance()
+{
+ if (!SC_instance)
+ SC_instance = new SearchChecker;
+ return SC_instance;
+}
void SearchChecker::processHeaderFile() {
std::fstream in;
View
@@ -40,23 +40,7 @@
#include <vector>
#include "ReadHolder.h"
#include "StringCheck.h"
-class SearchData;
-class SearchChecker {
- std::string SC_FileName; //a file containing a list of headers for interesting reads
- std::set<std::string> SC_Headers; // a lookup for our interesting headers
- std::vector<SearchData> SC_Data; // data about individual reads
-
-public:
- SearchChecker(){}
- ~SearchChecker(){}
-
-
- // get/set
- inline bool hasHeader(std::string s) {return (SC_Headers.find(s) != SC_Headers.end());}
- inline void headerFile(std::string s ) {SC_FileName = s;}
- void processHeaderFile(void);
-};
class SearchData {
ReadHolder * SD_ReadHolder;
@@ -76,4 +60,23 @@ class SearchData {
inline void read(ReadHolder * r) {SD_ReadHolder = r;}
};
+
+class SearchChecker
+{
+ static SearchChecker *SC_instance;
+ SearchChecker(){};
+ std::string SC_FileName; //a file containing a list of headers for interesting reads
+ std::set<std::string> SC_Headers; // a lookup for our interesting headers
+ std::vector<SearchData> SC_Data; // data about individual reads
+
+public:
+ // get/set
+ inline bool hasHeader(std::string s) {return (SC_Headers.find(s) != SC_Headers.end());}
+ inline void headerFile(std::string s ) {SC_FileName = s;}
+
+ void processHeaderFile(void);
+ static SearchChecker * instance();
+};
+static SearchChecker * debugger = SearchChecker::instance();
+
#endif
View
@@ -159,16 +159,7 @@ int WorkHorse::doWork(std::vector<std::string> seqFiles)
// wrapper for the various processes needed to assemble crisprs
//
-#if DEBUG
- try {
- WH_SeachChecker.headerFile(mOpts->searchChecker);
- WH_SeachChecker.processHeaderFile();
- } catch (crispr::exception& e) {
- std::cerr<<e.what()<<std::endl;
- return 1;
- }
-#endif
logInfo("Parsing reads in " << (seqFiles.size()) << " files", 1);
if(parseSeqFiles(seqFiles))
@@ -295,11 +286,7 @@ int WorkHorse::parseSeqFiles(std::vector<std::string> seqFiles)
{
logInfo("Parsing file: " << *seq_iter, 1);
try {
-#if DEBUG
- int max_len = decideWhichSearch(seq_iter->c_str(), *mOpts, &mReads, &mStringCheck, patterns_lookup, reads_found, WH_SeachChecker);
-#else
int max_len = decideWhichSearch(seq_iter->c_str(), *mOpts, &mReads, &mStringCheck, patterns_lookup, reads_found);
-#endif
mMaxReadLength = (max_len > mMaxReadLength) ? max_len : mMaxReadLength;
logInfo("Finished file: " << *seq_iter, 1);
View
@@ -160,9 +160,6 @@ class WorkHorse {
std::map<int, bool> mGroupMap; // list of valid group IDs
DR_Cluster_Map mDR2GIDMap; // map a DR (StringToken) to a GID
std::map<int, std::string> mTrueDRs; // map GId to true DR strings
-#if DEBUG
- SearchChecker WH_SeachChecker; // our debugging object
-#endif
};
#endif //WorkHorse_h
View
@@ -57,6 +57,7 @@
#include "WorkHorse.h"
#include "Rainbow.h"
#include "StlExt.h"
+#include "Exception.h"
#ifdef PERFORM_CRASS_ASSEMBLY
#include "AssemblyWrapper.h"
#endif
@@ -556,9 +557,20 @@ int main(int argc, char *argv[])
cmd_line += argv[i];
cmd_line += ' ';
}
-
WorkHorse * mHorse = new WorkHorse(&opts, timestamp,cmd_line);
+#if DEBUG
+ try {
+ debugger->headerFile(opts.searchChecker);
+ debugger->processHeaderFile();
+ } catch (crispr::exception& e) {
+ std::cerr<<e.what()<<std::endl;
+ return 1;
+ }
+
+#endif
+
int error_code = mHorse->doWork(seq_files);
+ delete debugger;
delete mHorse;
return error_code;
}
View
@@ -69,24 +69,13 @@
*/
KSEQ_INIT(gzFile, gzread)
-#if DEBUG
-int decideWhichSearch(const char *inputFastq,
- const options& opts,
- ReadMap * mReads,
- StringCheck * mStringCheck,
- lookupTable& patternsHash,
- lookupTable& readsFound,
- SearchChecker& searchDebugger
- )
-#else
int decideWhichSearch(const char *inputFastq,
const options& opts,
ReadMap * mReads,
StringCheck * mStringCheck,
lookupTable& patternsHash,
lookupTable& readsFound
)
-#endif
{
//-----
@@ -125,7 +114,7 @@ int decideWhichSearch(const char *inputFastq,
ReadHolder * tmp_holder = new ReadHolder(seq->seq.s, seq->name.s);
// test if it has a comment entry and a quality entry (fastq input file)
#if DEBUG
- if (searchDebugger.hasHeader(seq->name.s)) {
+ if (debugger->hasHeader(seq->name.s)) {
changeLogLevel(8);
SearchData sd;
sd.read(tmp_holder);
View
@@ -80,31 +80,60 @@ enum side{rightSide, leftSide};
//**************************************
// search functions
//**************************************
-#if DEBUG
-int decideWhichSearch(const char *inputFile, const options &opts, ReadMap * mReads, StringCheck * mStringCheck, lookupTable& patternsHash, lookupTable& readsFound, SearchChecker& searchDebugger );
-
-#else
-int decideWhichSearch(const char *inputFile, const options &opts, ReadMap * mReads, StringCheck * mStringCheck, lookupTable& patternsHash, lookupTable& readsFound);
-#endif
-int longReadSearch(ReadHolder * seq, const options &opts, ReadMap * mReads, StringCheck * mStringCheck, lookupTable &patterns_hash, lookupTable &readsFound);
-
-int shortReadSearch(ReadHolder * seq, const options &opts, ReadMap * mReads, StringCheck * mStringCheck, lookupTable &patterns_hash, lookupTable &readsFound);
-
-void findSingletons(const char *input_fastq, const options &opts, lookupTable &patterns_hash, lookupTable &readsFound, ReadMap *mReads, StringCheck * mStringCheck);
-
-void findSingletonsMultiVector(const char *inputFastq, const options &opts, std::vector<std::vector<std::string> *> &patterns, lookupTable &readsFound, ReadMap * mReads, StringCheck * mStringCheck);
-
-int scanRight(ReadHolder * tmp_holder, std::string& pattern, unsigned int minSpacerLength, unsigned int scanRange);
-
-unsigned int extendPreRepeat(ReadHolder* tmp_holder, int searchWindowLength);
-
-bool qcFoundRepeats(ReadHolder * tmp_holder, int minSpacerLength, int maxSpacerLength);
+int decideWhichSearch(const char *inputFile,
+ const options &opts,
+ ReadMap * mReads,
+ StringCheck * mStringCheck,
+ lookupTable& patternsHash,
+ lookupTable& readsFound);
+
+int longReadSearch(ReadHolder * seq,
+ const options &opts,
+ ReadMap * mReads,
+ StringCheck * mStringCheck,
+ lookupTable &patterns_hash,
+ lookupTable &readsFound);
+
+int shortReadSearch(ReadHolder * seq,
+ const options &opts,
+ ReadMap * mReads,
+ StringCheck * mStringCheck,
+ lookupTable &patterns_hash,
+ lookupTable &readsFound);
+
+void findSingletons(const char *input_fastq,
+ const options &opts,
+ lookupTable &patterns_hash,
+ lookupTable &readsFound,
+ ReadMap *mReads,
+ StringCheck * mStringCheck);
+
+void findSingletonsMultiVector(const char *inputFastq,
+ const options &opts,
+ std::vector<std::vector<std::string> *> &patterns,
+ lookupTable &readsFound,
+ ReadMap * mReads,
+ StringCheck * mStringCheck);
+
+int scanRight(ReadHolder * tmp_holder,
+ std::string& pattern,
+ unsigned int minSpacerLength,
+ unsigned int scanRange);
+
+unsigned int extendPreRepeat(ReadHolder* tmp_holder,
+ int searchWindowLength);
+
+bool qcFoundRepeats(ReadHolder * tmp_holder,
+ int minSpacerLength,
+ int maxSpacerLength);
bool isRepeatLowComplexity(std::string& repeat);
bool drHasHighlyAbundantKmers(std::string& directRepeat);
-void addReadHolder(ReadMap * mReads, StringCheck * mStringCheck, ReadHolder * tmp_holder);
+void addReadHolder(ReadMap * mReads,
+ StringCheck * mStringCheck,
+ ReadHolder * tmp_holder);
//
//

0 comments on commit 04bf829

Please sign in to comment.