/** ** 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 AlignStatsXmlWriter.hh ** ** \brief Alignment data statistics into an Xml file. ** ** \author Roman Petrovski **/ #include #include #include #include "common/Exceptions.hh" #include "io/PtreeXml.hh" #include "statistics/AlignStatsXmlWriter.hh" namespace casava { namespace statistics { namespace cc=casava::common; AlignStatsXmlWriter::AlignStatsXmlWriter(const fs::path &statsFilePath) : statsFilePath_(statsFilePath), os_(statsFilePath.string().c_str()){ if (!os_) { BOOST_THROW_EXCEPTION(cc::IoException(errno, "ERROR: Unable to open file for writing: " + statsFilePath_.string())); } } void AlignStatsXmlWriter::addTile(const std::string &sampleName, const std::string &barcode, const unsigned int lane, const unsigned int read, const unsigned int tile, const Stats_Set& tileStats) { const std::string tileValuePrefix("Stats" ".Sample." + sampleName +".Barcode." + barcode +".Read." + boost::lexical_cast(read) +".Lane." + boost::lexical_cast(lane) +".Tile." + boost::lexical_cast(tile) +".."); tree_.add(tileValuePrefix + "Yield", tileStats.basesTotal()); tree_.add(tileValuePrefix + "YieldQ20", tileStats.q20BasesTotal()); tree_.add(tileValuePrefix + "YieldQ30", tileStats.q30BasesTotal()); tree_.add(tileValuePrefix + "QualityScoreSum", tileStats.qualityScoreSum()); tree_.add(tileValuePrefix + "ClusterCount", tileStats.clustersTotal()); tree_.add(tileValuePrefix + "UniquelyAlignedClusterCount", tileStats.uniqueAligns()); tree_.add(tileValuePrefix + "AlignScoreSum", tileStats.alignScoreSum()); tree_.add(tileValuePrefix + "UniquelyAlignedBasesOutsideIndels", tileStats.basesAligned()); tree_.add(tileValuePrefix + "AlignMismatches", tileStats.alignMismatches()); } void AlignStatsXmlWriter::close() { using namespace casava::io; os_ << tree_; if (!os_) { BOOST_THROW_EXCEPTION(cc::IoException(errno, "ERROR: failed to store alignment statistics: " + statsFilePath_.string())); } } } //namespace statistics } //namespace casava