File: TestScoreMatrixSerialization.cpp

package info (click to toggle)
mmseqs2 12-113e3%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 25,760 kB
  • sloc: cpp: 67,306; ansic: 6,279; sh: 2,425; makefile: 94; perl: 32
file content (30 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download
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
#include "ExtendedSubstitutionMatrix.h"
#include "SubstitutionMatrix.h"
#include "ScoreMatrix.h"
#include "Parameters.h"
#include "Debug.h"

const char* binary_name = "test_scorematrixserialization";

int main (int, const char**) {
    Parameters& par = Parameters::getInstance();
    SubstitutionMatrix subMat(par.scoringMatrixFile.aminoacids, 8.0, 0);
    ScoreMatrix extMattwo = ExtendedSubstitutionMatrix::calcScoreMatrix(subMat, 2);

    Debug(Debug::INFO) << extMattwo.elementSize << " " << extMattwo.rowSize  << " "
                       << extMattwo.score[0]    << " " << extMattwo.index[0] << "\n";

    char* serialized = ScoreMatrix::serialize(extMattwo);
    ExtendedSubstitutionMatrix::freeScoreMatrix(extMattwo);

    ScoreMatrix unserialized = ScoreMatrix::unserialize(serialized, subMat.alphabetSize, 2);
    Debug(Debug::INFO) << unserialized.elementSize << " " << unserialized.rowSize  << " "
                       << unserialized.score[0]    << "\n";
    free(serialized);

    free(extMattwo);
    // Why not use an operator. Will free & destruct & will not SIGSEGV
    delete(unserialized);

    return EXIT_SUCCESS;
}