| 1 |
#ifndef SNOWMAN_SEQLIB_COVERAGE_H__ |
| 2 |
#define SNOWMAN_SEQLIB_COVERAGE_H__ |
| 3 |
|
| 4 |
#include <memory> |
| 5 |
#include <unordered_map> |
| 6 |
#include <vector> |
| 7 |
#include <cstdint> |
| 8 |
#include <vector> |
| 9 |
#include <cassert> |
| 10 |
#include <iostream> |
| 11 |
#include <memory> |
| 12 |
|
| 13 |
#include "htslib/hts.h" |
| 14 |
#include "htslib/sam.h" |
| 15 |
#include "htslib/bgzf.h" |
| 16 |
#include "htslib/kstring.h" |
| 17 |
|
| 18 |
#include "SeqLib/BamRecord.h" |
| 19 |
#include "SeqLib/GenomicRegion.h" |
| 20 |
#include "SeqLib/GenomicRegionCollection.h" |
| 21 |
|
| 22 |
typedef std::shared_ptr<std::vector<uint16_t>> uint16_sp; |
| 23 |
typedef std::unordered_map<int,int> CovMap; |
| 24 |
|
| 25 |
|
| 26 |
namespace SeqLib { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
class STCoverage { |
| 35 |
|
| 36 |
private: |
| 37 |
|
| 38 |
GRC m_grc; |
| 39 |
GenomicRegion m_gr; |
| 40 |
|
| 41 |
|
| 42 |
std::vector<CovMap> m_map; |
| 43 |
|
| 44 |
uint16_sp v; |
| 45 |
|
| 46 |
|
| 47 |
public: |
| 48 |
|
| 49 |
|
| 50 |
void clear(); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
void settleCoverage(); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
void addRead(const BamRecord &r, int buff, bool full_length); |
| 61 |
|
| 62 |
|
| 63 |
STCoverage(const GenomicRegion& gr); |
| 64 |
|
| 65 |
uint16_t maxCov() const; |
| 66 |
|
| 67 |
|
| 68 |
STCoverage() {} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
void ToBedgraph(std::ofstream * o, const bam_hdr_t * h) const; |
| 78 |
|
| 79 |
|
| 80 |
friend std::ostream& operator<<(std::ostream &out, const STCoverage &c); |
| 81 |
|
| 82 |
|
| 83 |
int getCoverageAtPosition(int chr, int pos) const; |
| 84 |
|
| 85 |
}; |
| 86 |
|
| 87 |
} |
| 88 |
#endif |