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

Conversation

xjasg
Copy link
Contributor

@xjasg xjasg commented Oct 10, 2024

Extension of the analysis of Bruker files (precursor information) based on the timsconvert Python code
MS_inverse_reduced_ion_mobility, MS_collisional_cross_sectional_area, MS_peak_intensity.
lowest observed mz and highest observed mz included

@xjasg xjasg force-pushed the feature/bruker_precursor_2 branch from ac53357 to 3ab4cff Compare October 11, 2024 00:29
Copy link
Member

@chambm chambm left a comment

Choose a reason for hiding this comment

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

Looks much better! Still a bit of work to do though.

@@ -132,6 +132,16 @@ void Serializer_MGF::Impl::write(ostream& os, const MSData& msd,
os << " " << intensityParam.valueFixedNotation();
os << '\n';

CVParam inverseReduceIonMobility = scan->cvParam(MS_inverse_reduced_ion_mobility);
if (!inverseReduceIonMobility.empty())
os << "INVREION=" << inverseReduceIonMobility.valueFixedNotation();
Copy link
Member

Choose a reason for hiding this comment

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

Did you check whether some official product already writes it this way? Because according to the official MGF spec this is not a valid parameter. https://www.matrixscience.com/help/data_file_help.html
It should be ION_MOBILITY= and it has a weird format that reproduces the PEPMASS parameter for some reason (see the link). I don't see why 1/k0 needs a separate parameter if an official one already exists. Except maybe for being sure of what kind of ion mobility is being recorded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I´ll check this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope it´s done now. :-)


CVParam collisionalCrossSectionalArea = scan->cvParam(MS_collisional_cross_sectional_area);
if (!collisionalCrossSectionalArea.empty())
os << "COLLCROSSSA=" << collisionalCrossSectionalArea.valueFixedNotation();
Copy link
Member

Choose a reason for hiding this comment

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

There is no official MGF parameter for this. I would be more comfortable with this in the TITLE string, unless a Bruker product is already writing MGFs this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, Is there an example of adding some parameters to the title string?

Copy link
Member

Choose a reason for hiding this comment

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

There's a titleMaker filter that allows for easy customization of the MGF title string with a user-defined format. Although it doesn't support CCS currently, only instrument-level ion mobility metrics. If you don't want to use that, you can add "ccs=" to the title string above this, before the line:
if (!scanTimeParam.empty())
os << "RTINSECONDS=" << scanTimeParam.timeInSeconds() << '\n';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, that sounds good, I'll implement it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be finished.

pwiz/data/vendor_readers/Bruker/SpectrumList_Bruker.cpp Outdated Show resolved Hide resolved
pwiz/data/vendor_readers/Bruker/SpectrumList_Bruker.cpp Outdated Show resolved Hide resolved
pwiz_aux/msrc/utility/vendor_api/Bruker/TimsData.cpp Outdated Show resolved Hide resolved
static unsigned int precision(T) { return 10; }
// we want the numbers always to be in fixed format
static int floatfield(T) { return boost::spirit::karma::real_policies<T>::fmtflags::fixed; }
template <typename T>
Copy link
Member

Choose a reason for hiding this comment

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

Revert whitespace only change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I´ll fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be removed.

if (continueOnError)
{
{
SpectrumPtr s;
Copy link
Member

Choose a reason for hiding this comment

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

Revert whitespace only change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still seeing whitespace changes here. You know how to review the diff in GitHub? You can also review it locally if you set your diff engine to show whitespace changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, sorry, but unfortunately it's not finished yet. Yes, It's easy to see whitespace changes, but undoing them without removing other important things is a bit difficult for me. But I´m on it. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whitespaces should now be removed.

@@ -535,7 +535,7 @@ void write_precursors(XMLWriter& xmlWriter, const vector<PrecursorInfo>& precurs
attributes.add("activationMethod", it->activation);
if (it->windowWideness != 0)
attributes.add("windowWideness", it->windowWideness);

Copy link
Member

Choose a reason for hiding this comment

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

Revert whitespace only changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay.

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.

pwiz_aux/msrc/utility/vendor_api/Bruker/TimsData.cpp Outdated Show resolved Hide resolved
pwiz/data/msdata/Serializer_MGF.cpp Outdated Show resolved Hide resolved
@xjasg
Copy link
Contributor Author

xjasg commented Oct 11, 2024

Okay, thank you very much. I really appreciate that. I would try to fix the things you mentioned.

bal::trim(value);
scan.cvParams.push_back(CVParam(MS_inverse_reduced_ion_mobility, value, MS_volt_second_per_square_centimeter));
}
else if (name == "COLLCROSSSA")
Copy link
Member

Choose a reason for hiding this comment

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

When moving CCS to the title, it can be parsed back in the name == TITLE block above.

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.

@@ -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.

@xjasg xjasg force-pushed the feature/bruker_precursor_2 branch from 913253a to bb1a8ee Compare November 1, 2024 00:40
@chambm chambm self-requested a review November 6, 2024 19:55
Copy link
Member

@chambm chambm left a comment

Choose a reason for hiding this comment

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

Please add ion mobility and CCS cvParams in Serializer_MGF_Test so this new code gets tested. Maybe for just one of the spectra there so it gets tested with an without.

@xjasg
Copy link
Contributor Author

xjasg commented Nov 6, 2024

@chambm Thank´s for your review and comment. yes, okay, I´ll write some tests.

@chambm
Copy link
Member

chambm commented Nov 6, 2024

You don't need to add any new test, just update the existing one in Serializer_MGF_Test by adding the cvParams to one of the spectra there.

@xjasg
Copy link
Contributor Author

xjasg commented Nov 6, 2024

@chambm okay.

@xjasg xjasg requested a review from chambm November 8, 2024 23:05
@@ -228,14 +228,17 @@ struct PWIZ_API_DECL DiffConfig : public pwiz::data::BaseDiffConfig

bool ignoreDataProcessing;

bool ignoreSpectrumTitle;

Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? I would expect the new CCS-in-title code to round trip the CCS so the title will be preserved and not different. What diffs were you getting without this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, unfortunately it is different. The serializer writes it into the title string, but the reference does not contain the text ‘ccs=...’. But this reference is used for both - reading and writing.
The other cases of code where the title is extended too seem not to run through the test, so it was not a problem there.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I dropped the ball here. What did you mean "the reference does not contain the text"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to apologise. I had a lot to do in another project. As far as I understand it, the following happens: testWriteRead(const MSData& msd) uses msd as a reference. msd contains previously generated test data with a specific title. ‘serializer.write(oss, msd);’ extends the title by “ccs=...” and saves the new extended data with the new title. Then "serializer.read(iss, msd2);" reads back the written data with the new title. But after that the comparison with msd fails because of the different title. That is why I have introduced a flag that disables the comparison of the titles. Maybe its better to changed the test than the main program. I`ll try this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I have now understood the problem. The additional text must be removed from the title after loading. Then everything should work. Otherwise, the title could be expanded more than once if we save and load the data twice or more. I think we would have to do the same with other title parameters.

Copy link
Member

Choose a reason for hiding this comment

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

Did you see this reply @xjasg ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replied, but my answers were marked as "pending".

Here is what I wrote:

"I have to apologise. I had a lot to do in another project. As far as I understand it, the following happens: testWriteRead(const MSData& msd) uses msd as a reference. msd contains previously generated test data with a specific title. ‘serializer.write(oss, msd);’ extends the title by “ccs=...” and saves the new extended data with the new title. Then "serializer.read(iss, msd2);" reads back the written data with the new title. But after that the comparison with msd fails because of the different title. That is why I have introduced a flag that disables the comparison of the titles. Maybe its better to changed the test than the main program. I`ll try this.

I think I have now understood the problem. The additional text must be removed from the title after loading. Then everything should work. Otherwise, the title could be expanded more than once if we save and load the data twice or more. I think we would have to do the same with other title parameters."

My last commit should have resolved this issue?

@xjasg xjasg requested a review from chambm November 12, 2024 19:41
@xjasg
Copy link
Contributor Author

xjasg commented Dec 2, 2024

@chambm: Hi Matt, have you had a chance to look at the latest changes again? Should I change anything else? Thank you very much. Best regards.

@chambm chambm merged commit a2cc5cc into ProteoWizard:master Jan 15, 2025
15 checks passed
@chambm
Copy link
Member

chambm commented Jan 15, 2025

Thanks @xjasg and @Andre99999999 !

@xjasg
Copy link
Contributor Author

xjasg commented Jan 16, 2025

@chambm : I have to thank you for your kind support.

@chambm chambm deleted the feature/bruker_precursor_2 branch January 16, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants