SS DFStatement::buildSS( const StringList &inVarNameList, const DoubleList &inCoefList, const StringList &outVarNameList, const DoubleList &outCoefList ) { // // FIRST, BUILD THE FILTER EQUATION // StringList::const_iterator inVarNameItr = inVarNameList.begin(); DoubleList::const_iterator inCoefItr = inCoefList.begin(); StringList::const_iterator outVarNameItr = outVarNameList.begin(); DoubleList::const_iterator outCoefItr = outCoefList.begin(); BE be( 0, "+", BE( *inCoefItr, "*", *inVarNameItr ) ); while( ++inVarNameItr != inVarNameList.end() ) { (void)++inCoefItr; be = BE( be, "+", BE( *inCoefItr, "*", *inVarNameItr ) ); } while( ++outVarNameItr != outVarNameList.end() ) { (void)++outCoefItr; be = BE( be, "-", BE( *outCoefItr, "*", *outVarNameItr ) ); } be = BE( be, "/", outCoefList.front() ); be = BE( outVarNameList.front(), "=", be ); // // SHIFT THE VARIABLES // SS ss( IE( 1 ), be ); (void)--inVarNameItr; while( inVarNameItr != inVarNameList.begin() ) { StringList::const_iterator nxtInVarNameItr = inVarNameItr; (void)--nxtInVarNameItr; ss = SS( ss, BE( *inVarNameItr, "=", *nxtInVarNameItr ) ); inVarNameItr = nxtInVarNameItr; } (void)--outVarNameItr; while( outVarNameItr != outVarNameList.begin() ) { StringList::const_iterator nxtOutVarNameItr = outVarNameItr; (void)--nxtOutVarNameItr; ss = SS( ss, BE( *outVarNameItr, "=", *nxtOutVarNameItr ) ); outVarNameItr = nxtOutVarNameItr; } return ss; }
void ProteinResolver::computeIntensityOfMSD_(vector<MSDGroup> & msd_groups) { // iteriert ueber alles msd gruppe for (vector<MSDGroup>::iterator group = msd_groups.begin(); group != msd_groups.end(); ++group) { DoubleList intensities; // iterierere ueber peptide entry (peptide identification), intensitaet (summe der einzelintensitaeten) for (list<PeptideEntry *>::iterator pep = group->peptides.begin(); pep != group->peptides.end(); ++pep) { intensities.push_back((*pep)->intensity); } // median von der list ist itensity der msd group group->intensity = Math::median(intensities.begin(), intensities.end()); } }
///////////////////////////////////////////////////////////// START_TEST( StatisticFunctions, "$Id$" ); ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// START_SECTION([EXTRA](template <typename IteratorType> static DoubleReal sum(IteratorType begin, IteratorType end))) { int x[] = {-1, 0, 1, 2, 3}; TEST_EQUAL(int(Math::sum(x, x + 5)), 5); TEST_EQUAL(int(Math::sum(x, x)), 0); DoubleList y; y << -1.0 << -0.5 << 0.0 << 0.5 << 1.0 << 1.5 << 2.0; TEST_REAL_SIMILAR(Math::sum(y.begin(), y.end()), 3.5); } END_SECTION START_SECTION([EXTRA](template <typename IteratorType> static DoubleReal mean(IteratorType begin, IteratorType end))) { int x[] = {-1, 0, 1, 2, 3}; TEST_EQUAL(Math::mean(x, x + 5), 1); TEST_EXCEPTION(Exception::InvalidRange, Math::mean(x, x)); DoubleList y; y << -1.0 << -0.5 << 0.0 << 0.5 << 1.0 << 1.5 << 2.0; TEST_REAL_SIMILAR(Math::mean(y.begin(), y.end()), 0.5); } END_SECTION