Using HUPO-PSI ProXI, Universal Spectrum Identifier (USI), Pyteomics and spectrum_utils:
- ProXI: https://github.com/HUPO-PSI/proxi-schemas
- USI: https://github.com/HUPO-PSI/usi
- Pyteomics: https://pyteomics.readthedocs.io/
- spectrum_utils: https://spectrum-utils.readthedocs.io/
from pyteomics.usi import USI, proxi
from pyteomics.mass.unimod import Unimod
import spectrum_utils.spectrum as sus
import spectrum_utils.plot as sup
def reshape_attributes(attributes):
return {item["name"]: item["value"] for item in attributes}
unimod = Unimod()
# Input
modified_sequence = "IENN[UNIMOD:34]DNKPVTNSR"
unmodified_sequence = "IENNDNKPVTNSR"
modifications = {4: unimod.get(34).monoisotopic_mass}
charge = 2
usi = USI(
"mzspec",
"PXD000561",
"Adult_CD8Tcells_Gel_Elite_44_f12",
"scan",
"1770",
modified_sequence + "/" + str(charge)
)
# Get spectrum through ProXI
proxi_response = proxi(usi)
proxi_attributes = reshape_attributes(proxi_response["attributes"])
# Process spectrum, annotate, and plot
spectrum = (
sus.MsmsSpectrum(
identifier=usi,
precursor_mz=proxi_attributes["isolation window target m/z"],
precursor_charge=int(proxi_attributes["charge state"]),
mz=proxi_response["m/z array"],
intensity=proxi_response["intensity array"],
peptide=unmodified_sequence,
modifications=modifications
)
.filter_intensity(0.01, 50)
#.scale_intensity('root')
.annotate_peptide_fragments(0.5, 'Da', ion_types='aby')
)
spectrum = (
sup.spectrum(spectrum)
)