ProteoWizard
Public Member Functions | Protected Member Functions | List of all members
DemuxSolverTest Class Reference

Public Member Functions

void Run ()
 

Protected Member Functions

virtual void SetUp ()
 
void TearDown ()
 
void NNLSSolverTest ()
 
void TestNNLSGivenSolution (const vector< double > &expectedSolution, double trailingWindowIntensity)
 

Detailed Description

Definition at line 28 of file DemuxSolverTest.cpp.

Member Function Documentation

◆ Run()

void DemuxSolverTest::Run ( )
inline

Definition at line 30 of file DemuxSolverTest.cpp.

31 {
32 SetUp();
34 TearDown();
35 }
virtual void SetUp()

References NNLSSolverTest(), SetUp(), and TearDown().

Referenced by main().

◆ SetUp()

virtual void DemuxSolverTest::SetUp ( )
inlineprotectedvirtual

Definition at line 39 of file DemuxSolverTest.cpp.

40 {
41 }

Referenced by Run().

◆ TearDown()

void DemuxSolverTest::TearDown ( )
inlineprotected

Definition at line 43 of file DemuxSolverTest.cpp.

44 {
45 }

Referenced by Run().

◆ NNLSSolverTest()

void DemuxSolverTest::NNLSSolverTest ( )
inlineprotected

Definition at line 47 of file DemuxSolverTest.cpp.

48 {
49 // Assume an expected solution
50 vector<double> expectedSolution = {
51 0.0,
52 0.0,
53 0.0,
54 11.0,
55 13.0,
56 0.0,
57 0.0
58 };
59
60 // Assume that the trailing precursor window that is only half represented has no spectral contribution from the unseen portion
61 double trailingWindowIntensity = 0.0;
62
63 TestNNLSGivenSolution(expectedSolution, trailingWindowIntensity);
64
65 // Try a more dense solution
66 expectedSolution = {
67 5.0,
68 3.0,
69 2.0,
70 11.0,
71 13.0,
72 9.0,
73 3.0
74 };
75
76 TestNNLSGivenSolution(expectedSolution, trailingWindowIntensity);
77 }
void TestNNLSGivenSolution(const vector< double > &expectedSolution, double trailingWindowIntensity)

References TestNNLSGivenSolution().

Referenced by Run().

◆ TestNNLSGivenSolution()

void DemuxSolverTest::TestNNLSGivenSolution ( const vector< double > &  expectedSolution,
double  trailingWindowIntensity 
)
inlineprotected

Definition at line 79 of file DemuxSolverTest.cpp.

80 {
81 NNLSSolver solver;
82 MatrixPtr signal;
83 MatrixPtr masks;
84 MatrixPtr solution;
85 int numSpectra = 7;
86 int numDemuxWindows = 7;
87 int numTransitions = 1;
88 signal.reset(new MatrixType(numSpectra, numTransitions));
89 masks.reset(new MatrixType(numSpectra, numDemuxWindows));
90 solution.reset(new MatrixType(numDemuxWindows, numTransitions));
91
92 /*
93 * Create mask matrix of the form
94 * 1 1 0 0 0 0 0 \ \00000
95 * 0 1 1 0 0 0 0 0\ \0000
96 * 0 0 1 1 0 0 0 00\ \000
97 * 0 0 0 1 1 0 0 000\ \00
98 * 0 0 0 0 1 1 0 0000\ \0
99 * 0 0 0 0 0 1 1 00000\ j = i + 1
100 * 0 0 0 0 0 0 1 000000j = i
101 *
102 * This mask matrix is used in overlap demultiplexing
103 */
104 for (int i = 0; i < numSpectra; ++i)
105 {
106 for (int j = 0; j < numDemuxWindows; ++j)
107 {
108 if (j == i || j == i + 1)
109 {
110 masks->row(i)[j] = 1.0;
111 }
112 else
113 {
114 masks->row(i)[j] = 0.0;
115 }
116 }
117 }
118
119 // Create a multiplexed signal from the expected solution
120 vector<double> signalVec;
121 for (int i = 0; i < numSpectra; ++i)
122 {
123 double signalSum = expectedSolution[i];
124 if (i + 1 < numSpectra)
125 signalSum += expectedSolution[i + 1];
126 else
127 signalSum += trailingWindowIntensity;
128 signalVec.push_back(signalSum);
129 }
130 for (size_t i = 0; i < signalVec.size(); ++i)
131 {
132 signal->row(i)[0] = signalVec[i];
133 }
134
135 solver.Solve(masks, signal, solution);
136
137 // Verify result
138 for (size_t i = 0; i < expectedSolution.size(); ++i)
139 {
140 unit_assert_equal(expectedSolution[i], solution->row(i)[0], 0.0001);
141 }
142 }
Implementation of the DemuxSolver interface as a non-negative least squares (NNLS) problem.
void Solve(const MatrixPtr &masks, const MatrixPtr &signal, MatrixPtr &solution) override
Implementation of DemuxSolver interface.
boost::shared_ptr< MatrixType > MatrixPtr
Matrix< DemuxScalar, Dynamic, Dynamic > MatrixType
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99

References pwiz::analysis::NNLSSolver::Solve(), and unit_assert_equal.

Referenced by NNLSSolverTest().


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