bittremieux / spectrum_utils

Python package for efficient mass spectrometry data processing and visualization
https://spectrum-utils.readthedocs.io/
Apache License 2.0
130 stars 21 forks source link

annotate using custom fragment list #58

Closed samcphee closed 2 months ago

samcphee commented 7 months ago

My peptide cannot be described with proforma.

Does anyone have an example script of how to annotate from a custom table of fragments in tabular format ie (name,mz)


import spectrum_utils.plot as sup
import spectrum_utils.spectrum as sus
import spectrum_utils.fragment_annotation as frg
import numpy as np

# Retrieve the spectrum by its USI.
identifier = "non-conventional peptide"
precursor_mz = 600
precursor_charge = 2
mz = np.array([160, 200, 300, 400, 500])
intensity = np.array([4, 5, 6, 7, 8])
retention_time = 3.02
spectrum = sus.MsmsSpectrum(identifier,precursor_mz,precursor_charge,mz,intensity,retention_time)

fragment1 = "200"
fragment1_label = "y1"

fig, ax = plt.subplots(figsize=(12, 6))
sup.spectrum(spectrum,grid=False, ax=ax)
ax.set_title(identifier, fontdict={"fontsize": "xx-large"})
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
plt.savefig("annot_fmt.png", dpi=300, bbox_inches="tight", transparent=True)
plt.show()```
bittremieux commented 7 months ago

Unfortunately this currently is a bit challenging. Does the workaround described in #56 work for your use case?

samcphee commented 7 months ago

Unfortunately this only works for a small part of linear peptide in my molecule.

bittremieux commented 7 months ago

Could you provide some more details of what you specifically want to achieve? The toy example should be possible by using X[+200] as ProForma string, so I expect it's a bit more complex than that then. Even if there might not be a good solution at the moment, that can help me improve the annotation functionality. A concrete example would be ideal.