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

[Question] Adding 1/k0 information to selected precursor ions #21

Open
jspaezp opened this issue Oct 12, 2023 · 2 comments
Open

[Question] Adding 1/k0 information to selected precursor ions #21

jspaezp opened this issue Oct 12, 2023 · 2 comments

Comments

@jspaezp
Copy link

jspaezp commented Oct 12, 2023

Hello Joshua!

I hope everything is going well!
I had a question on the usage of the package. I am trying to write an mzML where the spectra
has ion mobility information and I was wondering if this was currently supported (or the option to pass a custom entry at a specific place). Let me know if you can point me to a place in the documentation where I could find that!

Here is a sample of the arguments I am trying to pass to the writer.

sample = {
            "mz_array": mz,
            "intensity_array": intensity,
            "scan_start_time": rt,
            "id": f"scan={i+offset}",
            "params": [
                "MSn Spectrum",
                {"ms level": 2},
                {"total ion current": sum(intensity)},
            ],
            "precursor_information": {
                "activation": [
                    "beam-type collisional dissociation",
                    {"collision energy": 25},
                ],
                "mz": quad_mid,
                "intensity": sum(intensity),
                "charge": 2,
                "isolation_window": [quad_low, quad_mid, quad_high],
                "scan_id": last_precursor_scan_id,
                "selectedIonList": [
                    {
                        ########## HERE ###########
                        "inverse reduced ion mobility": mobility_value,
                    }
                ],
            },
        }
with IndexedMzMLWriter("outfile.mzml") as out:
    ...
    out.write_spectrum(**sample)

And I would like the precursor list section of the mzml to look something like this:

            <precursorList count="1">
                <precursor>
                    <isolationWindow>
                        <cvParam cvRef="MS" accession="MS:1000827" name="isolation window target m/z" value="457.723968505859" unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
                        <cvParam cvRef="MS" accession="MS:1000828" name="isolation window lower offset" value="1.5" unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
                        <cvParam cvRef="MS" accession="MS:1000829" name="isolation window upper offset" value="0.75" unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
                    </isolationWindow>
                    <selectedIonList count="1">
                        <selectedIon>
                            <cvParam cvRef="MS" accession="MS:1000744" name="selected ion m/z" value="457.723968505859" unitAccession="MS:1000040" unitName="m/z" unitCvRef="MS" />
                            <cvParam cvRef="MS" accession="MS:1000041" name="charge state" value="2" />
                            <cvParam cvRef="MS" accession="MS:1002815" name="inverse reduced ion mobility" value="1.078628" unitAccession="MS:1002814" unitName="volt-second per square centimeter"/>
                        </selectedIon>
                    </selectedIonList>
                    <activation>
                        <cvParam cvRef="MS" accession="MS:1000133" name="collision-induced dissociation" />
                        <cvParam cvRef="MS" accession="MS:1000045" name="collision energy" value="35.0"/>
                    </activation>
                </precursor>
            </precursorList>
@mobiusklein
Copy link
Owner

To accomplish this, you need to pass the ion mobility measure as part of the params list that most components take. The following is brain-compiled, so it may need to be adjusted but I don't think I'll have much time to answer in detail tomorrow.

"precursor_information": [ # note the enclosing list
    {
        "activation": [
            "beam-type collisional dissociation",
            {"collision energy": 25},
        ],
        "isolation_window": [quad_low, quad_mid, quad_high],
        "scan_id": last_precursor_scan_id,
        "selected_ion_list": [
            {
                "mz": quad_mid,
                "intensity": sum(intensity),
                "charge": 2,
                "params": [
                    {"inverse reduced ion mobility": mobility_value}
                ]
            }
        ],
    },
]

The ergonomics of building a precursor ion list are still really bad, in part because the way <precursorList> is substantially more complicated than regular DDA-MS2-focused tools need it to be. I added https://github.com/mobiusklein/psims/blob/master/psims/mzml/writer.py#L1124C19-L1124C19 which tries to make this easier, but merely ends up a little more terse, a little more opaque without much better documentation than I've had time to write as yet.

@jspaezp
Copy link
Author

jspaezp commented Oct 13, 2023

Ohhh I see, thanks a lot for the reply! (It is by no means something critical so dont worry too much about it, just wanted to make sure I was not overlooking a part of the docs)

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

No branches or pull requests

2 participants