# fn() computeAlignmentStats
Compute alignment statistics.

Defined in | <seqan/align.h>
Signature | `TScoreVal computeAlignmentStats(stats, align, scoringScheme); TScoreVal computeAlignmentStats(stats, row0, row1, scoringScheme);`

## Parameters

`stats` | The AlignmentStats object to store alignment statistics in.
`align` | The Align object to score.
`row0` | The first row (Gaps object).
`row1` | The second row (Gaps object).
`score` | The Score object to use for the scoring scheme.

## Return Values

`TScoreVal` | The score value of the alignment, of the same type as the value type of `scoringScheme`

## Detailed Description

### Examples

    #include <iostream>

    #include <seqan/align.h>
    #include <seqan/sequence.h>

    using namespace seqan;

    int main()
    {
        // Create an alignment between subject and query.
        Peptide subject =
            "MGLSDGEWQLVLNVWGKVEADIPGHGQEVLIRLFKGHPETLEKFDKFKHLKSEDEMKASE"
            "DLKKHGATVLTALGGILKKKGHHEAEIKPLAQSHATKHKIPVKYLEFISECIIQVLQSKH"
            "PGDFGADAQGAMNKALELFRKDMASNYK";
        Peptide query =
            "MSLTKTERTIIVSMWAKISTQADTIGTETLERLFLSHPQTKTYFPHFDLHPGSA"
            "QLRAHGSKVVAAVGDAVKSIDDIGGALSKLSELHAYILRVDPVNFKLLSHCLLVTLAARF"
            "PADFTAEAHAAWDKFLSVTEKYR";

        Align<Peptide> align;
        resize(rows(align), 2);
        setSource(row(align, 0), subject);
        setSource(row(align, 1), query);

        Blosum62 scoringScheme(-1, -12);
        globalAlignment(align, scoringScheme);

        // Compute the statistics of the alignment.
        AlignmentStats stats;
        computeAlignmentStats(stats, align, scoringScheme);
        std::cout << align
                  << "score:               " << stats.alignmentScore << "\n"
                  << "gap opens:           " << stats.numGapOpens << "\n"
                  << "gap extensions:      " << stats.numGapExtensions << "\n"
                  << "num insertions:      " << stats.numInsertions << "\n"
                  << "num deletions:       " << stats.numDeletions << "\n"
                  << "num matches:         " << stats.numMatches << "\n"
                  << "num mismatches:      " << stats.numMismatches << "\n"
                  << "num positive scores: " << stats.numPositiveScores << "\n"
                  << "num negative scores: " << stats.numNegativeScores << "\n"
                  << "percent similarity:  " << stats.alignmentSimilarity << "\n"
                  << "percent identity:    " << stats.alignmentIdentity << "\n\n\n";

        // Clip alignment rows and compute score of this view.
        setClippedEndPosition(row(align, 0), 100);
        setClippedEndPosition(row(align, 1), 100);
        setClippedBeginPosition(row(align, 0), 5);
        setClippedBeginPosition(row(align, 1), 5);

        computeAlignmentStats(stats, align, scoringScheme);
        std::cout << "Clipping alignment to (5, 100)\n"
                  << align
                  << "score:               " << stats.alignmentScore << "\n"
                  << "gap opens:           " << stats.numGapOpens << "\n"
                  << "gap extensions:      " << stats.numGapExtensions << "\n"
                  << "num insertions:      " << stats.numInsertions << "\n"
                  << "num deletions:       " << stats.numDeletions << "\n"
                  << "num matches:         " << stats.numMatches << "\n"
                  << "num mismatches:      " << stats.numMismatches << "\n"
                  << "num positive scores: " << stats.numPositiveScores << "\n"
                  << "num negative scores: " << stats.numNegativeScores << "\n"
                  << "percent similarity:  " << stats.alignmentSimilarity << "\n"
                  << "percent identity:    " << stats.alignmentIdentity << "\n";
        return 0;
    }

Demo: demos/dox/align/compute_alignment_stats.cpp

The output is as follows:

          0     .    :    .    :    .    :    .    :    .    :
            MGLSDGEWQLVLNVWGKVEADIPGHGQEVLIRLFKGHPETLEKFDKFKHL
            | |   |       | |        | | | |||  || |   |  |
            MSLTKTERTIIVSMWAKISTQADTIGTETLERLFLSHPQTKTYFPHF---

         50     .    :    .    :    .    :    .    :    .    :
            KSEDEMKASEDLKKHGATVLTALGGILKKKGHHEAEIKPLAQSHATKHKI
               |    |  |  ||  |  | |   |           |   ||
            ---DLHPGSAQLRAHGSKVVAAVGDAVKSIDDIGGALSKLSELHAYILRV

        100     .    :    .    :    .    :    .    :    .
            PVKYLEFISECIIQVLQSKHPGDFGADAQGAMNKALELFRKDMASNYK
                    | |    |    | || | |  |  | |    |     |
            DPVNFKLLSHCLLVTLAARFPADFTAEAHAAWDKFLSVTEK-----YR

    score:               159
    gap opens:           2
    gap extensions:      9
    num insertions:      11
    num deletions:       0
    num matches:         41
    num mismatches:      96
    num positive scores: 69
    num negative scores: 68
    percent similarity:  46.6216
    percent identity:    27.7027

    Clipping alignment to (5, 100)
          0     .    :    .    :    .    :    .    :    .    :
            GEWQLVLNVWGKVEADIPGHGQEVLIRLFKGHPETLEKFDKFKHLKSEDE
             |       | |        | | | |||  || |   |  |      |
            TERTIIVSMWAKISTQADTIGTETLERLFLSHPQTKTYFPHF------DL

         50     .    :    .    :    .    :    .    :    .
            MKASEDLKKHGATVLTALGGILKKKGHHEAEIKPLAQSHATKHKI
               |  |  ||  |  | |   |           |   ||
            HPGSAQLRAHGSKVVAAVGDAVKSIDDIGGALSKLSELHAYILRV

    score:               99
    gap opens:           1
    gap extensions:      5
    num insertions:      6
    num deletions:       0
    num matches:         26
    num mismatches:      63
    num positive scores: 43
    num negative scores: 46
    percent similarity:  45.2632
    percent identity:    27.3684

## Data Races

Thread safety unknown!

## See Also

- AlignmentStats

#### Dox Sources

    /*!
     * @fn computeAlignmentStats
     *
     * @headerfile <seqan/align.h>
     *
     * @brief Compute alignment statistics.
     *
     * @signature TScoreVal computeAlignmentStats(stats, align, scoringScheme);
     * @signature TScoreVal computeAlignmentStats(stats, row0, row1, scoringScheme);
     *
     * @param[out] stats The @link AlignmentStats @endlink object to store alignment
     *                   statistics in.
     * @param[in] align The @link Align @endlink object to score.
     * @param[in] row0 The first row (@link Gaps @endlink object).
     * @param[in] row1 The second row (@link Gaps @endlink object).
     * @param[in] score The @link Score @endlink object to use for the scoring
     *                  scheme.
     *
     * @return TScoreVal The score value of the alignment, of the same type as the
     *                   value type of <tt>scoringScheme</tt>
     *
     * @section Examples
     *
     * @include demos/dox/align/compute_alignment_stats.cpp
     *
     * The output is as follows:
     *
     * @include demos/dox/align/compute_alignment_stats.cpp.stdout
     *
     *
     *
     * @see AlignmentStats
     */