Skip to content
Snippets Groups Projects
Commit bd1467f7 authored by Langella Olivier's avatar Langella Olivier
Browse files

compute TIC on spectrum ms levels

parent 3e9bba19
No related branches found
No related tags found
No related merge requests found
......@@ -152,6 +152,7 @@ SET(CPP_FILES
utils/fastafilestore.cpp
utils/identificationdatasourcestore.cpp
utils/groupstore.cpp
utils/msrunstatisticshandler.cpp
utils/msrunstore.cpp
utils/peptideevidencestore.cpp
utils/peptidestore.cpp
......
......@@ -38,6 +38,7 @@
#include <pappsomspp/msrun/msrunreaderfactory.h>
#include <pappsomspp/exception/exceptionnotfound.h>
#include <pappsomspp/xicextractor/msrunxicextractorfactory.h>
#include "../utils/msrunstatisticshandler.h"
MsRun::MsRun(const QString &location) : pappso::MsRunId(location)
{
......@@ -144,7 +145,7 @@ MsRun::checkMsRunStatistics()
{
try
{
pappso::MsRunSimpleStatistics stats;
MsRunStatisticsHandler stats;
_msrun_reader_sp.get()->readSpectrumCollection(stats);
setMsRunStatistics(MsRunStatistics::total_spectra,
......@@ -155,6 +156,12 @@ MsRun::checkMsRunStatistics()
(unsigned int)stats.getMsLevelCount(2));
setMsRunStatistics(MsRunStatistics::total_spectra_ms3,
(unsigned int)stats.getMsLevelCount(3));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms1,
(unsigned int)stats.getMsLevelTic(1));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms2,
(unsigned int)stats.getMsLevelTic(2));
setMsRunStatistics(MsRunStatistics::tic_spectra_ms3,
(unsigned int)stats.getMsLevelTic(3));
}
catch(pappso::ExceptionNotFound &error)
{
......
/**
* \file utils/msrunstatisticshandler.cpp
* \date 12/08/2018
* \author Olivier Langella
* \brief handler on MZ data file to read all spectrums and make basic
* statistics
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "msrunstatisticshandler.h"
#include <pappsomspp/msrun/msrunreader.h>
bool
MsRunStatisticsHandler::needPeakList() const
{
return true;
}
void
MsRunStatisticsHandler::setQualifiedSpectrum(
const pappso::QualifiedSpectrum &qspectrum)
{
unsigned int ms_level = qspectrum.getMsLevel();
if(ms_level == 0)
return;
if(ms_level > _count_ms_level_spectrum.size())
{
_count_ms_level_spectrum.resize(ms_level);
_tic_ms_level_spectrum.resize(ms_level);
}
_count_ms_level_spectrum[ms_level - 1]++;
pappso::SpectrumSp spectrum_sp = qspectrum.getOriginalSpectrumSp();
if(spectrum_sp != nullptr)
{
for(auto &&peak : *(spectrum_sp.get()))
{
_tic_ms_level_spectrum[ms_level - 1] += peak.intensity;
}
}
}
unsigned long
MsRunStatisticsHandler::getMsLevelCount(unsigned int ms_level) const
{
if(ms_level == 0)
return 0;
if(ms_level > _count_ms_level_spectrum.size())
return 0;
return (_count_ms_level_spectrum[ms_level - 1]);
}
pappso::pappso_double
MsRunStatisticsHandler::getMsLevelTic(unsigned int ms_level) const
{
if(ms_level == 0)
return 0;
if(ms_level > _tic_ms_level_spectrum.size())
return 0;
return (_tic_ms_level_spectrum[ms_level - 1]);
}
unsigned long
MsRunStatisticsHandler::getTotalCount() const
{
unsigned long total = 0;
for(unsigned long count : _count_ms_level_spectrum)
{
total += count;
}
return total;
}
/**
* \file utils/msrunstatisticshandler.h
* \date 12/08/2018
* \author Olivier Langella
* \brief handler on MZ data file to read all spectrums and make basic statistics
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp 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.
*
* XTPcpp 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 XTPcpp. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include <pappsomspp/msrun/msrunreader.h>
class MsRunStatisticsHandler : public pappso::SpectrumCollectionHandlerInterface
{
public:
virtual void setQualifiedSpectrum (const pappso::QualifiedSpectrum & qspectrum) override;
virtual bool needPeakList () const override ;
unsigned long getMsLevelCount(unsigned int ms_level) const;
pappso::pappso_double getMsLevelTic(unsigned int ms_level) const;
unsigned long getTotalCount() const;
private:
std::vector<unsigned long> _count_ms_level_spectrum;
std::vector<pappso::pappso_double> _tic_ms_level_spectrum;
};
......@@ -124,6 +124,9 @@ enum class MsRunStatistics : std::int8_t
total_spectra_ms1 = 2, ///< total number of MS1 spectra
total_spectra_ms2 = 3, ///< total number of MS2 spectra
total_spectra_ms3 = 4, ///< total number of MS3 spectra
tic_spectra_ms1 = 5, ///< total ion current in MS1 spectra
tic_spectra_ms2 = 6, ///< total ion current in MS2 spectra
tic_spectra_ms3 = 7, ///< total ion current in MS3 spectra
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment