Commit 89d61ef3 authored by Haowen Zhang's avatar Haowen Zhang
Browse files

use a driver class to simplify main

parent 69f9fa00
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ objs_dir=objs
objs+=$(patsubst %.cc,$(objs_dir)/%.o,$(cpp_source))

cxx=g++
cxxflags=-std=c++11 -Wall -O3 -funroll-all-loops -fopenmp -march=native
cxxflags=-std=c++11 -Wall -O3 -fopenmp -march=native
ldflags=-lm -lz

exec=chromap
+8 −3
Original line number Diff line number Diff line
@@ -1488,9 +1488,8 @@ uint8_t Chromap<MappingRecord>::GetMAPQ(int num_positive_candidates, int num_neg
  mapq <<= 1;
  return (uint8_t)mapq;
}
} // namespace chromap

int main(int argc, char *argv[]) {
void ChromapDriver::ParseArgsAndRun(int argc, char *argv[]) {
  cxxopts::Options options("chromap", "A short read mapper for chromatin biology");
  options.add_options("Indexing")
    ("i,build-index", "Build index")
@@ -1777,5 +1776,11 @@ int main(int argc, char *argv[]) {
  } else {
    std::cerr << options.help({"", "Indexing", "Mapping", "Input", "Output"});
  }
}
} // namespace chromap

int main(int argc, char *argv[]) {
  chromap::ChromapDriver chromap_driver;
  chromap_driver.ParseArgsAndRun(argc, argv);
  return 0;
}
+8 −0
Original line number Diff line number Diff line
@@ -38,6 +38,14 @@ enum Direction {

#define SortMappingWithoutBarcode(m) (((((m).fragment_start_position<<16)|(m).fragment_length)<<8)|(m).mapq)
//#define SortMappingWithoutBarcode(m) (m)

class ChromapDriver {
 public:
  ChromapDriver() {}
  ~ChromapDriver() {}
  void ParseArgsAndRun(int argc, char *argv[]);
};

template <typename MappingRecord = MappingWithoutBarcode>
class Chromap {
 public: