83 lines
2.9 KiB
C++
83 lines
2.9 KiB
C++
#pragma once
|
||
|
||
#include <common/hts/bam_buf.h>
|
||
#include <robin-map/include/tsl/robin_map.h>
|
||
#include <sam/utils/read_ends.h>
|
||
|
||
#include <set>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
using std::set;
|
||
using std::string;
|
||
using std::vector;
|
||
|
||
/* 存放未匹配readend相同位点的所有readend */
|
||
struct UnpairedREInfo {
|
||
int64_t taskSeq;
|
||
ReadEnds unpairedRE;
|
||
};
|
||
|
||
/* 对于一个pair数据,一个完整的计算点,包含read1的比对位置和read2的比对位置 */
|
||
struct CalcKey {
|
||
int64_t read1Pos;
|
||
int64_t read2Pos;
|
||
bool operator<(const CalcKey &o) const {
|
||
int comp = (int)(read1Pos - o.read1Pos);
|
||
if (comp == 0)
|
||
comp = (int)(read2Pos - o.read2Pos);
|
||
return comp < 0;
|
||
}
|
||
};
|
||
|
||
/* 当遗留数据在当前任务找到了pair read后,进行冗余计算时候存放结果的数据结构 */
|
||
struct TaskSeqDupInfo {
|
||
set<int64_t> dupIdx;
|
||
set<int64_t> opticalDupIdx;
|
||
set<int64_t> notDupIdx;
|
||
};
|
||
|
||
/* 保存有未匹配pair位点的信息,包括read end数组和有几个未匹配的read end */
|
||
struct UnpairedPosInfo {
|
||
int unpairedNum = 0;
|
||
int64_t taskSeq;
|
||
vector<ReadEnds> pairArr;
|
||
set<string> readNameSet;
|
||
};
|
||
// typedef unordered_map<string, UnpairedREInfo> UnpairedNameMap;
|
||
// typedef unordered_map<int64_t, UnpairedPosInfo> UnpairedPositionMap;
|
||
|
||
typedef tsl::robin_map<string, UnpairedREInfo> UnpairedNameMap; // 以read name为索引,保存未匹配的pair read
|
||
typedef tsl::robin_map<int64_t, UnpairedPosInfo> UnpairedPositionMap; // 以位点为索引,保存该位点包含的对应的所有read和该位点包含的剩余未匹配的read的数量
|
||
|
||
/* 单线程处理冗余参数结构体 */
|
||
struct SerailMarkDupArg {
|
||
int64_t taskSeq; // 任务序号
|
||
int64_t bamStartIdx; // 当前vBam数组中第一个bam记录在整体bam中所处的位置
|
||
vector<BamWrap *> bams; // 存放待处理的bam read
|
||
vector<ReadEnds> pairs; // 成对的reads
|
||
vector<ReadEnds> frags; // 暂未找到配对的reads
|
||
set<int64_t> pairDupIdx; // pair的冗余read的索引
|
||
set<int64_t> pairOpticalDupIdx; // optical冗余read的索引
|
||
set<int64_t> fragDupIdx; // frag的冗余read的索引
|
||
UnpairedNameMap unpairedDic; // 用来寻找pair end
|
||
UnpairedPositionMap unpairedPosArr; // 存放未匹配的ReadEnd对应位点的所有ReadEnd,为了避免重复存储
|
||
};
|
||
|
||
/* 全局保留的数据,因为有些paired数据比对到了不同的染色体,相距甚远 */
|
||
struct GlobalDataArg {
|
||
UnpairedNameMap unpairedDic; // 用来寻找pair end
|
||
UnpairedPositionMap unpairedPosArr;
|
||
|
||
// 每个task对应一个vector
|
||
vector<vector<int64_t>> dupIdxArr;
|
||
vector<vector<int64_t>> opticalDupIdxArr;
|
||
|
||
// 用来存放后续计算的数据
|
||
vector<set<int64_t>> latterDupIdxArr;
|
||
vector<set<int64_t>> latterOpticalDupIdxArr;
|
||
vector<set<int64_t>> latterNotDupIdxArr;
|
||
};
|
||
|
||
// 串行运行mark duplicate
|
||
void serialMarkDups(); |