1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
//
// RapMap - Rapid and accurate mapping of short reads to transcriptomes using
// quasi-mapping.
// Copyright (C) 2015, 2016 Rob Patro, Avi Srivastava, Hirak Sarkar
//
// This file is part of RapMap.
//
// RapMap is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// RapMap is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with RapMap. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef __HIT_MANAGER_HPP__
#define __HIT_MANAGER_HPP__
#include "RapMapUtils.hpp"
#include "RapMapSAIndex.hpp"
#include "chobo/small_vector.hpp"
#include <tuple>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
namespace rapmap {
namespace hit_manager {
using HitInfo = rapmap::utils::HitInfo;
using ProcessedHit = rapmap::utils::ProcessedHit;
using MateStatus = rapmap::utils::MateStatus;
using PositionListHelper = rapmap::utils::PositionListHelper;
using QuasiAlignment = rapmap::utils::QuasiAlignment;
using TxpQueryPos = rapmap::utils::TxpQueryPos;
using SATxpQueryPos = rapmap::utils::SATxpQueryPos;
template <typename T>
using SAIntervalHit = rapmap::utils::SAIntervalHit<T>;
using ProcessedSAHit = rapmap::utils::ProcessedSAHit;
using SAHitMap = std::map<int, ProcessedSAHit>;
template <typename SAIntervalHitT>
using SAIntervalVector = std::vector<SAIntervalHitT>;
class SAProcessedHitVec {
public:
std::vector<ProcessedSAHit> hits;
std::vector<uint32_t> txps;
};
template <typename SAIntervalHitT>
class HitCollectorInfo {
public:
void clear() {
readLen = 0;
maxDist = 0;
fwdSAInts.clear();
rcSAInts.clear();
}
size_t readLen{0};
int32_t maxDist{0};
SAIntervalVector<SAIntervalHitT> fwdSAInts;
SAIntervalVector<SAIntervalHitT> rcSAInts;
};
/*
using SAProcessedHitVec = std::tuple<std::vector<ProcessedSAHit>, std::vector<uint32_t>>;
*/
// Return hits from processedHits where position constraints
// match maxDist
bool collectHitsSimple(std::vector<ProcessedHit>& processedHits,
uint32_t readLen,
uint32_t maxDist,
std::vector<QuasiAlignment>& hits,
MateStatus mateStatus);
// Return hits from processedHits where position constraints
// match maxDist
bool collectHitsSimpleSA(SAHitMap& processedHits,
uint32_t readLen,
int32_t maxDist,
std::vector<QuasiAlignment>& hits,
MateStatus mateStatus,
rapmap::utils::MappingConfig& mc);
// Return hits from processedHits where position constraints
// match maxDist
bool collectHitsSimpleSA2(std::vector<ProcessedSAHit>& processedHits,
uint32_t readLen,
uint32_t maxDist,
std::vector<QuasiAlignment>& hits,
MateStatus mateStatus);
// Intersects the hit h2 with outHits.
// This will modify outHits so that the tqvec field of the
// entries in outHits that are labeled by the transcripts in
// which h2 appears will have an iterator to the beginning of
// the position list for h2.
//void intersectWithOutput(HitInfo& h2, RapMapIndex& rmi,
// std::vector<ProcessedHit>& outHits);
template <typename RapMapIndexT>
void intersectSAIntervalWithOutput(SAIntervalHit<typename RapMapIndexT::IndexType>& h,
RapMapIndexT& rmi,
uint32_t intervalCounter,
int32_t maxSlack,
SAHitMap& outHits);
template <typename RapMapIndexT>
void intersectSAIntervalWithOutput2(SAIntervalHit<typename RapMapIndexT::IndexType>& h,
RapMapIndexT& rmi,
SAProcessedHitVec& outStructs);
template <typename RapMapIndexT>
SAHitMap intersectSAHits(
SAIntervalVector<SAIntervalHit<typename RapMapIndexT::IndexType>>& inHits,
RapMapIndexT& rmi,
size_t readLen,
bool strictFilter=false);
template <typename RapMapIndexT>
void hitsToMappingsSimple(RapMapIndexT& rmi,
rapmap::utils::MappingConfig& mc,
rapmap::utils::MateStatus mateStatus,
HitCollectorInfo<SAIntervalHit<typename RapMapIndexT::IndexType>>& hcinfo,
std::vector<rapmap::utils::QuasiAlignment>& hits);
}
}
#endif // __HIT_MANAGER_HPP__
|