libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::specpeptidoms::Scenario Class Reference

#include <scenario.h>

Public Member Functions

 Scenario ()
 ~Scenario ()
void saveOrigin (std::size_t current_row, std::size_t current_column, std::size_t previous_row, std::size_t previous_column, int score, AlignType alignment_type)
 Stores the origin (cell location and alignment type) of the provided cell in the backtracking matrix.
void reserve (std::size_t n_rows, std::size_t n_columns)
 Allocate new storage to the backtracking matrix if needed.
std::pair< std::vector< ScenarioCell >, int > getBestAlignment () const
 Returns the scenario cells corresponding to the best alignment and the best alignment's score.
int getBestScore () const
void resetScenario ()
void clear ()

Private Attributes

std::vector< std::vector< ScenarioCell > > m_origin_matrix
std::pair< ScenarioCell, int > m_best_alignment = {{0, 0, AlignType::init}, -15}

Detailed Description

Definition at line 55 of file scenario.h.

Constructor & Destructor Documentation

◆ Scenario()

pappso::specpeptidoms::Scenario::Scenario ( )

Constructor

Definition at line 75 of file scenario.cpp.

76{
77}

◆ ~Scenario()

pappso::specpeptidoms::Scenario::~Scenario ( )

Destructor

Definition at line 79 of file scenario.cpp.

80{
81}

Member Function Documentation

◆ clear()

void pappso::specpeptidoms::Scenario::clear ( )

Definition at line 120 of file scenario.cpp.

121{
122 m_origin_matrix.clear();
123 m_best_alignment = {{0, 0, AlignType::init}, -15};
124}
std::pair< ScenarioCell, int > m_best_alignment
Definition scenario.h:98
std::vector< std::vector< ScenarioCell > > m_origin_matrix
Definition scenario.h:97

References pappso::specpeptidoms::init, m_best_alignment, and m_origin_matrix.

◆ getBestAlignment()

std::pair< std::vector< pappso::specpeptidoms::ScenarioCell >, int > pappso::specpeptidoms::Scenario::getBestAlignment ( ) const

Returns the scenario cells corresponding to the best alignment and the best alignment's score.

Definition at line 91 of file scenario.cpp.

92{
93 std::pair<std::vector<ScenarioCell>, int> best_alignment;
94 ScenarioCell current_cell = m_best_alignment.first;
95 current_cell.alignment_type = AlignType::init;
96 while(current_cell.previous_column > 0 && current_cell.previous_row > 0)
97 {
98 best_alignment.first.push_back(current_cell);
99 current_cell = m_origin_matrix.at(current_cell.previous_row).at(current_cell.previous_column);
100 }
101 best_alignment.first.push_back(current_cell);
102 best_alignment.second = m_best_alignment.second;
103 return best_alignment;
104}

References pappso::specpeptidoms::ScenarioCell::alignment_type, pappso::specpeptidoms::init, m_best_alignment, m_origin_matrix, pappso::specpeptidoms::ScenarioCell::previous_column, and pappso::specpeptidoms::ScenarioCell::previous_row.

◆ getBestScore()

int pappso::specpeptidoms::Scenario::getBestScore ( ) const

Definition at line 107 of file scenario.cpp.

108{
109 return m_best_alignment.second;
110}

References m_best_alignment.

◆ reserve()

void pappso::specpeptidoms::Scenario::reserve ( std::size_t n_rows,
std::size_t n_columns )

Allocate new storage to the backtracking matrix if needed.

Definition at line 84 of file scenario.cpp.

85{
86 m_origin_matrix = std::vector<std::vector<ScenarioCell>>(
87 n_rows, std::vector<ScenarioCell>(n_columns, {0, 0, AlignType::init}));
88}

References pappso::specpeptidoms::init, and m_origin_matrix.

◆ resetScenario()

void pappso::specpeptidoms::Scenario::resetScenario ( )

Definition at line 113 of file scenario.cpp.

114{
115 // m_origin_matrix.clear();
116 m_best_alignment = {{0, 0, AlignType::init}, -15};
117}

References pappso::specpeptidoms::init, and m_best_alignment.

◆ saveOrigin()

void pappso::specpeptidoms::Scenario::saveOrigin ( std::size_t current_row,
std::size_t current_column,
std::size_t previous_row,
std::size_t previous_column,
int score,
AlignType alignment_type )

Stores the origin (cell location and alignment type) of the provided cell in the backtracking matrix.

Definition at line 42 of file scenario.cpp.

48{
49 if(score > m_best_alignment.second)
50 {
51 m_best_alignment = {{current_row, current_column, alignment_type}, score};
52 }
53 try
54 {
55 m_origin_matrix.at(current_row).at(current_column) = {
56 previous_row, previous_column, alignment_type};
57 }
58 catch(const std::exception &error)
59 {
60 int max_column_size = 0;
61 if(current_row < m_origin_matrix.size())
62 {
63 max_column_size = m_origin_matrix.at(current_row).size();
64 }
65 throw pappso::ExceptionOutOfRange(
66 QObject::tr(
67 "Scenario::saveOrigin failed for current_row %1 (size %2) current_column %3 (size %4)")
68 .arg(current_row)
69 .arg(m_origin_matrix.size())
70 .arg(current_column)
71 .arg(max_column_size));
72 }
73}

References m_best_alignment, and m_origin_matrix.

Member Data Documentation

◆ m_best_alignment

std::pair<ScenarioCell, int> pappso::specpeptidoms::Scenario::m_best_alignment = {{0, 0, AlignType::init}, -15}
private

Definition at line 98 of file scenario.h.

98{{0, 0, AlignType::init}, -15};

Referenced by clear(), getBestAlignment(), getBestScore(), resetScenario(), and saveOrigin().

◆ m_origin_matrix

std::vector<std::vector<ScenarioCell> > pappso::specpeptidoms::Scenario::m_origin_matrix
private

Definition at line 97 of file scenario.h.

Referenced by clear(), getBestAlignment(), reserve(), and saveOrigin().


The documentation for this class was generated from the following files: