00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGA_TOOLS_LANE_BATCH_CACHE_HPP_
00016 #define CGA_TOOLS_LANE_BATCH_CACHE_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/util/Streams.hpp"
00022
00023 #include <boost/filesystem/path.hpp>
00024 #include <boost/ptr_container/ptr_map.hpp>
00025
00026 #include <vector>
00027
00028 namespace cgatools { namespace util {
00029 class DelimitedFileMetadata;
00030 }}
00031
00032 namespace cgatools { namespace mapping {
00033
00034 class BaseLaneBatchStreams
00035 {
00036 public:
00037 static std::string getBatchStreamKey(const std::string& slide, const std::string& lane, size_t batchNo);
00038 };
00039
00041 class OutLaneBatchStreams : public BaseLaneBatchStreams
00042 {
00043 public:
00044 typedef boost::ptr_map<std::string,util::CompressedOutputStream> OutputLaneBatches;
00045
00046 OutLaneBatchStreams(const boost::filesystem::path& outputPrefix, const std::string & fileType)
00047 :outputPrefix_(outputPrefix), fileType_(fileType)
00048 {}
00049
00050 OutLaneBatchStreams(
00051 const boost::filesystem::path& outputPrefix,
00052 const std::string & fileType,
00053 const std::string & headerLine
00054 )
00055 :outputPrefix_(outputPrefix), fileType_(fileType), headerLine_(headerLine)
00056 {}
00057
00058 virtual ~OutLaneBatchStreams() {}
00059
00060 std::ostream& getBatchStream(const std::string& slide, const std::string& lane, size_t batchNo);
00061
00062 protected:
00063 virtual void writeMetadata(std::ostream &output,
00064 const std::string& slide, const std::string& lane, size_t batchNo) const;
00065
00066 virtual void addMetadata(util::DelimitedFileMetadata &meta) const {}
00067
00068 boost::filesystem::path outputPrefix_;
00069 const std::string fileType_;
00070 const std::string headerLine_;
00071 OutputLaneBatches outputLanes_;
00072 };
00073
00074 class InLaneBatchStreams : public BaseLaneBatchStreams
00075 {
00076 public:
00077 typedef std::vector<boost::filesystem::path> InputBatchFiles;
00078 typedef boost::ptr_map<std::string,InputBatchFiles> InputLaneBatches;
00079
00080 InLaneBatchStreams(const boost::filesystem::path& inputRoot)
00081 :inputRoot_(inputRoot)
00082 {}
00083
00085 void collectFiles();
00086
00087 const InputBatchFiles& getBatchFiles(
00088 const std::string& slide, const std::string& lane, size_t batchNo) const;
00089
00090 protected:
00091
00092 boost::filesystem::path inputRoot_;
00093 InputLaneBatches inputBatches_;
00094 InputBatchFiles emptyBatch_;
00095 };
00096
00097 } }
00098
00099 #endif // CGA_TOOLS_LANE_BATCH_CACHE_HPP_