libpappsomspp
Library for mass spectrometry
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 
28 #include "timsmsfilereader.h"
29 #include "../vendors/tims/timsdata.h"
30 #include "../pappsoexception.h"
31 #include <QDebug>
32 #include <QFileInfo>
33 
34 namespace pappso
35 {
36 
37 
38 TimsMsFileReader::TimsMsFileReader(const QString &file_name)
39  : MsFileReader(file_name)
40 {
41  qDebug() << " " << m_fileName;
42  initialize();
43 }
44 
45 
47 {
48 }
49 
50 
51 std::size_t
53 {
54 
55  m_fileFormat = MzFormat::unknown;
56  try
57  {
58  TimsData tims_data(m_fileName);
59  m_fileFormat = MzFormat::brukerTims;
60  }
61  catch(PappsoException &error)
62  {
63  return 0;
64  }
65 
66  return 1;
67 }
68 
69 
72 {
73  return m_fileFormat;
74 }
75 
76 
77 std::vector<MsRunIdCstSPtr>
78 TimsMsFileReader::getMsRunIds(const QString &run_prefix)
79 {
80  std::vector<MsRunIdCstSPtr> ms_run_ids;
81 
82  if(!initialize())
83  return ms_run_ids;
84 
85  // Finally create the MsRunId with the file name.
86  MsRunId ms_run_id(m_fileName);
87  ms_run_id.setMzFormat(m_fileFormat);
88 
89  // We need to set the unambiguous xmlId string.
90  ms_run_id.setXmlId(QString("%1a1").arg(run_prefix));
91 
92  ms_run_id.setRunId("a1");
93 
94  // Now set the sample name to the run id:
95 
96  ms_run_id.setSampleName(QFileInfo(m_fileName).baseName());
97 
98  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
99  << "Current ms_run_id:" << ms_run_id.toString();
100 
101  // Finally make a shared pointer out of it and append it to the vector.
102  ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
103 
104  return ms_run_ids;
105 }
106 
107 
108 } // namespace pappso
pappso::TimsMsFileReader::getFileFormat
virtual MzFormat getFileFormat() override
Definition: timsmsfilereader.cpp:71
timsmsfilereader.h
MSrun file reader for native Bruker TimsTOF raw data.
pappso::MsRunId::setMzFormat
void setMzFormat(MzFormat format)
Definition: msrunid.cpp:152
pappso::TimsMsFileReader::~TimsMsFileReader
virtual ~TimsMsFileReader()
Definition: timsmsfilereader.cpp:46
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::MsRunId::setXmlId
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition: msrunid.cpp:131
pappso::MsRunId::setRunId
void setRunId(const QString &run_id)
Definition: msrunid.cpp:117
pappso::MsRunId::setSampleName
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition: msrunid.cpp:73
pappso::TimsMsFileReader::getMsRunIds
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
Definition: timsmsfilereader.cpp:78
pappso::TimsMsFileReader::initialize
virtual std::size_t initialize()
Definition: timsmsfilereader.cpp:52
pappso::TimsData
Definition: timsdata.h:71
pappso::MsRunId
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition: msrunid.h:53
pappso::MsFileReader::m_fileFormat
MzFormat m_fileFormat
Definition: msfilereader.h:18
pappso::MsFileReader::m_fileName
QString m_fileName
Definition: msfilereader.h:17
pappso::TimsMsFileReader::TimsMsFileReader
TimsMsFileReader(const QString &file_name)
Definition: timsmsfilereader.cpp:38
pappso::MsFileReader
Definition: msfilereader.h:15
pappso::MzFormat
MzFormat
Definition: types.h:107
pappso::PappsoException
Definition: pappsoexception.h:42
pappso::MsRunId::toString
QString toString() const
Definition: msrunid.cpp:187