예제 #1
0
 def __init__(self,
              neutral_mass,
              intensity,
              charge,
              signal_to_noise,
              index,
              full_width_at_half_max,
              a_to_a2_ratio=0,
              most_abundant_mass=0,
              average_mass=0,
              score=0,
              envelope=None,
              mz=0,
              fit=None,
              chosen_for_msms=False,
              area=0):
     if index is None:
         index = _Index()
     if envelope is None:
         envelope = ()
     self.neutral_mass = neutral_mass
     self.intensity = intensity
     self.signal_to_noise = signal_to_noise
     self.index = index
     self.full_width_at_half_max = full_width_at_half_max
     self.charge = charge
     self.a_to_a2_ratio = a_to_a2_ratio
     self.most_abundant_mass = most_abundant_mass
     self.average_mass = average_mass
     self.score = score
     self.envelope = Envelope(envelope)
     self.mz = mz or mass_charge_ratio(self.neutral_mass, self.charge)
     self.fit = fit
     self.chosen_for_msms = chosen_for_msms
     self.area = area
예제 #2
0
def decharge(self,
             include_envelopes=True,
             charge_carrier=PROTON,
             new_charge=1):
    """Transfomr multiply charged deconvoluted peaks into singly charged deconvoluted peaks.

    This operation returns a copy of the peak set, the input peak set is unchanged.

    Parameters
    ----------
    include_envelopes : bool, optional
        Whether or not to charge-transform the isotopic envelope fitted in :attr:`DeconvolutedPeak.envelope`
        (the default is True)
    charge_carrier : float, optional
        The charge carrier mass to use when recalculating m/z (the default is PROTON)
    new_charge : int, optional
        The new charge to set all peaks to, the default being +1


    Returns
    -------
    DeconvolutedPeakSet
    """
    peaks = []
    for peak in self:
        mz = mass_charge_ratio(peak.neutral_mass,
                               new_charge,
                               charge_carrier=charge_carrier)
        if include_envelopes:
            envelope = Envelope([
                EnvelopePair(
                    mass_charge_ratio(
                        calc_neutral_mass(p.mz, peak.charge, charge_carrier),
                        new_charge, charge_carrier), p.intensity)
                for p in peak.envelope
            ])
        else:
            envelope = peak.envelope
        new_peak = DeconvolutedPeak(peak.neutral_mass, peak.intensity,
                                    new_charge, peak.signal_to_noise, None,
                                    peak.full_width_at_half_max,
                                    peak.a_to_a2_ratio,
                                    peak.most_abundant_mass, peak.average_mass,
                                    peak.score, envelope, mz, peak.fit,
                                    peak.chosen_for_msms, peak.area)
        peaks.append(new_peak)
    new_peak_set = self.__class__(peaks)
    new_peak_set.reindex()
    return new_peak_set