Skip to content

Commit

Permalink
Use EList instead of std::vector
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4rr0 committed Jun 16, 2020
1 parent 90144a1 commit 931b322
Show file tree
Hide file tree
Showing 42 changed files with 544 additions and 533 deletions.
35 changes: 18 additions & 17 deletions aligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "aligner_metrics.h"
#include "assert_helpers.h"
#include "ds.h"
#include "ebwt.h"
#include "pat.h"
#include "range.h"
Expand Down Expand Up @@ -94,8 +95,8 @@ class AlignerFactory {
* Allocate a vector of n Aligners; use destroy(std::vector...) to
* free the memory.
*/
virtual std::vector<Aligner*>* create(uint32_t n) const {
std::vector<Aligner*>* v = new std::vector<Aligner*>;
virtual EList<Aligner*>* create(uint32_t n) const {
EList<Aligner*>* v = new EList<Aligner*>;
for(uint32_t i = 0; i < n; i++) {
v->push_back(create());
assert(v->back() != NULL);
Expand All @@ -111,7 +112,7 @@ class AlignerFactory {
}

/// Free memory associated with an aligner list
virtual void destroy(std::vector<Aligner*>* als) const {
virtual void destroy(EList<Aligner*>* als) const {
assert(als != NULL);
// Free all of the Aligners
for(size_t i = 0; i < als->size(); i++) {
Expand Down Expand Up @@ -185,8 +186,8 @@ class MultiAligner {
uint32_t qUpto_; /// Number of reads to align before stopping
const AlignerFactory& alignFact_;
const PatternSourcePerThreadFactory& patsrcFact_;
std::vector<Aligner *>* aligners_;
std::vector<PatternSourcePerThread *>* patsrcs_;
EList<Aligner *>* aligners_;
EList<PatternSourcePerThread *>* patsrcs_;
};

/**
Expand Down Expand Up @@ -365,10 +366,10 @@ class MixedMultiAligner {
const AlignerFactory& alignSEFact_;
const AlignerFactory& alignPEFact_;
const PatternSourcePerThreadFactory& patsrcFact_;
std::vector<Aligner *>* alignersSE_;
std::vector<Aligner *>* alignersPE_;
EList<Aligner *>* alignersSE_;
EList<Aligner *>* alignersPE_;
bool * seOrPe_;
std::vector<PatternSourcePerThread *>* patsrcs_;
EList<PatternSourcePerThread *>* patsrcs_;
};

/**
Expand All @@ -387,7 +388,7 @@ class UnpairedAlignerV2 : public Aligner {
HitSink& sink,
const HitSinkPerThreadFactory& sinkPtFactory,
HitSinkPerThread* sinkPt,
vector<BTRefString >& os, // TODO: remove this, not used
EList<BTRefString >& os, // TODO: remove this, not used
BitPairReference *refs,
bool rangeMode,
bool verbose,
Expand Down Expand Up @@ -605,8 +606,8 @@ template<typename TRangeSource>
class PairedBWAlignerV1 : public Aligner {

typedef std::pair<TIndexOffU,TIndexOffU> UPair;
typedef std::vector<UPair> UPairVec;
typedef std::vector<Range> TRangeVec;
typedef EList<UPair> UPairVec;
typedef EList<Range> TRangeVec;
typedef RangeSourceDriver<TRangeSource> TDriver;
typedef std::pair<uint64_t, uint64_t> TU64Pair;
typedef std::set<TU64Pair> TSetPairs;
Expand Down Expand Up @@ -1050,8 +1051,8 @@ class PairedBWAlignerV1 : public Aligner {
// 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<TIndexOffU> offs;
EList<Range> ranges;
EList<TIndexOffU> offs;
refAligner_->find(1, tidx, refs_, seq, qual, begin, end, ranges,
offs, doneFw_ ? &pairs_rc_ : &pairs_fw_,
toff, fw);
Expand Down Expand Up @@ -1482,8 +1483,8 @@ template<typename TRangeSource>
class PairedBWAlignerV2 : public Aligner {

typedef std::pair<TIndexOffU,TIndexOffU> UPair;
typedef std::vector<UPair> UPairVec;
typedef std::vector<Range> TRangeVec;
typedef EList<UPair> UPairVec;
typedef EList<Range> TRangeVec;
typedef RangeSourceDriver<TRangeSource> TDriver;
typedef std::pair<uint64_t, uint64_t> TU64Pair;
typedef std::set<TU64Pair> TSetPairs;
Expand Down Expand Up @@ -1964,8 +1965,8 @@ class PairedBWAlignerV2 : public Aligner {
// 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<TIndexOffU> offs;
EList<Range> ranges;
EList<TIndexOffU> offs;
refAligner_->find(1, tidx, refs_, seq, qual, begin, end, ranges,
offs, pairFw ? &pairs_fw_ : &pairs_rc_,
toff, fw);
Expand Down
15 changes: 8 additions & 7 deletions aligner_0mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#define ALIGNER_0MM_H_

#include <utility>
#include <vector>

#include "aligner.h"
#include "ds.h"
#include "hit.h"
#include "row_chaser.h"
#include "range_chaser.h"
Expand All @@ -19,7 +20,7 @@
class UnpairedExactAlignerV1Factory : public AlignerFactory {

typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;

public:
Expand All @@ -35,7 +36,7 @@ class UnpairedExactAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference *refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool maqPenalty,
bool qualOrder,
bool strandFix,
Expand Down Expand Up @@ -126,7 +127,7 @@ class UnpairedExactAlignerV1Factory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference *refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
bool maqPenalty_;
bool qualOrder_;
bool strandFix_;
Expand All @@ -141,7 +142,7 @@ class UnpairedExactAlignerV1Factory : public AlignerFactory {
class PairedExactAlignerV1Factory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
public:
PairedExactAlignerV1Factory(
Ebwt& ebwtFw,
Expand All @@ -164,7 +165,7 @@ class PairedExactAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool reportSe,
bool maqPenalty,
bool strandFix,
Expand Down Expand Up @@ -363,7 +364,7 @@ class PairedExactAlignerV1Factory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference* refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
const bool reportSe_;
const bool maqPenalty_;
const bool qualOrder_;
Expand Down
15 changes: 8 additions & 7 deletions aligner_1mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#define ALIGNER_1MM_H_

#include <utility>
#include <vector>

#include "aligner.h"
#include "ds.h"
#include "hit.h"
#include "range_source.h"
#include "row_chaser.h"
Expand All @@ -21,7 +22,7 @@
class Unpaired1mmAlignerV1Factory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
public:
Unpaired1mmAlignerV1Factory(
Ebwt& ebwtFw,
Expand All @@ -35,7 +36,7 @@ class Unpaired1mmAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference *refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool maqPenalty,
bool qualOrder,
bool strandFix,
Expand Down Expand Up @@ -161,7 +162,7 @@ class Unpaired1mmAlignerV1Factory : public AlignerFactory {
RangeCache *cacheBw_;
const uint32_t cacheLimit_;
ChunkPool *pool_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
BitPairReference *refs_;
const bool maqPenalty_;
const bool qualOrder_;
Expand All @@ -177,7 +178,7 @@ class Unpaired1mmAlignerV1Factory : public AlignerFactory {
class Paired1mmAlignerV1Factory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
public:
Paired1mmAlignerV1Factory(
Ebwt& ebwtFw,
Expand All @@ -200,7 +201,7 @@ class Paired1mmAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool reportSe,
bool maqPenalty,
bool qualOrder,
Expand Down Expand Up @@ -474,7 +475,7 @@ class Paired1mmAlignerV1Factory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference* refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
const bool reportSe_;
const bool maqPenalty_;
const bool qualOrder_;
Expand Down
15 changes: 8 additions & 7 deletions aligner_23mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#define ALIGNER_23MM_H_

#include <utility>
#include <vector>

#include "aligner.h"
#include "ds.h"
#include "hit.h"
#include "range_source.h"
#include "row_chaser.h"
Expand All @@ -20,7 +21,7 @@
class Unpaired23mmAlignerV1Factory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
public:
Unpaired23mmAlignerV1Factory(
Ebwt& ebwtFw,
Expand All @@ -35,7 +36,7 @@ class Unpaired23mmAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool maqPenalty,
bool qualOrder,
bool strandFix,
Expand Down Expand Up @@ -232,7 +233,7 @@ class Unpaired23mmAlignerV1Factory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference *refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
const bool maqPenalty_;
const bool qualOrder_;
const bool strandFix_;
Expand All @@ -248,7 +249,7 @@ class Paired23mmAlignerV1Factory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef ListRangeSourceDriver<EbwtRangeSource> TListRangeSrcDr;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
public:
Paired23mmAlignerV1Factory(
Ebwt& ebwtFw,
Expand All @@ -272,7 +273,7 @@ class Paired23mmAlignerV1Factory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool reportSe,
bool maqPenalty,
bool qualOrder,
Expand Down Expand Up @@ -671,7 +672,7 @@ class Paired23mmAlignerV1Factory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference* refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
const bool reportSe_;
const bool maqPenalty_;
const bool qualOrder_;
Expand Down
15 changes: 8 additions & 7 deletions aligner_seed_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#define ALIGNER_SEED_MM_H_

#include <utility>
#include <vector>

#include "aligner.h"
#include "ds.h"
#include "hit.h"
#include "row_chaser.h"
#include "range_chaser.h"
Expand All @@ -19,7 +20,7 @@
class UnpairedSeedAlignerFactory : public AlignerFactory {

typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;

public:
Expand All @@ -39,7 +40,7 @@ class UnpairedSeedAlignerFactory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool maqPenalty,
bool qualOrder,
bool strandFix,
Expand Down Expand Up @@ -555,7 +556,7 @@ class UnpairedSeedAlignerFactory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference *refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
bool strandFix_;
bool maqPenalty_;
bool qualOrder_;
Expand All @@ -570,7 +571,7 @@ class UnpairedSeedAlignerFactory : public AlignerFactory {
*/
class PairedSeedAlignerFactory : public AlignerFactory {
typedef RangeSourceDriver<EbwtRangeSource> TRangeSrcDr;
typedef std::vector<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef EList<TRangeSrcDr*> TRangeSrcDrPtrVec;
typedef CostAwareRangeSourceDriver<EbwtRangeSource> TCostAwareRangeSrcDr;
public:
PairedSeedAlignerFactory(
Expand Down Expand Up @@ -598,7 +599,7 @@ class PairedSeedAlignerFactory : public AlignerFactory {
uint32_t cacheLimit,
ChunkPool *pool,
BitPairReference* refs,
vector<BTRefString >& os,
EList<BTRefString >& os,
bool reportSe,
bool maqPenalty,
bool qualOrder,
Expand Down Expand Up @@ -1373,7 +1374,7 @@ class PairedSeedAlignerFactory : public AlignerFactory {
const uint32_t cacheLimit_;
ChunkPool *pool_;
BitPairReference* refs_;
vector<BTRefString >& os_;
EList<BTRefString >& os_;
const bool reportSe_;
const bool maqPenalty_;
const bool qualOrder_;
Expand Down
4 changes: 2 additions & 2 deletions binary_sa_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <stdint.h>
#include <iostream>
#include <limits>
#include <vector>

#include "alphabet.h"
#include "assert_helpers.h"
#include "btypes.h"
#include "ds.h"
#include "sstring.h"

/**
Expand All @@ -29,7 +29,7 @@
template<typename TStr, typename TSufElt> inline
TIndexOffU binarySASearch(const TStr& host,
TIndexOffU qry,
const std::vector<TSufElt>& sa)
const EList<TSufElt>& sa)
{
TIndexOffU lLcp = 0, rLcp = 0; // greatest observed LCPs on left and right
TIndexOffU l = 0, r = (TIndexOffU)sa.size()+1; // binary-search window
Expand Down
Loading

0 comments on commit 931b322

Please sign in to comment.