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>

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;
    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 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);

    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 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;
}

The output is as follows:

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

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

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


gap opens:           2
gap extensions:      9
num insertions:      11
num deletions:       0
num matches:         41
num mismatches:      96
num positive scores: 91
num negative scores: 46
percent similarity:  61.4865
percent identity:    27.7027


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

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


gap opens:           1
gap extensions:      5
num insertions:      6
num deletions:       0
num matches:         26
num mismatches:      63
num positive scores: 55
num negative scores: 34
percent similarity:  57.8947
percent identity:    27.3684

See Also