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

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

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

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.

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

@@ -379,6 +379,9 @@ class SpectrumList_MGFImpl : public SpectrumList_MGF
}
}

if(ccsStr.empty())
ccsStr = title.substr(start, title.length() - start);
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified to:

        const size_t end = title.length();
        for(int i=0; i< sizeof(endTags)/sizeof(endTags[0]); i++)
        {
            const size_t tmpEnd = title.find(endTags[i], start);
            if(tmpEnd != string::npos)
            {
                end = tmpEnd;
                break;
            }
        }

        ccsStr = title.substr(start,  end - start);

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, looks good, I change 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.

Done.

@xjasg xjasg requested a review from chambm November 12, 2024 19:41
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