mapquanti.cpp 4.7 KB
Newer Older
Olivier Langella's avatar
Olivier Langella committed
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

/*******************************************************************************
 * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
 *
 * This file is part of the MassChroQ software.
 *
 *     MassChroQ 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.
 *
 *     MassChroQ 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 MassChroQ.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and implementation
 ******************************************************************************/
#include "mapquanti.h"
#include "../quanti_items/quantiItemBase.h"
#include "../xic/xicfilterdetectmatch.h"
26
#include "../xic/xicfilterdetectmatchrealrt.h"
Olivier Langella's avatar
Olivier Langella committed
27
#include "../xic/xic_base.h"
Olivier Langella's avatar
Olivier Langella committed
28
#include "../xic/xictracebase.h"
Olivier Langella's avatar
Olivier Langella committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "../consoleout.h"

MapQuanti::MapQuanti(MonitorSpeedInterface & monitor, Msrun * current_msrun, McqXicType xic_type, Quantificator * quantificator,
                     const pappso::XicFilterInterface * p_xic_filter,const pappso::XicDetectionInterface * p_detection)
    :_monitor(monitor), _xic_type(xic_type) {
    _p_msrun = current_msrun;
    _p_xic_filter = p_xic_filter;
    _p_detection = p_detection;
    _matching_mode = quantificator->getMatchingMode();
    _quantificator = quantificator;
}

void MapQuanti::operator()(QuantiItemBase * p_currentSearchItem)
{
    qDebug() << " MapQuanti::operator begin";
    try {
        pappso::pappso_double rt_target = -1;
46
        //std::vector<MsMsRtIntensity> rt_list;
Olivier Langella's avatar
Olivier Langella committed
47

Olivier Langella's avatar
Olivier Langella committed
48
49
50
        PeptideRt * p_peptide_rt = p_currentSearchItem->getPeptideRtSp().get();

        if (p_peptide_rt != nullptr) {
Olivier Langella's avatar
Olivier Langella committed
51
            rt_target = p_peptide_rt->getRtTarget(_p_msrun, _matching_mode);
52

Olivier Langella's avatar
Olivier Langella committed
53
54
55
56
57
58
            if (std::isnan(rt_target)) {
                qDebug() << " MapQuanti::operator() isnan(rt_target) " << p_currentSearchItem->getQuantiItemId() << " " << rt_target;
                throw mcqError(QObject::tr("Error in MapQuanti::operator() isnan(rt_target) %1")
                               .arg(p_currentSearchItem->getQuantiItemId()));
            }
        }
Olivier Langella's avatar
Olivier Langella committed
59
60

        if (rt_target == -1) {
61
            if (_matching_mode == McqMatchingMode::post_matching) {
62
                //it's Ok, just detect and keep peaks
63
            } else if (_matching_mode == McqMatchingMode::no_matching) {
Olivier Langella's avatar
Olivier Langella committed
64
65
66
67
68
69
70
                rt_target = p_currentSearchItem->getRt();
            } else {
                qDebug() << " MapQuanti::operator rt_target == -1 exit";
                return;
            }
        }
        qDebug() << " MapQuanti::operator _p_msrun->extractXic";
71
        McqXicNoConstSp _p_xic = _p_msrun->extractXic(_xic_type, _quantificator->getXicExtractionMethod()->getPappsoMassRange( p_currentSearchItem->getMz()));
Olivier Langella's avatar
Olivier Langella committed
72
73
74
75
76
77
78
79

        if (_p_xic == nullptr) {
            qDebug() << "detectAndQuantify null xic ";

            qDebug() << " MapQuanti::operator begin 2";
        }
        else {
            qDebug() << " MapQuanti::operator begin 3 rt_target=" << rt_target;
80
81
            XicTraceBase * p_xic_trace = nullptr;

82
83
            //only take an rt reference to match peak
            p_xic_trace = p_currentSearchItem->newXicTrace(_quantificator, _p_msrun, "target");
Olivier Langella's avatar
Olivier Langella committed
84

Olivier Langella's avatar
Olivier Langella committed
85

86
87
            XicFilterDetectMatch filter_detect_match(p_xic_trace, _monitor, _p_xic_filter, _p_detection, _matching_mode) ;
            filter_detect_match.filterDetectQuantify(*(_p_xic.get()), rt_target, p_currentSearchItem, _p_msrun);
88

Olivier Langella's avatar
Olivier Langella committed
89
90

            if (p_xic_trace != nullptr) {
91
                p_xic_trace->setAlignedRtTarget(_p_msrun->getAlignedRtByOriginalRt(rt_target));
Olivier Langella's avatar
Olivier Langella committed
92
93
                p_xic_trace->setRtTarget(rt_target);
                p_xic_trace->setXic(_p_xic);
Olivier Langella's avatar
Olivier Langella committed
94
                p_xic_trace->close();
Olivier Langella's avatar
Olivier Langella committed
95
96
                delete p_xic_trace;
            }
Olivier Langella's avatar
Olivier Langella committed
97
98
99
100
101
102
103
104
105
        }
        qDebug() << " MapQuanti::operator end";
    }
    catch (mcqError& errorException)
    {
        // QObject::tr("%1 CPUs used").arg(cpu_number)
        // mcqerr() << "Oops! an error occurred in MassChroQ. Dont Panic :" << endl;
        // mcqerr() << error.qwhat() << endl;
        qDebug() << " MapQuanti::operator " << errorException.qwhat();
Olivier Langella's avatar
Olivier Langella committed
106
107
        throw mcqError(QObject::tr("Error in MapQuanti::operator() :\n %1")
                       .arg(errorException.qwhat()));
Olivier Langella's avatar
Olivier Langella committed
108
109
110
111
        // windaube_exit();
        // return 1;
    }
}