libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzcbormsfilereader.cpp
Go to the documentation of this file.
2
5
6namespace pappso
7{
8
9
15
16
20
21
24{
25 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
26 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
27 // << std::endl;
28
29 return m_fileFormat;
30}
31
32std::size_t
34{
35
37 QString str_index_file = m_fileName;
38 QFileInfo mzcbor_index_fileinfo(str_index_file.append(".idx"));
39 if(mzcbor_index_fileinfo.exists())
40 {
41 qDebug() << "mzcbor_index_fileinfo.exists()";
42 QFile mzcbor_index_file(mzcbor_index_fileinfo.absoluteFilePath());
43 mzcbor_index_file.open(QIODevice::ReadOnly);
44
45 m_mzcborIndexReader.readCbor(&mzcbor_index_file);
46 if(m_mzcborIndexReader.isMzcborIndex())
47 {
49 }
50 m_mzcborIndexReader.close();
51 mzcbor_index_file.close();
52
53 qDebug() << m_mzcborIndexReader.getRunIdList().size();
54
55 return m_mzcborIndexReader.getRunIdList().size();
56 }
57 else
58 {
59 qDebug();
60 QFile mzcbor_file(m_fileName);
61 mzcbor_file.open(QIODevice::ReadOnly);
62
63 m_mzcborReaderBase.readCbor(&mzcbor_file, monitor);
64 if(m_mzcborReaderBase.isMzcbor())
65 {
67 }
68 m_mzcborReaderBase.close();
69 mzcbor_file.close();
70
71 qDebug() << m_mzcborReaderBase.getMsrunIdList().join(" ");
72
73 return m_mzcborReaderBase.getMsrunIdList().size();
74 }
75}
76
77
78std::vector<MsRunIdCstSPtr>
79MzcborMsFileReader::getMsRunIds(const QString &run_prefix)
80{
81 std::vector<MsRunIdCstSPtr> ms_run_ids;
82
83
85 {
86
87 if(m_mzcborIndexReader.getRunIdList().size() > 0)
88 {
89 qDebug();
90 std::size_t iter = 0;
91 for(auto &msrun_id_str : m_mzcborIndexReader.getRunIdList())
92 {
93 MsRunId ms_run_id(m_fileName, msrun_id_str);
94
95
96 // Set the MS data format as determined in initialize().
98
99 // We need to set the unambiguous xmlId string.
100 ms_run_id.setXmlId(
101 QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
102
103 // Now set the sample name to the run id : we can not do that, this is not the use
104 // sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
105
106 // And if it is possible, the real sample name because this one is for the
107 // end user to recognize his sample:
108 ms_run_id.setSampleName(msrun_id_str);
109
110
111 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
112 iter++;
113 }
114 }
115 else
116 {
117
118 std::size_t iter = 0;
119 for(auto &msrun_id_str : m_mzcborReaderBase.getMsrunIdList())
120 {
121 MsRunId ms_run_id(m_fileName, msrun_id_str);
122
123
124 // Set the MS data format as determined in initialize().
125 ms_run_id.setMsDataFormat(m_fileFormat);
126
127 // We need to set the unambiguous xmlId string.
128 ms_run_id.setXmlId(
129 QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
130
131 // Now set the sample name to the run id : we can not do that, this is not the use
132 // sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
133
134 // And if it is possible, the real sample name because this one is for the
135 // end user to recognize his sample:
136 ms_run_id.setSampleName(msrun_id_str);
137
138
139 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
140 iter++;
141 }
142 }
143 }
144
145 return ms_run_ids;
146}
147} // namespace pappso
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
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:168
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
pappso::cbor::mzcbor::MzcborIndexReader m_mzcborIndexReader
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
virtual Enums::MsDataFormat getFileFormat() override
pappso::cbor::mzcbor::MzcborReaderBase m_mzcborReaderBase
MzcborMsFileReader(const QString &file_name)
virtual std::size_t initialize()
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72
const std::vector< QString > & getRunIdList() const
const QStringList & getMsrunIdList() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39