/** ** Copyright (c) 2007-2009 Illumina, Inc. ** ** This software is covered by the "Illumina Genome Analyzer Software ** License Agreement" and the "Illumina Source Code License Agreement", ** and certain third party copyright/licenses, and any user of this ** source file is bound by the terms therein (see accompanying files ** Illumina_Genome_Analyzer_Software_License_Agreement.pdf and ** Illumina_Source_Code_License_Agreement.pdf and third party ** copyright/license notices). ** ** This file is part of the Consensus Assessment of Sequence And VAriation ** (CASAVA) software package. ** ** \file CompositeBclReader.hh ** ** \brief Reads BCL files and other associated files (filter, position). ** ** \author Come Raczy **/ #ifndef CASAVA_DEMULTIPLEX_COMPOSITE_BCL_READER_HH #define CASAVA_DEMULTIPLEX_COMPOSITE_BCL_READER_HH #include #include #include #include "alignment/BclReader.hh" namespace casava { namespace demultiplex { namespace fs = boost::filesystem; namespace ca = casava::alignment; class CompositeBclReader { public: struct RecordType { RecordType() : filter_(0){} RecordType(ca::BclReader::Cluster cluster, unsigned int filter, ca::PositionsReader::FloatPosition position) : cluster_(cluster), filter_(filter), position_(position){} RecordType(ca::BclReader::Cluster cluster, unsigned int filter, unsigned int control, ca::PositionsReader::FloatPosition position) : cluster_(cluster), filter_(filter), control_(control), position_(position){} ca::BclReader::Cluster cluster_; unsigned int filter_; unsigned int control_; ca::PositionsReader::FloatPosition position_; }; CompositeBclReader(const std::vector bclPaths, const fs::path filtersPath, const fs::path positionsPath, const bool ignoreMissingBcl, const bool ctrlIncluded) : bclReader_(bclPaths,ignoreMissingBcl) , filtersReader_(filtersPath, ctrlIncluded) , positionsReader_(ca::PositionsReader::create(positionsPath, bclReader_.getClusterCount())) {} CompositeBclReader(const std::vector bclPaths, const fs::path filtersPath, const fs::path controlsPath, const fs::path positionsPath, const bool ignoreMissingBcl, const bool ctrlIncluded) : bclReader_(bclPaths,ignoreMissingBcl) , filtersReader_(filtersPath, ctrlIncluded) , controlsReader_(controlsPath, true) , positionsReader_(ca::PositionsReader::create(positionsPath, bclReader_.getClusterCount())) { if (controlsReader_.getClusterCount() != filtersReader_.getClusterCount()) { BOOST_THROW_EXCEPTION( cc::IoException(EINVAL, (boost::format("Mismatched number of clusters in %s: expected %d: got %d") % controlsPath % filtersReader_.getClusterCount() % controlsReader_.getClusterCount()).str())); } } unsigned int getClusterCount() const {return bclReader_.getClusterCount();} RecordType &get(RecordType &whereTo) { bclReader_.get(whereTo.cluster_); filtersReader_.get(whereTo.filter_); // get control bits from controls reader only if it has been constructed with // a file path if (controlsReader_.getClusterCount()) { controlsReader_.get(whereTo.control_); } positionsReader_->get(whereTo.position_); return whereTo; } std::string getDescription() const { return bclReader_.getDescription(); } private: ca::BclReader bclReader_; ca::FiltersReader filtersReader_; ca::FiltersReader controlsReader_; boost::shared_ptr positionsReader_; CompositeBclReader(); CompositeBclReader(const CompositeBclReader &); CompositeBclReader &operator=(const CompositeBclReader &); }; } // namespace demultiplex } // namespace casava #endif // #ifndef CASAVA_DEMULTIPLEX_COMPOSITE_BCL_READER_HH