00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGA_TOOLS_EVIDENCECACHE_HPP_
00016 #define CGA_TOOLS_EVIDENCECACHE_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/util/RangeSet.hpp"
00022 #include "cgatools/cgdata/EvidenceReader.hpp"
00023 #include "cgatools/mapping/LaneBatchCache.hpp"
00024
00025 namespace cgatools { namespace cgdata {
00026 class GenomeMetadata;
00027 }}
00028
00029 namespace cgatools { namespace reference {
00030 class CrrFile;
00031 }}
00032
00033 namespace cgatools { namespace util {
00034 class DelimitedFile;
00035 }}
00036
00037
00038 namespace cgatools { namespace mapping {
00039
00040 class CacheOutStreams : public OutLaneBatchStreams
00041 {
00042 public:
00043 CacheOutStreams(const boost::filesystem::path& outputPrefix)
00044 :OutLaneBatchStreams(outputPrefix, "EVIDENCE_CACHE")
00045 {}
00046
00047 protected:
00048 virtual void writeMetadata(std::ostream &output,
00049 const std::string& slide, const std::string& lane, size_t batchNo) const;
00050 };
00051
00052
00053 class LibraryMetadataContainer;
00054
00055 class EvidenceCacheBuilder
00056 {
00057 public:
00058 EvidenceCacheBuilder(const cgdata::GenomeMetadata& genomeMetadata,const reference::CrrFile& reference);
00059
00060 void processChrData(uint16_t chr, const boost::filesystem::path& outputPrefix,
00061 const util::FastRangeSet::RangeSet &exportRanges);
00062
00063 void exportRanges(const boost::filesystem::path& outputPrefix, const util::FastRangeSet& ranges);
00064
00065 protected:
00066 boost::shared_ptr<LibraryMetadataContainer> libraries_;
00067
00068 const cgdata::GenomeMetadata& genomeMetadata_;
00069 const reference::CrrFile& reference_;
00070 };
00071
00072 class EvidenceCacheDnbRecord : public cgdata::EvidenceReader::DnbRecord
00073 {
00074 public:
00075 double alleleConcordance_;
00076 };
00077
00078 typedef std::multimap<uint64_t,EvidenceCacheDnbRecord> BatchRecords;
00079
00080 class EvidenceCacheReader
00081 {
00082 public:
00083 typedef std::vector<boost::filesystem::path> InputBatchFiles;
00084 typedef boost::ptr_map<uint64_t,InputBatchFiles> InputLaneBatches;
00085
00086 EvidenceCacheReader(const boost::filesystem::path& rootDir)
00087 : inputBatches_(rootDir)
00088 {
00089 inputBatches_.collectFiles();
00090 }
00091
00092 void readBatchRecords(const std::string& slide, const std::string& lane, size_t batchNo,
00093 BatchRecords& result, const reference::CrrFile& crr);
00094
00095 protected:
00096
00097 static void initCacheRecordParser(
00098 util::DelimitedFile& delimitedFile, EvidenceCacheDnbRecord& record, const reference::CrrFile& crr);
00099
00100 InLaneBatchStreams inputBatches_;
00101 };
00102
00103
00104 } }
00105
00106 #endif // CGA_TOOLS_EVIDENCECACHE_HPP_