How to use the pyteomics.mass.fast_mass function in pyteomics

To help you get started, we’ve selected a few pyteomics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github compomics / ms2pip_c / ms2pip / ms2pip_tools / spectrum_output.py View on Github external
"""
	Calculate precursor mass and mz for given peptide and modification list,
	using Pyteomics.

	peptide: stripped peptide sequence
	modifications: MS2PIP-style formatted modifications list (e.g.
	`0|Acetyl|2|Oxidation`)
	mass_shifts: dictionary with `modification_name -> mass_shift` pairs

	Returns: tuple(prec_mass, prec_mz)

	Note: This method does not use the build-in Pyteomics modification handling, as
	that would require a known atomic composition of the modification.
	"""
	charge = int(charge)
	unmodified_mass = mass.fast_mass(peptide)
	mods_massses = sum([mass_shifts[mod] for mod in modifications.split('|')[1::2]])
	prec_mass = unmodified_mass + mods_massses
	prec_mz = (prec_mass + charge * PROTON_MASS) / charge
	return prec_mass, prec_mz