fn() computeAlignmentStats
Compute alignment statistics.

Defined in <seqan/align.h>
Signature TScoreVal computeAlignmentStats([stats, ]align, scoringScheme);

Parameters

stats The AlignmentStats object to store alignment statistics in.
align The Align object to score.
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>

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

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

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

    // Compute the statistics of the alignment.
    seqan::AlignmentStats stats;
    int scoreVal = computeAlignmentStats(stats, align, scoringScheme);
    SEQAN_ASSERT_EQ(scoreVal, stats.alignmentScore);
    std::cout << align
              << "gap opens:           " << stats.numGapOpens << "\n"
              << "gap extensions:      " << stats.numGapExtensions << "\n"
              << "num matches:         " << stats.numMatches << "\n"
              << "num mismatches:      " << stats.numMismatches << "\n"
              << "num positive scores: " << stats.numPositiveScores << "\n"
              << "num negative scores: " << stats.numNegativeScores << "\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);

    scoreVal = computeAlignmentStats(stats, align, scoringScheme);
    SEQAN_ASSERT_EQ(scoreVal, stats.alignmentScore);
    std::cout << "Clipping alignment to (5, 100)\n"
              << align
              << "gap opens:           " << stats.numGapOpens << "\n"
              << "gap extensions:      " << stats.numGapExtensions << "\n"
              << "num matches:         " << stats.numMatches << "\n"
              << "num mismatches:      " << stats.numMismatches << "\n"
              << "num positive scores: " << stats.numPositiveScores << "\n"
              << "num negative scores: " << stats.numNegativeScores << "\n";

    return 0;
}

The output is as follows:

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

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

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


gap opens:           2
gap extensions:      9
num matches:         41
num mismatches:      96
num positive scores: 91
num negative scores: 46


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

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


gap opens:           1
gap extensions:      5
num matches:         26
num mismatches:      63
num positive scores: 55
num negative scores: 34

See Also