Permalink
Browse files

These still needs review.

  • Loading branch information...
1 parent 5b21922 commit b1dab64425dcc4d4aebcd1fc5b0b9e460d615c72 @val-antonescu val-antonescu committed Jun 9, 2014
Showing with 496 additions and 489 deletions.
  1. +55 −55 aligner.h
  2. +10 −10 ebwt.h
  3. +43 −43 ebwt_search_backtrack.h
  4. +7 −0 random_source.h
  5. +6 −6 range.h
  6. +375 −375 ref_aligner.h
View
110 aligner.h
@@ -408,8 +408,8 @@ class UnpairedAlignerV2 : public Aligner {
* Helper for reporting an alignment.
*/
inline bool report(const Range& ra,
- uint32_t first,
- uint32_t second,
+ TIndexOffU first,
+ TIndexOffU second,
uint32_t tlen)
{
bool ebwtFw = ra.ebwt->fw();
@@ -433,7 +433,7 @@ class UnpairedAlignerV2 : public Aligner {
ra.refcs, // reference characters for mms
ra.numMms, // # mismatches
make_pair(first, second), // position
- make_pair(0, 0), // (bogus) mate position
+ make_pair<TIndexOffU,TIndexOffU>(0, 0), // (bogus) mate position
true, // (bogus) mate orientation
0, // (bogus) mate length
make_pair(ra.top, ra.bot),// arrows
@@ -808,23 +808,23 @@ class PairedBWAlignerV1 : public Aligner {
*/
bool report(const Range& rL, // range for upstream mate
const Range& rR, // range for downstream mate
- uint32_t first, // ref idx
- uint32_t upstreamOff, // offset for upstream mate
- uint32_t dnstreamOff, // offset for downstream mate
- uint32_t tlen, // length of ref
+ TIndexOffU first, // ref idx
+ TIndexOffU upstreamOff, // offset for upstream mate
+ TIndexOffU dnstreamOff, // offset for downstream mate
+ TIndexOffU tlen, // length of ref
bool pairFw, // whether the pair is being mapped to fw strand
bool ebwtFwL,
bool ebwtFwR,
const ReferenceMap* rmap)
{
assert(gAllowMateContainment || upstreamOff < dnstreamOff);
- uint32_t spreadL = rL.bot - rL.top;
- uint32_t spreadR = rR.bot - rR.top;
- uint32_t oms = min(spreadL, spreadR) - 1;
+ TIndexOffU spreadL = rL.bot - rL.top;
+ TIndexOffU spreadR = rR.bot - rR.top;
+ TIndexOffU oms = min(spreadL, spreadR) - 1;
ReadBuf* bufL = pairFw ? bufa_ : bufb_;
ReadBuf* bufR = pairFw ? bufb_ : bufa_;
- uint32_t lenL = pairFw ? alen_ : blen_;
- uint32_t lenR = pairFw ? blen_ : alen_;
+ TIndexOffU lenL = pairFw ? alen_ : blen_;
+ TIndexOffU lenR = pairFw ? blen_ : alen_;
bool ret;
assert(!params_->sink().exceededOverThresh());
params_->setFw(rL.fw);
@@ -900,10 +900,10 @@ class PairedBWAlignerV1 : public Aligner {
bool report(const Range& rL, // range for upstream mate
const Range& rR, // range for downstream mate
- uint32_t first, // ref idx
- uint32_t upstreamOff, // offset for upstream mate
- uint32_t dnstreamOff, // offset for downstream mate
- uint32_t tlen, // length of ref
+ TIndexOffU first, // ref idx
+ TIndexOffU upstreamOff, // offset for upstream mate
+ TIndexOffU dnstreamOff, // offset for downstream mate
+ TIndexOffU tlen, // length of ref
bool pairFw, // whether the pair is being mapped to fw strand
const ReferenceMap* rmap)
{
@@ -920,7 +920,7 @@ class PairedBWAlignerV1 : public Aligner {
*/
bool resolveOutstandingInRef(const bool off1,
const UPair& off,
- const uint32_t tlen,
+ const TIndexOffU tlen,
const Range& range)
{
assert(refs_->loaded());
@@ -976,17 +976,17 @@ class PairedBWAlignerV1 : public Aligner {
if((uint32_t)maxins <= max(qlen, alen)) {
return false;
}
- const uint32_t tidx = off.first;
- const uint32_t toff = off.second;
+ const TIndexOffU tidx = off.first;
+ const TIndexOffU toff = off.second;
// Set begin/end to be a range of all reference
// positions that are legally permitted to be involved in
// the alignment of the outstanding mate.
//
// Note that one of the constraints imposed on which positions
// go into this range is that the opposite mate cannot be
// contained entirely within the anchor mate, or vice versa.
- uint32_t begin, end;
- uint32_t insDiff = maxins - minins;
+ TIndexOffU begin, end;
+ TIndexOffU insDiff = maxins - minins;
if(matchRight) {
end = toff + maxins;
// Adding 1 disallows the opposite from starting at the
@@ -999,12 +999,12 @@ class PairedBWAlignerV1 : public Aligner {
begin += alen-qlen;
}
if(end > insDiff + qlen) {
- begin = max<uint32_t>(begin, end - insDiff - qlen);
+ begin = max<TIndexOffU>(begin, end - insDiff - qlen);
}
- end = min<uint32_t>(refs_->approxLen(tidx), end);
- begin = min<uint32_t>(refs_->approxLen(tidx), begin);
+ end = min<TIndexOffU>(refs_->approxLen(tidx), end);
+ begin = min<TIndexOffU>(refs_->approxLen(tidx), begin);
} else {
- if(toff + alen < (uint32_t)maxins) {
+ if(toff + alen < (TIndexOffU)maxins) {
begin = 0;
} else {
begin = toff + alen - maxins;
@@ -1014,15 +1014,15 @@ class PairedBWAlignerV1 : public Aligner {
end = toff + alen;
} else {
end = toff + mi - 1;
- end = min<uint32_t>(end, toff + alen - minins + qlen - 1);
+ end = min<TIndexOffU>(end, toff + alen - minins + qlen - 1);
if(toff + alen + qlen < (uint32_t)minins + 1) end = 0;
}
}
// Check if there's not enough space in the range to fit an
// alignment for the outstanding mate.
if(end - begin < qlen) return false;
std::vector<Range> ranges;
- std::vector<uint32_t> offs;
+ std::vector<TIndexOffU> offs;
refAligner_->find(1, tidx, refs_, seq, qual, begin, end, ranges,
offs, doneFw_ ? &pairs_rc_ : &pairs_fw_,
toff, fw);
@@ -1033,7 +1033,7 @@ class PairedBWAlignerV1 : public Aligner {
r.fw = fw;
r.cost |= (r.stratum << 14);
r.mate1 = !off1;
- const uint32_t result = offs[i];
+ const TIndexOffU result = offs[i];
// NOTE: We have no idea what the BW range delimiting the
// opposite hit is, because we were operating entirely in
// reference space when we found it. For now, we just copy
@@ -1102,8 +1102,8 @@ class PairedBWAlignerV1 : public Aligner {
assert(drR_->foundRange);
const Range& r = drR_->range();
assert(r.repOk());
- uint32_t top = r.top;
- uint32_t bot = r.bot;
+ TIndexOffU top = r.top;
+ TIndexOffU bot = r.bot;
uint32_t qlen = doneFw_? qlen1_ : qlen2_;
rchase_->setTopBot(top, bot, qlen, rand_, r.ebwt);
*chaseR_ = true;
@@ -1147,8 +1147,8 @@ class PairedBWAlignerV1 : public Aligner {
assert(drL_->foundRange);
const Range& r = drL_->range();
assert(r.repOk());
- uint32_t top = r.top;
- uint32_t bot = r.bot;
+ TIndexOffU top = r.top;
+ TIndexOffU bot = r.bot;
uint32_t qlen = doneFw_? qlen2_ : qlen1_;
rchase_->setTopBot(top, bot, qlen, rand_, r.ebwt);
*chaseL_ = true;
@@ -1687,23 +1687,23 @@ class PairedBWAlignerV2 : public Aligner {
*/
bool report(const Range& rL, // range for upstream mate
const Range& rR, // range for downstream mate
- uint32_t first, // ref idx
- uint32_t upstreamOff, // offset for upstream mate
- uint32_t dnstreamOff, // offset for downstream mate
- uint32_t tlen, // length of ref
+ TIndexOffU first, // ref idx
+ TIndexOffU upstreamOff, // offset for upstream mate
+ TIndexOffU dnstreamOff, // offset for downstream mate
+ TIndexOffU tlen, // length of ref
bool pairFw, // whether the pair is being mapped to fw strand
bool ebwtFwL,
bool ebwtFwR,
const ReferenceMap *rmap)
{
assert(gAllowMateContainment || upstreamOff < dnstreamOff);
- uint32_t spreadL = rL.bot - rL.top;
- uint32_t spreadR = rR.bot - rR.top;
- uint32_t oms = min(spreadL, spreadR) - 1;
+ TIndexOffU spreadL = rL.bot - rL.top;
+ TIndexOffU spreadR = rR.bot - rR.top;
+ TIndexOffU oms = min(spreadL, spreadR) - 1;
ReadBuf* bufL = pairFw ? bufa_ : bufb_;
ReadBuf* bufR = pairFw ? bufb_ : bufa_;
- uint32_t lenL = pairFw ? alen_ : blen_;
- uint32_t lenR = pairFw ? blen_ : alen_;
+ TIndexOffU lenL = pairFw ? alen_ : blen_;
+ TIndexOffU lenR = pairFw ? blen_ : alen_;
bool ret;
assert(!params_->sink().exceededOverThresh());
params_->setFw(rL.fw);
@@ -1829,7 +1829,7 @@ class PairedBWAlignerV2 : public Aligner {
}
void resolveOutstanding(const UPair& off,
- const uint32_t tlen,
+ const TIndexOffU tlen,
const Range& range)
{
assert(!this->done);
@@ -1866,7 +1866,7 @@ class PairedBWAlignerV2 : public Aligner {
* 'offs' array. It returns the number that it actually picked.
*/
bool resolveOutstandingInRef(const UPair& off,
- const uint32_t tlen,
+ const TIndexOffU tlen,
const Range& range)
{
assert(!donePe_);
@@ -1920,14 +1920,14 @@ class PairedBWAlignerV2 : public Aligner {
if((uint32_t)maxins <= max(qlen, alen)) {
return false;
}
- const uint32_t tidx = off.first; // text id where anchor mate hit
- const uint32_t toff = off.second; // offset where anchor mate hit
+ const TIndexOffU tidx = off.first; // text id where anchor mate hit
+ const TIndexOffU toff = off.second; // offset where anchor mate hit
// Set begin/end to the range of reference positions where
// outstanding mate may align while fulfilling insert-length
// constraints.
- uint32_t begin, end;
+ TIndexOffU begin, end;
assert_geq(maxins, minins);
- uint32_t insDiff = maxins - minins;
+ TIndexOffU insDiff = maxins - minins;
if(matchRight) {
end = toff + maxins;
// Adding 1 disallows the opposite from starting at the
@@ -1940,12 +1940,12 @@ class PairedBWAlignerV2 : public Aligner {
begin += alen-qlen;
}
if(end > insDiff + qlen) {
- begin = max<uint32_t>(begin, end - insDiff - qlen);
+ begin = max<TIndexOffU>(begin, end - insDiff - qlen);
}
- end = min<uint32_t>(refs_->approxLen(tidx), end);
- begin = min<uint32_t>(refs_->approxLen(tidx), begin);
+ end = min<TIndexOffU>(refs_->approxLen(tidx), end);
+ begin = min<TIndexOffU>(refs_->approxLen(tidx), begin);
} else {
- if(toff + alen < (uint32_t)maxins) {
+ if(toff + alen < (TIndexOffU)maxins) {
begin = 0;
} else {
begin = toff + alen - maxins;
@@ -1955,15 +1955,15 @@ class PairedBWAlignerV2 : public Aligner {
end = toff + alen - 1;
} else {
end = toff + mi - 1;
- end = min<uint32_t>(end, toff + alen - minins + qlen - 1);
- if(toff + alen + qlen < (uint32_t)minins + 1) end = 0;
+ end = min<TIndexOffU>(end, toff + alen - minins + qlen - 1);
+ if(toff + alen + qlen < (TIndexOffU)minins + 1) end = 0;
}
}
// Check if there's not enough space in the range to fit an
// alignment for the outstanding mate.
if(end - begin < qlen) return false;
std::vector<Range> ranges;
- std::vector<uint32_t> offs;
+ std::vector<TIndexOffU> offs;
refAligner_->find(1, tidx, refs_, seq, qual, begin, end, ranges,
offs, pairFw ? &pairs_fw_ : &pairs_rc_,
toff, fw);
@@ -1973,7 +1973,7 @@ class PairedBWAlignerV2 : public Aligner {
r.fw = fw;
r.cost |= (r.stratum << 14);
r.mate1 = !range.mate1;
- const uint32_t result = offs[i];
+ const TIndexOffU result = offs[i];
// Just copy the known range's top and bot for now
r.top = range.top;
r.bot = range.bot;
View
20 ebwt.h
@@ -1131,8 +1131,8 @@ 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, 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 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<TIndexOffU>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, TIndexOffU off, TIndexOffU top, TIndexOffU 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<TIndexOffU>& mmui32, const std::vector<uint8_t>& refcs, size_t numMms, TIndexOffU i, TIndexOffU top, TIndexOffU 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;
@@ -1297,7 +1297,7 @@ class EbwtSearchParams {
const BitPairReference* ref, // reference (= NULL if not necessary)
const ReferenceMap* rmap, // map to another reference coordinate system
bool ebwtFw, // whether index is forward (true) or mirror (false)
- const std::vector<uint32_t>& mmui32, // mismatch list
+ const std::vector<TIndexOffU>& mmui32, // mismatch list
const std::vector<uint8_t>& refcs, // reference characters
size_t numMms, // # mismatches
UPair h, // ref coords
@@ -2650,12 +2650,12 @@ inline bool Ebwt<TStr>::report(const String<Dna5>& query,
bool colExEnds,
int snpPhred,
const BitPairReference* ref,
- const std::vector<uint32_t>& mmui32,
+ const std::vector<TIndexOffU>& mmui32,
const std::vector<uint8_t>& refcs,
size_t numMms,
TIndexOffU off,
- uint32_t top,
- uint32_t bot,
+ TIndexOffU top,
+ TIndexOffU bot,
uint32_t qlen,
int stratum,
uint16_t cost,
@@ -2689,7 +2689,7 @@ inline bool Ebwt<TStr>::report(const String<Dna5>& query,
refcs, // reference characters for mms
numMms, // # mismatches
make_pair(tidx, textoff), // position
- make_pair(0, 0), // (bogus) mate position
+ make_pair<TIndexOffU,TIndexOffU>(0, 0), // (bogus) mate position
true, // (bogus) mate orientation
0, // (bogus) mate length
make_pair(top, bot), // arrows
@@ -2722,12 +2722,12 @@ inline bool Ebwt<TStr>::reportChaseOne(const String<Dna5>& query,
bool colExEnds,
int snpPhred,
const BitPairReference* ref,
- const std::vector<uint32_t>& mmui32,
+ const std::vector<TIndexOffU>& mmui32,
const std::vector<uint8_t>& refcs,
size_t numMms,
TIndexOffU i,
- uint32_t top,
- uint32_t bot,
+ TIndexOffU top,
+ TIndexOffU bot,
uint32_t qlen,
int stratum,
uint16_t cost,
Oops, something went wrong.

0 comments on commit b1dab64

Please sign in to comment.