Permalink
Browse files

More work. Code compilable now.

  • Loading branch information...
1 parent 43a1b37 commit fdabf72141b065cdfc2d9efc21774644c8696f58 @val-antonescu val-antonescu committed Apr 17, 2014
Showing with 131 additions and 129 deletions.
  1. +19 −19 aligner.h
  2. +2 −2 blockwise_sa.h
  3. +3 −3 diff_sample.h
  4. +2 −2 ebwt.cpp
  5. +26 −27 ebwt.h
  6. +2 −2 ebwt_build.cpp
  7. +5 −5 ebwt_search_backtrack.h
  8. +3 −3 hit.h
  9. +6 −5 hit_set.h
  10. +1 −1 multikey_qsort.h
  11. +35 −35 range_chaser.h
  12. +1 −1 refmap.cpp
  13. +4 −3 refmap.h
  14. +19 −19 row_chaser.h
  15. +1 −1 sam.cpp
  16. +2 −1 sam.h
View
@@ -556,8 +556,8 @@ class UnpairedAlignerV2 : public Aligner {
template<typename TRangeSource>
class PairedBWAlignerV1 : public Aligner {
- typedef std::pair<uint32_t,uint32_t> U32Pair;
- typedef std::vector<U32Pair> U32PairVec;
+ typedef std::pair<TIndexOffU,TIndexOffU> UPair;
+ typedef std::vector<UPair> UPairVec;
typedef std::vector<Range> TRangeVec;
typedef RangeSourceDriver<TRangeSource> TDriver;
typedef std::pair<uint64_t, uint64_t> TU64Pair;
@@ -919,7 +919,7 @@ class PairedBWAlignerV1 : public Aligner {
* mate) aligns such that mating constraint is satisfied.
*/
bool resolveOutstandingInRef(const bool off1,
- const U32Pair& off,
+ const UPair& off,
const uint32_t tlen,
const Range& range)
{
@@ -1364,20 +1364,20 @@ class PairedBWAlignerV1 : public Aligner {
// Range-finding state for first mate
TDriver* driver1Fw_;
TDriver* driver1Rc_;
- U32PairVec offs1FwArr_[32];
+ UPairVec offs1FwArr_[32];
TRangeVec ranges1FwArr_[32];
uint32_t offs1FwSz_; // total size of all ranges found in this category
- U32PairVec offs1RcArr_[32];
+ UPairVec offs1RcArr_[32];
TRangeVec ranges1RcArr_[32];
uint32_t offs1RcSz_; // total size of all ranges found in this category
// Range-finding state for second mate
TDriver* driver2Fw_;
TDriver* driver2Rc_;
- U32PairVec offs2FwArr_[32];
+ UPairVec offs2FwArr_[32];
TRangeVec ranges2FwArr_[32];
uint32_t offs2FwSz_; // total size of all ranges found in this category
- U32PairVec offs2RcArr_[32];
+ UPairVec offs2RcArr_[32];
TRangeVec ranges2RcArr_[32];
uint32_t offs2RcSz_; // total size of all ranges found in this category
@@ -1387,8 +1387,8 @@ class PairedBWAlignerV1 : public Aligner {
bool& delayedchaseR_fw_;
TDriver& drL_fw_;
TDriver& drR_fw_;
- U32PairVec* offsLarr_fw_;
- U32PairVec* offsRarr_fw_;
+ UPairVec* offsLarr_fw_;
+ UPairVec* offsRarr_fw_;
TRangeVec* rangesLarr_fw_;
TRangeVec* rangesRarr_fw_;
uint32_t& offsLsz_fw_;
@@ -1400,8 +1400,8 @@ class PairedBWAlignerV1 : public Aligner {
bool& delayedchaseR_rc_;
TDriver& drL_rc_;
TDriver& drR_rc_;
- U32PairVec* offsLarr_rc_;
- U32PairVec* offsRarr_rc_;
+ UPairVec* offsLarr_rc_;
+ UPairVec* offsRarr_rc_;
TRangeVec* rangesLarr_rc_;
TRangeVec* rangesRarr_rc_;
uint32_t& offsLsz_rc_;
@@ -1413,8 +1413,8 @@ class PairedBWAlignerV1 : public Aligner {
bool* delayedchaseR_;
TDriver* drL_;
TDriver* drR_;
- U32PairVec* offsLarr_;
- U32PairVec* offsRarr_;
+ UPairVec* offsLarr_;
+ UPairVec* offsRarr_;
TRangeVec* rangesLarr_;
TRangeVec* rangesRarr_;
uint32_t* offsLsz_;
@@ -1443,7 +1443,7 @@ class PairedBWAlignerV1 : public Aligner {
*/
struct RangeWithCoords {
Range r;
- U32Pair h;
+ UPair h;
};
/**
@@ -1453,8 +1453,8 @@ struct RangeWithCoords {
template<typename TRangeSource>
class PairedBWAlignerV2 : public Aligner {
- typedef std::pair<uint32_t,uint32_t> U32Pair;
- typedef std::vector<U32Pair> U32PairVec;
+ typedef std::pair<TIndexOffU,TIndexOffU> UPair;
+ typedef std::vector<UPair> UPairVec;
typedef std::vector<Range> TRangeVec;
typedef RangeSourceDriver<TRangeSource> TDriver;
typedef std::pair<uint64_t, uint64_t> TU64Pair;
@@ -1782,7 +1782,7 @@ class PairedBWAlignerV2 : public Aligner {
* a paired alignment by reporting two consecutive alignments, one
* for each mate.
*/
- void reportSe(const Range& r, U32Pair h, uint32_t tlen) {
+ void reportSe(const Range& r, UPair h, uint32_t tlen) {
EbwtSearchParams<String<Dna> >*params = (r.mate1 ? paramsSe1_ : paramsSe2_);
assert(!(r.mate1 ? doneSe1_ : doneSe2_));
params->setFw(r.fw);
@@ -1828,7 +1828,7 @@ class PairedBWAlignerV2 : public Aligner {
}
}
- void resolveOutstanding(const U32Pair& off,
+ void resolveOutstanding(const UPair& off,
const uint32_t tlen,
const Range& range)
{
@@ -1865,7 +1865,7 @@ class PairedBWAlignerV2 : public Aligner {
* This function picks up to 'pick' anchors at random from the
* 'offs' array. It returns the number that it actually picked.
*/
- bool resolveOutstandingInRef(const U32Pair& off,
+ bool resolveOutstandingInRef(const UPair& off,
const uint32_t tlen,
const Range& range)
{
View
@@ -501,8 +501,8 @@ void KarkkainenBlockwiseSA<TStr>::buildSamples() {
// and split/merge as necessary
TIndexOff added = 0;
TIndexOff merged = 0;
- assert_eq(bucketSzs.size(), numBuckets);
- assert_eq(bucketReps.size(), numBuckets);
+ assert_eq(length(bucketSzs), numBuckets);
+ assert_eq(length(bucketReps), numBuckets);
{
Timer timer(cout, " Splitting and merging time: ", this->verbose());
VMSG_NL("Splitting and merging");
View
@@ -566,7 +566,7 @@ class DifferenceCoverSample {
ostream& log() const { return _logger; }
void build();
- TIndexOffU tieBreakOff(TIndexOffU i, TIndexOffU j) const;
+ uint32_t tieBreakOff(TIndexOffU i, TIndexOffU j) const;
int64_t breakTie(TIndexOffU i, TIndexOffU j) const;
bool isCovered(TIndexOffU i) const;
TIndexOffU rank(TIndexOffU i) const;
@@ -790,11 +790,11 @@ void DifferenceCoverSample<TStr>::build() {
// Extract backing-store array from sPrime and sPrimeOrder;
// the mkeyQSortSuf2 routine works on the array for maximum
// efficiency
- TIndexOffU *sPrimeArr = (uint32_t*)begin(sPrime);
+ TIndexOffU *sPrimeArr = (TIndexOffU*)begin(sPrime);
size_t slen = length(sPrime);
assert_eq(sPrimeArr[0], sPrime[0]);
assert_eq(sPrimeArr[slen-1], sPrime[slen-1]);
- TIndexOffU *sPrimeOrderArr = (uint32_t*)begin(sPrimeOrder);
+ TIndexOffU *sPrimeOrderArr = (TIndexOffU*)begin(sPrimeOrder);
assert_eq(sPrimeOrderArr[0], sPrimeOrder[0]);
assert_eq(sPrimeOrderArr[slen-1], sPrimeOrder[slen-1]);
// Sort sample suffixes up to the vth character using a
View
@@ -15,11 +15,11 @@ using namespace std;
#ifdef BOWTIE_64BIT_INDEX
-const std::string gEbwt_ext("bt2l");
+std::string gEbwt_ext("bt2l");
#else
-const std::string gEbwt_ext("bt2");
+std::string gEbwt_ext("bt2");
#endif // BOWTIE_64BIT_INDEX
View
53 ebwt.h
@@ -53,7 +53,6 @@ using namespace seqan;
// From ccnt_lut.cpp, automatically generated by gen_lookup_tables.pl
extern uint8_t cCntLUT_4[4][4][256];
-extern const std::string gEbwt_ext;
static const uint64_t c_table[4] = {
0xffffffffffffffffllu,
@@ -1132,16 +1131,16 @@ class Ebwt {
// Searching and reporting
void joinedToTextOff(TIndexOffU qlen, TIndexOffU off, TIndexOffU& tidx, TIndexOffU& textoff, TIndexOffU& tlen) const;
- inline bool report(const String<Dna5>& query, String<char>* quals, String<char>* name, bool color, char primer, char trimc, bool colExEnds, int snpPhred, const BitPairReference* ref, const std::vector<uint32_t>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, uint32_t off, uint32_t top, uint32_t bot, uint32_t qlen, int stratum, uint16_t cost, uint32_t patid, uint32_t seed, const EbwtSearchParams<TStr>& params) const;
- inline bool reportChaseOne(const String<Dna5>& query, String<char>* quals, String<char>* name, bool color, char primer, char trimc, bool colExEnds, int snpPhred, const BitPairReference* ref, const std::vector<uint32_t>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, uint32_t i, uint32_t top, uint32_t bot, uint32_t qlen, int stratum, uint16_t cost, uint32_t patid, uint32_t seed, const EbwtSearchParams<TStr>& params, SideLocus *l = NULL) const;
+ inline bool report(const String<Dna5>& query, String<char>* quals, String<char>* name, bool color, char primer, char trimc, bool colExEnds, int snpPhred, const BitPairReference* ref, const std::vector<uint32_t>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, TIndexOffU off, uint32_t top, uint32_t bot, uint32_t qlen, int stratum, uint16_t cost, uint32_t patid, uint32_t seed, const EbwtSearchParams<TStr>& params) const;
+ inline bool reportChaseOne(const String<Dna5>& query, String<char>* quals, String<char>* name, bool color, char primer, char trimc, bool colExEnds, int snpPhred, const BitPairReference* ref, const std::vector<uint32_t>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, TIndexOffU i, uint32_t top, uint32_t bot, uint32_t qlen, int stratum, uint16_t cost, uint32_t patid, uint32_t seed, const EbwtSearchParams<TStr>& params, SideLocus *l = NULL) const;
inline bool reportReconstruct(const String<Dna5>& query, String<char>* quals, String<char>* name, String<Dna5>& lbuf, String<Dna5>& rbuf, const uint32_t *mmui32, const char* refcs, size_t numMms, uint32_t i, uint32_t top, uint32_t bot, uint32_t qlen, int stratum, const EbwtSearchParams<TStr>& params, SideLocus *l = NULL) const;
inline int rowL(const SideLocus& l) const;
inline TIndexOffU countUpTo(const SideLocus& l, int c) const;
inline void countUpToEx(const SideLocus& l, TIndexOffU* pairs) const;
inline uint32_t countFwSide(const SideLocus& l, int c) const;
- inline void countFwSideEx(const SideLocus& l, uint32_t *pairs) const;
+ inline void countFwSideEx(const SideLocus& l, TIndexOffU *pairs) const;
inline uint32_t countBwSide(const SideLocus& l, int c) const;
- inline void countBwSideEx(const SideLocus& l, uint32_t *pairs) const;
+ inline void countBwSideEx(const SideLocus& l, TIndexOffU *pairs) const;
inline TIndexOffU mapLF(const SideLocus& l ASSERT_ONLY(, bool overrideSanity = false)) const;
inline void mapLFEx(const SideLocus& l, TIndexOffU *pairs ASSERT_ONLY(, bool overrideSanity = false)) const;
inline void mapLFEx(const SideLocus& ltop, const SideLocus& lbot, TIndexOffU *tops, TIndexOffU *bots ASSERT_ONLY(, bool overrideSanity = false)) const;
@@ -1301,11 +1300,11 @@ class EbwtSearchParams {
const std::vector<uint32_t>& mmui32, // mismatch list
const std::vector<uint8_t>& refcs, // reference characters
size_t numMms, // # mismatches
- U32Pair h, // ref coords
- U32Pair mh, // mate's ref coords
+ UPair h, // ref coords
+ UPair mh, // mate's ref coords
bool mfw, // mate's orientation
uint16_t mlen, // mate length
- U32Pair a, // arrow pair
+ UPair a, // arrow pair
uint32_t tlen, // length of text
uint32_t qlen, // length of query
int stratum, // alignment stratum
@@ -1972,7 +1971,7 @@ inline static int countInU64(int c, uint64_t dw) {
#ifdef POPCNT_CAPABILITY
template<typename Operation>
#endif
-inline static void countInU64Ex(uint64_t dw, uint32_t* arrs) {
+inline static void countInU64Ex(uint64_t dw, TIndexOffU* arrs) {
uint64_t c0 = c_table[0];
uint64_t x0 = dw ^ c0;
uint64_t x1 = (x0 >> 1);
@@ -2219,7 +2218,7 @@ inline uint32_t Ebwt<TStr>::countFwSide(const SideLocus& l, int c) const { /* ch
* break just prior to the side.
*/
template<typename TStr>
-inline void Ebwt<TStr>::countFwSideEx(const SideLocus& l, uint32_t* arrs) const
+inline void Ebwt<TStr>::countFwSideEx(const SideLocus& l, TIndexOffU* arrs) const
{
assert_lt(l._by, (int)this->_eh._sideBwtSz);
assert_geq(l._by, 0);
@@ -2247,8 +2246,8 @@ inline void Ebwt<TStr>::countFwSideEx(const SideLocus& l, uint32_t* arrs) const
}
}
// Now factor in the occ[] count at the side break
- const uint32_t *ac = reinterpret_cast<const uint32_t*>(side - 8);
- const uint32_t *gt = reinterpret_cast<const uint32_t*>(side + this->_eh._sideSz - 8);
+ const TIndexOffU *ac = reinterpret_cast<const TIndexOffU*>(side - 8);
+ const TIndexOffU *gt = reinterpret_cast<const TIndexOffU*>(side + this->_eh._sideSz - 8);
#ifndef NDEBUG
assert_leq(ac[0], this->_fchr[1] + this->_eh.sideBwtLen());
assert_leq(ac[1], this->_fchr[2]-this->_fchr[1]);
@@ -2324,7 +2323,7 @@ inline uint32_t Ebwt<TStr>::countBwSide(const SideLocus& l, int c) const {
* occ[] count up to the side break.
*/
template<typename TStr>
-inline void Ebwt<TStr>::countBwSideEx(const SideLocus& l, uint32_t* arrs) const {
+inline void Ebwt<TStr>::countBwSideEx(const SideLocus& l, TIndexOffU* arrs) const {
assert_lt(l._by, (int)this->_eh._sideBwtSz);
assert_geq(l._by, 0);
assert_lt(l._bp, 4);
@@ -2346,8 +2345,8 @@ inline void Ebwt<TStr>::countBwSideEx(const SideLocus& l, uint32_t* arrs) const
}
}
// Now factor in the occ[] count at the side break
- const uint32_t *ac = reinterpret_cast<const uint32_t*>(side + this->_eh._sideSz - 8);
- const uint32_t *gt = reinterpret_cast<const uint32_t*>(side + (2*this->_eh._sideSz) - 8);
+ const TIndexOffU *ac = reinterpret_cast<const TIndexOffU*>(side + this->_eh._sideSz - 8);
+ const TIndexOffU *gt = reinterpret_cast<const TIndexOffU*>(side + (2*this->_eh._sideSz) - 8);
#ifndef NDEBUG
assert_leq(ac[0], this->_fchr[1] + this->_eh.sideBwtLen());
assert_leq(ac[1], this->_fchr[2]-this->_fchr[1]);
@@ -2654,7 +2653,7 @@ inline bool Ebwt<TStr>::report(const String<Dna5>& query,
const std::vector<uint32_t>& mmui32,
const std::vector<uint8_t>& refcs,
size_t numMms,
- uint32_t off,
+ TIndexOffU off,
uint32_t top,
uint32_t bot,
uint32_t qlen,
@@ -2667,11 +2666,11 @@ inline bool Ebwt<TStr>::report(const String<Dna5>& query,
VMSG_NL("In report");
assert_geq(cost, (uint32_t)(stratum << 14));
assert_lt(off, this->_eh._len);
- uint32_t tidx;
- uint32_t textoff;
- uint32_t tlen;
+ TIndexOffU tidx;
+ TIndexOffU textoff;
+ TIndexOffU tlen;
joinedToTextOff(qlen, off, tidx, textoff, tlen);
- if(tidx == 0xffffffff) {
+ if(tidx == OFF_MASK) {
return false;
}
return params.reportHit(
@@ -2726,7 +2725,7 @@ inline bool Ebwt<TStr>::reportChaseOne(const String<Dna5>& query,
const std::vector<uint32_t>& mmui32,
const std::vector<uint8_t>& refcs,
size_t numMms,
- uint32_t i,
+ TIndexOffU i,
uint32_t top,
uint32_t bot,
uint32_t qlen,
@@ -2738,13 +2737,13 @@ inline bool Ebwt<TStr>::reportChaseOne(const String<Dna5>& query,
SideLocus *l) const
{
VMSG_NL("In reportChaseOne");
- uint32_t off;
+ TIndexOffU off;
uint32_t jumps = 0;
ASSERT_ONLY(uint32_t origi = i);
SideLocus myl;
- const uint32_t offMask = this->_eh._offMask;
+ const TIndexOffU offMask = this->_eh._offMask;
const uint32_t offRate = this->_eh._offRate;
- const uint32_t* offs = this->_offs;
+ const TIndexOffU* offs = this->_offs;
// If the caller didn't give us a pre-calculated (and prefetched)
// locus, then we have to do that now
if(l == NULL) {
@@ -2756,7 +2755,7 @@ inline bool Ebwt<TStr>::reportChaseOne(const String<Dna5>& query,
// Walk along until we reach the next marked row to the left
while(((i & offMask) != i) && i != _zOff) {
// Not a marked row; walk left one more char
- uint32_t newi = mapLF(*l); // calc next row
+ TIndexOffU newi = mapLF(*l); // calc next row
assert_neq(newi, i);
i = newi; // update row
l->initFromRow(i, this->_eh, this->_ebwt); // update locus
@@ -4283,8 +4282,8 @@ void Ebwt<TStr>::buildToDisk(InorderBlockwiseSA<TStr>& sa,
uint8_t *absorbFtab;
try {
VMSG_NL("Allocating ftab, absorbFtab");
- ftab = new uint32_t[ftabLen];
- memset(ftab, 0, 4 * ftabLen);
+ ftab = new TIndexOffU[ftabLen];
+ memset(ftab, 0, OFF_SIZE * ftabLen);
absorbFtab = new uint8_t[ftabLen];
memset(absorbFtab, 0, ftabLen);
} catch(bad_alloc &e) {
View
@@ -377,7 +377,7 @@ static void driver(const string& infile,
plens.clear();
// Now read in the colorspace size records; these are
// the ones that were indexed
- int numSeqs2 = 0;
+ TIndexOff numSeqs2 = 0;
sztot = fastaRefReadSizes(is, szs, plens, refparams, NULL, numSeqs2);
assert_geq(numSeqs, numSeqs2);
} else {
@@ -414,7 +414,7 @@ static void driver(const string& infile,
} else {
// Read in the sizes of all the unambiguous stretches of the
// genome into a vector of RefRecords
- int numSeqs = 0;
+ TIndexOff numSeqs = 0;
sztot = fastaRefReadSizes(is, szs, plens, refparams, NULL, numSeqs);
#ifndef NDEBUG
if(refparams.color) {
View
@@ -549,7 +549,7 @@ class GreedyDFSRangeSource {
// Clear pairs
memset(&pairs[d*8], 0, 8 * 4);
// Calculate next quartet of ranges
- ebwt.mapLFEx(ltop, lbot, &pairs[d*8], &pairs[(d*8)+4]);
+ ebwt.mapLFEx(ltop, lbot, (TIndexOffU*)&pairs[d*8], (TIndexOffU*)&pairs[(d*8)+4]);
// Update top and bot
if(c < 4) {
top = pairTop(pairs, d, c); bot = pairBot(pairs, d, c);
@@ -2217,18 +2217,18 @@ class EbwtRangeSource : public RangeSource {
rs->bots[3] = 0;
if(br->lbot_.valid()) {
if(metrics_ != NULL) metrics_->curBwtOps_++;
- ebwt.mapLFEx(br->ltop_, br->lbot_, rs->tops, rs->bots);
+ ebwt.mapLFEx(br->ltop_, br->lbot_, (TIndexOffU*)rs->tops, (TIndexOffU*)rs->bots);
} else {
#ifndef NDEBUG
- uint32_t tmptops[] = {0, 0, 0, 0};
- uint32_t tmpbots[] = {0, 0, 0, 0};
+ TIndexOffU tmptops[] = {0, 0, 0, 0};
+ TIndexOffU tmpbots[] = {0, 0, 0, 0};
SideLocus ltop, lbot;
ltop.initFromRow(otop, ebwt_->_eh, ebwt_->_ebwt);
lbot.initFromRow(obot, ebwt_->_eh, ebwt_->_ebwt);
ebwt.mapLFEx(ltop, lbot, tmptops, tmpbots);
#endif
if(metrics_ != NULL) metrics_->curBwtOps_++;
- int cc = ebwt.mapLF1(otop, br->ltop_);
+ int cc = ebwt.mapLF1((TIndexOffU&)otop, br->ltop_);
br->top_ = otop;
assert(cc == -1 || (cc >= 0 && cc < 4));
if(cc >= 0) {
Oops, something went wrong.

0 comments on commit fdabf72

Please sign in to comment.