text:
// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2015, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Knut Reinert or the FU Berlin nor the names of
//       its contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Hannes Hauswedell <hannes.hauswedell@fu-berlin.de>
// ==========================================================================
// bitScore and e-Value calculation
// ==========================================================================
// contains empiric values from blast_stat.c as well as small portions of
// code from blast_stat.c written by Tom Madden and released into the public
// domain by the NCBI.
// ==========================================================================

#ifndef __BLAST_STATISTICS_H__
#define __BLAST_STATISTICS_H__

#ifndef NCBI_INT2_MAX
#define NCBI_INT2_MAX    32767
#endif

namespace seqan
{

// ============================================================================
// Classes
// ============================================================================

// ----------------------------------------------------------------------------
// Class KarlinAltschulValues
// ----------------------------------------------------------------------------

//NOTE(h-2): removed to clean up interface
/*
 * @class KarlinAltschulValues
 * @headerfile <seqan/blast.h>
 * @brief An object that holds Statistical parameters
 * @signature struct KarlinAltschulValues<TScore, TSpec> { ... };
 *
 * This is an adapter around the SeqAn scoring scheme, for use with BLAST and
 * other e-value statistics. If you only use high-level Blast IO, you do not
 * have to worry about this, except that you have to know that not every scoring
 * scheme supported by SeqAn and not every combination of gap scores is supported.
 * [@link BlastIOContext#setBlastScoringScheme @endlink/@link BlastIOContext#setScoringScheme @endlink will fail if
 * a non-supported scoringScheme is passed]
 *
 * @section Details
 *
 * This data structure holds Karlin-Altschul statistical scoring
 * parameters (λ, Κ, H, α, β, θ) for the given
 * scoring scheme. These values are empirically derived. The ones in
 * SeqAn are imported from the NCBI blast source code (blast-2.2.26).
 * For an explanation of the role of λ and Κ please see these
 * slides:
 * https://www.cs.umd.edu/class/fall2011/cmsc858s/Local_Alignment_Statistics.pdf.
 *
 * Warning, not every scoring scheme supported by SeqAn and not every
 * combination of gap scores is supported.
 */

/// GENERIC
template <typename TScore, typename TSpec = void>
struct KarlinAltschulValues
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 0;
    static constexpr TSize nParamSets = 0;
    static double const VALUE[1][8]; // size 8 to silence warnings
};

template <typename TScore, typename TSpec>
double const KarlinAltschulValues<TScore, TSpec>::VALUE[1][8] =
{
    {0,0,0,0,0,0,0,0}
};

/// BLOSUM30
// not implemented in BLAST

/// BLOSUM45
template <typename TSpec>
struct KarlinAltschulValues<Blosum45, TSpec>
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 8;
    static constexpr TSize nParamSets = 16;
    static double const VALUE[nParamSets][nParams];
};

template <typename TSpec>
double const KarlinAltschulValues<Blosum45, TSpec>::VALUE
  [KarlinAltschulValues<Blosum45, TSpec>::nParamSets]
  [KarlinAltschulValues<Blosum45, TSpec>::nParams] =
{
    {(double) NCBI_INT2_MAX, (double) NCBI_INT2_MAX,
            (double) NCBI_INT2_MAX, 0.2291, 0.0924, 0.2514, 0.9113, -5.7},
    {13, 3, (double) NCBI_INT2_MAX, 0.207,  0.049,  0.14,   1.5, -22},
    {12, 3, (double) NCBI_INT2_MAX, 0.199,  0.039,  0.11,   1.8, -34},
    {11, 3, (double) NCBI_INT2_MAX, 0.190,  0.031,  0.095,  2.0, -38},
    {10, 3, (double) NCBI_INT2_MAX, 0.179,  0.023,  0.075,  2.4, -51},
    {16, 2, (double) NCBI_INT2_MAX, 0.210,  0.051,  0.14,   1.5, -24},
    {15, 2, (double) NCBI_INT2_MAX, 0.203,  0.041,  0.12,   1.7, -31},
    {14, 2, (double) NCBI_INT2_MAX, 0.195,  0.032,  0.10,   1.9, -36},
    {13, 2, (double) NCBI_INT2_MAX, 0.185,  0.024,  0.084,  2.2, -45},
    {12, 2, (double) NCBI_INT2_MAX, 0.171,  0.016,  0.061,  2.8, -65},
    {19, 1, (double) NCBI_INT2_MAX, 0.205,  0.040,  0.11,   1.9, -43},
    {18, 1, (double) NCBI_INT2_MAX, 0.198,  0.032,  0.10,   2.0, -43},
    {17, 1, (double) NCBI_INT2_MAX, 0.189,  0.024,  0.079,  2.4, -57},
    {16, 1, (double) NCBI_INT2_MAX, 0.176,  0.016,  0.063,  2.8, -67},
};

/// BLOSUM50
// not implemented in seqan

/// BLOSUM62
template <typename TSpec>
struct KarlinAltschulValues<Blosum62, TSpec>
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 8;
    static constexpr TSize nParamSets = 12;
    static double const VALUE[nParamSets][nParams];
};

template <typename TSpec>
double const KarlinAltschulValues<Blosum62, TSpec>::VALUE
  [KarlinAltschulValues<Blosum62, TSpec>::nParamSets]
  [KarlinAltschulValues<Blosum62, TSpec>::nParams] =
{
        {(double) NCBI_INT2_MAX, (double) NCBI_INT2_MAX,
                (double) NCBI_INT2_MAX, 0.3176, 0.134, 0.4012, 0.7916, -3.2},
        {11, 2, (double) NCBI_INT2_MAX, 0.297,  0.082, 0.27,   1.1,    -10} ,
        {10, 2, (double) NCBI_INT2_MAX, 0.291,  0.075, 0.23,   1.3,    -15} ,
        { 9, 2, (double) NCBI_INT2_MAX, 0.279,  0.058, 0.19,   1.5,    -19} ,
        { 8, 2, (double) NCBI_INT2_MAX, 0.264,  0.045, 0.15,   1.8,    -26} ,
        { 7, 2, (double) NCBI_INT2_MAX, 0.239,  0.027, 0.10,   2.5,    -46} ,
        { 6, 2, (double) NCBI_INT2_MAX, 0.201,  0.012, 0.061,  3.3,    -58} ,
        {13, 1, (double) NCBI_INT2_MAX, 0.292,  0.071, 0.23,   1.2,    -11} ,
        {12, 1, (double) NCBI_INT2_MAX, 0.283,  0.059, 0.19,   1.5,    -19} ,
        {11, 1, (double) NCBI_INT2_MAX, 0.267,  0.041, 0.14,   1.9,    -30} ,
        {10, 1, (double) NCBI_INT2_MAX, 0.243,  0.024, 0.10,   2.5,    -44} ,
        { 9, 1, (double) NCBI_INT2_MAX, 0.206,  0.010, 0.052,  4.0,    -87} ,
};
/// BLOSUM80
template <typename TSpec>
struct KarlinAltschulValues<Blosum80, TSpec>
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 8;
    static constexpr TSize nParamSets = 10;
    static double const VALUE[nParamSets][nParams];
};

template <typename TSpec>
double const KarlinAltschulValues<Blosum80, TSpec>::VALUE
 [KarlinAltschulValues<Blosum80, TSpec>::nParamSets]
 [KarlinAltschulValues<Blosum80, TSpec>::nParams] =
{
    {(double) NCBI_INT2_MAX, (double) NCBI_INT2_MAX,
            (double) NCBI_INT2_MAX, 0.3430,  0.177, 0.6568, 0.5222, -1.6},
    {25, 2, (double) NCBI_INT2_MAX, 0.342,   0.17,  0.66,   0.52,   -1.6},
    {13, 2, (double) NCBI_INT2_MAX, 0.336,   0.15,  0.57,   0.59,   -3},
    { 9, 2, (double) NCBI_INT2_MAX, 0.319,   0.11,  0.42,   0.76,   -6},
    { 8, 2, (double) NCBI_INT2_MAX, 0.308,   0.090, 0.35,   0.89,   -9},
    { 7, 2, (double) NCBI_INT2_MAX, 0.293,   0.070, 0.27,   1.1,   -14},
    { 6, 2, (double) NCBI_INT2_MAX, 0.268,   0.045, 0.19,   1.4,   -19},
    {11, 1, (double) NCBI_INT2_MAX, 0.314,   0.095, 0.35,   0.90,   -9},
    {10, 1, (double) NCBI_INT2_MAX, 0.299,   0.071, 0.27,   1.1,   -14},
    { 9, 1, (double) NCBI_INT2_MAX, 0.279,   0.048, 0.20,   1.4,   -19},
};

/// BLOSUM90
// not implemented in seqan

/// PAM30
// not implemented in seqan

/// PAM40
// not implemented in blast

/// PAM70
// not implemented in seqan

/// PAM120
// not implemented in blast

/// PAM200
// not implemented in blast

/// PAM250
template <typename TSpec>
struct KarlinAltschulValues<Pam250, TSpec>
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 8;
    static constexpr TSize nParamSets = 16;
    static double const VALUE[nParamSets][nParams];
};

template <typename TSpec>
double const KarlinAltschulValues<Pam250, TSpec>::VALUE
  [KarlinAltschulValues<Pam250, TSpec>::nParamSets]
  [KarlinAltschulValues<Pam250, TSpec>::nParams] =
{
    {(double) NCBI_INT2_MAX, (double) NCBI_INT2_MAX,
            (double) NCBI_INT2_MAX, 0.2252, 0.0868, 0.2223, 0.98,  -5.0},
    {15, 3, (double) NCBI_INT2_MAX, 0.205,  0.049,  0.13,   1.6,  -23},
    {14, 3, (double) NCBI_INT2_MAX, 0.200,  0.043,  0.12,   1.7,  -26},
    {13, 3, (double) NCBI_INT2_MAX, 0.194,  0.036,  0.10,   1.9,  -31},
    {12, 3, (double) NCBI_INT2_MAX, 0.186,  0.029,  0.085,  2.2,  -41},
    {11, 3, (double) NCBI_INT2_MAX, 0.174,  0.020,  0.070,  2.5,  -48},
    {17, 2, (double) NCBI_INT2_MAX, 0.204,  0.047,  0.12,   1.7,  -28},
    {16, 2, (double) NCBI_INT2_MAX, 0.198,  0.038,  0.11,   1.8,  -29},
    {15, 2, (double) NCBI_INT2_MAX, 0.191,  0.031,  0.087,  2.2,  -44},
    {14, 2, (double) NCBI_INT2_MAX, 0.182,  0.024,  0.073,  2.5,  -53},
    {13, 2, (double) NCBI_INT2_MAX, 0.171,  0.017,  0.059,  2.9,  -64},
    {21, 1, (double) NCBI_INT2_MAX, 0.205,  0.045,  0.11,   1.8,  -34},
    {20, 1, (double) NCBI_INT2_MAX, 0.199,  0.037,  0.10,   1.9,  -35},
    {19, 1, (double) NCBI_INT2_MAX, 0.192,  0.029,  0.083,  2.3,  -52},
    {18, 1, (double) NCBI_INT2_MAX, 0.183,  0.021,  0.070,  2.6,  -60},
    {17, 1, (double) NCBI_INT2_MAX, 0.171,  0.014,  0.052,  3.3,  -86},
};

/// VTML200
// not implemented in blast

/// NUCLEOTIDES
template <typename TSpec>
struct KarlinAltschulValues<Score<int, Simple>, TSpec>
{
    typedef uint8_t TSize;

    /* statics */
    static constexpr TSize nParams = 11;
    static constexpr TSize nParamSets = 60;
    /*  0 = matchScore
        1 = mismatch cost
        2 = Gap opening cost,
        3 = Gap extension cost,
        4 = Lambda,
        5 = K,
        6 = H,
        7 = Alpha,
        8 = Beta,
        9 = Theta
        10 = only applicable to even score, uneven need to be rounded down */
    static double const VALUE[nParamSets][nParams];
};

template <typename TSpec>
double const KarlinAltschulValues<Score<int, Simple>, TSpec>::VALUE
 [KarlinAltschulValues<Score<int, Simple>, TSpec>::nParamSets]
 [KarlinAltschulValues<Score<int, Simple>, TSpec>::nParams] =
{
    { 1, 5, 0, 0, 1.39, 0.747, 1.38, 1.00,  0, 100, 0 } ,
    { 1, 5, 3, 3, 1.39, 0.747, 1.38, 1.00,  0, 100, 0 } ,

    { 1, 4, 0, 0, 1.383, 0.738, 1.36, 1.02,  0, 100, 0 } ,
    { 1, 4, 1, 2,  1.36,  0.67,  1.2,  1.1,  0,  98, 0 } ,
    { 1, 4, 0, 2,  1.26,  0.43, 0.90,  1.4, -1,  91, 0 } ,
    { 1, 4, 2, 1,  1.35,  0.61,  1.1,  1.2, -1,  98, 0 } ,
    { 1, 4, 1, 1,  1.22,  0.35, 0.72,  1.7, -3,  88, 0 } ,

    { 2, 7, 0, 0,  0.69, 0.73, 1.34, 0.515,  0, 100, 1 } ,
    { 2, 7, 2, 4,  0.68, 0.67,  1.2,  0.55,  0,  99, 1 } ,
    { 2, 7, 0, 4,  0.63, 0.43, 0.90,   0.7, -1,  91, 1 } ,
    { 2, 7, 4, 2, 0.675, 0.62,  1.1,   0.6, -1,  98, 1 } ,
    { 2, 7, 2, 2,  0.61, 0.35, 0.72,   1.7, -3,  88, 1 } ,

    { 1, 3, 0, 0, 1.374, 0.711, 1.31, 1.05,  0, 100, 0 } ,
    { 1, 3, 2, 2,  1.37,  0.70,  1.2,  1.1,  0,  99, 0 } ,
    { 1, 3, 1, 2,  1.35,  0.64,  1.1,  1.2, -1,  98, 0 } ,
    { 1, 3, 0, 2,  1.25,  0.42, 0.83,  1.5, -2,  91, 0 } ,
    { 1, 3, 2, 1,  1.34,  0.60,  1.1,  1.2, -1,  97, 0 } ,
    { 1, 3, 1, 1,  1.21,  0.34, 0.71,  1.7, -2,  88, 0 } ,

    { 2, 5, 0, 0, 0.675, 0.65,  1.1,  0.6, -1, 99, 1 },
    { 2, 5, 2, 4,  0.67, 0.59,  1.1,  0.6, -1, 98, 1 },
    { 2, 5, 0, 4,  0.62, 0.39, 0.78,  0.8, -2, 91, 1 },
    { 2, 5, 4, 2,  0.67, 0.61,  1.0, 0.65, -2, 98, 1 },
    { 2, 5, 2, 2,  0.56, 0.32, 0.59, 0.95, -4, 82, 1 },

    { 1, 2, 0, 0, 1.28, 0.46, 0.85, 1.5, -2, 96, 0 },
    { 1, 2, 2, 2, 1.33, 0.62,  1.1, 1.2,  0, 99, 0 },
    { 1, 2, 1, 2, 1.30, 0.52, 0.93, 1.4, -2, 97, 0 },
    { 1, 2, 0, 2, 1.19, 0.34, 0.66, 1.8, -3, 89, 0 },
    { 1, 2, 3, 1, 1.32, 0.57,  1.0, 1.3, -1, 99, 0 },
    { 1, 2, 2, 1, 1.29, 0.49, 0.92, 1.4, -1, 96, 0 },
    { 1, 2, 1, 1, 1.14, 0.26, 0.52, 2.2, -5, 85, 0 },

    { 2, 3, 0, 0,  0.55, 0.21, 0.46,  1.2, -5, 87, 1 },
    { 2, 3, 4, 4,  0.63, 0.42, 0.84, 0.75, -2, 99, 1 },
    { 2, 3, 2, 4, 0.615, 0.37, 0.72, 0.85, -3, 97, 1 },
    { 2, 3, 0, 4,  0.55, 0.21, 0.46,  1.2, -5, 87, 1 },
    { 2, 3, 3, 3, 0.615, 0.37, 0.68,  0.9, -3, 97, 1 },
    { 2, 3, 6, 2,  0.63, 0.42, 0.84, 0.75, -2, 99, 1 },
    { 2, 3, 5, 2, 0.625, 0.41, 0.78,  0.8, -2, 99, 1 },
    { 2, 3, 4, 2,  0.61, 0.35, 0.68,  0.9, -3, 96, 1 },
    { 2, 3, 2, 2, 0.515, 0.14, 0.33, 1.55, -9, 81, 1 },

    { 3, 4, 6, 3, 0.389, 0.25, 0.56, 0.7, -5, 95, 0},
    { 3, 4, 5, 3, 0.375, 0.21, 0.47, 0.8, -6, 92, 0},
    { 3, 4, 4, 3, 0.351, 0.14, 0.35, 1.0, -9, 86, 0},
    { 3, 4, 6, 2, 0.362, 0.16, 0.45, 0.8, -4, 88, 0},
    { 3, 4, 5, 2, 0.330, 0.092, 0.28, 1.2, -13, 81, 0},
    { 3, 4, 4, 2, 0.281, 0.046, 0.16, 1.8, -23, 69, 0},

    { 4, 5, 0, 0, 0.22, 0.061, 0.22, 1.0, -15, 74, 0 },
    { 4, 5, 6, 5, 0.28,  0.21, 0.47, 0.6 , -7, 93, 0 },
    { 4, 5, 5, 5, 0.27,  0.17, 0.39, 0.7,  -9, 90, 0 },
    { 4, 5, 4, 5, 0.25,  0.10, 0.31, 0.8, -10, 83, 0 },
    { 4, 5, 3, 5, 0.23, 0.065, 0.25, 0.9, -11, 76, 0 },

    { 1, 1, 3,  2, 1.09,  0.31, 0.55, 2.0,  -2, 99, 0 },
    { 1, 1, 2,  2, 1.07,  0.27, 0.49, 2.2,  -3, 97, 0 },
    { 1, 1, 1,  2, 1.02,  0.21, 0.36, 2.8,  -6, 92, 0 },
    { 1, 1, 0,  2, 0.80, 0.064, 0.17, 4.8, -16, 72, 0 },
    { 1, 1, 4,  1, 1.08,  0.28, 0.54, 2.0,  -2, 98, 0 },
    { 1, 1, 3,  1, 1.06,  0.25, 0.46, 2.3,  -4, 96, 0 },
    { 1, 1, 2,  1, 0.99,  0.17, 0.30, 3.3, -10, 90, 0 },

    { 3, 2,  5, 5, 0.208, 0.030, 0.072, 2.9, -47, 77, 0},
    { 5, 4, 10, 6, 0.163, 0.068, 0.16,  1.0, -19, 85, 0 },
    { 5, 4,  8, 6, 0.146, 0.039, 0.11,  1.3, -29, 76, 0 }

};

// ----------------------------------------------------------------------------
// Class BlastScoringScheme
// ----------------------------------------------------------------------------

/*!
 * @class BlastScoringScheme
 * @brief Wrapper around a SeqAn scoring scheme
 * @signature struct BlastScoringScheme<TScoringScheme> { ... };
 * @headerfile <seqan/blast.h>
 *
 * This class wraps around a SeqAn scoring scheme and add functions for the retrievel of pre-computed
 * Karlin-Altschul-Values (required for e-value statistics) and it modifies the gap-scoring slightly.
 * If you use high-level IO (@link BlastReport @endlink, @link BlastTabular @endlink) you need not worry about the
 * specifics, however you should always make sure that the scoring scheme @link BlastScoringScheme#isValid @endlink
 * after you modify it (or check the return values of the set* functions).
 *
 * To retrieve a score-object compatible with regular SeqAn-functions, call
 * @link BlastScoringScheme#seqanScheme @endlink.
 *
 * @section Gap cost computation
 *
 * Gap-costs are computed differently in SeqAn and in BLAST.
 * Blast (and many other tools) compute scores of a stretch of gaps as
 * <tt>s = gO + n * gE</tt>
 * where gO is the gapOpen score, gE is the gap extend score and n ist the
 * total number of gap characters.
 *
 * SeqAn, however, normally computes them as as <tt>s = gO + (n-1) * gE</tt>.
 *
 * Effectively this results only in a different gap open score. To make dealing with this easier, there are
 * convenience functions for setting and getting the gap open score in blast convention:
 * @link BlastScoringScheme#scoreGapOpenBlast @endlink and @link BlastScoringScheme#setScoreGapOpenBlast @endlink.
 *
 * @section Karlin-Altschul values
 *
 * E-Value statistics require certain pre-computed constants. The BlastScoringScheme picks these automatically
 * whenever you modify it. Unfortunately there aren't parameters for all combinations of scoring schemes and gap
 * costs, so you have to check @link BlastScoringScheme#isValid @endlink after modifying it or verify the return
 * value of the set* functions which is bool here (instead of void).
 *
 * More details on the scoring parameters is in these slides:
 *
 * https://www.cs.umd.edu/class/fall2011/cmsc858s/Local_Alignment_Statistics.pdf.
 *
 * The constants used in SeqAn were imported from the NCBI blast source code (blast-2.2.26)
 *
 * @tparam TScoringScheme A SeqAn Score type
 */

/* NOTE(h-2): Maybe this should specialize Score<> instead of being a wrapper.
 * This would however involve adding a new template parameter to score and
 * changing lots of code. Also it would become confusing as the shortcuts
 * like Blosum62 would no longer work...
 * TODO for SeqAn3: include this files implications when redesigning scoring schemes
 * and reduce complexity
 */
template <typename TScore>
struct BlastScoringScheme
{
    typedef typename Value<TScore>::Type TValue;
    typedef typename KarlinAltschulValues<TScore, void>::TSize TNumValues;

    /* related to ScoringScheme conversion */
    TValue _gapOpenBlast = 0;
    TScore _internalScheme;

    /* parameter selection */
    TNumValues parameterIndex = std::numeric_limits<TNumValues>::max();

    /* hacks for the dynamic matrix */
    double const * _m;
    TNumValues _nParams;
};

// ============================================================================
// Functions
// ============================================================================

/*!
 * @fn BlastScoringScheme#seqanScheme
 * @headerfile <seqan/blast.h>
 * @brief Retrieve a @link Score @endlink object for use with e.g. @link localAlignment @endlink.
 * @signature TScoringScheme const & seqanScheme(blastScoringScheme);
 * @return TScoringScheme_const_& the internal scoring object for use with other SeqAn functions.
 *
 * @section Remarks
 *
 * The reference returned is always const, because you should not modify the internal score object
 * directly. Use @link BlastScoringScheme @endlink's interface instead.
 */

template <typename TScore>
inline TScore const &
seqanScheme(BlastScoringScheme<TScore> const & bscheme)
{
    return bscheme._internalScheme;
}

// ----------------------------------------------------------------------------
// Function overloads for getScore*
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#scoreMatch
 * @headerfile <seqan/blast.h>
 * @brief The Match score (only for SimpleScore specialization).
 * @signature int scoreMatch(blastScoringScheme);
 */

inline int
scoreMatch(BlastScoringScheme<Score<int, Simple>> & scheme)
{
    return scoreMatch(scheme._internalScheme);
}

/*!
 * @fn BlastScoringScheme#scoreMismatch
 * @headerfile <seqan/blast.h>
 * @brief The Mismatch score (only for SimpleScore specialization).
 * @signature int scoreMismatch(blastScoringScheme);
 */

inline int
scoreMismatch(BlastScoringScheme<Score<int, Simple>> & scheme)
{
    return scoreMismatch(scheme._internalScheme);
}

/*!
 * @fn BlastScoringScheme#scoreGapOpen
 * @headerfile <seqan/blast.h>
 * @brief The Gap Open score in SeqAn convention.
 * @signature TValue scoreGapOpen(blastScoringScheme);
 */

template <typename TScore>
inline typename Value<TScore>::Type
scoreGapOpen(BlastScoringScheme<TScore> const & scheme)
{
    return scoreGapOpen(scheme._internalScheme);
}

/*!
 * @fn BlastScoringScheme#scoreGapOpenBlast
 * @headerfile <seqan/blast.h>
 * @brief The Gap Open score in Blast convention.
 * @signature TValue scoreGapOpenBlast(blastScoringScheme);
 */

template <typename TScore>
inline typename Value<TScore>::Type
scoreGapOpenBlast(BlastScoringScheme<TScore> const & scheme)
{
    return scheme._gapOpenBlast;
}

/*!
 * @fn BlastScoringScheme#scoreGapExtend
 * @headerfile <seqan/blast.h>
 * @brief The Gap Extend score.
 * @signature TValue scoreGapExtend(blastScoringScheme);
 */

template <typename TScore>
inline typename Value<TScore>::Type
scoreGapExtend(BlastScoringScheme<TScore> const & scheme)
{
    return scoreGapExtend(scheme._internalScheme);
}

// ----------------------------------------------------------------------------
// Function isValid
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#isValid
 * @headerfile <seqan/blast.h>
 * @brief check whether valid KarlinAltschulValues are selected
 * @signature bool isValid(blastScoringScheme);
 */

template <typename TScore>
inline bool
isValid(BlastScoringScheme<TScore> const & scheme)
{
    typedef KarlinAltschulValues<TScore> TKAValues;
    return scheme.parameterIndex != std::numeric_limits<typename TKAValues::TSize>::max();
}

// ----------------------------------------------------------------------------
// Function _selectSet
// ----------------------------------------------------------------------------

template <typename TScore, typename TKAValues>
inline bool
_selectSet(BlastScoringScheme<TScore> & scheme)
{
    for (typename TKAValues::TSize i = 0; i < TKAValues::nParamSets; ++i)
    {
        if ((TKAValues::VALUE[i][0] == -scoreGapOpenBlast(scheme)) &&
            (TKAValues::VALUE[i][1] == -scoreGapExtend(scheme)))
        {
            scheme.parameterIndex = i;
            return true;
        }
    }
    // no suitable adapter
    scheme.parameterIndex = std::numeric_limits<typename TKAValues::TSize>::max();
    return false;
}

template <typename TValue, typename TSpec>
inline bool
_selectSet(BlastScoringScheme<Score<TValue, ScoreMatrix<AminoAcid, TSpec>>> & scheme)
{
    using TScore = Score<TValue, ScoreMatrix<AminoAcid, TSpec>>;
    using TKAValues = KarlinAltschulValues<TScore>;
    return _selectSet<TScore, TKAValues>(scheme);
}

template <typename TValue>
inline bool
_selectSet(BlastScoringScheme<Score<TValue, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> & scheme)
{
    using TScoreOrig = Score<TValue, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>;
    bool ret = false;
    impl::score::matrixTagDispatch(impl::score::MatrixTags(),
                                   getScoreMatrixId(seqanScheme(scheme)),
                                   [&] (auto const & tag)
    {
        using TScoreMod = Score<TValue, ScoreMatrix<AminoAcid, std::decay_t<decltype(tag)>>>;
        using TKAValues = KarlinAltschulValues<TScoreMod>;
        ret =  _selectSet<TScoreOrig, TKAValues>(scheme);
        // save some KAV data in scheme for retrievel without tag dispatching
        scheme._m = &TKAValues::VALUE[0][0];
        scheme._nParams = TKAValues::nParams;
    });
    return ret;
}

inline bool
_selectSet(BlastScoringScheme<Score<int, Simple>> & scheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;

    for (typename TKAValues::TSize i = 0; i < TKAValues::nParamSets; ++i)
    {
        if ((TKAValues::VALUE[i][0] ==  scoreMatch(scheme))  &&
            (TKAValues::VALUE[i][1] == -scoreMismatch(scheme)) &&
            (TKAValues::VALUE[i][2] == -scoreGapOpenBlast(scheme)) &&
            (TKAValues::VALUE[i][3] == -scoreGapExtend(scheme)))
        {
            scheme.parameterIndex = i;
            return true;
        }
    }
    // no suitable adapter
    scheme.parameterIndex = std::numeric_limits<typename TKAValues::TSize>::max();
    return false;
}

// ----------------------------------------------------------------------------
// Function overloads for setScore*
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#setScoreMatch
 * @brief Set match score.
 * @signature bool setScoreMatch(blastScoringScheme, value);
 * @param[in,out] blastScoringScheme The @link BlastScoringScheme @endlink to modify.
 * @param[in]     value              The new value.
 * @return isValid(blastScoringScheme) whether Karlin-Altschul values for the new scheme exist.
 */

inline bool
setScoreMatch(BlastScoringScheme<Score<int, Simple>> & scheme, int const val)
{
    setScoreMatch(scheme._internalScheme, val);
    return _selectSet(scheme);
}

/*!
 * @fn BlastScoringScheme#setScoreMismatch
 * @brief Set mismatch score.
 * @signature bool setScoreMismatch(blastScoringScheme, value);
 * @param[in,out] blastScoringScheme The @link BlastScoringScheme @endlink to modify.
 * @param[in]     value              The new value.
 * @return isValid(blastScoringScheme) whether Karlin-Altschul values for the new scheme exist.
 */

inline bool
setScoreMismatch(BlastScoringScheme<Score<int, Simple>> & scheme, int const val)
{
    setScoreMismatch(scheme._internalScheme, val);
    return _selectSet(scheme);
}

/*!
 * @fn BlastScoringScheme#setScoreGapOpenBlast
 * @headerfile <seqan/blast.h>
 * @brief Set gap open score in BLAST convention.
 * @signature bool setScoreGapOpenBlast(blastScoringScheme, value);
 * @param[in,out] blastScoringScheme The @link BlastScoringScheme @endlink to modify.
 * @param[in]     value              The new value.
 * @return isValid(blastScoringScheme) whether Karlin-Altschul values for the new scheme exist.
 */

template <typename TScore>
inline bool
setScoreGapOpenBlast(BlastScoringScheme<TScore> & scheme, typename Value<TScore>::Type const val)
{
    scheme._gapOpenBlast = val;
    setScoreGapOpen(scheme._internalScheme, scoreGapOpenBlast(scheme) + scoreGapExtend(scheme));

    return _selectSet(scheme);
}

/*!
 * @fn BlastScoringScheme#setScoreGapOpen
 * @brief Set gap open score in SeqAn convention.
 * @signature bool setScoreGapOpen(blastScoringScheme, value);
 * @param[in,out] blastScoringScheme The @link BlastScoringScheme @endlink to modify.
 * @param[in]     value              The new value.
 * @return isValid(blastScoringScheme) whether Karlin-Altschul values for the new scheme exist.
 */

template <typename TScore>
inline bool
setScoreGapOpen(BlastScoringScheme<TScore> & scheme, typename Value<TScore>::Type const val)
{
    return setScoreGapOpenBlast(scheme, val - scoreGapExtend(scheme));
}

/*!
 * @fn BlastScoringScheme#setScoreGapExtend
 * @brief Set gap extend score.
 * @signature bool setScoreGapExtend(blastScoringScheme, value);
 * @param[in,out] blastScoringScheme The @link BlastScoringScheme @endlink to modify.
 * @param[in]     value              The new value.
 * @return isValid(blastScoringScheme) whether Karlin-Altschul values for the new scheme exist.
 */

template <typename TScore>
inline bool
setScoreGapExtend(BlastScoringScheme<TScore> & scheme, typename Value<TScore>::Type const val)
{
    setScoreGapExtend(scheme._internalScheme, val);
    setScoreGapOpen(scheme._internalScheme, scoreGapOpenBlast(scheme) + scoreGapExtend(scheme));

    return _selectSet(scheme);
}

// ----------------------------------------------------------------------------
// Function getLambda
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#getLambda
 * @headerfile <seqan/blast.h>
 * @brief Get the λ value of the Karlin-Altschul parameters.
 * @signature double getLambda(blastScoringScheme);
 */

inline double
getLambda(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> const & scoringScheme)
{
    SEQAN_ASSERT(isValid(scoringScheme));
    return *(scoringScheme._m + scoringScheme.parameterIndex * scoringScheme._nParams + 3);
}

template <typename TMatrixSpec>
inline double
getLambda(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][3];
}

inline double
getLambda(BlastScoringScheme<Score<int, Simple>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][4];
}

// ----------------------------------------------------------------------------
// Function getKappa
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#getKappa
 * @headerfile <seqan/blast.h>
 * @brief Get the Κ value of the Karlin-Altschul parameters.
 * @signature double getKappa(blastScoringScheme);
 */

inline double
getKappa(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> const & scoringScheme)
{
    SEQAN_ASSERT(isValid(scoringScheme));
    return *(scoringScheme._m + scoringScheme.parameterIndex * scoringScheme._nParams + 4);
}

template <typename TMatrixSpec>
inline double
getKappa(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int,
        ScoreMatrix< AminoAcid, TMatrixSpec>>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][4];
}

inline double
getKappa(BlastScoringScheme<Score<int, Simple>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][5];
}

// ----------------------------------------------------------------------------
// Function getH
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#getH
 * @headerfile <seqan/blast.h>
 * @brief Get the H value of the Karlin-Altschul parameters.
 * @signature double getH(blastScoringScheme);
 */

inline double
getH(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> const & scoringScheme)
{
    SEQAN_ASSERT(isValid(scoringScheme));
    return *(scoringScheme._m + scoringScheme.parameterIndex * scoringScheme._nParams + 5);
}

template <typename TMatrixSpec>
inline double
getH(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int,
        ScoreMatrix< AminoAcid, TMatrixSpec>>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][5];
}

inline double
getH(BlastScoringScheme<Score<int, Simple>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][6];
}

// ----------------------------------------------------------------------------
// Function getAlpha
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#getAlpha
 * @headerfile <seqan/blast.h>
 * @brief Get the α value of the Karlin-Altschul parameters.
 * @signature double getAlpha(blastScoringScheme);
 */

inline double
getAlpha(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> const & scoringScheme)
{
    SEQAN_ASSERT(isValid(scoringScheme));
    return *(scoringScheme._m + scoringScheme.parameterIndex * scoringScheme._nParams + 6);
}

template <typename TMatrixSpec>
inline double
getAlpha(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][6];
}

inline double
getAlpha(BlastScoringScheme<Score<int, Simple>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][7];
}

// ----------------------------------------------------------------------------
// Function getBeta
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#getBeta
 * @headerfile <seqan/blast.h>
 * @brief Get the β value of the Karlin-Altschul parameters.
 * @signature double getBeta(blastScoringScheme);
 */

inline double
getBeta(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, ScoreSpecSelectable>>> const & scoringScheme)
{
    SEQAN_ASSERT(isValid(scoringScheme));
    return *(scoringScheme._m + scoringScheme.parameterIndex * scoringScheme._nParams + 7);
}

template <typename TMatrixSpec>
inline double
getBeta(BlastScoringScheme<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, ScoreMatrix<AminoAcid, TMatrixSpec>>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][7];
}

inline double
getBeta(BlastScoringScheme<Score<int, Simple>> const & scoringScheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    SEQAN_ASSERT(isValid(scoringScheme));
    return TKAValues::VALUE[scoringScheme.parameterIndex][8];
}

// ----------------------------------------------------------------------------
// Function _lengthAdjustment
// ----------------------------------------------------------------------------

// Computes the length adjustment for E-value computation
// Based on the public domain NCBI BLAST code by Tom Madden.
template <typename TSize, typename TSize2, typename TScore>
inline TSize
_lengthAdjustment(TSize     const & dbLength,
                  TSize2    const & queryLength,
                  BlastScoringScheme<TScore> const & scheme)
{
    const double lambda = getLambda(scheme);
    const double K      = getKappa(scheme);
    const double logK   = std::log(K);
    const double alpha  = getAlpha(scheme);
    const double alphaByLambda = alpha/lambda;
    const double beta   = getBeta(scheme);
    const TSize maxIterations = 20;

    double n = (double)dbLength;
    double m = (double)queryLength;
    double totalLen;

    double val = 0, val_min = 0, val_max;
    bool converged = false;

     /* Choose val_max to be the largest nonnegative value that satisfies
      *    K * (m - val) * (n - N * val) > max(m,n)
      * Use quadratic formula: 2 c /( - b + sqrt( b*b - 4 * a * c )) */

    { // scope of mb, and c, the coefficients in the quadratic formula (the variable mb is -b, a=1 ommited)
        double mb = m + n;
        double c  = n * m - std::max(m, n) / K;

        if(c < 0) {
            return 0;
        } else {
            val_max = 2 * c / (mb + std::sqrt(mb * mb - 4 * c));
        }
    } // end scope of mb and c

    for(TSize i = 1; i <= maxIterations; i++) {
        totalLen = (m - val) * (n - val);
        double val_new  = alphaByLambda * (logK + std::log(totalLen)) + beta;  // proposed next value of val
        if(val_new >= val) { // val is no bigger than the true fixed point
            val_min = val;
            if(val_new - val_min <= 1.0) {
                converged = true;
                break;
            }
            if(val_min == val_max) { // There are no more points to check
                break;
            }
        } else { // val is greater than the true fixed point
            val_max = val;
        }
        if(val_min <= val_new && val_new <= val_max) { // ell_new is in range. Accept it.
            val = val_new;
        } else { // else val_new is not in range. Reject it.
            val = (i == 1) ? val_max : (val_min + val_max) / 2;
        }
    }

    if(converged) { // the iteration converged
        // If val_fixed is the (unknown) true fixed point, then we wish to set lengthAdjustment to floor(val_fixed).
        // We assume that floor(val_min) = floor(val_fixed)
        return (TSize) val_min;

        // But verify that ceil(val_min) != floor(val_fixed)
        val = std::ceil(val_min);
        if( val <= val_max ) {
          totalLen = (m - val) * (n - val);
          if(alphaByLambda * (logK + std::log(totalLen)) + beta >= val) {
            // ceil(val_min) == floor(val_fixed)
            return (TSize) val;
          }
        }
    } else { // the iteration did not converge
        // Use the best value seen so far.
        return (TSize) val_min;
    }
}

// ----------------------------------------------------------------------------
// Function computeAlignmentStats
// ----------------------------------------------------------------------------

/*!
 * @fn BlastMatch#computeAlignmentStats
 * @headerfile <seqan/blast.h>
 * @brief Compute the @link BlastMatch::alignStats @endlink member of a @link BlastMatch @endlink.
 * @signature void computeAlignmentStats(blastMatch, context);
 *
 * @param[in,out]   blastMatch  A @link BlastMatch @endlink that has a valid align member.
 * @param[in]       context     A @link BlastIOContext @endlink with parameters and buffers.
 *
 * The alignRow-members (@link BlastMatch::alignRow0 @endlink, @link BlastMatch::alignRow1 @endlink) are used as
 * in-parameter to compute the @link BlastMatch::alignStats @endlink member. This includes the raw
 * score, amount of gaps, mismatches et cetera. This is a prerequisite for printing a match to file or computing it's
 * e-value.
 */

template <typename TBlastMatch,
          typename TScore,
          BlastProgram p,
          BlastTabularSpec h>
inline void
computeAlignmentStats(TBlastMatch & match,
                      BlastIOContext<TScore, p, h> const & context)
{
    computeAlignmentStats(match.alignStats, match.alignRow0, match.alignRow1, seqanScheme(context.scoringScheme));
}

// ----------------------------------------------------------------------------
// Function computeBitScore
// ----------------------------------------------------------------------------

/*!
 * @fn BlastScoringScheme#computeBitScore
 * @brief Compute the bit-score for a given raw score.
 * @signature double computeBitScore(rawScore, blastScoringScheme);
 *
 * @param[in]   rawScore            The raw score of the alignment.
 * @param[in]   blastScoringScheme The @link BlastScoringScheme @endlink.
 *
 * @return double The bit-score computed.
 * @headerfile <seqan/blast.h>
 */

template <typename TScore>
inline double
computeBitScore(double const rawScore, BlastScoringScheme<TScore> const & scheme)
{
    return (getLambda(scheme) * rawScore - std::log(getKappa(scheme))) / std::log(2);
}

/*!
 * @fn BlastMatch#computeBitScore
 * @brief Compute the bit-score for a @link BlastMatch @endlink.
 * @signature double computeBitScore(blastMatch, context);
 *
 * @param[in,out]   blastMatch  A @link BlastMatch @endlink that has a valid align member.
 * @param[in]       context     A @link BlastIOContext @endlink with parameters and buffers.
 *
 * @return double blastMatch.@link BlastMatch::bitScore @endlink after computation
 * @headerfile <seqan/blast.h>
 *
 * @section Remarks
 *
 * This  will compute the bit-score for a @link BlastMatch @endlink. At least the following
 * members need to be set before calling this function:
 *
 blastMatch.@link BlastMatch::alignStats @endlink.@link AlignmentStats::alignmentScore @endlink (if you have valid
 * alignRow-members (@link BlastMatch::alignRow0 @endlink, @link BlastMatch::alignRow1 @endlink), you can call
 * @link BlastMatch#computeAlignmentStats @endlink to compute the stats member).

 */

template <typename TBlastMatch,
          typename TScore,
          BlastProgram p,
          BlastTabularSpec h>
inline double
computeBitScore(TBlastMatch & match,
                BlastIOContext<TScore, p, h> const & context)
{
    match.bitScore = computeBitScore(match.alignStats.alignmentScore, context.scoringScheme);
    return match.bitScore;
}

/*!
 * @fn BlastScoringScheme#computeEValue
 * @brief Compute the E-Value for a given raw score and sequence lengths.
 * @signature double computeEValue(rawScore, queryLength, dbLength, blastScoringScheme);
 *
 * @param[in]   rawScore            The raw score of the alignment.
 * @param[in]   queryLength         The length of the query sequence.
 * @param[in]   dbLength            The length of the database in case of many subject sequences, otherwise the
 * length of the subject sequence.
 * @param[in]   blastScoringScheme The @link BlastScoringScheme @endlink.
 *
 * @return double The e-value computed.
 * @headerfile <seqan/blast.h>
 */

template <typename TScore>
inline double
_computeEValue(double const rawScore,
               double const adjustedQueryLength,
               double const adjustedDbLength,
               BlastScoringScheme<TScore> const & scheme)
{
    return getKappa(scheme) * adjustedQueryLength * adjustedDbLength * std::exp(-getLambda(scheme) * rawScore);
}

template <typename T, typename TScore>
inline void
_conditionalDec(T &, BlastScoringScheme<TScore> const &)
{}

template <typename T>
inline void
_conditionalDec(T & val, BlastScoringScheme<Score<int, Simple>> const & scheme)
{
    typedef KarlinAltschulValues<Score<int, Simple>> TKAValues;
    if (TKAValues::VALUE[scheme.parameterIndex][10])
        --val;
}

template <typename TScore>
inline double
computeEValue(uint64_t rawScore,
              uint64_t const queryLength,
              uint64_t const dbLength,
              BlastScoringScheme<TScore> const & scheme)
{
    // for some parameters the score has to be "rounded down" to being even
    _conditionalDec(rawScore, scheme);

    uint64_t adj = _lengthAdjustment(dbLength, queryLength, scheme);
    return _computeEValue(rawScore, queryLength - adj, dbLength - adj, scheme);
}

/*!
 * @fn BlastMatch#computeEValue
 * @brief Compute the E-Value for a @link BlastMatch @endlink.
 * @signature double computeEValue(blastMatch, qLength, context);
 * [[deprecated]] double computeEValue(blastMatch, context);
 *
 * @param[in,out]   blastMatch  A @link BlastMatch @endlink that has a valid align member.
 * @param[in]       qLength     The length of the query sequence (pass @link BlastRecord::qLength @endlink).
 * @param[in,out]   context     A @link BlastIOContext @endlink with parameters and buffers.
 *
 * @return double blastMatch.@link BlastMatch::eValue @endlink after computation
 * @headerfile <seqan/blast.h>
 *
 * @section Remarks
 *
 * This  will compute the e-value for a @link BlastMatch @endlink. At least the following
 * members need to be set before calling this function:
 *
 blastMatch.@link BlastMatch::alignStats @endlink.@link AlignmentStats::alignmentScore @endlink (if you have valid
 * alignRow-members (@link BlastMatch::alignRow0 @endlink, @link BlastMatch::alignRow1 @endlink), you can call
 * @link BlastMatch#computeAlignmentStats @endlink to compute the stats member).

 *
 blastMatch.@link BlastMatch::qLength @endlink (only in the deprecated interface)

 *
 context.@link BlastIOContext::dbTotalLength @endlink

 *
 * Note, that in contrast to the general interface (@link BlastScoringScheme#computeEValue @endlink), this interface
 * caches some computation steps in the context and is therefore faster.
 */

template <typename TBlastMatch,
          typename TScore,
          BlastProgram p,
          BlastTabularSpec h>
inline double
computeEValue(TBlastMatch & match,
              uint64_t ql,
              BlastIOContext<TScore, p, h> & context)
{
    SEQAN_ASSERT_GT(ql, 0ull);

    // convert to 64bit and divide for translated sequences
    ql = ql / (qIsTranslated(context.blastProgram) ? 3 : 1);
    // length adjustment not yet computed
    if (context._cachedLengthAdjustments.find(ql) == context._cachedLengthAdjustments.end())
        context._cachedLengthAdjustments[ql] = _lengthAdjustment(context.dbTotalLength, ql, context.scoringScheme);

    uint64_t adj = context._cachedLengthAdjustments[ql];

    match.eValue = _computeEValue(match.alignStats.alignmentScore,
                                  ql - adj,
                                  context.dbTotalLength - adj,
                                  context.scoringScheme);
    return match.eValue;
}

template <typename TBlastMatch,
          typename TScore,
          BlastProgram p,
          BlastTabularSpec h>
[[deprecated("Use the interface with an explicit query length parameter instead (use the record's member).")]]
inline double
computeEValue(TBlastMatch & match,
              BlastIOContext<TScore, p, h> & context)
{
    return computeEValue(match, match.qLength, context);
}

}

#endif // ndef __BLAST_STATISTICS_H__

redpajama_set_name: RedPajamaGithub


text:
Congress Agrees on One Trillion Budget Plan to Avoid Shutdown
After more partisan rancor and infighting, heads of the Republican and Democrat caucuses in the House agreed on a 10-figure budget deal that would avoid a government shutdown and keep things at bay.
The problem is that it doesn't really do much good.
First, it doesn't fund the border wall promised by President Trump, but it DOES fund sanctuary cities, Planned Parenthood and countless other pork projects.
When both Democrats and Republicans are praising a deal, it's usually not a good deal for the American people.
Lawmakers on Monday unveiled a huge $1 trillion-plus spending bill that would fund most government operations through September but would deny President Donald Trump money for a border wall and rejects his proposed cuts to popular domestic programs.
The 1,665-page bill agreed to on Sunday is the product of weeks of negotiations. It was made public in the predawn hours Monday and is tentatively scheduled for a House vote on Wednesday.
The catchall spending bill would be the first major piece of bipartisan legislation to advance during Trump's short tenure in the White House. While losing on funding for the wall along the U.S.-Mexico border, Trump won a $15 billion down payment on his request to strengthen the military, though that too fell short of what he requested.
The measure funds the remainder of the 2017 budget year, through Sept. 30, rejecting cuts to popular domestic programs targeted by Trump such as medical research and infrastructure grants.
Successful votes later this week would also clear away any remaining threat of a government shutdown — at least until the Oct. 1 start of the 2018 budget year. Trump has submitted a partial 2018 budget promising a whopping $54 billion, 10 percent increase for the Pentagon from current levels, financed by cutting to foreign aid and other nondefense programs by an equal amount. Negotiators on the pending measure, however, rejected a smaller $18 billion package of cuts and instead slightly increased funding for domestic programs.
Rumors of Joe Biden in 2020 Gain New Life Again
Report: Feds Pay 17% More Than Private Sector for Similar Workers
Newt: Obama's Legacy Will 'Disappear Within a Year'
AG Jeff Sessions Kills Federal Slush Fund For Leftwing Groups
Report: DOJ Caught Trying to Kill Clinton Foundation Investigation
Heads Are Rolling: Another Senior DOJ Official Demoted

redpajama_set_name: RedPajamaCommonCrawl


text:
Fun / Television
Open Casting Call for Bend Reality TV Show
Posted By Erin Rook on Wed, Feb 25, 2015 at 4:03 PM
Do you ever think to yourself, "I should've been a star"? Well, listen up, because this may (or may not) be your chance. An unnamed, L.A.-based "boutique production company" is apparently casting for a reality show based in Bend. The company, which claims to have credits with HGTV and GSN, describes the hypothetical show on its casting call website as being "in the tradition of scripted shows like Picket Fences, Twin Peaks, Northern Exposure and Portlandia."
I'll admit, I'm a little skeptical. Not because Bend seems unworthy of reality stardom. On the contrary, we've had our fair share of reality stars and there's plenty of local flavor to flesh out a script with. But the elusive production company doesn't seem that familiar with Bend. (Or, you know, basic grammar and punctuation.) It describes Bend as "the epicenter of micro brewing of the mid-west" and the Cascade Mountains' most fascinating city." (Note: I reached out to the casting company but haven't heard back yet.)
Still, if you're game, the company is looking for real people to portray the following:
From families who have been rooted to the city for generations, to the brand new resident who hasn't even finished unpacking; the teacher who serves as the town's armchair historian, the wisecracking bartender, the hotel clerk, the hero, the mechanic, the bakers daughter, the Doc, the town gossip, and everyone in between.
I mean, what's the harm in sending off a bunch of personal information to a stranger in the hopes you will be selected to audition "at certain times" in March and April at "various locations"?
So, what do you say, are you going for it?
Check out the full casting call here.
Tags: reality TV, casting call
Erin Rook
Erin is the Source Weekly's Associate Editor. Before moving to Bend in 2013, Erin worked as a writer and editor for publications in Portland including PQ Monthly and Just Out. He has also written for the Willamette Week, El Hispanic News, Travel Portland, OUT City, Boston magazine and the Taunton Daily Gazette...
Speaking of Reality TV, casting Call
Side Notes 3/11-3/18
Letters 2/24-3/10
The Price of Fame: The Reality of Television Contracts
More by Erin Rook
A More Livable Bend
Bend Livability Project engages community in creating change
by Erin Rook
Top Local News Stories of the Year
Top 5 Additions to the Central Oregon Food Scene


text:
Jukani | Wildlife Sanctuary | Plettenberg Bay
Where Rescued Big Cats Feel At Home
A life changing experience, that you can't miss out on.
At Jukani our mission is to maintain and manage a sustainable wildlife sanctuary, with the focus on creating widespread awareness about the plight of large predators in captivity, in South Africa and all over the world.Tours take place from 9.00am to 4.00pm every day of the week, including Sundays. We are open on all public holidays including Christmas and New Years day. We conduct tours in all weather conditions. Tours depart every 15 to 20 minutes as clients arrive. All tours depart from the Jukani Wildlife Sanctuary reception area and they last around one and a half hours. On tour you are guided through the sanctuary by one of our highly skilled and very motivated guides who will not only give you an insight into all the animals at Jukani Wildlife Sanctuary, but enable you to gain a better understanding of these creatures in the wild.After the tour, you are welcome to join another tour and as many tours during that day as you like, the nearby Puzzle Park Cafe serves cold drinks, coffee and tea, yummy cakes, light lunches and snacks, and our curio shop is well stocked with mementos of your visit.Meet Our Creatures· Cheetah· Zorilla· Raccoons· Honey Badger· Hyena· Tawny Lion· White Tiger· Zebra· Siberian Tiger· Bengal Tiger· White Lion· Leopard· Jaguar· Caracal· Serval· Puma
AE-Excitometer-Icons-2.0Mind Blowing
About Jukani
Jukani Wildlife Sanctuary is home to big cats such as lions (white and tawny), cheetahs, tigers (Siberian, Bengal and white), leopard (spotted and black), jaguar, pumas, caracal, serval cats and other wildlife species such as zebra, wild dog, springbuck, zorilla, honey badger, raccoons and various snake species (which are housed separately).
At Jukani the focus is on conservation education and specifically the plight of large predators in captivity, in South Africa and all over the world. "Big cats" are extraordinary animals with a dangerous beauty that is both awe inspiring but also fearsome because of their power and ability to kill. However at most wildlife facilities various wildlife species and especially large predatory species are kept as a way of attracting visitors without regard for the animals' physical and emotional needs, they are just commodities to attract visitors. The Jukani approach is one of respect for what each animal represents. All the female predator cats are on birth control, and the sanctuary is a no-touch facility.
Visiting Jukani is not just about viewing predator cats – it is also an informative experience. Our experienced and trained guides will take you on an tour of the sanctuary and introduce you to all the sanctuary inhabitants. Dictionaries define a sanctuary for animals as merely a place where animals are protected from hunting. A true sanctuary for "big cats" and other wildlife should, however, also be a place of refuge to protect them from much more than hunting and/or the petting trade.
Jukani has secured the future of all its predator cats and wildlife. The South African Animal Sanctuary Alliance (PBO Number 200/060 667/08), is the sole custodian of all the Jukani inhabitants. The Jukani sanctuary funds itself by means of responsible eco-tourism and we strive to achieve an effective balance between conservation and economic reality.
Jukani is situated 10km east of Plettenberg Bay next to the Plettenberg Bay Puzzle Park.
David Attenborough was quoted saying: "People are not going to care about animal conservation unless they think that animals are worthwhile." At Jukani Wildlife Sanctuary we make our visitors aware of the plight "Big cats" face.
How far is Jukani situated from Monkeyland and Birds of Eden?
Jukani is situated 10km from Monkeyland and Birds of Eden along the N2 towards Port Elizabeth.
Why are the animals in enclosures and not set free?
There are many reasons:
The animals at Jukani were born in captivity and they can't be released into the wild because:
a) They can't defend themselves from other wild predators even if they respect the territories of those other predators; they do not have the "street smarts" of the established wild predators. They will fall victim to these established predators which will see them as a threat and eliminate them and as they do not have these same "street smarts" they will lose the battle.
b) They don't know how to hunt, but let's say the instinct does kick in and they do learn (In a month or so before they starve), even their prey may be a threat to them. Buck are equipped with horns, Zebras have a nasty bite and can kick them, inflicting life threatening injuries.
c) By far their biggest threat is persecution by humans either because they will threaten human safety or will be killed as a result.
There is a huge amount of poaching that is taking place internationally and the black-market trade in predator species body parts has resulted in big cats being persecuted all over the world. Researchers have estimated that lions will be extinct in the wild in Africa in the next twenty years, all tiger sub species will be extinct within 15 years, several leopard species have only a few hundred left in the wild and jaguar numbers have dwindled from approximately 10,000 to less than 5,000 in the wild in a very short space of time. In the US Pumas are regarded by some people as problem animals and killed on sight and cheetahs are considered vermin by Namibian farmers.
Where is the wild?
It is a fact that in South Africa that just about every inch of land is owned by someone. That person has a fence around their property. Is it a fence that will keep a predator out? – NO. Sadly that leaves us with a fence to keep a predator in.
It is a pity that the world has changed so much, but we have gone passed the tipping point for most predators. 100 Years ago, cities & towns were small and far apart. Pieces of land were unclaimed or unfenced areas where no farming took place. You hardly had any human / predator conflict. Predators could roam freely. Now, think about the urban sprawl, people moving around easier with highways, 4X4s, and technological advances that have made the most inhospitable places a breeze to access. You will find that there is literally nowhere on Earth that humans cannot and do not go nowadays. What happens to the predators in these areas, they get pushed out unfortunately.
Why do you feed them daily when in the wild they don't eat every day?
In the wild they can hunt when they are hungry (most species are only about 30% to 40% successful when hunting). They consume huge amounts of food during a feeding because they don't know where or when the next meal will be coming from. They gorge on a kill to make sure they eat their fill before threats such as clan of hyenas chase them off their prey. Obviously, they cannot hunt when they are in an enclosure and they don't know how to hunt. Each animal is fed approximately 7% of its body weight per week. This is divided into 7 days with small, medium and large feedings. They are also fed various kinds of meat to which are added nutrients and supplements to ensure healthy and content cats.
Why are some of the lionesses so fat?
The female lions are on contraceptives to prevent breeding. The contraceptives have the same effect on the females as they would on your domestic dog or cat once it has been neutered or spayed.
Do you breed with them?
We don't breed with any of the animals at Jukani. Most facilities that breed do so to sell the cubs or use them for animal touching / interaction with guests. Please follow the #HandsOffOurWildlife campaign and watch the documentary Bloodlions. We simply provide a forever home.
How old do the animals get?
In captivity, they live a lot longer than in nature where they are in a constant battle for survival. A male lion seldom gets older than eight to nine years in nature whilst in captivity they can live up to twenty years of age. The same goes for tigers, leopards, jaguars etc.
What happens to animals when they get too old?
Jukani is a sanctuary for all the animals in its care and they will receive life time care and treatment here. With this commitment also comes the huge responsibility of proper animal keeping and planning for the future of each animal at Jukani. Also, a sustainable business has been put in place to ensure that these animals will be taken care of for the rest of their natural lives.
What does the word/name Jukani mean?
The word Jukani has no meaning and is a portmanteau of Juka and Shanti. Juka and Shanti are the names we use to refer to the 2 Bengal Tigers who occupy the largest enclosure at Jukani. It is also the central most enclosure located in the heart of the Sanctuary. The name has a lovely African ring to it.
Do the animals have names?
We do not believe that they are pets, but it makes it easier to give them names so we have camp names for administration purposes and logistics in this case it makes it easier to refer to them by a name. We have enough respect for them to appreciate the fact that they may like to call themselves whatever they feel like and we have considered the fact that they might not even have names. We are very mindful of not projecting human emotion or rules onto the animals. After all, a Hyena laughing is no joke and a cat smiling is not always a sign of friendliness.
Do you buy animals and will you get more?
We do not buy any animals at Jukani. All the animals at Jukani are rescues. Our animals have come from persons or the authorities such as Cape Nature rescuing them and if there has been space at Jukani they were placed here. Space only opens if an animal has passed away.
What do you consider as ethical animal attractions and what would an unethical animal attraction be?
Firstly, look at the animals' quality of life. It is as easy as that. Look at a facility carefully and see how the animals are treated. Now think about animal well-being for a moment. Does it need interaction with humans every day of its life? The answer is absolutely NOT. Wild animals, unlike domestic animals do not need nor crave human interaction, for the most part they shy away from humans and that is an instinct that should be preserved not only in the animal, but also in humans. If the animals are walked, touched, ridden on, played with or subjected to any human interaction with the public, then we regard such a facility as unethical. No facility involved in conservation can justify sacrificing any animal's well-being to earn funds to conserve it. It does not make sense. It is not conservation – it is exploitation!
N2 Plettenberg Bay, 6600 Plettenberg Bay, South Africa


text:
UCL events news and reviews
UCL events calendar
Follow UCL on social media
The UCL Awards for Enterprise – inspiring the next generation of entrepreneurs with stories of the last
newseditor25 May 2012
A startling and inspiring story marked UCL's fifth Annual Awards for Enterprise – that of Professor Roger Ekins, who invented technology that enables a single drop of a newborn baby's blood to be used to test for thousands of different substances and ensure that they begin life in the best possible health.
Yet the technology – now used in hospitals around the world and worth billions of dollars annually – started with research by one man, who was presented with a Lifetime Achievement Award during the ceremony in recognition of his accomplishments.
It summed up the mood at the Awards – this year, with an appropriately chosen Olympic theme – of a feeling that a vision, with nurturance and support, can become a success that defies expectations.
Some visions for the enterprises awarded were very inspiring and exciting – especially Art Stavenka's eye-catching bikes that can display 3D animations, ads and cartoons on the wheels.
A demonstration at the reception afterwards quickly grabbed the assembled guests' attention, having already achieved that of the judges – resulting in an Award of £7,500 in funds to kick-start his business, Old Bond Ltd.
Filed under Enterprise
Tags: business, Business start-up, enterprise, Entrepreneur, entrepreneurship, students, UCL Advances, UCL Business
UCL Entrepreneurship Guest Lecture: Edward Parkinson, Viagogo
newseditor26 January 2012
UCL Classics student Carolina Mostert summarises the talk held on 19 January below.
It is not the first time Edward Parkinson has engaged a UCL audience in an inspiring lecture. Having studied Chemistry at Oxford, Edward worked in consultancy in England and America. He joined Viagogo five years ago and is now Director of Viagogo's UK offices.
The idea behind Viagogo is quite straightforward: it aims to make the experience of getting tickets for an event better and easier. Through technology and the internet, Viagogo promises to create a secure place to sell and buy tickets, guaranteeing transparency in the transaction.
In its early days, Viagogo was the official retail ticket holder for Chelsea FC. Football tickets, in fact, are the only tickets that, in order to be resold legally, need to be resold through an official website.
Tags: enterprise, Entrepreneur, entrepreneurship, UCL Advances, viagogo
UCL Entrepreneurship Guest Lecture: The Lovefilm Story
The 2012 Entrepreneurship Guest Lecture Series kicked off on 12 January with Simon Calver, CEO of Lovefilm.
UCL Classics student Carolina Mostert summarises the talk below.
Simon Calver has an interesting story and CV for an entrepreneur. Since he was a child, the atmosphere around him was 'entrepreneurial', as his family owned a supermarket chain.
At university, he studied Computer Science and worked as a consultant for Deloitte. During his employment at Pepsi, he launched Pepsi Max and was Head of Sales in New York. Later on, he worked for Dell and for Riverdeep.
Tags: enterprise, Entrepreneur, entrepreneurship, lovefilm, UCL Advances
UCL Entrepreneurship Guest Lecture 2011/12: Nicolas Hantzsch, Groupon UK & Ireland
newseditor19 December 2011
The eighth lecture of this series took place on 8 December. UCL Classics student Carolina Mostert summarises the talk below.
Nicolas Hantzsch's talk did not feel like a lecture. It sounded more like an adventure story, something very unique and unusual. Nicolas completed a degree in informatics in Germany, moved on to financial studies and joined Pacific Stock Exchange. He then worked for a Dutch investment bank, an experience which left him with mixed feelings. After joining My City Deal, which can be described as a "Groupon copy", he quit and enrolled in a Master's degree at UCL. Fed up with academia, in a very 'Bill Gates' fashion, he dropped out of the course: he was going to be an entrepreneur. Then, the adventure with Groupon began.
"It's been a roller coaster", are Nicolas's words to describe his experience. When he started at Groupon, he started at the bottom: what's important at the beginning, he explains, is to learn the value chain at the heart of Groupon. "We are like a newspaper": on a daily basis, Groupon has to offer new deals. Some of those will make the headlines, the bigger ones, and the other ones – although they're not as flashy – must still appeal to people. Every Groupon deal, however, has an aim: to offer its customers the opportunity, and excuse, to always try something new.
Tags: enterprise, Entrepreneur, entrepreneurship, Groupon, Nicholas Hantzsch
The 2018 UCL Neuroscience Symposium
David Olusoga's 2018 Cities Imaginaries lecture on the UK's 'Orwellian' housing situation
UCL Populations & Lifelong Health Domain Symposium
Archives Select Month August 2018 May 2018 February 2018 January 2018 December 2017 November 2017 October 2017 July 2017 June 2017 May 2017 March 2017 February 2017 January 2017 December 2016 November 2016 October 2016 September 2016 July 2016 June 2016 May 2016 March 2016 February 2016 January 2016 December 2015 November 2015 October 2015 September 2015 August 2015 July 2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 September 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 April 2013 March 2013 February 2013 January 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 April 2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September 2011 August 2011 July 2011 June 2011 May 2011 April 2011 March 2011 February 2011


text:
IMAX® and Major Cineplex Expand Partnership in Thailand with Three New IMAX® with Laser Theatres
New and Upgraded Locations in Bangkok Set to Significantly Grow IMAX Position
in Key Southeast Asian Market
BANGKOK AND NEW YORK – April 25, 2022 – IMAX Corporation (NYSE: IMAX) and Major Cineplex today announced plans to expand their partnership with an agreement for three new, state-of-the-art IMAX® with Laser systems in Thailand. The deal marks a significant step forward for IMAX and Major Cineplex — the largest exhibitor in Thailand with a growing regional presence — and will bring IMAX's total presence to seven screens in the fast-growing Thai market.
The new agreement provides for IMAX with Laser upgrades at two key locations in central Bangkok, including ICON CINECONIC at ICONSIAM, the venue for this year's CineAsia annual conference of Asian exhibitors. The ICON CINECONIC at ICONSIAM upgrade is slated to be installed prior to the conference. ICON CINECONIC at ICONSIAM and the additional location, Paragon Cineplex at Siam Paragon , are two of Thailand's top-performing theatres and are in prime retail and entertainment complexes. The third system will be a brand-new construction located at the Mega Cineplex at Mega Bangna Mall, a massive complex with hundreds of stores, in the Bangkok Metro region.
"We are excited to bring these new state-of-the-art systems into Bangkok's most iconic shopping and entertainment complexes as we further expand on our long, successful partnership with IMAX," Major Cineplex CEO Vicha Poolvaraluck said. "I look forward to experiencing the latest blockbuster films in one of the most immersive, high-quality theater systems around. With the continuous evolution of Thailand's film market, the premium movie experience represented by IMAX has become a driving force to attract audiences back to the box office and support the industry's post-pandemic recovery."
"From our increasing number of screens to growing box office returns, Thailand is an emerging market for IMAX and this agreement marks a big step forward in capturing the opportunity at hand," said Rich Gelfond, CEO of IMAX. "We are excited to expand our partnership with Major Cineplex, and look forward to further growing the IMAX brand in Thailand and around the globe as a premier destination for entertainment and events."
The new and upgraded locations will showcase IMAX with Laser, IMAX's most advanced theatre experience. IMAX with Laser has been developed from the ground-up to be immersive by design and deliver crystal clear, lifelike images and precision audio for a moviegoing experience unlike anything else. It is unmatched with by a groundbreaking 4K laser projection system that features a new optical engine, custom designed lenses, and a suite of proprietary technology that delivers brighter images with increased resolution, deeper contrast, and the widest range of colors exclusively to IMAX screens.
About IMAX Corporation
IMAX, an innovator in entertainment technology, combines proprietary software, architecture and equipment to create experiences that take you beyond the edge of your seat to a world you've never imagined. Top filmmakers and studios are utilizing IMAX theaters to connect with audiences in extraordinary ways, and, as such, IMAX's network is among the most important and successful theatrical distribution platforms for major event films around the globe.
IMAX is headquartered in New York, Toronto, and Los Angeles, with additional offices in London, Dublin, Tokyo, and Shanghai. As of December 31, 2021, there were 1,683 IMAX theater systems (1,599 commercial multiplexes, 12 commercial destinations, 72 institutional) operating in 87 countries and territories. Shares of IMAX China Holding, Inc., a subsidiary of IMAX Corporation, trade on the Hong Kong Stock Exchange under the stock code "1970."
IMAX®, IMAX® Dome, IMAX® 3D, IMAX® 3D Dome, Experience It In IMAX®, The IMAX Experience®, An IMAX Experience®, An IMAX 3D Experience®, IMAX DMR®, DMR®, IMAX nXos® and Films to the Fullest®, are trademarks and trade names of the Company or its subsidiaries that are registered or otherwise protected under laws of various jurisdictions. More information about the Company can be found at www.imax.com. You may also connect with IMAX on Instagram (https://www.instagram.com/imax), Facebook (www.facebook.com/imax), Twitter (www.twitter.com/imax) and YouTube (www.youtube.com/imaxmovies).
Heather Anthony
hanthony@imax.xom
Mark Jafar
mjafar@imax.com
IMAX® Rings in Record-Breaking Chinese New Year with $34 Million
IMAX® Rockets to Second Best Opening Day Every for Chinese New Year
"Avatar: The Way of Water" Now Among Top Three IMAX® Releases of All Time with $215 Million in IMAX Global Box Office
IMAX® Enhanced to Expand Offering on Disney+ with IMAX Signature Sound by DTS for The Home in 2023
IMAX® Crowns "Avatar: The Way of Water" as its Highest Grossing Film of 2022, With $160 Million and Counting


text:
You are here: Home Furman v. Georgia
In this Furman v. Georgia case, the United State Supreme court declared that capital punishment was very unconstitutional. Five justices supported this ruling since they also believed that it was good to ban capital punishment in the country (Smith, 2008). One of them was Mr. Douglas who said that capital punishment was a problem since the punishment itself was discriminatory in its context. He argued that the announcement of a death penalty on a person would be highly incontestable if it discriminated against a person due to his race, wealth, religion or social class (Smith 2008). He therefore considered death penalty extremely unacceptable, and in contrary to the outlines of the constitution due to the discriminative nature at which this judgement was passed and the execution carried out.
The background of the case
It was on 11th August, 1967 at night when Micke William Jr., 29 years old, had come from work to his house. He had a wife and five children living in Savannah, Georgia (Smith, 2008). It was around midnight, two hours after arriving in the house, when the Micke awoke from some strange noises and screams that were coming from the kitchen. William initially thought that one of his Children was sleepwalking. Therefore, he went into the kitchen to find out if he was the one and get him back to the house. To his amazement, Micke found Henry Furman who was in the kitchen. One thing is that Furman was an uneducated, very poor and mentally incapacitated person; he was an African American and he had broken into the kitchen and had a gun with him (Smith 2008). When Furman saw Micke he fled the house and tried to shoot Micke as he was leaving; the bullet penetrated in Micke's chest killing him at the spot. Following this incident, Micke's family members called the police immediately. In a few minutes' time, the police came and searched the entire neighborhood and as they were searching, they found Furman who was with his gun. Afterwards, Furman was arrested and charged for murdering Micke (Philip 1974). Before the trial of Furman, the court ordered that Furman should be taken to CCSH (Georgia Central State Hospital) to have a psychological examination. It was after medical examination that Furman was found to be psychotic and mentally ill.
During the day of trial, the appellant was William Henry and the appellee was the State of Georgia. The appellant's claim was that the death penalty sentence was an unusual and cruel punishment under Amendments. The Chief Lawyer for Appellant was Anthony G. Amsterdam and Dorothy Beasley as the Appellee's lawyer (Smith 2008). The Justices of the court were William Brennan, Jr., Thurgood Marshall, William Douglas, Byron White and Stewart Potter. The Justices Dissenting included Harry Blackman, Powell Lewis, Warren Burger, and William Rehnquist (Philip 1974). The day for this case was on 29th June, the year 1972. The trial of Furman was held on 20th September, 1968 and since he was poor he got a fairly bad trial.
Although cases of murder are usually long and complicated, this trial lasted for only a day with the court rejecting Furman's insanity idea; the jury also declared that Furman was guilty for killing Micke and sentenced him to death despite the fact that all the evidences suggested that Micke's death had occurred accidentally (Philip 1974). Shortly, Furman had to appeal for his conviction. On 3rd May, 1969, however, the court delayed his execution and because of that reason, Furman was not able to appeal to the Supreme Court of the United States (James 2003). Since this Furman's case attracted so much publicity, quite a number of distinguished lawyers such as Anthony Amsterdam joined Mayfield in helping Furman with his appeal. On 17th January, 1972 before the hearing, Amsterdam declared that death penalty that had been passed in Georgia had violated the Constitution of United States (James 2003). According to the Eighth Amendment of the constitution, the government would not use unusual or cruel punishments to the people (Philip 1974).
Constitutional Questions Raised by the Case
It was quite clear that a number of constitutional issues were raised after this case. Justices White and Douglas expressed concerns on the unfairness with which sentences, especially death sentences, were being imposed in accordance to the existing laws of the land (Smith 2008). Also, Justices Marshall and Brennan argued that death sentences were extremely cruel according to the Eighth Amendment and lacking decency in an American society. Following these opinions from these two Justices, it was a duty to find out whether death penalties were being applied as under the existing statutes (Philip 1974). The Chief Justice, Burger, together with Justices Harry, Powell and William Rehnquist, all appointed by President Nixon held different views. They all argued that the application of capital punishment should be vital since it had for the past years been regarded appropriate according to the American tradition. This would be applied in dealing with serious criminal offences and other crimes as authorized by the Constitution of the country. The argument here was that the 14th Amendment of the Constitution gave reference to capital punishment (Smith 2008).
Summary of the Supreme Court's Decision
Having a 5–4 decision, it was necessary for the Supreme Court to reverse the old Furman's conviction (Philip 1974). During the case, five justices agreed harmonious that Furman's death sentence conviction was an unusual and cruel punishment. However, the justices were unable to agree with a common reasoning for this decision. Since these five made a majority, it was what would influence the outcome of the case. Justice Douglas ended up writing an opinion that would come to explain the decision of the Court at his best (Philip 1974). It was after this case that Justice Douglas came up with a historic review of the death sentence penalty for both America and England (Philip 1974). The Justice noted that, according to the English law, the application of death sentencing was extremely unfair because it was applied only to the minorities, the outcasts and the smaller populations in the country. Justice Douglas therefore decided that death penalty was unusual and against God's plan.
Constitutional significance of the Decision
After this case's decision, there were issues that led to constitutional application when dealing with the death penalty. Later, Justice Douglas reviewed a number of studies concerning how the death sentences were being applied in countries such as America and even Britain (Smith 2008). He also noted it were the Black-Americans, the poor, the sick, the uneducated people in the society who had been receiving death penalties and not the Whites or the rich. He strongly believed that this was caused by the fact that the juries had no much guidance or understanding of the law when passing some of these death sentences (James, 2003). Because of this, they allowed the juries to use their prejudices in determining the outcome of such cases. Douglas therefore suggested that there was the need to rewrite such laws in order to avoid such a miscarriage of justice (Philip 1974).
The most important thing here is that this case did not ban the death penalty completely. It just ensured that there were no prejudices by preventing random, unfair and racial results through giving the jury a necessary guidance that it would apply when passing penalties. Later after this case, a number of states rewrote penalties on death. Such laws therefore created a double-phased system in determining cases on death penalties (James 2003). The jury was now to decide whether the defendant was guilty with irrefutable evidences; then the jury would listen to any new evidence in order to have a final decision on whether the defendant would deserve such a penalty.
Philip, M. (1974): Furman v. Georgia: Cambridge: Cambridge University Press.
Smith, F. (2008): The Supreme Court and the Politics of Death: Oxford: Oxford University Press.
James, S. (2003): Slow Dancing with Death: New Jersey: Prentice Hall.
Blaustein, A. (1993): Constitutions of the World: New York: Fred B. Rothman & Company.


TO REGISTER YOURSELF IN OUR WEBSITE YOU NEED TO BE A INDIAN HAVING A ACTIVE MOBILE CONNECTION. BY COMPLETING THE REGISTRATION PROCESS AND CLICKING THE "SUBMIT" BUTTON, YOU ARE AGREEING TO BE BOUND BY THE ATSMS4U TERMS OF SERVICES.
a.	Provide Accurate Information. You agree to provide true, accurate, current and complete information about yourself as requested in the ATSMS4U Please maintain and promptly update the Registration data to keep it current and accurate. (Later on if ATSMS4U founds that the information provided by user is untrue, inaccurate, not current or incomplete, ATSMS4U has the right to suspend or terminate your account and refuse any and all current or future use of the Service (or any portion thereof) without any liability to you.
b.	Guard Your Password. You agree to be responsible for maintaining the confidentiality of your password and account. And you are fully responsible for all activities that occur using your password or account. Please notify ATSMS4U immediately of any unauthorized use of your password or account or any other breach of security.
a.	It is very important for a registered user to know that all postings (Messages, Content or any other text) transmitted through the Site, are the sole responsibility of the registered users from whom such content is originated. Registered users are entirely responsible for all Content that they send, or otherwise make available through the Site.
b.	SMS that would be send are subject to monitoring. Any SMS which contains abusive words would be filtered for compliance purpose. Features and the services provided by this site should not be used for illegal activities or any crime purpose, any such action is strictly prohibited and serious action may be taken against the user.
A registered User agrees to the following terms and conditionss while using product/or services provided by ATSMS4U.
Users are not suppose to upload, post, transmit any content or SMS that is unlawful, harmful, threatening, abusive, harassing, tortuous, defamatory, vulgar, obscene, libellous.
Do not gain unauthorized access to other User accounts.
This website is not intended for distribution to, or use by, any person or entity in any jurisdiction or country where such distribution or use would be contrary to local law or regulation. The information and materials contained in these pages, and the terms, conditions, and descriptions that appear, are subject to change. Unauthorized use of this web site or misuse of any information posted on this site is strictly prohibited. Please note that authorized and unauthorized activities may be monitored. The Users shall be held responsible for obtaining and maintaining all computer hardware, software and communications equipment that are needed to access the Products and/or Services.
Marketing, Advertising and Promotional SMS of any Business, Product or Services is totally prohibited and ATSMS4U does not allows User to use Free SMS services for Business Purpose.
ATSMS4U is used for Free SMS services to send SMS to known peoples like your Friend, Relatives, Family, Loved Ones or the people you may know. ATSMS4U Monitors each and every sms sent and Users account will be Bolcoked without any prior intimation if any Marketing, Advertising or Promotional SMS is sent.
The Products and/or Services are "AS IS" (Current Process) and are subject to the disclaimers of warranty and the limitations of liability as found in this agreement and which are subject to testing by the Users before entering into this agreement. ATSMS4U has all the rights to change or terminate the Products and/or the Services and/ or alter the Terms and Conditions of this agreement at any time with/without notice and/or with immediate effect.
Protect and defend the rights or property of ATSMS4U.
Enforce this Service Agreement or protect ATSMS4U business or reputation, including without limitation upon termination,cancellation or suspension of this Agreement by ATSMS4U.
Respond to request for identification in connection with claim of copyright or trademark infringement by the User, or a claim by a third party that the User is using the Service in connection with an infringing, illegal or improper activity.
Act to protect the interests of the User or others.
ATSMS4U suggest the Sender's name and/ Mobile Number or email address should be with each message that the user sends.
The customer agrees that, by definition, access to the Internet, the GSM and CDMA networks and other communication media is associated with risks concerning authentication, data security, privacy, availability of services, reliability of transmission etc. The customer agrees to bear full and exclusively responsibility arising from such risks and consequences of the customer's usage of ATSMS4U services.
The User agrees that ATSMS4U can access his/her account, including the message content, as stated above or respond to product specific queries or technical issues.
The User hereby permits ATSMS4U to send him/her communication via email and/or SMS of any updates, upgrades, notices, or any other information that ATSMS4U deems important for the Users to know, relating to the Products and/or Services.
ATSMS4U might send certain appropriate and/or contextual promotional messages to its Users, based on the User demographics, traffic usage etc.
Any unauthorized commercial use of the Service, is expressly prohibited. The User agrees to abide by all applicable local, national and international laws and regulations and is solely responsible for all acts or omissions that occur under its account or password, including the content of any transmissions through the Service.
Use the Service in connection with junk SMS messages, spamming or any unsolicited messages (commercial or otherwise).
Create a false identity mobile phone address or header, or otherwise attempt to mislead others as to the identity of the sender or the origin of the message.
Transmit any material that contains viruses, Trojan horses, worms, time bombs, cancel bots, or any other harmful or deleterious programs.
Interfere with another User's use and enjoyment of the Service or another entity's use and enjoyment of similar services or Interfere with or disrupt the networks connected to ATSMS4U or violate the regulations, policies or procedures of such networks.
Engage in any other activity that ATSMS4U believes could subject it to criminal liability or civil penalty or judgment.
Interfere with or disrupt the Service or servers or networks connected to the Service, or disobey any requirements, procedures, policies or regulations of networks connected to the Service "Stalk" or otherwise harass others.
Part of this Site will contain advertising, displays and/ or other related materials ("Materials") submitted to ATSMS4U by third parties/entity(s). Advertisers are responsible for ensuring that Materials submitted for inclusion on the Site complies with applicable national and international laws. ATSMS4U will not be responsible for or endorse any advertiser's claim, error, omission or inaccuracy in the Materials and reserves the right to omit, suspend or change the position of any Material submitted for insertion.
In this regard, the User(s), Subscriber(s), Member(s) acknowledges that he/ she/ it will be utilizing the Materials, solely at their own risk and responsibility and the User(s) Member(s) shall hold ATSMS4U for any such usage of such Materials, either directly or indirectly, so provided by the third parties/ entity(s).
Any opinion, advice, statement, service(s), offers or other information or content expressed or made available by third parties, including information providers, advertisers, User(s), Subscriber(s), Member(s) or any other user of the Site (the "Content"), are those of the respective author(s) or distributor(s) or information and/ or content providers and not of the Company. Neither the Company nor any third party provider of information guarantees the accuracy, completeness or usefulness of any Content nor its merchantability or fitness for any particular purpose.
In many instances, the Content available through this site represents the opinions and judgements of the respective information provider, subscriber or other user not under any specific contract, agreement, arrangement or understanding with ATSMS4U, nor is responsible for the correctness, accuracy, reliability or otherwise of any opinion, advice or statement made on this site by anyone other than specifically authorized by ATSMS4U through its designated authorized spokesperson(s) acting in their official capacities.
In this regard, the User(s), Subscriber(s), Member(s) acknowledges that he/ she/ it will be utilizing the Contents, solely at their own risk and responsibility and the User(s), Subscriber(s), Member(s) shall hold neither batchmates nor its parent/ subsidiary companies nor their affiliates nor its officers responsible for any such usage, either directly or indirectly, of the Contents so provided by the third parties/ entity(s).
In the event the User(s), Subscriber(s), Member(s) has any correspondence or business dealings with, or participates in promotions of, advertisers found on or through the Site, including payment and delivery of related goods or services, and any other terms, conditions, warranties or representations associated with such dealings, such a communication is solely between such a User(s), Subscriber(s), Member(s) and the advertiser. The User(s), Subscriber(s), Member(s) agree that ATSMS4U shall not be responsible or liable for any loss or damage of any sort incurred as the result of any such dealings or as the result of the presence of such advertisers on the Site.
ATSMS4U (INCLUDING ITS OWNERS, EMPLOYEES, SUPPLIERS, INTERNET SERVICE PROVIDERS, PARTNERS, AFFILIATES AND AGENTS) SHALL NOT BE LIABLE FOR ANY DAMAGE, LOSS OR LIABILITY OF ANY NATURE INCURRED BY WHOMEVER AND RESULTING FROM USE OF THE SERVICE AND THE INTERNET GENERALLY.
THE USER ACKNOWLEDGES AND AGREES THAT IS AT ITS OWN RISK AND THAT ATSMS4U IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT ANY WARRANTIES OR CONDITIONS WHATSOEVER, EXPRESS OR IMPLIED. ATSMS4U WILL USE COMMERCIALLY REASONABLE EFFORTS TO MAKE ACCESS TO atsms4u AVAILABLE TO THE USER THROUGH THE REQUIRED ACCESS PROTOCOLS, BUT MAKES NO WARRANTY OR GUARANTEE THAT THE USER WILL BE ABLE TO ACCESS ATSMS4U AT ANY PARTICULAR TIME OR ANY PARTICULAR LOCATION.
ATSMS4U does not make any warranties or representations that the ATSMS4U website shall be available at all times. Users acknowledge that the ATSMS4U website may be unavailable due to updates or other causes beyond the reasonable control of ATSMS4U, including, but not limited to virus infection, unauthorized access (hacking), power failure or other natural disasters. Though ATSMS4U shall take all reasonable caution about the quality and accuracy of content available from the ATSMS4U website, The information, ideas and opinions expressed on the ATSMS4U website should not be regarded as professional advice or the official opinion of ATSMS4U, and Users are strongly encouraged to consult professionals before taking on any course of action that is related to the information, ideas or opinions expressed on the ATSMS4U website.
SMS Messages will be considered as delivered when ATSMS4U has delivered, or sent the messages to the immediate destination that SMSCountry Core Messaging Platform has been programmed to do, which include SMPP/SMTP servers, or Mobile Telephone Networks.
ATSMS4U assumes no responsibility for the deletion or failure to store information. Currently, ATSMS4U has set an upper limit on the number of messages an User may send; however, in the future, with/without prior notification, ATSMS4U may increase or reduce the number of SMS messages able to be sent by a user and the amount of storage space available to each User.
Although ATSMS4U makes all efforts to ensure delivery and prides itself on speedy delivery of messages, messages may be delivered late as a result of queuing or network congestion/traffic.
ATSMS4U continually makes efforts to improve its existing Products and/or Services, apart from adding new ones, resulting in frequent updates or modifications. Such changes often dictate that we simultaneously modify our Terms and Conditions. Hence, ATSMS4U shall have the right to modify any or all the terms of this Agreement and to change or drop any aspect or feature of the ATSMS4U Products and/or Services, as it deems reasonably necessary. Such changes shall be effective immediately upon posting of such addition, change or deletion. Any use by the Users of the Products and/or Services after any such change has been posted, shall be construed as the acceptance of the change. If the User is not agreeable to any such change, the relevant Product and/or Services or the User account, may be cancelled in accordance with the procedures for cancellation set forth in this Agreement. The Users acknowledge their responsibility to read and review this Agreement from time to time and also to be aware of any such changes.
User must not Send SMS like abuse, adultery content, insulting content, etc also Marketing, Advertising and Promotional SMS of any products, services and company is not allowed in ATSMS4U. This site is for Free SMS to known persons and not for business use.
The User has the right and is free to terminate or cancel this Agreement and his/her ATSMS4U account at any time and for any reason. The User only has to intimate ATSMS4U by sending an email (support@atsms4u.com) of this intention.
ATSMS4U can terminate, cancel and/or suspend this Agreement and/or the User account any time if, in ATSMS4U's sole discretion, the User has breached the Terms of this Agreement. Such termination, cancellation and/or suspension by ATSMS4U shall come into effect immediately after giving notice by ATSMS4U to the Users in any reasonable manner, including but not limited to, notification by email and/or SMS. In addition, ATSMS4U has the right to recover any and all damages from the Users arising from or relating to the event(s) giving rise to the suspension, termination or cancellation.
ATSMS4U reserves the right to suspend the User's account at any stage for any reason that it may deem necessary in order to continue to provide any of its Products and or Services in a way that may be hindered by the User's status as being a ATSMS4U User, or the content of the messages originating from the User.
Upon the termination, cancellation and/or suspension of this Agreement, the Users remains responsible for any obligations that have been accrued including, but not limited to, payment of any costs or charges, including legal obligation that may be arising in connection with such termination, cancellation and/or suspension, and payment of all outstanding transaction fees for use prior to said termination, cancellation and/or suspension occurs. Upon termination and/or cancellation, for any reason, the User agrees to immediately cease using ATSMS4U Products and/or Services and removes all the ATSMS4U software and applications on any computer, database, and server (local or remote) in its possession or under its control. ATSMS4U shall have no obligation whatsoever to the User after the termination or cancellation of this Agreement.
User(s) are responsible for providing all personal computer and communications equipment necessary to gain access to the Service. Access to and use of premium services is through a combination of an ID and a password. Each User(s) must keep his password strictly confidential. ATSMS4U will not release passwords for any reason, except as may be specifically required by law or court order. Unauthorized access to premium service is a breach of this Agreement and a violation of law.
No warranty is made by ATSMS4U regarding any information, services, or products provided through or in connection with subscription services, and batchmates.com hereby expressly disclaims any and all warranties, including without limitation: any warranties as to the availability, accuracy, or content of information, products, or services; any warranties of merchantability or fitness for a particular purpose. Some countries/ states do not allow the exclusion of implied warranties, so the above exclusion may not apply to you. The User hereby warrants and represents that he or she is in all respects is qualified and competent to enter into this agreement.
Answers to the questions about your ATSMS4U Product(s) or Service(s), please visit our Help link or mail us at (support@atsms4u.com). Please include your Name, Mobile Number and email address in all sorts of correspondence/ communication to get a quick response from us.