Skip to content

Latest commit

 

History

History
73 lines (45 loc) · 2.28 KB

WorkWithCustomScoreMatrices.rst

File metadata and controls

73 lines (45 loc) · 2.28 KB

ToC

Working With Custom Score Matrices

This How To describes how to create new scoring matrices for Amino Acids and DNA alphabets and how to load score matrices from files.

Creating A New Built-In Score Matrix

The following program demonstrates how to implement a new built-in score matrix.

demos/howto/scores/init_score.cpp

We need to perform the necessary definitions for the matrix. This consists of two steps:

  1. Defining a tag struct.
  2. Specializing the class ScoringMatrixData_ with your tag.

Note how we use enum values to compute the matrix size which itself is retrieved from the FiniteOrderedAlphabetConcept#ValueSize metafunction.

demos/howto/scores/init_score.cpp

Now we define a function showScoringMatrix for displaying a matrix.

demos/howto/scores/init_score.cpp

Finally, the main function demostrates some of the things you can do with scores:

  • Construct an empty score matrix object (2.)
  • Fill the score matrix in a loop (3.1)
  • Fill the matrix with the user-defined matrix values (3.2)
  • Directly create a score matrix with the user-defined matrix values (4)

demos/howto/scores/init_score.cpp

Here is the output of the program:

demos/howto/scores/init_score.cpp.stdout

Loading Score Matrices From File

This small demo program shows how to load a score matrix from a file. Examples for a score file are demos/howto/scores/dna_example.txt for DNA alphabets and tests/sPAM250 for amino acids.

Include the necessary headers.

demos/howto/scores/load_score.cpp

We define a function that can show a scoring matrix.

demos/howto/scores/load_score.cpp

Finally, the main program loads the scoring matrix and then shows it.

demos/howto/scores/load_score.cpp

Here's the program output.

demos/howto/scores/load_score.cpp.stdout