Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension of bruker precursor information (2nd attempt) #3191

Merged
merged 29 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ba475f1
Feature Reader Bruker with extended precursor info
xjasg Nov 6, 2023
c9f071e
Collisional Cross Sectional Area added
Andre99999999 Sep 4, 2024
5c7e77a
mzXML and MGF Reader/Writer externded
xjasg Nov 19, 2023
e8e5c5e
Bugfix Typo
xjasg Nov 25, 2023
112bf17
Changes after review
Andre99999999 Sep 4, 2024
0b8ffc4
Bugfix merges
Andre99999999 Sep 4, 2024
ee17fef
Test files changed
Andre99999999 Sep 7, 2024
8aeecd0
lowest and highest observed mz
Andre99999999 Sep 29, 2024
0f3b1a3
small cleanup
Andre99999999 Sep 29, 2024
8104588
Merge branch 'master' into feature/bruker_precursor_2
xjasg Oct 10, 2024
3ab4cff
Bugfix
Andre99999999 Oct 10, 2024
912c3c6
Fix Build exception
Andre99999999 Oct 11, 2024
56949cf
Bugfix unused header
Andre99999999 Oct 11, 2024
e7bf0d5
Revert changes after review
Andre99999999 Oct 11, 2024
3e7fd96
Remove unnecessary code
Andre99999999 Oct 11, 2024
5f5a974
Remove unused function
Andre99999999 Oct 11, 2024
ef4e5d4
cleanup
Andre99999999 Oct 11, 2024
e2e6ea2
Revert "lowest and highest observed mz"
Andre99999999 Oct 11, 2024
bb1a8ee
Partially revert last changes ( add intensity population again )
Andre99999999 Oct 31, 2024
853d207
Whitespace issues
Andre99999999 Nov 1, 2024
701ac75
merge latest version
Andre99999999 Nov 1, 2024
a80d333
Whitespace issue
Andre99999999 Nov 1, 2024
f4213a0
MGF Serializer + Spectrum list changes (Revwiew findings)
Andre99999999 Nov 6, 2024
e487769
Bugfix Build error
Andre99999999 Nov 6, 2024
73aca39
Extend MGF test with new parameters
Andre99999999 Nov 8, 2024
c18d414
Cleanup
Andre99999999 Nov 12, 2024
3cb5ae3
Bugfix remove ccs Parameter from title after mgf file was read
Andre99999999 Dec 27, 2024
924b415
Merge branch 'master' into feature/bruker_precursor_2
chambm Jan 9, 2025
3587b11
Merge branch 'master' into feature/bruker_precursor_2
chambm Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 25 additions & 36 deletions pwiz_aux/msrc/utility/vendor_api/Bruker/TimsData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
vector<double> scanNumbers(maxNumScans+1);
for (int i = 0; i <= maxNumScans; ++i)
scanNumbers[i] = i;

for (size_t i = 0; i < oneOverK0ByScanNumberByCalibration_.size(); ++i)
{
vector<double>& oneOverK0 = oneOverK0ByScanNumberByCalibration_[i];
Expand Down Expand Up @@ -320,7 +319,7 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
{
if (isDdaPasef)
{
string querySql = "SELECT Frame, ScanNumBegin, ScanNumEnd, IsolationMz, IsolationWidth, CollisionEnergy, LargestPeakMz, MonoisotopicMz, Charge, ScanNumber, Intensity, Parent "
string querySql = "SELECT Frame, ScanNumBegin, ScanNumEnd, IsolationMz, IsolationWidth, CollisionEnergy, MonoisotopicMz, Charge, ScanNumber, Intensity, Parent "
"FROM PasefFrameMsMsInfo f "
"JOIN Precursors p ON p.id=f.precursor " +
pasefIsolationMzFilter +
Expand All @@ -338,7 +337,6 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
auto& frame = findItr->second;

frame->pasef_precursor_info_.emplace_back(new PasefPrecursorInfo);

PasefPrecursorInfo& info = *frame->pasef_precursor_info_.back();

info.scanBegin = row.get<int>(++idx);
Expand All @@ -347,7 +345,6 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
info.isolationMz = row.get<double>(++idx);
info.isolationWidth = row.get<double>(++idx);
info.collisionEnergy = row.get<double>(++idx);
largestPeakMz = row.get<double>(++idx);
info.monoisotopicMz = row.get<double>(++idx);
info.charge = row.get<int>(++idx);
info.avgScanNumber = row.get<double>(++idx);
Expand Down Expand Up @@ -387,8 +384,6 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
// NB: some data has ScanNumEnd > NumScans, which should not happen because ScanNumEnd is supposed to be an exclusive 0-based index, so clamp it here
info.numScans = min(frame->numScans(), 1 + scanEnd) - scanBegin;

const map<double, int>& scanNumberByOneOverK0 = scanNumberByOneOverK0ByCalibrationIndex[frame->calibrationIndex_];

if (!isolationMzFilter_.empty())
{
// swap values for min/max below
Expand All @@ -413,6 +408,8 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
break;
}

const map<double, int>& scanNumberByOneOverK0 = scanNumberByOneOverK0ByCalibrationIndex[frame->calibrationIndex_];

// 1/k0 is inverse to scan number (lowest scan number is highest 1/k0)
auto scanNumLowerBoundItr = scanNumberByOneOverK0.upper_bound(mzMobilityWindow.mobilityBounds.get().second); --scanNumLowerBoundItr;
auto scanNumUpperBoundItr = scanNumberByOneOverK0.upper_bound(mzMobilityWindow.mobilityBounds.get().first); if (scanNumUpperBoundItr != scanNumberByOneOverK0.begin()) --scanNumUpperBoundItr;
Expand Down Expand Up @@ -541,22 +538,22 @@ TimsDataImpl::TimsDataImpl(const string& rawpath, bool combineIonMobilitySpectra
{
const auto& precursor = frame->pasef_precursor_info_[p];

// add MS2s that don't have PASEF info (between last precursor's scanEnd and this precursor's scanBegin)
if (p > 0)
{
const auto& lastPrecursor = frame->pasef_precursor_info_[p - 1];
for (int i = lastPrecursor->scanEnd + 1; i < precursor->scanBegin; ++i, ++scanIndex)
// add MS2s that don't have PASEF info (between last precursor's scanEnd and this precursor's scanBegin)
if (p > 0)
{
spectra_.emplace_back(boost::make_shared<TimsSpectrumPASEF>(frame, i, TimsSpectrum::empty_));
const auto& lastPrecursor = frame->pasef_precursor_info_[p - 1];
for (int i = lastPrecursor->scanEnd + 1; i < precursor->scanBegin; ++i, ++scanIndex)
{
spectra_.emplace_back(boost::make_shared<TimsSpectrumPASEF>(frame, i, TimsSpectrum::empty_));
}
}
}
else
{
for (int i = 0; i < precursor->scanBegin; ++i, ++scanIndex)
else
{
spectra_.emplace_back(boost::make_shared<TimsSpectrumPASEF>(frame, i, TimsSpectrum::empty_));
for (int i = 0; i < precursor->scanBegin; ++i, ++scanIndex)
{
spectra_.emplace_back(boost::make_shared<TimsSpectrumPASEF>(frame, i, TimsSpectrum::empty_));
}
}
}

// add MS2s for this precursor
for (int i = precursor->scanBegin; i <= precursor->scanEnd; ++i, ++scanIndex)
Expand Down Expand Up @@ -604,11 +601,6 @@ double TimsDataImpl::oneOverK0ToCCS(double oneOverK0, double mz, int charge) con
return tims_oneoverk0_to_ccs_for_mz(oneOverK0, charge, mz);
}

double TimsDataImpl::oneOverK0ToCCS(double oneOverK0, int charge) const
{
return oneOverK0ToCCS(oneOverK0, largestPeakMz, charge);
}

double TimsDataImpl::ccsToOneOverK0(double ccs, double mz, int charge) const
{
return tims_ccs_to_oneoverk0_for_mz(ccs, charge, mz);
Expand Down Expand Up @@ -862,21 +854,16 @@ void TimsSpectrum::getIsolationData(std::vector<IsolationInfo>& isolationInfo) c
if (HasPasefPrecursorInfo())
{
const auto& info = GetPasefPrecursorInfo();
isolationInfo.resize(1, IsolationInfo{
info.isolationMz, IsolationMode_On, info.collisionEnergy,
info.intensity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You reverted your intensity population here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding this. I will fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

});
isolationInfo.resize(1, IsolationInfo{ info.isolationMz, IsolationMode_On, info.collisionEnergy });
}
else if (!frame_.diaPasefIsolationInfoByScanNumber_.empty())
{
const auto& info = getDiaPasefIsolationInfo();
isolationInfo.resize(1, IsolationInfo{
info.isolationMz, IsolationMode_On, info.collisionEnergy, 0
});
isolationInfo.resize(1, IsolationInfo{ info.isolationMz, IsolationMode_On, info.collisionEnergy });
}
else if (frame_.precursorMz_.is_initialized())
{
isolationInfo.resize(1, IsolationInfo{ frame_.precursorMz_.get(), IsolationMode_On, 0 });
isolationInfo.resize(1, IsolationInfo{ frame_.precursorMz_.get(), IsolationMode_On, 0 });
}
}

Expand Down Expand Up @@ -916,18 +903,20 @@ int TimsSpectrum::getChargeState() const
{
if (HasPasefPrecursorInfo())
return GetPasefPrecursorInfo().charge;
return frame_.chargeState_.get_value_or(0);
else
return frame_.chargeState_.get_value_or(0);
}

double TimsSpectrum::getIsolationWidth() const
{
if (HasPasefPrecursorInfo())
return GetPasefPrecursorInfo().isolationWidth;

if (!frame_.diaPasefIsolationInfoByScanNumber_.empty())
else if (!frame_.diaPasefIsolationInfoByScanNumber_.empty())
{
return getDiaPasefIsolationInfo().isolationWidth;

return frame_.isolationWidth_.get_value_or(0);
}
else
return frame_.isolationWidth_.get_value_or(0);
}

int TimsSpectrum::getWindowGroup() const
Expand Down
4 changes: 0 additions & 4 deletions pwiz_aux/msrc/utility/vendor_api/Bruker/TimsData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ struct PWIZ_API_DECL TimsDataImpl : public CompassData

virtual double oneOverK0ToCCS(double oneOverK0, double mz, int charge) const;

virtual double oneOverK0ToCCS(double oneOverK0, int charge) const;

virtual double ccsToOneOverK0(double ccs, double mz, int charge) const;

/// returns the number of spectra available from the MS source
Expand Down Expand Up @@ -321,8 +319,6 @@ struct PWIZ_API_DECL TimsDataImpl : public CompassData
TimsBinaryDataPtr tdfStoragePtr_;
TimsBinaryData& tdfStorage_;

double largestPeakMz;

///
/// cache entire frames while dealing with single spectrum access
///
Expand Down
Loading