def scale(self, mz, charge=1, charge_carrier=PROTON): neutral = neutral_mass(mz, charge, charge_carrier) scale = neutral / self.base_mass scaled = {} for elem, count in self.base_composition.items(): scaled[elem] = round(count * scale) scaled_mass = calculate_mass(scaled) delta_hydrogen = round(scaled_mass - neutral) H = scaled["H"] if H > delta_hydrogen: scaled["H"] = H - delta_hydrogen else: scaled["H"] = 0 return scaled
def scale(self, mz, charge=1, charge_carrier=PROTON): """Given an m/z and a charge state, interpolate the composition of the polymer with the matching neutral mass Parameters ---------- mz : float The reference m/z to calculate the neutral mass to interpolate from charge : int, optional The reference charge state to calculate the neutral mass. Defaults to 1 charge_carrier : float, optional The mass of the charge carrier. Defaults to the mass of a proton. Returns ------- Mapping The interpolated composition for the calculated neutral mass, rounded to the nearest integer and hydrogen corrected. References ---------- Senko, M. W., Beu, S. C., & McLafferty, F. W. (1995). Determination of monoisotopic masses and ion populations for large biomolecules from resolved isotopic distributions. Journal of the American Society for Mass Spectrometry, 6(4), 229–233. http://doi.org/10.1016/1044-0305(95)00017-8 """ neutral = neutral_mass(mz, charge, charge_carrier) scale = neutral / self.base_mass scaled = {} for elem, count in self.base_composition.items(): scaled[elem] = round(count * scale) scaled_mass = calculate_mass(scaled) delta_hydrogen = round(scaled_mass - neutral) H = scaled["H"] if H > delta_hydrogen: scaled["H"] = H - delta_hydrogen else: scaled["H"] = 0 return scaled
def __init__(self, base_composition): self.base_composition = dict(base_composition) self.base_mass = calculate_mass(self.base_composition)
try: _Averagine = Averagine _TheoreticalIsotopicPattern = TheoreticalIsotopicPattern from ms_deisotope._c.averagine import Averagine, TheoreticalIsotopicPattern except ImportError as e: print(e, "averagine") peptide = Averagine({"C": 4.9384, "H": 7.7583, "N": 1.3577, "O": 1.4773, "S": 0.0417}) glycopeptide = Averagine({"C": 10.93, "H": 15.75, "N": 1.6577, "O": 6.4773, "S": 0.02054}) glycan = Averagine({'C': 7.0, 'H': 11.8333, 'N': 0.5, 'O': 5.16666}) permethylated_glycan = Averagine({'C': 12.0, 'H': 21.8333, 'N': 0.5, 'O': 5.16666}) heparin = Averagine({'H': 10.5, 'C': 6, 'S': 0.5, 'O': 5.5, 'N': 0.5}) _neutron_shift = calculate_mass({"C[13]": 1}) - calculate_mass({"C[12]": 1}) def isotopic_shift(charge=1): return _neutron_shift / float(charge) @dict_proxy("averagine") class AveragineCache(object): def __init__(self, averagine, backend=None, cache_truncation=1.0): if backend is None: backend = {} self.backend = backend self.averagine = Averagine(averagine) self.cache_truncation = cache_truncation
permethylated_glycan = Averagine({ 'C': 12.0, 'H': 21.8333, 'N': 0.5, 'O': 5.16666 }) heparin = Averagine({'H': 10.5, 'C': 6, 'S': 0.5, 'O': 5.5, 'N': 0.5}) heparan_sulfate = Averagine({ 'H': 10.667, 'C': 6.0, 'S': 1.333, 'O': 9.0, 'N': 0.667 }) _neutron_shift = calculate_mass({"C[13]": 1}) - calculate_mass({"C[12]": 1}) def isotopic_shift(charge=1): return _neutron_shift / float(charge) @dict_proxy("averagine") class AveragineCache(object): """A wrapper around a :class:`Averagine` instance which will cache isotopic patterns produced for new (m/z, charge) pairs and reuses it for nearby m/z values Attributes ---------- averagine : :class:`~Averagine` The averagine to use to generate new isotopic patterns