libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::TimsMsRunReaderMs2Selected Class Reference

#include <timsmsrunreaderms2selected.h>

Inheritance diagram for pappso::TimsMsRunReaderMs2Selected:
pappso::TimsMsRunReaderMs2 pappso::TimsMsRunReaderBase pappso::MsRunReader

Public Member Functions

 TimsMsRunReaderMs2Selected (MsRunIdCstSPtr &msrun_id_csp)
 
virtual ~TimsMsRunReaderMs2Selected ()
 
virtual MassSpectrumSPtr massSpectrumSPtr (std::size_t spectrum_index) override
 get a MassSpectrumSPtr class given its spectrum index
 
virtual MassSpectrumCstSPtr massSpectrumCstSPtr (std::size_t spectrum_index) override
 
virtual QualifiedMassSpectrum qualifiedMassSpectrum (std::size_t spectrum_index, bool want_binary_data=true) const override
 get a QualifiedMassSpectrum class given its scan number
 
virtual void readSpectrumCollection (SpectrumCollectionHandlerInterface &handler) override
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
 
virtual void readSpectrumCollection2 (const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
 
virtual std::size_t spectrumListSize () const override
 get the totat number of spectrum conained in the MSrun data file
 
virtual bool hasScanNumbers () const override
 tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided functions can check if scan numbers are available in the current file
 
void setMs2FilterCstSPtr (pappso::FilterInterfaceCstSPtr filter)
 
void setMs1FilterCstSPtr (pappso::FilterInterfaceCstSPtr filter)
 
- Public Member Functions inherited from pappso::TimsMsRunReaderMs2
 TimsMsRunReaderMs2 (MsRunIdCstSPtr &msrun_id_csp)
 
 TimsMsRunReaderMs2 (const TimsMsRunReaderBase &msrun_reader_base)
 
virtual ~TimsMsRunReaderMs2 ()
 
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
 get a xic coordinate object from a given spectrum index
 
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum (const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
 get a xic coordinate object from a given spectrum
 
virtual void readSpectrumCollectionByMsLevel (SpectrumCollectionHandlerInterface &handler, unsigned int ms_level) override
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
 
void setMs2FilterCstSPtr (pappso::FilterInterfaceCstSPtr filter)
 
void setMs1FilterCstSPtr (pappso::FilterInterfaceCstSPtr filter)
 
void setMs2BuiltinCentroid (bool centroid)
 enable or disable simple centroid filter on raw tims data for MS2
 
virtual std::vector< std::size_t > getPrecursorsIDFromMzRt (int charge, double mz_val, double rt_sec, double k0)
 Get all the precursors id which match the values.
 
virtual bool releaseDevice () override
 release data back end device if a the data back end is released, the developper has to use acquireDevice before using the msrunreader object
 
virtual bool acquireDevice () override
 acquire data back end device
 
virtual TimsDataSp getTimsDataSPtr ()
 give an access to the underlying raw data pointer
 
virtual std::vector< double > getRetentionTimeLine () override
 retention timeline get retention times along the MSrun in seconds
 
virtual Trace getTicChromatogram () override
 get a TIC chromatogram
 
- Public Member Functions inherited from pappso::TimsMsRunReaderBase
 TimsMsRunReaderBase (MsRunIdCstSPtr &msrun_id_csp)
 
 TimsMsRunReaderBase (const TimsMsRunReaderBase &msrun_reader_base)
 
virtual ~TimsMsRunReaderBase ()
 
- Public Member Functions inherited from pappso::MsRunReader
 MsRunReader (const MsRunIdCstSPtr &ms_run_id)
 
 MsRunReader (const MsRunReader &other)
 
virtual ~MsRunReader ()
 
const MsRunIdCstSPtrgetMsRunId () const
 
virtual std::size_t scanNumber2SpectrumIndex (std::size_t scan_number)
 if possible, converts a scan number into a spectrum index This is a convenient function to help transition from the old scan number (not implemented by all vendors) to more secure spectrum index (not vendor dependant). It is better to not rely on this function.
 
void setMonoThread (bool is_mono_thread)
 set only one is_mono_thread to true
 
bool isMonoThread () const
 

Protected Member Functions

virtual void initialize () override
 
virtual bool accept (const QString &file_name) const override
 tells if the reader is able to handle this file must be implemented by private MS run reader, specific of one or more file format
 

Private Attributes

TimsDatampa_timsData = nullptr
 

Friends

class MsFileAccessor
 

Additional Inherited Members

- Protected Attributes inherited from pappso::TimsMsRunReaderMs2
TimsDdaPrecursorsmp_timsDdaPrecursors = nullptr
 
- Protected Attributes inherited from pappso::TimsMsRunReaderBase
TimsDataSp msp_timsData = nullptr
 
- Protected Attributes inherited from pappso::MsRunReader
MsRunIdCstSPtr mcsp_msRunId
 
MsRunReaderScanNumberMultiMapmpa_multiMapScanNumber = nullptr
 

Detailed Description

Definition at line 41 of file timsmsrunreaderms2selected.h.

Constructor & Destructor Documentation

◆ TimsMsRunReaderMs2Selected()

TimsMsRunReaderMs2Selected::TimsMsRunReaderMs2Selected ( MsRunIdCstSPtr msrun_id_csp)
Todo:
write docs

Definition at line 38 of file timsmsrunreaderms2selected.cpp.

References initialize().

◆ ~TimsMsRunReaderMs2Selected()

TimsMsRunReaderMs2Selected::~TimsMsRunReaderMs2Selected ( )
virtual

Definition at line 45 of file timsmsrunreaderms2selected.cpp.

46{
47 if(mpa_timsData != nullptr)
48 {
49 delete mpa_timsData;
50 }
51}

References mpa_timsData.

Member Function Documentation

◆ accept()

bool TimsMsRunReaderMs2Selected::accept ( const QString &  file_name) const
overrideprotectedvirtual

tells if the reader is able to handle this file must be implemented by private MS run reader, specific of one or more file format

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 94 of file timsmsrunreaderms2selected.cpp.

95{
96 qDebug() << file_name;
97 return true;
98}

◆ hasScanNumbers()

bool TimsMsRunReaderMs2Selected::hasScanNumbers ( ) const
overridevirtual

tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided functions can check if scan numbers are available in the current file

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 326 of file timsmsrunreaderms2selected.cpp.

327{
328 return false;
329}

◆ initialize()

void pappso::TimsMsRunReaderMs2Selected::initialize ( )
overrideprotectedvirtual

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 54 of file timsmsrunreaderms2selected.cpp.

55{
56 mpa_timsData = new TimsData(mcsp_msRunId.get()->getFileName());
57
59}
MsRunIdCstSPtr mcsp_msRunId
TimsDdaPrecursors * getTimsDdaPrecursorsPtr() const
TimsDdaPrecursors * mp_timsDdaPrecursors

Referenced by TimsMsRunReaderMs2Selected().

◆ massSpectrumCstSPtr()

pappso::MassSpectrumCstSPtr TimsMsRunReaderMs2Selected::massSpectrumCstSPtr ( std::size_t  spectrum_index)
overridevirtual

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 111 of file timsmsrunreaderms2selected.cpp.

112{
113 QualifiedMassSpectrum mass_spectrum =
114 qualifiedMassSpectrum(spectrum_index, true);
115 return mass_spectrum.getMassSpectrumSPtr();
116}
Class representing a fully specified mass spectrum.
MassSpectrumSPtr getMassSpectrumSPtr() const
Get the MassSpectrumSPtr.
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number

References pappso::QualifiedMassSpectrum::getMassSpectrumSPtr(), and qualifiedMassSpectrum().

◆ massSpectrumSPtr()

pappso::MassSpectrumSPtr TimsMsRunReaderMs2Selected::massSpectrumSPtr ( std::size_t  spectrum_index)
overridevirtual

get a MassSpectrumSPtr class given its spectrum index

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 102 of file timsmsrunreaderms2selected.cpp.

103{
104 QualifiedMassSpectrum mass_spectrum =
105 qualifiedMassSpectrum(spectrum_index, true);
106 return mass_spectrum.getMassSpectrumSPtr();
107}

References pappso::QualifiedMassSpectrum::getMassSpectrumSPtr(), and qualifiedMassSpectrum().

◆ qualifiedMassSpectrum()

QualifiedMassSpectrum TimsMsRunReaderMs2Selected::qualifiedMassSpectrum ( std::size_t  spectrum_index,
bool  want_binary_data = true 
) const
overridevirtual

get a QualifiedMassSpectrum class given its scan number

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 120 of file timsmsrunreaderms2selected.cpp.

122{
123
124 std::size_t precursor_index = (spectrum_index / 2) + 1;
125
126 TimsDdaPrecursors::SpectrumDescr spectrum_descr =
128
129 if(spectrum_index % 2 == 0)
130 {
131 qDebug();
132 // this is an MS1 spectrum
133 QualifiedMassSpectrum mass_spectrum_ms1;
135 getMsRunId(), mass_spectrum_ms1, spectrum_descr, want_binary_data);
136 qDebug(); // << mass_spectrum_ms1.toString();
137
138 // qDebug() << mass_spectrum_ms1.getMassSpectrumSPtr().get()->toString();
139 return mass_spectrum_ms1;
140 }
141 else
142 {
143 qDebug();
144 QualifiedMassSpectrum mass_spectrum_ms2;
145 if(spectrum_descr.ms2_index != spectrum_index)
146 {
147 qDebug();
148 throw PappsoException(
149 QObject::tr(
150 "ERROR in %1 %2 %3 spectrum_descr.ms2_index != spectrum_index")
151 .arg(__FILE__)
152 .arg(__FUNCTION__)
153 .arg(__LINE__));
154 }
156 getMsRunId(), mass_spectrum_ms2, spectrum_descr, want_binary_data);
157 qDebug(); // << mass_spectrum_ms2.toString();
158
159 // qDebug() << mass_spectrum_ms2.getMassSpectrumSPtr().get()->toString();
160 return mass_spectrum_ms2;
161 }
162}
const MsRunIdCstSPtr & getMsRunId() const
void getQualifiedMs1MassSpectrumBySpectrumDescr(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, const SpectrumDescr &spectrum_descr, bool want_binary_data)
void getQualifiedMs2MassSpectrumBySpectrumDescr(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, const SpectrumDescr &spectrum_descr, bool want_binary_data)
TimsDdaPrecursors::SpectrumDescr getSpectrumDescrWithPrecursorId(std::size_t precursor_id) const
get an intermediate structure describing a spectrum

References pappso::MsRunReader::getMsRunId(), pappso::TimsDdaPrecursors::getQualifiedMs1MassSpectrumBySpectrumDescr(), pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr(), pappso::TimsDdaPrecursors::getSpectrumDescrWithPrecursorId(), pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors, and pappso::TimsDdaPrecursors::SpectrumDescr::ms2_index.

Referenced by massSpectrumCstSPtr(), massSpectrumSPtr(), and readSpectrumCollection().

◆ readSpectrumCollection()

void TimsMsRunReaderMs2Selected::readSpectrumCollection ( SpectrumCollectionHandlerInterface handler)
overridevirtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 166 of file timsmsrunreaderms2selected.cpp.

168{
169 const bool want_binary_data = handler.needPeakList();
170 // const bool want_binary_data = false;
171
172 // We'll need it to perform the looping in the spectrum list.
173 std::size_t spectrum_list_size = spectrumListSize();
174
175 // qDebug() << "The spectrum list has size:" << spectrum_list_size;
176
177 // Inform the handler of the spectrum list so that it can handle feedback to
178 // the user.
179 handler.spectrumListHasSize(spectrum_list_size);
180
181 std::vector<size_t> selected_precursor{63905,
182 73549,
183 105675,
184 130439,
185 177297,
186 177369,
187 177483,
188 190453,
189 196967,
190 246691,
191 271215,
192 289423,
193 310669};
194 // QFile temp_output("/data/temp.txt");
195 // temp_output.open(QIODevice::WriteOnly | QIODevice::Text);
196 // QTextStream out(&temp_output);
197
198 // Iterate in the full list of spectra.
199 bool readAhead = handler.isReadAhead();
200
201 if(readAhead)
202 {
203
204 std::size_t process_list_size = 300;
205
206 struct tmp_item
207 {
208 QualifiedMassSpectrum qualified_mass_spectrum;
209 std::size_t iter;
210 bool want_binary_data;
211 };
212
213 for(std::size_t i = 0; i < spectrum_list_size; i += process_list_size)
214 {
215 // QTextStream out(&temp_output);
216 qDebug();
217 // If the user of this reader instance wants to stop reading the
218 // spectra, then break this loop.
219 if(handler.shouldStop())
220 {
221 qDebug() << "The operation was cancelled. Breaking the loop.";
222 break;
223 }
224 std::vector<tmp_item> item_list;
225 for(std::size_t iter = 0;
226 (iter < process_list_size) && ((iter + i) < spectrum_list_size);
227 iter++)
228 {
229 if(std::find(selected_precursor.begin(),
230 selected_precursor.end(),
231 iter + i) != selected_precursor.end())
232 {
233 bool get_data = want_binary_data;
234 if((iter + i) % 2 == 0)
235 { // MS1
236 get_data = handler.needMsLevelPeakList(1);
237 }
238 else
239 {
240 get_data = handler.needMsLevelPeakList(2);
241 }
242
243 item_list.push_back(
244 {QualifiedMassSpectrum(), iter + i, get_data});
245 }
246 }
247 qDebug() << item_list.size();
248 // Use QtConcurrentBlocking::mapped to apply the scale function to all
249 // the images in the list.
250 QtConcurrent::blockingMap(
251 item_list.begin(), item_list.end(), [this](tmp_item &one_item) {
252 qDebug() << one_item.iter;
253 one_item.qualified_mass_spectrum =
254 qualifiedMassSpectrum(one_item.iter, one_item.want_binary_data);
255
256 // qDebug() << one_item.qualified_mass_spectrum.size() << " " <<
257 // one_item.qualified_mass_spectrum.getMassSpectrumSPtr().get()->toString();
258 });
259
260 qDebug() << item_list.size();
261 for(auto &item : item_list)
262 {
263 // qDebug() <<
264 // item.qualified_mass_spectrum.getMassSpectrumSPtr()
265 // .get()
266 // ->toString();
267 handler.setQualifiedMassSpectrum(item.qualified_mass_spectrum);
268 qDebug();
269 }
270 }
271 }
272 else
273 {
274 for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
275 {
276 qDebug();
277 // If the user of this reader instance wants to stop reading the
278 // spectra, then break this loop.
279 if(handler.shouldStop())
280 {
281 qDebug() << "The operation was cancelled. Breaking the loop.";
282 break;
283 }
284 bool get_data = want_binary_data;
285 if(iter % 2 == 0)
286 { // MS1
287 if(!handler.needMsLevelPeakList(1))
288 {
289 get_data = false;
290 }
291 }
292 QualifiedMassSpectrum qualified_mass_spectrum =
293 qualifiedMassSpectrum(iter, get_data);
294 handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
295 qDebug();
296 }
297 }
298 // End of
299 // for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
300
301 // Now let the loading handler know that the loading of the data has
302 // ended. The handler might need this "signal" to perform additional tasks
303 // or to cleanup cruft.
304
305 // qDebug() << "Loading ended";
306 // temp_output.close();
307 handler.loadingEnded();
308}
virtual bool isReadAhead() const
tells if we want to read ahead spectrum
virtual bool needPeakList() const =0
tells if we need the peak list (if we want the binary data) for each spectrum
virtual bool needMsLevelPeakList(unsigned int ms_level) const final
tells if we need the peak list (if we want the binary data) for each spectrum, given an MS level
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file

References pappso::SpectrumCollectionHandlerInterface::isReadAhead(), pappso::SpectrumCollectionHandlerInterface::loadingEnded(), pappso::SpectrumCollectionHandlerInterface::needMsLevelPeakList(), pappso::SpectrumCollectionHandlerInterface::needPeakList(), qualifiedMassSpectrum(), pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum(), pappso::SpectrumCollectionHandlerInterface::shouldStop(), pappso::SpectrumCollectionHandlerInterface::spectrumListHasSize(), and spectrumListSize().

Referenced by readSpectrumCollection2().

◆ readSpectrumCollection2()

void TimsMsRunReaderMs2Selected::readSpectrumCollection2 ( const MsRunReadConfig config,
SpectrumCollectionHandlerInterface handler 
)
overridevirtual

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 311 of file timsmsrunreaderms2selected.cpp.

314{
315 return readSpectrumCollection(handler);
316}
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

References readSpectrumCollection().

◆ setMs1FilterCstSPtr()

void TimsMsRunReaderMs2Selected::setMs1FilterCstSPtr ( pappso::FilterInterfaceCstSPtr  filter)

Definition at line 78 of file timsmsrunreaderms2selected.cpp.

80{
81 if(mp_timsDdaPrecursors != nullptr)
82 {
84 }
85 else
86 {
87 throw PappsoException(
88 QObject::tr("ERROR in TimsMsRunReaderMs2Selected::setMs1FilterCstSPtr "
89 "mp_timsDdaPrecursors is null"));
90 }
91}
void setMs1FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter)
filter interface to apply just after raw MS1 specturm extraction the filter can be a list of filters ...

References pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors, and pappso::TimsDdaPrecursors::setMs1FilterCstSPtr().

◆ setMs2FilterCstSPtr()

void TimsMsRunReaderMs2Selected::setMs2FilterCstSPtr ( pappso::FilterInterfaceCstSPtr  filter)

Definition at line 62 of file timsmsrunreaderms2selected.cpp.

64{
65 if(mp_timsDdaPrecursors != nullptr)
66 {
68 }
69 else
70 {
71 throw PappsoException(
72 QObject::tr("ERROR in TimsMsRunReaderMs2Selected::setMs2FilterCstSPtr "
73 "mp_timsDdaPrecursors is null"));
74 }
75}
void setMs2FilterCstSPtr(pappso::FilterInterfaceCstSPtr &filter)
filter interface to apply just after raw MS2 specturm extraction the filter can be a list of filters ...

References pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors, and pappso::TimsDdaPrecursors::setMs2FilterCstSPtr().

◆ spectrumListSize()

std::size_t TimsMsRunReaderMs2Selected::spectrumListSize ( ) const
overridevirtual

get the totat number of spectrum conained in the MSrun data file

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 319 of file timsmsrunreaderms2selected.cpp.

320{
322}
std::size_t getTotalPrecursorCount() const
get the number of precursors analyzed by PASEF

References pappso::TimsDdaPrecursors::getTotalPrecursorCount(), and pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors.

Referenced by readSpectrumCollection().

Friends And Related Symbol Documentation

◆ MsFileAccessor

friend class MsFileAccessor
friend

Definition at line 43 of file timsmsrunreaderms2selected.h.

Member Data Documentation

◆ mpa_timsData

TimsData* pappso::TimsMsRunReaderMs2Selected::mpa_timsData = nullptr
private

Definition at line 78 of file timsmsrunreaderms2selected.h.

Referenced by ~TimsMsRunReaderMs2Selected().


The documentation for this class was generated from the following files: