File: compute_alignment_stats.cpp

package info (click to toggle)
seqan2 2.4.0%2Bdfsg-16
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 224,180 kB
  • sloc: cpp: 256,886; ansic: 91,672; python: 8,330; sh: 995; xml: 570; makefile: 252; awk: 51; javascript: 21
file content (65 lines) | stat: -rw-r--r-- 2,945 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#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;
}