diff --git a/Makefile b/Makefile index 7fbfe20..b55e816 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ bindir ?= $(exec_prefix)/bin # Flags CXX ?= g++ -CXXFLAGS += -std=c++14 -isystem ${EBROOTHTSLIB} -pedantic -W -Wall -Wno-unknown-pragmas -D__STDC_LIMIT_MACROS -fno-strict-aliasing -fpermissive +CXXFLAGS += -std=c++17 -isystem ${EBROOTHTSLIB} -pedantic -W -Wall -Wno-unknown-pragmas -D__STDC_LIMIT_MACROS -fno-strict-aliasing -fpermissive LDFLAGS += -L${EBROOTHTSLIB} -lboost_iostreams -lboost_filesystem -lboost_system -lboost_program_options -lboost_date_time # Flags for parallel computation diff --git a/src/asmode.h b/src/asmode.h index b07b8fb..bcdaac6 100644 --- a/src/asmode.h +++ b/src/asmode.h @@ -129,9 +129,7 @@ namespace torali { } // Sort junctions - for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) { - std::sort(it->second.begin(), it->second.end(), SortJunction()); - } + for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) std::sort(it->second.begin(), it->second.end()); // Clean-up bam_hdr_destroy(hdr); @@ -170,7 +168,7 @@ namespace torali { for(uint32_t svt = 0; svt < srBR.size(); ++svt) { if (srBR[svt].empty()) continue; // Sort - std::sort(srBR[svt].begin(), srBR[svt].end(), SortSRBamRecord()); + std::sort(srBR[svt].begin(), srBR[svt].end()); //outputSRBamRecords(c, srBR, true); // Cluster @@ -364,7 +362,7 @@ namespace torali { _setAsmConsensus(c, svc, srStore); // Sort SVs - sort(svc.begin(), svc.end(), SortSVs()); + sort(svc.begin(), svc.end()); // Filter SVs uint32_t idCount = 0; @@ -396,7 +394,7 @@ namespace torali { for(uint32_t file_c = 0; file_c < c.files.size(); ++file_c) { jctMap[file_c].resize(svs.size(), JunctionCount()); spanMap[file_c].resize(svs.size(), SpanningCount()); - rcMap[file_c].resize(svs.size(), ReadCount()); + rcMap[file_c].resize(svs.size()); } // VCF Output diff --git a/src/cluster.h b/src/cluster.h index 9b7d022..fd85236 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -35,25 +35,19 @@ namespace torali uint8_t MapQuality; BamAlignRecord(bam1_t* rec, uint8_t pairQuality, uint16_t a, uint16_t ma, int32_t median, int32_t mad, int32_t maxISize) : tid(rec->core.tid), pos(rec->core.pos), mtid(rec->core.mtid), mpos(rec->core.mpos), alen(a), malen(ma), Median(median), Mad(mad), maxNormalISize(maxISize), flag(rec->core.flag), MapQuality(pairQuality) {} - }; - // Sort reduced bam alignment records - template - struct SortBamRecords : public std::binary_function - { - inline bool operator()(TRecord const& s1, TRecord const& s2) const { - if (s1.tid==s1.mtid) { - return ((std::min(s1.pos, s1.mpos) < std::min(s2.pos, s2.mpos)) || - ((std::min(s1.pos, s1.mpos) == std::min(s2.pos, s2.mpos)) && (std::max(s1.pos, s1.mpos) < std::max(s2.pos, s2.mpos))) || - ((std::min(s1.pos, s1.mpos) == std::min(s2.pos, s2.mpos)) && (std::max(s1.pos, s1.mpos) == std::max(s2.pos, s2.mpos)) && (s1.maxNormalISize < s2.maxNormalISize))); + bool operator<(const BamAlignRecord& s2) const { + if (tid==mtid) { + return ((std::min(pos, mpos) < std::min(s2.pos, s2.mpos)) || + ((std::min(pos, mpos) == std::min(s2.pos, s2.mpos)) && (std::max(pos, mpos) < std::max(s2.pos, s2.mpos))) || + ((std::min(pos, mpos) == std::min(s2.pos, s2.mpos)) && (std::max(pos, mpos) == std::max(s2.pos, s2.mpos)) && (maxNormalISize < s2.maxNormalISize))); } else { - return ((s1.pos < s2.pos) || - ((s1.pos == s2.pos) && (s1.mpos < s2.mpos)) || - ((s1.pos == s2.pos) && (s1.mpos == s2.mpos) && (s1.maxNormalISize < s2.maxNormalISize))); + return ((pos < s2.pos) || + ((pos == s2.pos) && (mpos < s2.mpos)) || + ((pos == s2.pos) && (mpos == s2.mpos) && (maxNormalISize < s2.maxNormalISize))); } } }; - // Edge struct template @@ -64,14 +58,9 @@ namespace torali TWeight weight; EdgeRecord(TVertex s, TVertex t, TWeight w) : source(s), target(t), weight(w) {} - }; - // Sort edge records - template - struct SortEdgeRecords : public std::binary_function - { - inline bool operator()(TRecord const& e1, TRecord const& e2) const { - return ((e1.weight < e2.weight) || ((e1.weight == e2.weight) && (e1.source < e2.source)) || ((e1.weight == e2.weight) && (e1.source == e2.source) && (e1.target < e2.target))); + bool operator<(const EdgeRecord e2) const { + return ((weight < e2.weight) || ((weight == e2.weight) && (source < e2.source)) || ((weight == e2.weight) && (source == e2.source) && (target < e2.target))); } }; @@ -225,7 +214,7 @@ namespace torali // Iterate all components for(typename TCompEdgeList::iterator compIt = compEdge.begin(); compIt != compEdge.end(); ++compIt) { // Sort edges by weight - std::sort(compIt->second.begin(), compIt->second.end(), SortEdgeRecords()); + std::sort(compIt->second.begin(), compIt->second.end()); // Find a large clique typename TEdgeList::const_iterator itWEdge = compIt->second.begin(); @@ -454,12 +443,11 @@ namespace torali inline void _searchCliques(TConfig const& c, TCompEdgeList& compEdge, TBamRecord const& bamRecord, TSVs& svs, int32_t const svt) { typedef typename TCompEdgeList::mapped_type TEdgeList; - typedef typename TEdgeList::value_type TEdgeRecord; // Iterate all components for(typename TCompEdgeList::iterator compIt = compEdge.begin(); compIt != compEdge.end(); ++compIt) { // Sort edges by weight - std::sort(compIt->second.begin(), compIt->second.end(), SortEdgeRecords()); + std::sort(compIt->second.begin(), compIt->second.end()); // Find a large clique typename TEdgeList::const_iterator itWEdge = compIt->second.begin(); diff --git a/src/cnv.h b/src/cnv.h index cece243..1b2b84a 100644 --- a/src/cnv.h +++ b/src/cnv.h @@ -35,18 +35,13 @@ namespace torali explicit SVBreakpoint(int32_t const p) : pos(p), cilow(0), cihigh(0), qual(0) {} SVBreakpoint(int32_t const p, int32_t const cil, int32_t const cih, int32_t q) : pos(p), cilow(cil), cihigh(cih), qual(q) {} - }; - - template - struct SortSVBreakpoint : public std::binary_function - { - inline bool operator()(TSVBp const& sv1, TSVBp const& sv2) { - return ((sv1.pos midpoint) searchEnd = midpoint; // Current CNV start for this breakpoint - typename TSVs::const_iterator itsv = std::lower_bound(svbp[refIndex].begin(), svbp[refIndex].end(), SVBreakpoint(searchStart), SortSVBreakpoint()); + auto itsv = std::lower_bound(svbp[refIndex].begin(), svbp[refIndex].end(), SVBreakpoint(searchStart)); for(; itsv != svbp[refIndex].end(); ++itsv) { if (itsv->pos > searchEnd) break; if ((itbest == svbp[refIndex].end()) || (itsv->qual > itbest->qual)) itbest = itsv; diff --git a/src/coral.h b/src/coral.h index 966f43c..9ce9d95 100644 --- a/src/coral.h +++ b/src/coral.h @@ -119,7 +119,7 @@ namespace torali svbp[svs[i].chr].push_back(SVBreakpoint(svs[i].svStart, svs[i].ciposlow, svs[i].ciposhigh, svs[i].mapq)); svbp[svs[i].chr2].push_back(SVBreakpoint(svs[i].svEnd, svs[i].ciendlow, svs[i].ciendhigh, svs[i].mapq)); } - for (uint32_t i = 0; i < svbp.size(); ++i) sort(svbp[i].begin(), svbp[i].end(), SortSVBreakpoint()); + for (uint32_t i = 0; i < svbp.size(); ++i) sort(svbp[i].begin(), svbp[i].end()); } // Iterate chromosomes @@ -458,7 +458,7 @@ namespace torali } // Sort CNVs - sort(cnvs.begin(), cnvs.end(), SortCNVs()); + sort(cnvs.begin(), cnvs.end()); // Genotype CNVs cnvVCF(c, cnvs); diff --git a/src/coverage.h b/src/coverage.h index 162adf6..196cb68 100644 --- a/src/coverage.h +++ b/src/coverage.h @@ -30,6 +30,10 @@ namespace torali { SpanPoint() : bppos(0), svt(0), id(0), chr2(0), otherBppos(0) {} explicit SpanPoint(int32_t const bp) : bppos(bp), svt(0), id(0), chr2(0), otherBppos(0) {} SpanPoint(int32_t const bp, int32_t const s, uint32_t const identifier, int32_t const tid, int32_t const obp) : bppos(bp), svt(s), id(identifier), chr2(tid), otherBppos(obp) {} + + bool operator<(const SpanPoint& s2) const { + return (bppos < s2.bppos); + } }; struct BpRegion { @@ -45,15 +49,12 @@ namespace torali { BpRegion() : regionStart(0), regionEnd(0), bppos(0), homLeft(0), homRight(0), svt(0), id(0), bpPoint(0) {} explicit BpRegion(int32_t bp) : regionStart(0), regionEnd(0), bppos(bp), homLeft(0), homRight(0), svt(0), id(0), bpPoint(0) {} BpRegion(int32_t rs, int32_t re, int32_t bpos, int32_t hl, int32_t hr, int32_t s, uint32_t identifier, uint8_t bpp) : regionStart(rs), regionEnd(re), bppos(bpos), homLeft(hl), homRight(hr), svt(s), id(identifier), bpPoint(bpp) {} - }; - template - struct SortBp : public std::binary_function { - inline bool operator()(TRecord const& s1, TRecord const& s2) const { - return (s1.bppos < s2.bppos); + bool operator<(const BpRegion& s2) const { + return (bppos < s2.bppos); } }; - + struct SpanningCount { std::vector ref; std::vector alt; @@ -228,7 +229,7 @@ namespace torali { fai_destroy(fai); for(int32_t refIndex=0; refIndex < (int32_t) hdr->n_targets; ++refIndex) { // Sort breakpoint regions - std::sort(bpRegion[refIndex].begin(), bpRegion[refIndex].end(), SortBp()); + std::sort(bpRegion[refIndex].begin(), bpRegion[refIndex].end()); } } @@ -236,7 +237,6 @@ namespace torali { inline void annotateCoverage(TConfig& c, TSampleLibrary& sampleLib, TSVs& svs, TCoverageCount& covCount, TCountMap& countMap, TSpanMap& spanMap) { - typedef typename TCoverageCount::value_type::value_type TCovPair; typedef typename TSpanMap::value_type::value_type TSpanPair; typedef typename TCountMap::value_type::value_type TCountPair; typedef std::vector TQuality; @@ -262,7 +262,7 @@ namespace torali { countMap.resize(c.files.size()); spanMap.resize(c.files.size()); for(uint32_t file_c = 0; file_c < c.files.size(); ++file_c) { - covCount[file_c].resize(svs.size(), TCovPair()); + covCount[file_c].resize(svs.size()); countMap[file_c].resize(svs.size(), TCountPair()); spanMap[file_c].resize(svs.size(), TSpanPair()); } @@ -372,7 +372,7 @@ namespace torali { spanPoint.push_back(SpanPoint(itSV->svEnd, itSV->svt, itSV->id, itSV->chr, itSV->svStart)); } } - std::sort(spanPoint.begin(), spanPoint.end(), SortBp()); + std::sort(spanPoint.begin(), spanPoint.end()); // Count reads hts_itr_t* iter = sam_itr_queryi(idx[file_c], refIndex, 0, hdr[file_c]->target_len[refIndex]); @@ -426,7 +426,7 @@ namespace torali { } if (bpvalid) { // Fetch all relevant SVs - typename TBpRegion::iterator itBp = std::lower_bound(bpRegion[refIndex].begin(), bpRegion[refIndex].end(), BpRegion(rbegin), SortBp()); + typename TBpRegion::iterator itBp = std::lower_bound(bpRegion[refIndex].begin(), bpRegion[refIndex].end(), BpRegion(rbegin)); for(; ((itBp != bpRegion[refIndex].end()) && (rec->core.pos + rec->core.l_qseq >= itBp->bppos)); ++itBp) { if ((countMap[file_c][itBp->id].ref.size() + countMap[file_c][itBp->id].alt.size()) >= c.maxGenoReadCount) continue; // Read spans breakpoint? @@ -582,7 +582,7 @@ namespace torali { } if (spanvalid) { // Fetch all relevant SVs - typename TSpanPoint::iterator itSpan = std::lower_bound(spanPoint.begin(), spanPoint.end(), SpanPoint(st), SortBp()); + typename TSpanPoint::iterator itSpan = std::lower_bound(spanPoint.begin(), spanPoint.end(), SpanPoint(st)); for(; ((itSpan != spanPoint.end()) && (st + spanlen >= itSpan->bppos)); ++itSpan) { // Account for reference bias if (++refAlignedSpanCount[file_c][itSpan->id] % 2) { @@ -617,7 +617,7 @@ namespace torali { } if (spanvalid) { // Fetch all relevant SVs - typename TSpanPoint::iterator itSpan = std::lower_bound(spanPoint.begin(), spanPoint.end(), SpanPoint(pbegin), SortBp()); + typename TSpanPoint::iterator itSpan = std::lower_bound(spanPoint.begin(), spanPoint.end(), SpanPoint(pbegin)); for(; ((itSpan != spanPoint.end()) && (pend >= itSpan->bppos)); ++itSpan) { if (svt == itSpan->svt) { // Make sure, mate is correct diff --git a/src/delly.h b/src/delly.h index c775e2d..f138953 100644 --- a/src/delly.h +++ b/src/delly.h @@ -148,7 +148,7 @@ namespace torali sam_close(samfile); // Re-number SVs - sort(svs.begin(), svs.end(), SortSVs()); + sort(svs.begin(), svs.end()); uint32_t cliqueCount = 0; for(typename TVariants::iterator svIt = svs.begin(); svIt != svs.end(); ++svIt, ++cliqueCount) svIt->id = cliqueCount; diff --git a/src/gaf.h b/src/gaf.h index a7266c3..80d4aef 100644 --- a/src/gaf.h +++ b/src/gaf.h @@ -35,15 +35,11 @@ namespace torali AlignRecord() : qstart(0), hap('*'), seed(0) {} AlignRecord(int32_t const q, std::size_t const s) : qstart(q), hap('*'), seed(s) {} - }; - template - struct SortAlignRecord : public std::binary_function { - inline bool operator()(TRecord const& s1, TRecord const& s2) const { - return ((s1.seed < s2.seed) || ((s1.seed == s2.seed) && (s1.qstart < s2.qstart))); + bool operator<(const AlignRecord& s2) const { + return ((seed < s2.seed) || ((seed == s2.seed) && (qstart < s2.qstart))); } }; - inline void parseGafCigar(std::string const& cigar, AlignRecord& ar) { diff --git a/src/gfa.h b/src/gfa.h index 7d6f75b..4cf138b 100644 --- a/src/gfa.h +++ b/src/gfa.h @@ -23,6 +23,10 @@ namespace torali Link() {} Link(bool const fv, bool const tv, uint32_t const fr, uint32_t tos) : fromfwd(fv), tofwd(tv), from(fr), to(tos) {} + + bool operator<(const Link& l2) const { + return ((from < l2.from) || ((from==l2.from) && (to < l2.to))); + } }; struct LinkCargo { @@ -36,19 +40,12 @@ namespace torali LinkCargo() {} LinkCargo(Link const lk) : fromfwd(lk.fromfwd), tofwd(lk.tofwd), from(lk.from), to(lk.to), support(0), mapq(0) {} LinkCargo(bool const fv, bool const tv, uint32_t const fr, uint32_t tos) : fromfwd(fv), tofwd(tv), from(fr), to(tos), support(0) {} - }; - - template - struct SortLinks : public std::binary_function - { - inline bool operator()(TLink const& l1, TLink const& l2) { - return ((l1.from < l2.from) || ((l1.from==l2.from) && (l1.to < l2.to))); + bool operator<(const LinkCargo& l2) const { + return ((from < l2.from) || ((from==l2.from) && (to < l2.to))); } }; - - struct Graph { typedef std::map TSegmentIdMap; diff --git a/src/junction.h b/src/junction.h index 6731cd4..2425a2e 100644 --- a/src/junction.h +++ b/src/junction.h @@ -432,9 +432,7 @@ namespace torali } // Sort junctions - for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) { - std::sort(it->second.begin(), it->second.end(), SortJunction()); - } + for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) std::sort(it->second.begin(), it->second.end()); // Clean-up bam_hdr_destroy(hdr); @@ -570,7 +568,7 @@ namespace torali if (srBR[svt].empty()) continue; // Sort - std::sort(srBR[svt].begin(), srBR[svt].end(), SortSRBamRecord()); + std::sort(srBR[svt].begin(), srBR[svt].end()); // Cluster cluster(c, srBR[svt], svc, svt); diff --git a/src/merge.h b/src/merge.h index f2ddf11..eb419fb 100644 --- a/src/merge.h +++ b/src/merge.h @@ -62,15 +62,10 @@ struct IntervalScore { int32_t score; IntervalScore(uint32_t s, uint32_t e, int32_t c) : start(s), end(e), score(c) {} -}; -template -struct SortIScores : public std::binary_function -{ - inline bool operator()(TRecord const& s1, TRecord const& s2) const { - return ((s1.start < s2.start) || ((s1.start == s2.start) && (s1.end < s2.end))); + bool operator<(const IntervalScore& s2) const { + return ((start < s2.start) || ((start == s2.start) && (end < s2.end))); } - }; template @@ -434,7 +429,7 @@ void _outputSelectedIntervals(MergeConfig& c, TGenomeIntervals const& iSelected, int32_t score = rec[idx]->qual; // Is this a selected interval - typename TIntervalScores::const_iterator iter = std::lower_bound(iSelected[tid].begin(), iSelected[tid].end(), IntervalScore(svStart, svEnd, score), SortIScores()); + typename TIntervalScores::const_iterator iter = std::lower_bound(iSelected[tid].begin(), iSelected[tid].end(), IntervalScore(svStart, svEnd, score)); bool foundInterval = false; for(; (iter != iSelected[tid].end()) && (iter->start == svStart); ++iter) { if ((iter->start == svStart) && (iter->end == svEnd) && (iter->score == score)) { @@ -693,7 +688,7 @@ void _outputSelectedIntervals(MergeConfig& c, TGenomeIntervals const& iSelected, int32_t score = rec[idx]->qual; // Is this a selected interval - typename TIntervalScores::const_iterator iter = std::lower_bound(iSelected[tid].begin(), iSelected[tid].end(), IntervalScore(svStart, svEnd, score), SortIScores()); + typename TIntervalScores::const_iterator iter = std::lower_bound(iSelected[tid].begin(), iSelected[tid].end(), IntervalScore(svStart, svEnd, score)); bool foundInterval = false; for(; (iter != iSelected[tid].end()) && (iter->start == svStart); ++iter) { if ((iter->start == svStart) && (iter->end == svEnd) && (iter->score == score)) { @@ -884,14 +879,14 @@ mergeRun(MergeConfig& c, int32_t const svt) { TGenomeIntervals iScore; iScore.resize(numseq, TIntervalScores()); _fillIntervalMap(c, iScore, contigMap, svt); - for(uint32_t i = 0; i()); + for(uint32_t i = 0; i()); + for(uint32_t i = 0; isecond.begin(), it->second.end(), SortJunction()); - } + for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) std::sort(it->second.begin(), it->second.end()); // Close file dataIn.pop(); diff --git a/src/scan.h b/src/scan.h index e347f8c..fd49003 100644 --- a/src/scan.h +++ b/src/scan.h @@ -27,17 +27,12 @@ namespace torali ScanWindow() : select(false), start(0), end(0), cov(0), uniqcov(0) {} explicit ScanWindow(int32_t const s) : select(false), start(s), end(s+1), cov(0), uniqcov(0) {} - }; - template - struct SortScanWindow : public std::binary_function - { - inline bool operator()(TScanWindow const& sw1, TScanWindow const& sw2) { - return ((sw1.start inline int32_t _findScanWindow(TConfig const& c, uint32_t const reflen, std::vector const& binMap, int32_t const midPoint) { @@ -105,7 +100,7 @@ namespace torali } } // Sort scan windows - sort(scanCounts[refIndex].begin(), scanCounts[refIndex].end(), SortScanWindow()); + sort(scanCounts[refIndex].begin(), scanCounts[refIndex].end()); } } diff --git a/src/shortpe.h b/src/shortpe.h index 9d04f79..1626704 100644 --- a/src/shortpe.h +++ b/src/shortpe.h @@ -414,9 +414,7 @@ namespace torali } // Process all junctions for this BAM file - for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) { - std::sort(it->second.begin(), it->second.end(), SortJunction()); - } + for(typename TReadBp::iterator it = readBp.begin(); it != readBp.end(); ++it) std::sort(it->second.begin(), it->second.end()); // Collect split-read SVs #pragma omp critical @@ -440,7 +438,7 @@ namespace torali if (srBR[svt].empty()) continue; // Sort - std::sort(srBR[svt].begin(), srBR[svt].end(), SortSRBamRecord()); + std::sort(srBR[svt].begin(), srBR[svt].end()); // Cluster cluster(c, srBR[svt], srSVs, svt); @@ -460,7 +458,7 @@ namespace torali if (bamRecord[svt].empty()) continue; // Sort BAM records according to position - std::sort(bamRecord[svt].begin(), bamRecord[svt].end(), SortBamRecords()); + std::sort(bamRecord[svt].begin(), bamRecord[svt].end()); // Cluster cluster(c, bamRecord[svt], svs, varisize, svt); @@ -493,10 +491,10 @@ namespace torali mergeSort(std::vector& pe, std::vector& sr) { typedef typename std::vector TVariants; // Sort PE records for look-up - sort(pe.begin(), pe.end(), SortSVs()); + sort(pe.begin(), pe.end()); // Sort SR records for look-up - sort(sr.begin(), sr.end(), SortSVs()); + sort(sr.begin(), sr.end()); // Augment PE SVs and append missing SR SVs for(int32_t svt = 0; svt < 10; ++svt) { @@ -507,7 +505,7 @@ namespace torali // Precise duplicates int32_t searchWindow = 500; bool svExists = false; - typename TVariants::iterator itOther = std::lower_bound(pe.begin(), pe.end(), StructuralVariantRecord(sr[i].chr, std::max(0, sr[i].svStart - searchWindow), sr[i].svEnd), SortSVs()); + typename TVariants::iterator itOther = std::lower_bound(pe.begin(), pe.end(), StructuralVariantRecord(sr[i].chr, std::max(0, sr[i].svStart - searchWindow), sr[i].svEnd)); for(; ((itOther != pe.end()) && (std::abs(itOther->svStart - sr[i].svStart) < searchWindow)); ++itOther) { if ((itOther->svt != svt) || (itOther->precise)) continue; if ((sr[i].chr != itOther->chr) || (sr[i].chr2 != itOther->chr2)) continue; // Mismatching chr @@ -569,7 +567,7 @@ namespace torali } if (!preciseDuplicate) { pe.push_back(sr[i]); - sort(pe.begin(), pe.end(), SortSVs()); + sort(pe.begin(), pe.end()); } } } diff --git a/src/tags.h b/src/tags.h index 51b6750..c59ea2f 100644 --- a/src/tags.h +++ b/src/tags.h @@ -48,18 +48,15 @@ namespace torali { int32_t refpos; int32_t seqpos; uint16_t qual; - + Junction(bool const fw, bool const cl, int32_t const idx, int32_t const rst, int32_t const r, int32_t const s, uint16_t const qval) : forward(fw), scleft(cl), refidx(idx), rstart(rst), refpos(r), seqpos(s), qual(qval) {} - }; - - template - struct SortJunction : public std::binary_function - { - inline bool operator()(TJunction const& j1, TJunction const& j2) { - return ((j1.seqpos - struct SortSRBamRecord : public std::binary_function - { - inline bool operator()(TSRBamRecord const& sv1, TSRBamRecord const& sv2) { - return ((sv1.chr - struct SortSVs : public std::binary_function - { - inline bool operator()(TSV const& sv1, TSV const& sv2) { - return ((sv1.chr sv2.peSupport)) || ((sv1.chr==sv2.chr) && (sv1.svStart==sv2.svStart) && (sv1.chr2==sv2.chr2) && (sv1.svEnd==sv2.svEnd) && (sv1.peSupport == sv2.peSupport) && (sv1.srSupport > sv2.srSupport))); + bool operator<(const StructuralVariantRecord& sv2) const { + return ((chr sv2.peSupport)) || ((chr==sv2.chr) && (svStart==sv2.svStart) && (chr2==sv2.chr2) && (svEnd==sv2.svEnd) && (peSupport == sv2.peSupport) && (srSupport > sv2.srSupport))); } + }; - struct Breakpoint { int32_t svStartBeg; int32_t svStartEnd; diff --git a/src/tegua.h b/src/tegua.h index 2638a43..8d4e08c 100644 --- a/src/tegua.h +++ b/src/tegua.h @@ -115,7 +115,7 @@ namespace torali { assemble(c, validRegions, svc, srStore); // Sort SVs - sort(svc.begin(), svc.end(), SortSVs()); + sort(svc.begin(), svc.end()); // Remove duplicates StructuralVariantRecord lastSV; @@ -136,7 +136,7 @@ namespace torali { } // Sort - sort(svs.begin(), svs.end(), SortSVs()); + sort(svs.begin(), svs.end()); // Re-number SVs uint32_t cliqueCount = 0; @@ -165,7 +165,7 @@ namespace torali { for(uint32_t file_c = 0; file_c < c.files.size(); ++file_c) { jctMap[file_c].resize(svs.size(), JunctionCount()); spanMap[file_c].resize(svs.size(), SpanningCount()); - rcMap[file_c].resize(svs.size(), ReadCount()); + rcMap[file_c].resize(svs.size()); } // SV Genotyping diff --git a/src/util.h b/src/util.h index d3ab1db..945b7a7 100644 --- a/src/util.h +++ b/src/util.h @@ -55,19 +55,12 @@ namespace torali CNV() : chr(0), start(0), end(0), ciposlow(0), ciposhigh(0), ciendlow(0), ciendhigh(0), qval(0), cn(-1), mappable(0), sd(1) {} CNV(int32_t const c, int32_t const s, int32_t const e, int32_t const cil, int32_t const cih, int32_t const cel, int32_t ceh, double const estcn, double const mp) : chr(c), start(s), end(e), ciposlow(cil), ciposhigh(cih), ciendlow(cel), ciendhigh(ceh), qval(0), cn(estcn), mappable(mp), sd(1) {} - }; - template - struct SortCNVs : public std::binary_function - { - inline bool operator()(TCNV const& sv1, TCNV const& sv2) { - return ((sv1.chr