// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright 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). // // /// \file /// \author Chris Saunders /// #include "blt_util/log.hh" #include "blt_util/math_util.hh" #include "blt_util/qscore.hh" #include "blt_util/qscore_cache.hh" #include #include qphred_cache:: qphred_cache() { for(int i(0);i<=MAX_QSCORE;++i){ q2p[i] = phred_to_error_prob(static_cast(i)); } for(int i(0);i<=MAX_QSCORE;++i){ q2lncompe[i] = log1p_switch(-q2p[i]); } static const double q2lnp(-std::log(10.)/10.); for(int i(0);i<=MAX_QSCORE;++i){ q2lne[i] = static_cast(i)*q2lnp; } for(int i(0);i<=MAX_QSCORE;++i){ for(int j(0);j<=MAX_MAP;++j){ mappedq[j][i] = error_prob_to_qphred(phred_to_mapped_error_prob(i,j)); } } } void qphred_cache:: qscore_error(const int qscore) const { log_os << "ERROR:: invalid phred qscore: " << qscore << "\n"; exit(EXIT_FAILURE); } qlogodds_cache:: qlogodds_cache() : q2p(q2p_base-MIN_QSCORE) { for(int i(MIN_QSCORE);i<=MAX_QSCORE;++i){ q2p[i] = logodds_to_error_prob(static_cast(i)); } } void qlogodds_cache:: qscore_error(const int qscore) const { log_os << "ERROR:: invalid logodds qscore: " << qscore << "\n"; exit(EXIT_FAILURE); }