libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
timsmsfilereader.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msfile/timsmsfilereader.cpp
3 * \date 06/09/2019
4 * \author Olivier Langella
5 * \brief MSrun file reader for native Bruker TimsTOF raw data
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms++ is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
33#include <QDebug>
34#include <QFileInfo>
35
36namespace pappso
37{
38
39
40TimsMsFileReader::TimsMsFileReader(const QString &file_name) : MsFileReader(file_name)
41{
42 qDebug() << " " << m_fileName;
43 initialize();
44}
45
46
50
51
52std::size_t
54{
55
57 try
58 {
59 TimsData tims_data(m_fileName);
61 }
62
63 catch(ExceptionNotRecognized &error)
64 {
65 qWarning() << "tims data not recognized initializing TimsData object:\n" << error.qwhat();
66
68 QObject::tr("Bruker tims data file not recognized in %1 :\n%2")
69 .arg(m_fileName)
70 .arg(error.qwhat()));
71 return 0;
72 }
73 catch(PappsoException &error)
74 {
76 throw pappso::PappsoException(QObject::tr("Error reading Bruker tims data in %1 :\n%2")
77 .arg(m_fileName)
78 .arg(error.qwhat()));
79 }
80
81 return 1;
82}
83
84
90
91
92std::vector<MsRunIdCstSPtr>
93TimsMsFileReader::getMsRunIds(const QString &run_prefix)
94{
95 std::vector<MsRunIdCstSPtr> ms_run_ids;
96
97 if(!initialize())
98 return ms_run_ids;
99
100 // Finally create the MsRunId with the file name.
101 MsRunId ms_run_id(m_fileName);
102 ms_run_id.setMsDataFormat(m_fileFormat);
103
104 // We need to set the unambiguous xmlId string.
105 ms_run_id.setXmlId(QString("%1a1").arg(run_prefix));
106
107 ms_run_id.setRunId("a1");
108
109 // Now set the sample name to the run id:
110
111 ms_run_id.setSampleName(QFileInfo(m_fileName).baseName());
112
113 qDebug() << "Current ms_run_id:" << ms_run_id.toString();
114
115 // Finally make a shared pointer out of it and append it to the vector.
116 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
117
118 return ms_run_ids;
119}
120
121
122} // namespace pappso
excetion to use when an item type is not recognized
MsFileReader(const QString &file_name)
Enums::MsDataFormat m_fileFormat
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
QString toString() const
Definition msrunid.cpp:203
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:168
void setRunId(const QString &run_id)
Definition msrunid.cpp:133
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:147
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:77
virtual const QString & qwhat() const
virtual Enums::MsDataFormat getFileFormat() override
virtual std::size_t initialize()
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
TimsMsFileReader(const QString &file_name)
@ unknown
unknown format
Definition types.h:149
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39