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)
 
virtual std::size_t spectrumStringIdentifier2SpectrumIndex (const QString &spectrum_identifier) override
 if possible, get the spectrum index given a string identifier throw a not found exception if spectrum identifier is not found
 
- 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 () override
 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 ()
 
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName () const override
 get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: instrument model def: "Instrument model name not including the vendor's name." [PSI:MS] relationship: part_of MS:1000463 ! instrument
 
- 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.

39 : TimsMsRunReaderMs2(msrun_id_csp)
40{
41 initialize();
42}
TimsMsRunReaderMs2(MsRunIdCstSPtr &msrun_id_csp)

References pappso::TimsMsRunReaderMs2::TimsMsRunReaderMs2(), and initialize().

Referenced by MsFileAccessor.

◆ ~TimsMsRunReaderMs2Selected()

TimsMsRunReaderMs2Selected::~TimsMsRunReaderMs2Selected ( )
virtual

Definition at line 44 of file timsmsrunreaderms2selected.cpp.

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

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 91 of file timsmsrunreaderms2selected.cpp.

92{
93 qDebug() << file_name;
94 return true;
95}

Referenced by MsFileAccessor.

◆ 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 313 of file timsmsrunreaderms2selected.cpp.

314{
315 return false;
316}

Referenced by MsFileAccessor.

◆ initialize()

void pappso::TimsMsRunReaderMs2Selected::initialize ( )
overrideprotectedvirtual

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 53 of file timsmsrunreaderms2selected.cpp.

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

References pappso::MsRunReader::mcsp_msRunId, pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors, and mpa_timsData.

Referenced by TimsMsRunReaderMs2Selected(), and MsFileAccessor.

◆ massSpectrumCstSPtr()

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

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 107 of file timsmsrunreaderms2selected.cpp.

108{
109 QualifiedMassSpectrum mass_spectrum = qualifiedMassSpectrum(spectrum_index, true);
110 return mass_spectrum.getMassSpectrumSPtr();
111}
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().

Referenced by MsFileAccessor.

◆ 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 99 of file timsmsrunreaderms2selected.cpp.

100{
101 QualifiedMassSpectrum mass_spectrum = qualifiedMassSpectrum(spectrum_index, true);
102 return mass_spectrum.getMassSpectrumSPtr();
103}

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

Referenced by MsFileAccessor.

◆ 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 115 of file timsmsrunreaderms2selected.cpp.

117{
118
119 std::size_t precursor_index = (spectrum_index / 2) + 1;
120
121 TimsDdaPrecursors::SpectrumDescr spectrum_descr =
122 mp_timsDdaPrecursors->getSpectrumDescrWithPrecursorId(precursor_index);
123
124 if(spectrum_index % 2 == 0)
125 {
126 qDebug();
127 // this is an MS1 spectrum
128 QualifiedMassSpectrum mass_spectrum_ms1;
129 mp_timsDdaPrecursors->getQualifiedMs1MassSpectrumBySpectrumDescr(
130 getMsRunId(), mass_spectrum_ms1, spectrum_descr, want_binary_data);
131 qDebug(); // << mass_spectrum_ms1.toString();
132
133 // qDebug() << mass_spectrum_ms1.getMassSpectrumSPtr().get()->toString();
134 return mass_spectrum_ms1;
135 }
136 else
137 {
138 qDebug();
139 QualifiedMassSpectrum mass_spectrum_ms2;
140 if(spectrum_descr.ms2_index != spectrum_index)
141 {
142 qDebug();
143 throw PappsoException(
144 QObject::tr("ERROR in %1 %2 %3 spectrum_descr.ms2_index != spectrum_index")
145 .arg(__FILE__)
146 .arg(__FUNCTION__)
147 .arg(__LINE__));
148 }
149 mp_timsDdaPrecursors->getQualifiedMs2MassSpectrumBySpectrumDescr(
150 getMsRunId(), mass_spectrum_ms2, spectrum_descr, want_binary_data);
151 qDebug(); // << mass_spectrum_ms2.toString();
152
153 // qDebug() << mass_spectrum_ms2.getMassSpectrumSPtr().get()->toString();
154 return mass_spectrum_ms2;
155 }
156}
const MsRunIdCstSPtr & getMsRunId() const

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

Referenced by massSpectrumCstSPtr(), massSpectrumSPtr(), MsFileAccessor, 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 160 of file timsmsrunreaderms2selected.cpp.

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

◆ readSpectrumCollection2()

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

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 299 of file timsmsrunreaderms2selected.cpp.

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

References readSpectrumCollection().

Referenced by MsFileAccessor.

◆ setMs1FilterCstSPtr()

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

Definition at line 76 of file timsmsrunreaderms2selected.cpp.

77{
78 if(mp_timsDdaPrecursors != nullptr)
79 {
80 mp_timsDdaPrecursors->setMs1FilterCstSPtr(filter);
81 }
82 else
83 {
84 throw PappsoException(
85 QObject::tr("ERROR in TimsMsRunReaderMs2Selected::setMs1FilterCstSPtr "
86 "mp_timsDdaPrecursors is null"));
87 }
88}
@ filter
concerning filters (psm, peptide, protein validation)

References pappso::filter, and pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors.

Referenced by MsFileAccessor.

◆ setMs2FilterCstSPtr()

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

Definition at line 61 of file timsmsrunreaderms2selected.cpp.

62{
63 if(mp_timsDdaPrecursors != nullptr)
64 {
65 mp_timsDdaPrecursors->setMs2FilterCstSPtr(filter);
66 }
67 else
68 {
69 throw PappsoException(
70 QObject::tr("ERROR in TimsMsRunReaderMs2Selected::setMs2FilterCstSPtr "
71 "mp_timsDdaPrecursors is null"));
72 }
73}

References pappso::filter, and pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors.

Referenced by MsFileAccessor.

◆ 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 306 of file timsmsrunreaderms2selected.cpp.

307{
308 return (mp_timsDdaPrecursors->getTotalPrecursorCount() * 2);
309}

References pappso::TimsMsRunReaderMs2::mp_timsDdaPrecursors.

Referenced by MsFileAccessor, and readSpectrumCollection().

◆ spectrumStringIdentifier2SpectrumIndex()

std::size_t TimsMsRunReaderMs2Selected::spectrumStringIdentifier2SpectrumIndex ( const QString & spectrum_identifier)
overridevirtual

if possible, get the spectrum index given a string identifier throw a not found exception if spectrum identifier is not found

Parameters
spectrum_identifierstring identifier of a specific spectrum
Returns
the spectrum index

Reimplemented from pappso::TimsMsRunReaderMs2.

Definition at line 320 of file timsmsrunreaderms2selected.cpp.

322{
323 throw pappso::ExceptionNotImplemented(
324 QObject::tr("%1 %2 %3 not implemented").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__));
325}

Referenced by MsFileAccessor.

Friends And Related Symbol Documentation

◆ MsFileAccessor

Member Data Documentation

◆ mpa_timsData

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

Definition at line 77 of file timsmsrunreaderms2selected.h.

Referenced by ~TimsMsRunReaderMs2Selected(), and initialize().


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