libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
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
29
#include "
timsframerawdatachunck.h
"
30
#include <QDebug>
31
32
#include "
pappsomspp/core/pappsoexception.h
"
33
34
using namespace
pappso
;
35
36
TimsFrameRawDataChunck::TimsFrameRawDataChunck
()
37
{
38
}
39
40
TimsFrameRawDataChunck::~TimsFrameRawDataChunck
()
41
{
42
if
(
mpa_memoryBuffer
!=
nullptr
)
43
delete
[]
mpa_memoryBuffer
;
44
}
45
46
bool
47
TimsFrameRawDataChunck::readTimsFrame
(QFile *p_file,
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;
140
mpa_memoryBuffer
=
new
char
[
m_memoryBufferSize
];
141
}
142
if
((
m_memoryBufferSize
- 10) <
m_frameLength
)
143
{
144
if
(
mpa_memoryBuffer
!=
nullptr
)
145
{
146
delete
[]
mpa_memoryBuffer
;
147
}
148
m_memoryBufferSize
= (qint64)
m_frameLength
+ 10;
149
mpa_memoryBuffer
=
new
char
[
m_memoryBufferSize
];
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
179
char
*
180
pappso::TimsFrameRawDataChunck::getMemoryBuffer
()
const
181
{
182
return
mpa_memoryBuffer
;
183
}
184
185
quint32
186
pappso::TimsFrameRawDataChunck::getCompressedSize
()
const
187
{
188
return
m_frameLength
- 8;
189
}
190
191
quint32
192
pappso::TimsFrameRawDataChunck::getFrameNumberOfScans
()
const
193
{
194
return
m_frameNumberOfScans
;
195
}
196
197
quint32
198
pappso::TimsFrameRawDataChunck::getFrameLength
()
const
199
{
200
return
m_frameLength
;
201
}
202
203
std::size_t
204
pappso::TimsFrameRawDataChunck::getFrameId
()
const
205
{
206
return
m_frameId
;
207
}
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::TimsFrameRawDataChunck::TimsFrameRawDataChunck
TimsFrameRawDataChunck()
Definition
timsframerawdatachunck.cpp:36
pappso::TimsFrameRawDataChunck::getFrameId
std::size_t getFrameId() const
Definition
timsframerawdatachunck.cpp:204
pappso::TimsFrameRawDataChunck::~TimsFrameRawDataChunck
virtual ~TimsFrameRawDataChunck()
Definition
timsframerawdatachunck.cpp:40
pappso::TimsFrameRawDataChunck::getCompressedSize
quint32 getCompressedSize() const
Definition
timsframerawdatachunck.cpp:186
pappso::TimsFrameRawDataChunck::m_frameLength
quint32 m_frameLength
Definition
timsframerawdatachunck.h:71
pappso::TimsFrameRawDataChunck::getFrameNumberOfScans
quint32 getFrameNumberOfScans() const
Definition
timsframerawdatachunck.cpp:192
pappso::TimsFrameRawDataChunck::readTimsFrame
bool readTimsFrame(QFile *p_file, std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
Definition
timsframerawdatachunck.cpp:47
pappso::TimsFrameRawDataChunck::m_frameId
std::size_t m_frameId
Definition
timsframerawdatachunck.h:70
pappso::TimsFrameRawDataChunck::m_frameNumberOfScans
quint32 m_frameNumberOfScans
Definition
timsframerawdatachunck.h:72
pappso::TimsFrameRawDataChunck::m_memoryBufferSize
qint64 m_memoryBufferSize
Definition
timsframerawdatachunck.h:68
pappso::TimsFrameRawDataChunck::mpa_memoryBuffer
char * mpa_memoryBuffer
Definition
timsframerawdatachunck.h:67
pappso::TimsFrameRawDataChunck::getMemoryBuffer
char * getMemoryBuffer() const
Definition
timsframerawdatachunck.cpp:180
pappso::TimsFrameRawDataChunck::getFrameLength
quint32 getFrameLength() const
Definition
timsframerawdatachunck.cpp:198
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappsoexception.h
pappso::TimsFrameRecord
Definition
timsframerecord.h:35
pappso::TimsFrameRecord::tims_offset
std::size_t tims_offset
Definition
timsframerecord.h:37
timsframerawdatachunck.h
pappsomspp
core
vendors
tims
timsframerawdatachunck.cpp
Generated on
for libpappsomspp by
1.17.0