File: test_tims_ion_mobility_grid.cpp

package info (click to toggle)
libpappsomspp 0.11.10-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,844 kB
  • sloc: cpp: 85,012; xml: 44,164; python: 668; sql: 186; sh: 33; makefile: 32
file content (290 lines) | stat: -rw-r--r-- 9,813 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290

// File: test_timsxicextractor.cpp
// Created by: Olivier Langella
// Created on: 3/2/2021
//
/*******************************************************************************
 * Copyright (c) 2021 Olivier Langella
 *<olivier.langella@universite-paris-saclay.fr>.
 *
 * This file is part of the PAPPSOms++ library.
 *
 *     PAPPSOms++ is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     PAPPSOms++ is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with PAPPSOms++.  If not, see <http://www.gnu.org/licenses/>.
 *
 ******************************************************************************/

// make test ARGS="-V -I 1,1"

// ./tests/pappsotree/catch2-only-pappsotree [TimsIonMobilityGrid] -a


#include <catch2/catch_test_macros.hpp>


#include <QDebug>

#include <pappsomspp/core/msrun/xiccoord/ionmobilitygrid.h>
#include "tests/tests-config.h"
#include "../common.h"
#include <time.h>


using namespace pappso;

TEST_CASE("test TimsIonMobilityGrid", "[TimsIonMobilityGrid]")
{
  qSetMessagePattern(QString("%{file}@%{line}, %{function}(): %{message}"));

  IonMobilityGrid ion_mobility_grid;


  pappso::MsFileAccessor accessor(
    "/gorgone/pappso/versions_logiciels_pappso/masschroq/donnees/"
    "PXD010012_msfragger_timstof/"
    "20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_"
    "2767.d/analysis.tdf",
    "a1");

  accessor.setPreferredFileReaderType(Enums::MsDataFormat::brukerTims,
                                      Enums::FileReaderType::tims_ms2);

  pappso::MsRunReaderSPtr p_msreader =
    accessor.msRunReaderSPtr(accessor.getMsRunIds().front());

  REQUIRE(p_msreader != nullptr);

  REQUIRE(accessor.getFileReaderType() == Enums::FileReaderType::tims_ms2);


  pappso::MsFileAccessor accessor_a2(
    "/gorgone/pappso/versions_logiciels_pappso/masschroq/donnees/"
    "PXD010012_msfragger_timstof/"
    "20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_"
    "2768.d/analysis.tdf",
    "a2");

  accessor_a2.setPreferredFileReaderType(Enums::MsDataFormat::brukerTims,
                                         Enums::FileReaderType::tims_ms2);

  pappso::MsRunReaderSPtr p_msreader_a2 =
    accessor_a2.msRunReaderSPtr(accessor_a2.getMsRunIds().front());

  REQUIRE(p_msreader_a2 != nullptr);

  REQUIRE(accessor_a2.getFileReaderType() == Enums::FileReaderType::tims_ms2);

  auto msrunid_a1 = *p_msreader->getMsRunId().get();

  auto msrunid_a2 = *p_msreader_a2->getMsRunId().get();

  qInfo() << "store observed";
  INFO("store observed");


  auto a1 = p_msreader.get()->newXicCoordSPtrFromSpectrumIndex(
    106171, pappso::PrecisionFactory::getPpmInstance(10));

  auto a2 = p_msreader_a2.get()->newXicCoordSPtrFromSpectrumIndex(
    106889, pappso::PrecisionFactory::getPpmInstance(10));
  qInfo() << "first a1" << a1.get()->toString();
  qInfo() << "first a2" << a2.get()->toString();

  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1, a1.get(), msrunid_a2, a2.get());


  INFO("store observed pepa1e17369");
  // pepa1e17369
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  // 261103	2586,61	650,346968967	ILDEIGADVQAR pepa1e17369
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 259019	2593,3	650,347328967	ILDEIGADVQAR

  a1 = p_msreader.get()->newXicCoordSPtrFromSpectrumIndex(
    261103, pappso::PrecisionFactory::getPpmInstance(10));

  a2 = p_msreader_a2.get()->newXicCoordSPtrFromSpectrumIndex(
    259019, pappso::PrecisionFactory::getPpmInstance(10));
  qInfo() << "2 a1" << a1.get()->toString();
  qInfo() << "2 a2" << a2.get()->toString();

  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1, a1.get(), msrunid_a2, a2.get());


  INFO("store observed pepa1e31234");
  // pepa1e31234
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  // 245667	2454,61	781,849418967	SNMEAQHNDLEFK
  // pepa1e31234
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 243535	2460,95	781,849797967	SNMEAQHNDLEFK

  a1 = p_msreader.get()->newXicCoordSPtrFromSpectrumIndex(
    245667, pappso::PrecisionFactory::getPpmInstance(10));

  a2 = p_msreader_a2.get()->newXicCoordSPtrFromSpectrumIndex(
    243535, pappso::PrecisionFactory::getPpmInstance(10));
  qInfo() << "3 a1" << a1.get()->toString();
  qInfo() << "3 a2" << a2.get()->toString();

  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1, a1.get(), msrunid_a2, a2.get());


  INFO("store observed pepb15b13");
  // pepb15b13
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  // 249403	2486,14	699,856334967	DPEKPQLGMIDR pepb15b13
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 247155	2491,71	699,856816467	DPEKPQLGMIDR


  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1,
    p_msreader.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        249403, pappso::PrecisionFactory::getPpmInstance(10))
      .get(),
    msrunid_a2,
    p_msreader_a2.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        247155, pappso::PrecisionFactory::getPpmInstance(10))
      .get());


  INFO("store observed pepb54b12");
  //  pepb54b12
  //  20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  //  79843	1106,79	832,442628967	EAGTEVVK
  // pepb54b12
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 79969	1104,68	832,440325967	EAGTEVVK

  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1,
    p_msreader.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        79843, pappso::PrecisionFactory::getPpmInstance(10))
      .get(),
    msrunid_a2,
    p_msreader_a2.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        79969, pappso::PrecisionFactory::getPpmInstance(10))
      .get());

  INFO("store observed pepb83a6");
  // pepb83a6
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  // 289387	2830,6	610,302429967	AAYFGIYDTAK pepb83a6
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 286699	2828,24	610,303296967	AAYFGIYDTAK

  ion_mobility_grid.storeObservedIdentityBetween(
    msrunid_a1,
    p_msreader.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        289387, pappso::PrecisionFactory::getPpmInstance(10))
      .get(),
    msrunid_a2,
    p_msreader_a2.get()
      ->newXicCoordSPtrFromSpectrumIndex(
        286699, pappso::PrecisionFactory::getPpmInstance(10))
      .get());


  auto map_diff = ion_mobility_grid.getMapDiferrencesStart();

  for(auto itmap : map_diff)
    {
      qInfo() << (itmap.first);
      for(auto list_diff : itmap.second)
        {

          qInfo() << (list_diff);
        }
    }

  WARN("ion_mobility_grid.computeCorrections()");
  ion_mobility_grid.computeCorrections();


  auto map_delta = ion_mobility_grid.getMapCorrectionsStart();

  REQUIRE(map_delta["a1a1-a2a1"] == -1);

  // pepa1e31244
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_1_A1_01_2767
  // 452469	4297,94	718,417257967	SNPDQPAVILLLR
  // pepa1e31244
  // 20180819_TIMS2_12-2_AnBr_SA_200ng_HeLa_50cm_120min_100ms_11CT_2_A1_01_2768
  // 448731	4288,53	718,417001467	SNPDQPAVILLLR

  auto target = p_msreader_a2.get()->newXicCoordSPtrFromSpectrumIndex(
    448731, pappso::PrecisionFactory::getPpmInstance(10));

  auto source = p_msreader.get()->newXicCoordSPtrFromSpectrumIndex(
    452469, pappso::PrecisionFactory::getPpmInstance(10));

  WARN("source");
  REQUIRE(source->toString().toStdString() ==
          "mz=mz=718.417 delta=0.00718417 : 718.41 < 718.417 < 718.424 "
          "rt=4297.94 begin=532 end=557");

  REQUIRE(source.get()
            ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
            .toInt() == 532);
  WARN("target");
  REQUIRE(target->toString().toStdString() ==
          "mz=mz=718.417 delta=0.00718417 : 718.41 < 718.417 < 718.424 "
          "rt=4288.53 begin=534 end=559");

  auto result = ion_mobility_grid.translateXicCoordFromTo(
    *source.get(), msrunid_a1, msrunid_a2);


  REQUIRE(source.get()
            ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
            .toInt() == 532);
  REQUIRE(result.get()
            ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
            .toInt() ==
          (source.get()
             ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
             .toInt() -
           1));
  WARN("result");
  REQUIRE(result->toString().toStdString() ==
          "mz=mz=718.417 delta=0.00718417 : 718.41 < 718.417 < 718.424 "
          "rt=4297.94 begin=531 end=556");

  result = ion_mobility_grid.translateXicCoordFromTo(
    *target.get(), msrunid_a2, msrunid_a1);

  REQUIRE(target.get()
            ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
            .toInt() == 534);

  REQUIRE(result.get()
            ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
            .toInt() ==
          (target.get()
             ->getParam(XicCoordParam::TimsTofIonMobilityScanNumberStart)
             .toInt() +
           1));
  WARN("result");
  REQUIRE(result->toString().toStdString() ==
          "mz=mz=718.417 delta=0.00718417 : 718.41 < 718.417 < 718.424 "
          "rt=4288.53 begin=535 end=560");
}