libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
timsframerawdatachunck.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/vendors/tims/timsframerawdatachunck.cpp
3 * \date 18/6/2022
4 * \author Olivier Langella
5 * \brief stores raw binary tims frame
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2022 Olivier Langella
10 *<Olivier.Langella@universite-paris-saclay.fr>.
11 *
12 * This file is part of the PAPPSOms++ library.
13 *
14 * PAPPSOms++ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * PAPPSOms++ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
30#include <QDebug>
31
33
34using namespace pappso;
35
39
45
46bool
48 std::size_t frameId,
49 const std::vector<pappso::TimsFrameRecord> &frame_record_list)
50{
51
52 m_frameId = frameId;
53 qint64 position = p_file->pos();
54 const pappso::TimsFrameRecord &frame_record = frame_record_list[frameId];
55 if(frameId == 1)
56 {
57 bool seekpos_ok = p_file->seek(frame_record.tims_offset);
58 if(!seekpos_ok)
59 {
60 throw PappsoException(QObject::tr("ERROR reading TIMS frame %1 "
61 "m_timsBinFile.seek(%3) failed")
62 .arg(frameId)
63 .arg(frame_record.tims_offset));
64 }
65 }
66 else
67 {
68
69 if(position == (qint64)frame_record.tims_offset)
70 {
71 // OK
72 }
73 else
74 {
75 // need to move to frame position :
76 if(position > (qint64)frame_record.tims_offset)
77 {
78 // get back
79 p_file->seek(frame_record.tims_offset);
80 position = p_file->pos();
81 }
82 else
83 {
84 const pappso::TimsFrameRecord &previous_frame_record = frame_record_list[frameId - 1];
85 if(position < (qint64)previous_frame_record.tims_offset)
86 {
87
88 throw PappsoException(QObject::tr("ERROR reading TIMS frame %1 "
89 "file position %2 is before previous frame %3")
90 .arg(frameId)
91 .arg(position)
92 .arg(previous_frame_record.tims_offset));
93 }
94 else
95 {
96 // catch up current position
97 qint64 move_size = (qint64)frame_record.tims_offset - position;
98 p_file->read(move_size);
99 position = p_file->pos();
100 }
101 }
102 }
103 }
104
105 if(position != (qint64)frame_record.tims_offset)
106 {
107
108 throw PappsoException(QObject::tr("ERROR reading TIMS frame %1 "
109 "file position %2 is different of frame offset %3")
110 .arg(frameId)
111 .arg(position)
112 .arg(frame_record.tims_offset));
113 }
114 // qDebug();
115 p_file->read((char *)&m_frameLength, 4);
116 // frame_length = qToBigEndian(frame_length);
117
118 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
119 // << " frame_length=" << frame_length;
120
121 // qDebug();
122 p_file->read((char *)&m_frameNumberOfScans, 4);
123 // scan_number = qToBigEndian(scan_number);
124
125 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
126 // << " pos=" << m_timsBinFile.pos();
127
128 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
129 // << " scan_number=" << scan_number;
130 // m_timsBinFile.seek(m_indexArray.at(timsId) + 8);
131
132
133 // qDebug();
134
135 // if (m_memoryBufferSize
136 if(mpa_memoryBuffer == nullptr)
137 {
138 qDebug() << "mpa_memoryBuffer == nullptr";
139 m_memoryBufferSize = (qint64)m_frameLength + 10;
141 }
143 {
144 if(mpa_memoryBuffer != nullptr)
145 {
146 delete[] mpa_memoryBuffer;
147 }
148 m_memoryBufferSize = (qint64)m_frameLength + 10;
150 }
151
152
153 // QByteArray frame_byte_array(mpa_memoryBuffer, m_memoryBufferSize);
154
155 // qDebug();
156 qint64 read_length = p_file->read(mpa_memoryBuffer, (qint64)m_frameLength - 8);
157 // qDebug();
158
159 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
160 // << " +frame_length-1="
161 // << (quint8) * (frame_byte_array.constData() + frame_length - 1);
162 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
163 // << " +frame_length="
164 // << (quint8) * (frame_byte_array.constData() + frame_length);
165 // m_timsBinFile.seek(m_indexArray.at(timsId) + 8);
166
167 if(read_length + 8 != (qint64)m_frameLength)
168 {
169 throw PappsoException(QObject::tr("ERROR reading TIMS frame %1: "
170 "read_length=%2 != %3frame_length")
171 .arg(frameId)
172 .arg(read_length)
173 .arg(m_frameLength));
174 }
175
176 return true;
177}
178
179char *
184
185quint32
190
191quint32
196
197quint32
202
203std::size_t
bool readTimsFrame(QFile *p_file, std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39