CoolFace
Datasetpublic

GSaha567/seq_level_training_data

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes52downloads
shard_000068.csv83656 linesDownload Raw Back to root
1text,length,is_long_context,metric_val,label_metric2"// --------------------------------------------------------------------------3//                   OpenMS -- Open-Source Mass Spectrometry4// --------------------------------------------------------------------------5// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,6// ETH Zurich, and Freie Universitaet Berlin 2002-2021.7//8// This software is released under a three-clause BSD license:9//  * Redistributions of source code must retain the above copyright10//    notice, this list of conditions and the following disclaimer.11//  * Redistributions in binary form must reproduce the above copyright12//    notice, this list of conditions and the following disclaimer in the13//    documentation and/or other materials provided with the distribution.14//  * Neither the name of any author or any participating institution15//    may be used to endorse or promote products derived from this software16//    without specific prior written permission.17// For a full list of authors, refer to the file AUTHORS.18// --------------------------------------------------------------------------19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""20// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING23// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;26// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,27// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR28// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF29// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30//31// --------------------------------------------------------------------------32// $Maintainer: Douglas McCloskey, Pasquale Domenico Colaianni $33// $Authors: Douglas McCloskey, Pasquale Domenico Colaianni $34// --------------------------------------------------------------------------35 36#include <OpenMS/CONCEPT/ClassTest.h>37#include <OpenMS/test_config.h>38 39///////////////////////////40#include <OpenMS/ANALYSIS/OPENSWATH/PeakIntegrator.h>41///////////////////////////42 43using namespace OpenMS;44using namespace std;45 46class PeakIntegratorTest : PeakIntegrator47{48  public:49  // make protected member public50  template <typename PeakContainerConstIteratorT>51  double findPosAtPeakHeightPercent(52      PeakContainerConstIteratorT it_left,  // must not be past the end53      PeakContainerConstIteratorT it_right, // might be past the end54      PeakContainerConstIteratorT it_end,   // definitely past-the-end55      const double peak_height,56      const double percent,57      const bool is_left_half)58    {59      return findPosAtPeakHeightPercent_(it_left, it_right, it_end, peak_height, percent, is_left_half);60    }61};62 63START_TEST(PeakIntegrator, ""$Id$"")64 65/////////////////////////////////////////////////////////////66/////////////////////////////////////////////////////////////67 68PeakIntegrator* ptr = 0;69PeakIntegrator* null_ptr = 0;70 71const double left = 2.472833334;72const double right = 3.022891666;73 74// Toy chromatogram75// data is taken from raw LC-MS/MS data points acquired for L-Glutamate in RBCs76const vector<double> position = {77  2.23095,2.239716667,2.248866667,2.25765,2.266416667,78  2.275566667,2.2847,2.293833333,2.304066667,2.315033333,2.325983333,2.336566667,79  2.3468,2.357016667,2.367283333,2.377183333,2.387083333,2.39735,2.40725,2.4175,80  2.4274,2.4373,2.44755,2.45745,2.4677,2.477966667,2.488216667,2.498516667,2.5084,81  2.5183,2.5282,2.538466667,2.548366667,2.558266667,2.568516667,2.578783333,82  2.588683333,2.59895,2.6092,2.619466667,2.630066667,2.64065,2.65125,2.662116667,83  2.672716667,2.6833,2.6939,2.7045,2.715083333,2.725683333,2.736266667,2.746866667,84  2.757833333,2.768416667,2.779016667,2.789616667,2.8002,2.810116667,2.820033333,85  2.830316667,2.840216667,2.849766667,2.859316667,2.868866667,2.878783333,2.888683333,86  2.898233333,2.907783333,2.916033333,2.924266667,2.93215,2.940383333,2.947933333,87  2.955816667,2.964066667,2.97195,2.979833333,2.987716667,2.995616667,3.003516667,88  3.011416667,3.01895,3.026833333,3.034366667,3.042266667,3.0498,3.05735,3.065233333,89  3.073133333,3.080666667,3.0882,3.095733333,3.103633333,3.111533333,3.119066667,90  3.126966667,3.134866667,3.14275,3.15065,3.15855,3.166433333,3.174333333,3.182233333,91  3.190133333,3.198016667,3.205916667,3.21316666792};93 94const vector<double> position_2 = {95  2270.93, 2272.86, 2273.1696};97 98const vector<double> intensity = {99  1447,2139,1699,755,1258,1070,944,1258,1573,1636,100  1762,1447,1133,1321,1762,1133,1447,2391,692,1636,2957,1321,1573,1196,1258,881,101  1384,2076,1133,1699,1384,692,1636,1133,1573,1825,1510,2391,4342,10382,17618,102  51093,153970,368094,632114,869730,962547,966489,845055,558746,417676,270942,103  184865,101619,59776,44863,31587,24036,20450,20324,11074,9879,10508,7928,7110,104  6733,6481,5726,6921,6670,5537,4971,4719,4782,5097,5789,4279,5411,4530,3524,105  2139,3335,3083,4342,4279,3083,3649,4216,4216,3964,2957,2202,2391,2643,3524,106  2328,2202,3649,2706,3020,3335,2580,2328,2894,3146,2769,2517107};108 109const vector<double> intensity_2 = {110  410430.0, 166125.0, 896669.0111};112 113const double left_past_5 = position[41];   // 2.64065114const double left_past_10 = position[42];  // 2.65125115const double left_past_50 = position[44];  // 2.672716667116const double right_past_5 = position[54];  // 2.779016667117const double right_past_10 = position[53]; // 2.768416667118const double right_past_50 = position[49]; // 2.725683333119const double left_few = position[46];      // 2.6939120const double right_few = position[48];     // 2.715083333121 122MSChromatogram chromatogram;123MSSpectrum spectrum;124for (Size i = 0; i < position.size(); ++i)125{126  chromatogram.push_back(ChromatogramPeak(position[i], intensity[i]));127  spectrum.push_back(Peak1D(position[i], intensity[i]));128}129 130MSChromatogram chromatogram_2;131MSSpectrum spectrum_2;132for (Size i = 0; i < position_2.size(); ++i)133{134  chromatogram_2.push_back(ChromatogramPeak(position_2[i], intensity_2[i]));135  spectrum_2.push_back(Peak1D(position_2[i], intensity_2[i]));136}137 138MSChromatogram::ConstIterator chrom_left_it = chromatogram.RTBegin(left);139MSChromatogram::ConstIterator chrom_right_it = chromatogram.RTEnd(right) - 1;140MSChromatogram::ConstIterator chrom_right_1pt_it = chromatogram.RTEnd(2.477966667) - 1;141MSChromatogram::ConstIterator chrom_right_2pt_it = chromatogram.RTEnd(2.488216667) - 1;142MSSpectrum::ConstIterator spec_left_it = spectrum.MZBegin(left);143MSSpectrum::ConstIterator spec_right_it = spectrum.MZEnd(right) - 1;144MSSpectrum::ConstIterator spec_right_1pt_it = spectrum.MZEnd(2.477966667) - 1;145MSSpectrum::ConstIterator spec_right_2pt_it = spectrum.MZEnd(2.488216667) - 1;146 147// To test a chromatogram with missing (5,10,50)% peak's height points148MSChromatogram::ConstIterator chrom_left_past_5_it = chromatogram.RTBegin(left_past_5);149MSChromatogram::ConstIterator chrom_right_past_5_it = chromatogram.RTEnd(right_past_5) - 1;150MSChromatogram::ConstIterator chrom_left_past_10_it = chromatogram.RTBegin(left_past_10);151MSChromatogram::ConstIterator chrom_right_past_10_it = chromatogram.RTEnd(right_past_10) - 1;152MSChromatogram::ConstIterator chrom_left_past_50_it = chromatogram.RTBegin(left_past_50);153MSChromatogram::ConstIterator chrom_right_past_50_it = chromatogram.RTEnd(right_past_50) - 1;154 155// To test a spectrum with missing (5,10,50)% peak's height points156MSSpectrum::ConstIterator spec_left_past_5_it = spectrum.MZBegin(left_past_5);157MSSpectrum::ConstIterator spec_right_past_5_it = spectrum.MZEnd(right_past_5) - 1;158MSSpectrum::ConstIterator spec_left_past_10_it = spectrum.MZBegin(left_past_10);159MSSpectrum::ConstIterator spec_right_past_10_it = spectrum.MZEnd(right_past_10) - 1;160MSSpectrum::ConstIterator spec_left_past_50_it = spectrum.MZBegin(left_past_50);161MSSpectrum::ConstIterator spec_right_past_50_it = spectrum.MZEnd(right_past_50) - 1;162 163// To test a chromatogram (and a spectrum) with few points (3 points, in this case)164MSChromatogram::ConstIterator chrom_left_few_it = chromatogram.RTBegin(left_few);165MSChromatogram::ConstIterator chrom_right_few_it = chromatogram.RTEnd(right_few) - 1;166MSSpectrum::ConstIterator spec_left_few_it = spectrum.MZBegin(left_few);167MSSpectrum::ConstIterator spec_right_few_it = spectrum.MZEnd(right_few) - 1;168 169constexpr const char* INTEGRATION_TYPE_INTENSITYSUM = ""intensity_sum"";170constexpr const char* INTEGRATION_TYPE_TRAPEZOID = ""trapezoid"";171constexpr const char* INTEGRATION_TYPE_SIMPSON = ""simpson"";172constexpr const char* BASELINE_TYPE_BASETOBASE = ""base_to_base"";173constexpr const char* BASELINE_TYPE_VERTICALDIVISION_MIN = ""vertical_division_min"";174constexpr const char* BASELINE_TYPE_VERTICALDIVISION_MAX = ""vertical_division_max"";175 176 177START_SECTION(PeakIntegrator())178{179  ptr = new PeakIntegrator();180  TEST_NOT_EQUAL(ptr, null_ptr)181}182END_SECTION183 184START_SECTION(~PeakIntegrator())185{186  delete ptr;187}188END_SECTION189 190ptr = new PeakIntegrator();191 192START_SECTION(getParameters())193{194  Param params = ptr->getParameters();195  TEST_EQUAL(params.getValue(""integration_type""), INTEGRATION_TYPE_INTENSITYSUM)196  TEST_EQUAL(params.getValue(""baseline_type""), BASELINE_TYPE_BASETOBASE)197}198END_SECTION199 200START_SECTION(PeakBackground estimateBackground(201  const MSChromatogram& chromatogram, const double left, const double right,202  const double peak_apex_pos203) const)204{205  Param params = ptr->getParameters();206  PeakIntegrator::PeakArea pa;207  PeakIntegrator::PeakBackground pb;208 209  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);210  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);211  ptr->setParameters(params);212  pa = ptr->integratePeak(chromatogram, left, right);213  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);214  TEST_REAL_SIMILAR(pb.area, 123446.661339019)215  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)216 217  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);218  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);219  ptr->setParameters(params);220  pa = ptr->integratePeak(chromatogram, left, right);221  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);222  TEST_REAL_SIMILAR(pb.area, 50217)223  TEST_REAL_SIMILAR(pb.height, 881)224 225  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);226  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);227  ptr->setParameters(params);228  pa = ptr->integratePeak(chromatogram, left, right);229  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);230  TEST_REAL_SIMILAR(pb.area, 190095)231  TEST_REAL_SIMILAR(pb.height, 3335)232 233  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);234  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);235  ptr->setParameters(params);236  pa = ptr->integratePeak(chromatogram, left, right);237  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);238  TEST_REAL_SIMILAR(pb.area, 1140.392865964)239  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)240 241  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);242  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);243  ptr->setParameters(params);244  pa = ptr->integratePeak(chromatogram, left, right);245  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);246  TEST_REAL_SIMILAR(pb.area, 476.606316373)247  TEST_REAL_SIMILAR(pb.height, 881)248 249  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);250  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);251  ptr->setParameters(params);252  pa = ptr->integratePeak(chromatogram, left, right);253  pb = ptr->estimateBackground(chromatogram, left, right, pa.apex_pos);254  TEST_REAL_SIMILAR(pb.area, 1804.179415555)255  TEST_REAL_SIMILAR(pb.height, 3335)256}257END_SECTION258 259START_SECTION(PeakBackground estimateBackground(260  const MSChromatogram& chromatogram, MSChromatogram::ConstIterator& left, MSChromatogram::ConstIterator& right,261  const double peak_apex_pos262) const)263{264  Param params = ptr->getParameters();265  PeakIntegrator::PeakArea pa;266  PeakIntegrator::PeakBackground pb;267 268  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);269  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);270  ptr->setParameters(params);271  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);272  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);273  TEST_REAL_SIMILAR(pb.area, 123446.661339019)274  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)275 276  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);277  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);278  ptr->setParameters(params);279  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);280  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);281  TEST_REAL_SIMILAR(pb.area, 50217)282  TEST_REAL_SIMILAR(pb.height, 881)283 284  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);285  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);286  ptr->setParameters(params);287  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);288  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);289  TEST_REAL_SIMILAR(pb.area, 190095)290  TEST_REAL_SIMILAR(pb.height, 3335)291 292  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);293  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);294  ptr->setParameters(params);295  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);296  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);297  TEST_REAL_SIMILAR(pb.area, 1140.392865964)298  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)299 300  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);301  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);302  ptr->setParameters(params);303  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);304  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);305  TEST_REAL_SIMILAR(pb.area, 476.606316373)306  TEST_REAL_SIMILAR(pb.height, 881)307 308  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);309  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);310  ptr->setParameters(params);311  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);312  pb = ptr->estimateBackground(chromatogram, chrom_left_it, chrom_right_it, pa.apex_pos);313  TEST_REAL_SIMILAR(pb.area, 1804.179415555)314  TEST_REAL_SIMILAR(pb.height, 3335)315}316END_SECTION317 318START_SECTION(PeakBackground estimateBackground(319  const MSSpectrum& spectrum, const double left, const double right,320  const double peak_apex_pos321) const)322{323  Param params = ptr->getParameters();324  PeakIntegrator::PeakArea pa;325  PeakIntegrator::PeakBackground pb;326 327  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);328  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);329  ptr->setParameters(params);330  pa = ptr->integratePeak(spectrum, left, right);331  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);332  TEST_REAL_SIMILAR(pb.area, 123446.661339019)333  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)334 335  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);336  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);337  ptr->setParameters(params);338  pa = ptr->integratePeak(spectrum, left, right);339  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);340  TEST_REAL_SIMILAR(pb.area, 50217)341  TEST_REAL_SIMILAR(pb.height, 881)342 343  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);344  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);345  ptr->setParameters(params);346  pa = ptr->integratePeak(spectrum, left, right);347  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);348  TEST_REAL_SIMILAR(pb.area, 190095)349  TEST_REAL_SIMILAR(pb.height, 3335)350 351  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);352  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);353  ptr->setParameters(params);354  pa = ptr->integratePeak(spectrum, left, right);355  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);356  TEST_REAL_SIMILAR(pb.area, 1140.392865964)357  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)358 359  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);360  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);361  ptr->setParameters(params);362  pa = ptr->integratePeak(spectrum, left, right);363  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);364  TEST_REAL_SIMILAR(pb.area, 476.606316373)365  TEST_REAL_SIMILAR(pb.height, 881)366 367  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);368  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);369  ptr->setParameters(params);370  pa = ptr->integratePeak(spectrum, left, right);371  pb = ptr->estimateBackground(spectrum, left, right, pa.apex_pos);372  TEST_REAL_SIMILAR(pb.area, 1804.179415555)373  TEST_REAL_SIMILAR(pb.height, 3335)374}375END_SECTION376 377START_SECTION(PeakBackground estimateBackground(378  const MSSpectrum& spectrum, MSSpectrum::ConstIterator& left, MSSpectrum::ConstIterator& right,379  const double peak_apex_pos380) const)381{382  Param params = ptr->getParameters();383  PeakIntegrator::PeakArea pa;384  PeakIntegrator::PeakBackground pb;385 386  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);387  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);388  ptr->setParameters(params);389  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);390  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);391  TEST_REAL_SIMILAR(pb.area, 123446.661339019)392  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)393 394  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);395  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);396  ptr->setParameters(params);397  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);398  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);399  TEST_REAL_SIMILAR(pb.area, 50217)400  TEST_REAL_SIMILAR(pb.height, 881)401 402  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);403  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);404  ptr->setParameters(params);405  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);406  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);407  TEST_REAL_SIMILAR(pb.area, 190095)408  TEST_REAL_SIMILAR(pb.height, 3335)409 410  params.setValue(""baseline_type"", BASELINE_TYPE_BASETOBASE);411  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);412  ptr->setParameters(params);413  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);414  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);415  TEST_REAL_SIMILAR(pb.area, 1140.392865964)416  TEST_REAL_SIMILAR(pb.height, 1908.59690598823)417 418  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MIN);419  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);420  ptr->setParameters(params);421  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);422  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);423  TEST_REAL_SIMILAR(pb.area, 476.606316373)424  TEST_REAL_SIMILAR(pb.height, 881)425 426  params.setValue(""baseline_type"", BASELINE_TYPE_VERTICALDIVISION_MAX);427  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);428  ptr->setParameters(params);429  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);430  pb = ptr->estimateBackground(spectrum, spec_left_it, spec_right_it, pa.apex_pos);431  TEST_REAL_SIMILAR(pb.area, 1804.179415555)432  TEST_REAL_SIMILAR(pb.height, 3335)433}434END_SECTION435 436START_SECTION(PeakArea integratePeak(437  const MSChromatogram& chromatogram, const double left, const double right438) const)439{440  Param params = ptr->getParameters();441  PeakIntegrator::PeakArea pa;442 443  params.setValue(""integration_type"", INTEGRATION_TYPE_SIMPSON);444  ptr->setParameters(params);445  STATUS(""Integration type: simpson"")446  447  pa = ptr->integratePeak(chromatogram_2, 2270.93, 2273.16);448  TEST_REAL_SIMILAR(pa.area, -665788.77663627)    // TO DO: Simpson rule results in negative area for strictly positive input.449}450END_SECTION451 452START_SECTION(PeakArea integratePeak(453  const MSChromatogram& chromatogram, const double left, const double right454) const)455{456  Param params = ptr->getParameters();457  PeakIntegrator::PeakArea pa;458  MSChromatogram::ConstIterator it;459 460  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);461  ptr->setParameters(params);462  STATUS(""Integration type: intensity_sum"")463  pa = ptr->integratePeak(chromatogram, left, right);464  TEST_REAL_SIMILAR(pa.area, 6768778)465  TEST_REAL_SIMILAR(pa.height, 966489.0)466  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)467  it = chromatogram.RTBegin(left);468  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)469  {470    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())471    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())472  }473 474  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);475  ptr->setParameters(params);476  STATUS(""Integration type: trapezoid"")477  pa = ptr->integratePeak(chromatogram, left, right);478  TEST_REAL_SIMILAR(pa.area, 71540.2)479  TEST_REAL_SIMILAR(pa.height, 966489.0)480  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)481  it = chromatogram.RTBegin(left);482  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)483  {484    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())485    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())486  }487 488  STATUS(""Integration type: trapezoid (1 point)"")489  pa = ptr->integratePeak(chromatogram, left, 2.478);490  TEST_REAL_SIMILAR(pa.area, 0.0)491  TEST_REAL_SIMILAR(pa.height, 881.0)492  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)493 494  params.setValue(""integration_type"", INTEGRATION_TYPE_SIMPSON);495  ptr->setParameters(params);496  STATUS(""Integration type: simpson (ODD number of points)"")497  pa = ptr->integratePeak(chromatogram, left, right);498  TEST_REAL_SIMILAR(pa.area, 71720.443144994)499  TEST_REAL_SIMILAR(pa.height, 966489.0)500  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)501  it = chromatogram.RTBegin(left);502  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)503  {504    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())505    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())506  }507  STATUS(""Integration type: simpson (EVEN number of points)"")508  pa = ptr->integratePeak(chromatogram, left, 3.011416667); // a lower value of ""right"" is passed, to have 1 less point509  TEST_REAL_SIMILAR(pa.area, 71515.0792609335)510  TEST_REAL_SIMILAR(pa.height, 966489.0)511  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)512  it = chromatogram.RTBegin(left);513  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)514  {515    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())516    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())517  }518 519  STATUS(""Integration type: simpson (1 point)"")520  pa = ptr->integratePeak(chromatogram, left, 2.478);521  TEST_REAL_SIMILAR(pa.area, 0.0)522  TEST_REAL_SIMILAR(pa.height, 881.0)523  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)524 525  STATUS(""Integration type: simpson (2 points)"")526  pa = ptr->integratePeak(chromatogram, left, 2.489);527  TEST_REAL_SIMILAR(pa.area, 11.6081250000001)528  TEST_REAL_SIMILAR(pa.height, 1384)529  TEST_REAL_SIMILAR(pa.apex_pos, 2.488216667)530}531END_SECTION532 533START_SECTION(PeakArea integratePeak(534  const MSChromatogram& chromatogram, MSChromatogram::ConstIterator& left, MSChromatogram::ConstIterator& right535) const)536{537  Param params = ptr->getParameters();538  PeakIntegrator::PeakArea pa;539  MSChromatogram::ConstIterator it;540 541  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);542  ptr->setParameters(params);543  STATUS(""Integration type: intensity_sum"")544  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);545  TEST_REAL_SIMILAR(pa.area, 6768778)546  TEST_REAL_SIMILAR(pa.height, 966489.0)547  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)548  it = chromatogram.RTBegin(left);549  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)550  {551    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())552    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())553  }554 555  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);556  ptr->setParameters(params);557  STATUS(""Integration type: trapezoid"")558  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);559  TEST_REAL_SIMILAR(pa.area, 71540.2)560  TEST_REAL_SIMILAR(pa.height, 966489.0)561  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)562  it = chromatogram.RTBegin(left);563  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)564  {565    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())566    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())567  }568 569  STATUS(""Integration type: trapezoid (1 point)"")570  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_1pt_it);571  TEST_REAL_SIMILAR(pa.area, 0.0)572  TEST_REAL_SIMILAR(pa.height, 881.0)573  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)574 575  params.setValue(""integration_type"", INTEGRATION_TYPE_SIMPSON);576  ptr->setParameters(params);577  STATUS(""Integration type: simpson (ODD number of points)"")578  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);579  TEST_REAL_SIMILAR(pa.area, 71720.443144994)580  TEST_REAL_SIMILAR(pa.height, 966489.0)581  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)582  it = chromatogram.RTBegin(left);583  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)584  {585    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())586    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())587  }588  STATUS(""Integration type: simpson (EVEN number of points)"")589  MSChromatogram::ConstIterator chrom_right_it_less = chrom_right_it - 1;590  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it_less); // a lower value of ""right"" is passed, to have 1 less point591  TEST_REAL_SIMILAR(pa.area, 71515.0792609335)592  TEST_REAL_SIMILAR(pa.height, 966489.0)593  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)594  it = chromatogram.RTBegin(left);595  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)596  {597    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getRT())598    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())599  }600 601  STATUS(""Integration type: simpson (1 point)"")602  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_1pt_it);603  TEST_REAL_SIMILAR(pa.area, 0.0)604  TEST_REAL_SIMILAR(pa.height, 881.0)605  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)606 607  STATUS(""Integration type: simpson (2 points)"")608  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_2pt_it);609  TEST_REAL_SIMILAR(pa.area, 11.6081250000001)610  TEST_REAL_SIMILAR(pa.height, 1384)611  TEST_REAL_SIMILAR(pa.apex_pos, 2.488216667)612}613END_SECTION614 615START_SECTION(PeakArea integratePeak(616  const MSSpectrum& spectrum, const double left, const double right617) const)618{619  Param params = ptr->getParameters();620  PeakIntegrator::PeakArea pa;621  MSSpectrum::ConstIterator it;622 623  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);624  ptr->setParameters(params);625  STATUS(""Integration type: intensity_sum"")626  pa = ptr->integratePeak(spectrum, left, right);627  TEST_REAL_SIMILAR(pa.area, 6768778)628  TEST_REAL_SIMILAR(pa.height, 966489.0)629  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)630  it = spectrum.MZBegin(left);631  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)632  {633    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())634    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())635  }636 637  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);638  ptr->setParameters(params);639  STATUS(""Integration type: trapezoid"")640  pa = ptr->integratePeak(spectrum, left, right);641  TEST_REAL_SIMILAR(pa.area, 71540.2)642  TEST_REAL_SIMILAR(pa.height, 966489.0)643  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)644  it = spectrum.MZBegin(left);645  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)646  {647    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())648    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())649  }650 651  STATUS(""Integration type: trapezoid (1 point)"")652  pa = ptr->integratePeak(spectrum, left, 2.478);653  TEST_REAL_SIMILAR(pa.area, 0.0)654  TEST_REAL_SIMILAR(pa.height, 881.0)655  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)656 657  params.setValue(""integration_type"", INTEGRATION_TYPE_SIMPSON);658  ptr->setParameters(params);659  STATUS(""Integration type: simpson (ODD number of points)"")660  pa = ptr->integratePeak(spectrum, left, right);661  TEST_REAL_SIMILAR(pa.area, 71720.443144994)662  TEST_REAL_SIMILAR(pa.height, 966489.0)663  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)664  it = spectrum.MZBegin(left);665  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)666  {667    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())668    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())669  }670  STATUS(""Integration type: simpson (EVEN number of points)"")671  pa = ptr->integratePeak(spectrum, left, 3.011416667); // a lower value of ""right"" is passed, to have 1 less point672  TEST_REAL_SIMILAR(pa.area, 71515.0792609335)673  TEST_REAL_SIMILAR(pa.height, 966489.0)674  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)675  it = spectrum.MZBegin(left);676  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)677  {678    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())679    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())680  }681 682  STATUS(""Integration type: simpson (1 point)"")683  pa = ptr->integratePeak(spectrum, left, 2.478);684  TEST_REAL_SIMILAR(pa.area, 0.0)685  TEST_REAL_SIMILAR(pa.height, 881.0)686  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)687 688  STATUS(""Integration type: simpson (2 points)"")689  pa = ptr->integratePeak(spectrum, left, 2.489);690  TEST_REAL_SIMILAR(pa.area, 11.6081250000001)691  TEST_REAL_SIMILAR(pa.height, 1384)692  TEST_REAL_SIMILAR(pa.apex_pos, 2.488216667)693}694END_SECTION695 696START_SECTION(PeakArea integratePeak(697  const MSSpectrum& spectrum, MSSpectrum::ConstIterator& left, MSSpectrum::ConstIterator& right698) const)699{700  Param params = ptr->getParameters();701  PeakIntegrator::PeakArea pa;702  MSSpectrum::ConstIterator it;703 704  params.setValue(""integration_type"", INTEGRATION_TYPE_INTENSITYSUM);705  ptr->setParameters(params);706  STATUS(""Integration type: intensity_sum"")707  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);708  TEST_REAL_SIMILAR(pa.area, 6768778)709  TEST_REAL_SIMILAR(pa.height, 966489.0)710  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)711  it = spectrum.MZBegin(left);712  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)713  {714    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())715    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())716  }717 718  params.setValue(""integration_type"", INTEGRATION_TYPE_TRAPEZOID);719  ptr->setParameters(params);720  STATUS(""Integration type: trapezoid"")721  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);722  TEST_REAL_SIMILAR(pa.area, 71540.2)723  TEST_REAL_SIMILAR(pa.height, 966489.0)724  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)725  it = spectrum.MZBegin(left);726  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)727  {728    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())729    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())730  }731 732  STATUS(""Integration type: trapezoid (1 point)"")733  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_1pt_it);734  TEST_REAL_SIMILAR(pa.area, 0.0)735  TEST_REAL_SIMILAR(pa.height, 881.0)736  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)737 738  params.setValue(""integration_type"", INTEGRATION_TYPE_SIMPSON);739  ptr->setParameters(params);740  STATUS(""Integration type: simpson (ODD number of points)"")741  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);742  TEST_REAL_SIMILAR(pa.area, 71720.443144994)743  TEST_REAL_SIMILAR(pa.height, 966489.0)744  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)745  it = spectrum.MZBegin(left);746  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)747  {748    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())749    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())750  }751  STATUS(""Integration type: simpson (EVEN number of points)"")752  MSSpectrum::ConstIterator spec_right_it_less = spec_right_it - 1;753  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it_less); // a lower value of ""right"" is passed, to have 1 less point754  TEST_REAL_SIMILAR(pa.area, 71515.0792609335)755  TEST_REAL_SIMILAR(pa.height, 966489.0)756  TEST_REAL_SIMILAR(pa.apex_pos, 2.7045)757  it = spectrum.MZBegin(left);758  for (Size i = 0; i < pa.hull_points.size(); i += 4, it +=4)759  {760    TEST_REAL_SIMILAR(pa.hull_points[i][0], it->getMZ())761    TEST_REAL_SIMILAR(pa.hull_points[i][1], it->getIntensity())762  }763 764  STATUS(""Integration type: simpson (1 point)"")765  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_1pt_it);766  TEST_REAL_SIMILAR(pa.area, 0.0)767  TEST_REAL_SIMILAR(pa.height, 881.0)768  TEST_REAL_SIMILAR(pa.apex_pos, 2.477966667)769 770  STATUS(""Integration type: simpson (2 points)"")771  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_2pt_it);772  TEST_REAL_SIMILAR(pa.area, 11.6081250000001)773  TEST_REAL_SIMILAR(pa.height, 1384)774  TEST_REAL_SIMILAR(pa.apex_pos, 2.488216667)775}776END_SECTION777 778START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics(779  const MSChromatogram& chromatogram, const double left, const double right,780  const double peak_height, const double peak_apex_pos781) const)782{783  PeakIntegrator::PeakArea pa;784  PeakIntegrator::PeakShapeMetrics psm;785  pa = ptr->integratePeak(chromatogram, left, right);786  psm = ptr->calculatePeakShapeMetrics(chromatogram, left, right, pa.height, pa.apex_pos);787  TEST_REAL_SIMILAR(psm.width_at_5, 0.15955)788  TEST_REAL_SIMILAR(psm.width_at_10, 0.138366667)789  TEST_REAL_SIMILAR(psm.width_at_50, 0.0741500000000004)790  TEST_REAL_SIMILAR(psm.start_position_at_5, 2.630066667)791  TEST_REAL_SIMILAR(psm.start_position_at_10, 2.64065)792  TEST_REAL_SIMILAR(psm.start_position_at_50, 2.662116667)793  TEST_REAL_SIMILAR(psm.end_position_at_5, 2.789616667)794  TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667)795  TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667)796  TEST_REAL_SIMILAR(psm.total_width, 0.540983333)797  TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376)798  TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539)799  TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454)800  TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033)801  TEST_EQUAL(psm.points_across_baseline, 57)802  TEST_EQUAL(psm.points_across_half_height, 6)803  pa = ptr->integratePeak(chromatogram, left_past_5, right_past_5);804  psm = ptr->calculatePeakShapeMetrics(chromatogram, left_past_5, right_past_5, pa.height, pa.apex_pos);805  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_5)806  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_5)807  pa = ptr->integratePeak(chromatogram, left_past_10, right_past_10);808  psm = ptr->calculatePeakShapeMetrics(chromatogram, left_past_10, right_past_10, pa.height, pa.apex_pos);809  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_10)810  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_10)811  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_10)812  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_10)813  pa = ptr->integratePeak(chromatogram, left_past_50, right_past_50);814  psm = ptr->calculatePeakShapeMetrics(chromatogram, left_past_50, right_past_50, pa.height, pa.apex_pos);815  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_50)816  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_50)817  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_50)818  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_50)819  TEST_REAL_SIMILAR(psm.start_position_at_50, left_past_50)820  TEST_REAL_SIMILAR(psm.end_position_at_50, right_past_50)821  pa = ptr->integratePeak(chromatogram, left_few, right_few);822  psm = ptr->calculatePeakShapeMetrics(chromatogram, left_few, right_few, pa.height, pa.apex_pos);823  TEST_REAL_SIMILAR(psm.start_position_at_5, left_few)824  TEST_REAL_SIMILAR(psm.end_position_at_5, right_few)825}826END_SECTION827 828START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics(829  const MSChromatogram& chromatogram, MSChromatogram::ConstIterator& left, MSChromatogram::ConstIterator& right,830  const double peak_height, const double peak_apex_pos831) const)832{833  PeakIntegrator::PeakArea pa;834  PeakIntegrator::PeakShapeMetrics psm;835  pa = ptr->integratePeak(chromatogram, chrom_left_it, chrom_right_it);836  psm = ptr->calculatePeakShapeMetrics(chromatogram, chrom_left_it, chrom_right_it, pa.height, pa.apex_pos);837  TEST_REAL_SIMILAR(psm.width_at_5, 0.15955)838  TEST_REAL_SIMILAR(psm.width_at_10, 0.138366667)839  TEST_REAL_SIMILAR(psm.width_at_50, 0.0741500000000004)840  TEST_REAL_SIMILAR(psm.start_position_at_5, 2.630066667)841  TEST_REAL_SIMILAR(psm.start_position_at_10, 2.64065)842  TEST_REAL_SIMILAR(psm.start_position_at_50, 2.662116667)843  TEST_REAL_SIMILAR(psm.end_position_at_5, 2.789616667)844  TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667)845  TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667)846  TEST_REAL_SIMILAR(psm.total_width, 0.540983333)847  TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376)848  TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539)849  TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454)850  TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033)851  TEST_EQUAL(psm.points_across_baseline, 57)852  TEST_EQUAL(psm.points_across_half_height, 6)853  pa = ptr->integratePeak(chromatogram, chrom_left_past_5_it, chrom_right_past_5_it);854  psm = ptr->calculatePeakShapeMetrics(chromatogram, chrom_left_past_5_it, chrom_right_past_5_it, pa.height, pa.apex_pos);855  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_5)856  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_5)857  pa = ptr->integratePeak(chromatogram, chrom_left_past_10_it, chrom_right_past_10_it);858  psm = ptr->calculatePeakShapeMetrics(chromatogram, chrom_left_past_10_it, chrom_right_past_10_it, pa.height, pa.apex_pos);859  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_10)860  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_10)861  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_10)862  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_10)863  pa = ptr->integratePeak(chromatogram, chrom_left_past_50_it, chrom_right_past_50_it);864  psm = ptr->calculatePeakShapeMetrics(chromatogram, chrom_left_past_50_it, chrom_right_past_50_it, pa.height, pa.apex_pos);865  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_50)866  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_50)867  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_50)868  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_50)869  TEST_REAL_SIMILAR(psm.start_position_at_50, left_past_50)870  TEST_REAL_SIMILAR(psm.end_position_at_50, right_past_50)871  pa = ptr->integratePeak(chromatogram, chrom_left_few_it, chrom_right_few_it);872  psm = ptr->calculatePeakShapeMetrics(chromatogram, chrom_left_few_it, chrom_right_few_it, pa.height, pa.apex_pos);873  TEST_REAL_SIMILAR(psm.start_position_at_5, left_few)874  TEST_REAL_SIMILAR(psm.end_position_at_5, right_few)875}876END_SECTION877 878START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics(879  const MSSpectrum& spectrum, const double left, const double right,880  const double peak_height, const double peak_apex_pos881) const)882{883  PeakIntegrator::PeakArea pa;884  PeakIntegrator::PeakShapeMetrics psm;885  pa = ptr->integratePeak(spectrum, left, right);886  psm = ptr->calculatePeakShapeMetrics(spectrum, left, right, pa.height, pa.apex_pos);887  TEST_REAL_SIMILAR(psm.width_at_5, 0.15955)888  TEST_REAL_SIMILAR(psm.width_at_10, 0.138366667)889  TEST_REAL_SIMILAR(psm.width_at_50, 0.0741500000000004)890  TEST_REAL_SIMILAR(psm.start_position_at_5, 2.630066667)891  TEST_REAL_SIMILAR(psm.start_position_at_10, 2.64065)892  TEST_REAL_SIMILAR(psm.start_position_at_50, 2.662116667)893  TEST_REAL_SIMILAR(psm.end_position_at_5, 2.789616667)894  TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667)895  TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667)896  TEST_REAL_SIMILAR(psm.total_width, 0.540983333)897  TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376)898  TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539)899  TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454)900  TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033)901  TEST_EQUAL(psm.points_across_baseline, 57)902  TEST_EQUAL(psm.points_across_half_height, 6)903  pa = ptr->integratePeak(spectrum, left_past_5, right_past_5);904  psm = ptr->calculatePeakShapeMetrics(spectrum, left_past_5, right_past_5, pa.height, pa.apex_pos);905  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_5)906  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_5)907  pa = ptr->integratePeak(spectrum, left_past_10, right_past_10);908  psm = ptr->calculatePeakShapeMetrics(spectrum, left_past_10, right_past_10, pa.height, pa.apex_pos);909  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_10)910  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_10)911  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_10)912  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_10)913  pa = ptr->integratePeak(spectrum, left_past_50, right_past_50);914  psm = ptr->calculatePeakShapeMetrics(spectrum, left_past_50, right_past_50, pa.height, pa.apex_pos);915  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_50)916  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_50)917  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_50)918  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_50)919  TEST_REAL_SIMILAR(psm.start_position_at_50, left_past_50)920  TEST_REAL_SIMILAR(psm.end_position_at_50, right_past_50)921  pa = ptr->integratePeak(spectrum, left_few, right_few);922  psm = ptr->calculatePeakShapeMetrics(spectrum, left_few, right_few, pa.height, pa.apex_pos);923  TEST_REAL_SIMILAR(psm.start_position_at_5, left_few)924  TEST_REAL_SIMILAR(psm.end_position_at_5, right_few)925}926END_SECTION927 928START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics(929  const MSSpectrum& spectrum, MSSpectrum::ConstIterator& left, MSSpectrum::ConstIterator& right,930  const double peak_height, const double peak_apex_pos931) const)932{933  PeakIntegrator::PeakArea pa;934  PeakIntegrator::PeakShapeMetrics psm;935  pa = ptr->integratePeak(spectrum, spec_left_it, spec_right_it);936  psm = ptr->calculatePeakShapeMetrics(spectrum, spec_left_it, spec_right_it, pa.height, pa.apex_pos);937  TEST_REAL_SIMILAR(psm.width_at_5, 0.15955)938  TEST_REAL_SIMILAR(psm.width_at_10, 0.138366667)939  TEST_REAL_SIMILAR(psm.width_at_50, 0.0741500000000004)940  TEST_REAL_SIMILAR(psm.start_position_at_5, 2.630066667)941  TEST_REAL_SIMILAR(psm.start_position_at_10, 2.64065)942  TEST_REAL_SIMILAR(psm.start_position_at_50, 2.662116667)943  TEST_REAL_SIMILAR(psm.end_position_at_5, 2.789616667)944  TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667)945  TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667)946  TEST_REAL_SIMILAR(psm.total_width, 0.540983333)947  TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376)948  TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539)949  TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454)950  TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033)951  TEST_EQUAL(psm.points_across_baseline, 57)952  TEST_EQUAL(psm.points_across_half_height, 6)953  pa = ptr->integratePeak(spectrum, spec_left_past_5_it, spec_right_past_5_it);954  psm = ptr->calculatePeakShapeMetrics(spectrum, spec_left_past_5_it, spec_right_past_5_it, pa.height, pa.apex_pos);955  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_5)956  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_5)957  pa = ptr->integratePeak(spectrum, spec_left_past_10_it, spec_right_past_10_it);958  psm = ptr->calculatePeakShapeMetrics(spectrum, spec_left_past_10_it, spec_right_past_10_it, pa.height, pa.apex_pos);959  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_10)960  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_10)961  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_10)962  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_10)963  pa = ptr->integratePeak(spectrum, spec_left_past_50_it, spec_right_past_50_it);964  psm = ptr->calculatePeakShapeMetrics(spectrum, spec_left_past_50_it, spec_right_past_50_it, pa.height, pa.apex_pos);965  TEST_REAL_SIMILAR(psm.start_position_at_5, left_past_50)966  TEST_REAL_SIMILAR(psm.end_position_at_5, right_past_50)967  TEST_REAL_SIMILAR(psm.start_position_at_10, left_past_50)968  TEST_REAL_SIMILAR(psm.end_position_at_10, right_past_50)969  TEST_REAL_SIMILAR(psm.start_position_at_50, left_past_50)970  TEST_REAL_SIMILAR(psm.end_position_at_50, right_past_50)971  pa = ptr->integratePeak(spectrum, spec_left_few_it, spec_right_few_it);972  psm = ptr->calculatePeakShapeMetrics(spectrum, spec_left_few_it, spec_right_few_it, pa.height, pa.apex_pos);973  TEST_REAL_SIMILAR(psm.start_position_at_5, left_few)974  TEST_REAL_SIMILAR(psm.end_position_at_5, right_few)975}976END_SECTION977 978START_SECTION([EXTRA]  template <typename PeakContainerConstIteratorT> double findPosAtPeakHeightPercent_(...))979{980  PeakIntegratorTest pit;981  double pos = pit.findPosAtPeakHeightPercent(spectrum.begin(), spectrum.end(), spectrum.end(), 0.0, 0.0, true);982  TEST_EQUAL(pos, spectrum[0].getPos()); // find first non-zero peak983 984  pos = pit.findPosAtPeakHeightPercent(spectrum.begin(), spectrum.end(), spectrum.end(), 0.0, 0.0, false);985  TEST_EQUAL(pos, spectrum.back().getPos()); // find non-zero peak from end986 987  // corner cases: just a single point in range988  pos = pit.findPosAtPeakHeightPercent(spectrum.begin(), spectrum.begin() + 1, spectrum.begin() + 1, 0.0, 0.0, false);989  TEST_EQUAL(pos, spectrum[0].getPos()); // return the only peak there is990  pos = pit.findPosAtPeakHeightPercent(spectrum.begin(), spectrum.begin() + 1, spectrum.begin() + 1, 0.0, 0.0, true);991  TEST_EQUAL(pos, spectrum[0].getPos()); // return the only peak there is992 993 994  // corner cases: empty range995  TEST_EXCEPTION(Exception::InvalidRange, pit.findPosAtPeakHeightPercent(spectrum.end(), spectrum.end(), spectrum.end(), 0.0, 0.0, false))996  TEST_EXCEPTION(Exception::InvalidRange, pit.findPosAtPeakHeightPercent(spectrum.end(), spectrum.end(), spectrum.end(), 0.0, 0.0, true))997}998END_SECTION999 1000delete ptr;1001 1002/////////////////////////////////////////////////////////////1003/////////////////////////////////////////////////////////////1004END_TEST1005",16129,True,3416.3898993792013,median1006"/*1007    -- MAGMA (version 2.2.0) --1008       Univ. of Tennessee, Knoxville1009       Univ. of California, Berkeley1010       Univ. of Colorado, Denver1011       @date November 20161012 1013       @generated from sparse/control/magma_zmtransfer.cpp, normal z -> d, Sun Nov 20 20:20:45 20161014       @author Hartwig Anzt1015*/1016#include ""magmasparse_internal.h""1017 1018 1019/**1020    Purpose1021    -------1022 1023    Copies a matrix from memory location src to memory location dst.1024 1025 1026    Arguments1027    ---------1028 1029    @param[in]1030    A           magma_d_matrix1031                sparse matrix A1032 1033    @param[out]1034    B           magma_d_matrix*1035                copy of A1036 1037    @param[in]1038    src         magma_location_t1039                original location A1040 1041    @param[in]1042    dst         magma_location_t1043                location of the copy of A1044 1045    @param[in]1046    queue       magma_queue_t1047                Queue to execute in.1048 1049    @ingroup magmasparse_daux1050    ********************************************************************/1051 1052extern ""C"" magma_int_t1053magma_dmtransfer(1054    magma_d_matrix A,1055    magma_d_matrix *B,1056    magma_location_t src,1057    magma_location_t dst,1058    magma_queue_t queue )1059{1060    magma_int_t info = 0;1061    1062    B->val = NULL;1063    B->diag = NULL;1064    B->row = NULL;1065    B->rowidx = NULL;1066    B->col = NULL;1067    B->blockinfo = NULL;1068    B->dval = NULL;1069    B->ddiag = NULL;1070    B->drow = NULL;1071    B->drowidx = NULL;1072    B->dcol = NULL;1073    B->diag = NULL;1074    B->ddiag = NULL;1075    B->list = NULL;1076    B->dlist = NULL;1077    B->tile_ptr = NULL;1078    B->dtile_ptr = NULL;1079    B->tile_desc = NULL;1080    B->dtile_desc = NULL;1081    B->tile_desc_offset_ptr = NULL;1082    B->dtile_desc_offset_ptr = NULL;1083    B->tile_desc_offset = NULL;1084    B->dtile_desc_offset = NULL;1085    B->calibrator = NULL;1086    B->dcalibrator = NULL;1087    1088 1089    // first case: copy matrix from host to device1090    if ( src == Magma_CPU && dst == Magma_DEV ) {1091        //CSR-type1092        if ( A.storage_type == Magma_CSR   ||1093             A.storage_type == Magma_CUCSR ||1094             A.storage_type == Magma_CSRD  ||1095             A.storage_type == Magma_CSRL  ||1096             A.storage_type == Magma_CSRU )1097        {1098            // fill in information for B1099            B->storage_type = A.storage_type;1100            B->memory_location = Magma_DEV;1101            B->sym = A.sym;1102            B->diagorder_type = A.diagorder_type;1103            B->fill_mode = A.fill_mode;1104            B->num_rows = A.num_rows;1105            B->num_cols = A.num_cols;1106            B->nnz = A.nnz; B->true_nnz = A.true_nnz;1107            B->max_nnz_row = A.max_nnz_row;1108            B->diameter = A.diameter;1109            // memory allocation1110            CHECK( magma_dmalloc( &B->dval, A.nnz ));1111            CHECK( magma_index_malloc( &B->drow, A.num_rows + 1 ));1112            CHECK( magma_index_malloc( &B->dcol, A.nnz ));1113            // data transfer1114            magma_dsetvector( A.nnz, A.val, 1, B->dval, 1, queue );1115            magma_index_setvector( A.num_rows + 1, A.row, 1, B->drow, 1, queue );1116            magma_index_setvector( A.nnz, A.col, 1, B->dcol, 1, queue );1117        }1118        //CSC-type1119        else if ( A.storage_type == Magma_CSC )1120        {1121            // fill in information for B1122            B->storage_type = A.storage_type;1123            B->memory_location = Magma_DEV;1124            B->sym = A.sym;1125            B->diagorder_type = A.diagorder_type;1126            B->fill_mode = A.fill_mode;1127            B->num_rows = A.num_rows;1128            B->num_cols = A.num_cols;1129            B->nnz = A.nnz; B->true_nnz = A.true_nnz;1130            B->max_nnz_row = A.max_nnz_row;1131            B->diameter = A.diameter;1132            // memory allocation1133            CHECK( magma_dmalloc( &B->dval, A.nnz ));1134            CHECK( magma_index_malloc( &B->drow, A.nnz ));1135            CHECK( magma_index_malloc( &B->dcol, A.num_cols+1 ));1136            // data transfer1137            magma_dsetvector( A.nnz, A.val, 1, B->dval, 1, queue );1138            magma_index_setvector( A.nnz, A.row, 1, B->drow, 1, queue );1139            magma_index_setvector( A.num_cols+1, A.col, 1, B->dcol, 1, queue );1140        }1141        //COO-type1142        else if ( A.storage_type == Magma_COO ) {1143            // fill in information for B1144            B->storage_type = A.storage_type;1145            B->memory_location = Magma_DEV;1146            B->sym = A.sym;1147            B->diagorder_type = A.diagorder_type;1148            B->fill_mode = A.fill_mode;1149            B->num_rows = A.num_rows;1150            B->num_cols = A.num_cols;1151            B->nnz = A.nnz; B->true_nnz = A.true_nnz;1152            B->max_nnz_row = A.max_nnz_row;1153            B->diameter = A.diameter;1154            // memory allocation1155            CHECK( magma_dmalloc( &B->dval, A.nnz ));1156            CHECK( magma_index_malloc( &B->dcol, A.nnz ));1157            CHECK( magma_index_malloc( &B->drowidx, A.nnz ));1158            // data transfer1159            magma_dsetvector( A.nnz, A.val, 1, B->dval, 1, queue );1160            magma_index_setvector( A.nnz, A.col, 1, B->dcol, 1, queue );1161            magma_index_setvector( A.nnz, A.rowidx, 1, B->drowidx, 1, queue );1162        }1163        //CSRCOO-type1164        else if ( A.storage_type == Magma_CSRCOO ) {1165            // fill in information for B1166            B->storage_type = A.storage_type;1167            B->memory_location = Magma_DEV;1168            B->sym = A.sym;1169            B->diagorder_type = A.diagorder_type;1170            B->fill_mode = A.fill_mode;1171            B->num_rows = A.num_rows;1172            B->num_cols = A.num_cols;1173            B->nnz = A.nnz; B->true_nnz = A.true_nnz;1174            B->max_nnz_row = A.max_nnz_row;1175            B->diameter = A.diameter;1176            // memory allocation1177            CHECK( magma_dmalloc( &B->dval, A.nnz ));1178            CHECK( magma_index_malloc( &B->drow, A.num_rows + 1 ));1179            CHECK( magma_index_malloc( &B->dcol, A.nnz ));1180            CHECK( magma_index_malloc( &B->drowidx, A.nnz ));1181            // data transfer1182            magma_dsetvector( A.nnz, A.val, 1, B->dval, 1, queue );1183            magma_index_setvector( A.num_rows + 1, A.row, 1, B->drow, 1, queue );1184            magma_index_setvector( A.nnz, A.col, 1, B->dcol, 1, queue );1185            magma_index_setvector( A.nnz, A.rowidx, 1, B->drowidx, 1, queue );1186        }1187        //ELL/ELLPACKT-type1188        else if ( A.storage_type == Magma_ELLPACKT || A.storage_type == Magma_ELL ) {1189            // fill in information for B1190            B->storage_type = A.storage_type;1191            B->memory_location = Magma_DEV;1192            B->sym = A.sym;1193            B->diagorder_type = A.diagorder_type;1194            B->fill_mode = A.fill_mode;1195            B->num_rows = A.num_rows;1196            B->num_cols = A.num_cols;1197            B->nnz = A.nnz; B->true_nnz = A.true_nnz;1198            B->max_nnz_row = A.max_nnz_row;1199            B->diameter = A.diameter;1200            // memory allocation

Showing the first 1,200 of 83656 lines. Download the file for the rest.