Skip to content

Commit eba0adb

Browse files
authored
Merge pull request #114 from topdownproteomics/ryan/negMode-chargeCarrier
Negative Mode and Charge Carriers
2 parents 1e70f64 + 9c8b3ae commit eba0adb

File tree

9 files changed

+467
-267
lines changed

9 files changed

+467
-267
lines changed

src/TopDownProteomics/MassSpectrometry/ChargedIsotopicDistribution.cs

+10-6
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,22 @@ public class ChargedIsotopicDistribution : IMzIntensityData, IChargedIsotopicDis
1818
/// <param name="mz">The mz.</param>
1919
/// <param name="intensity">The intensity.</param>
2020
/// <param name="charge">The charge.</param>
21-
public ChargedIsotopicDistribution(double[] mz, double[] intensity, int charge)
21+
/// <param name="chargeCarrier">The charge carrier.</param>
22+
public ChargedIsotopicDistribution(double[] mz, double[] intensity, int charge, double chargeCarrier)
2223
{
2324
_intensity = intensity;
2425
_mz = mz;
26+
2527
this.Charge = charge;
28+
this.ChargeCarrier = chargeCarrier;
2629
}
2730

28-
/// <summary>
29-
/// Gets the charge.
30-
/// </summary>
31+
/// <summary>The charge.</summary>
3132
public int Charge { get; }
3233

34+
/// <summary>The mass of the charge carrier.</summary>
35+
public double ChargeCarrier { get; }
36+
3337
/// <summary>
3438
/// Gets the mz.
3539
/// </summary>
@@ -68,7 +72,7 @@ public IChargedIsotopicDistribution CloneWithMostIntensePoints(int numberOfPoint
6872
{
6973
// Moving any more would only make things less intense ... stop
7074
return new ChargedIsotopicDistribution(_mz.SubSequence(i, i + numberOfPoints - 1).ToArray(),
71-
_intensity.SubSequence(i, i + numberOfPoints - 1).ToArray(), this.Charge);
75+
_intensity.SubSequence(i, i + numberOfPoints - 1).ToArray(), this.Charge, this.ChargeCarrier);
7276
}
7377
}
7478

@@ -89,7 +93,7 @@ public IChargedIsotopicDistribution CloneAndShift(double shiftMz)
8993
mz[i] = _mz[i] + shiftMz;
9094
}
9195

92-
return new ChargedIsotopicDistribution(mz, (double[])_intensity.Clone(), this.Charge);
96+
return new ChargedIsotopicDistribution(mz, (double[])_intensity.Clone(), this.Charge, this.ChargeCarrier);
9397
}
9498
}
9599
}

src/TopDownProteomics/MassSpectrometry/IChargedIsotopicDistribution.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
/// </summary>
66
public interface IChargedIsotopicDistribution : IMzIntensityData
77
{
8-
/// <summary>
9-
/// Gets the charge.
10-
/// </summary>
8+
/// <summary>The charge.</summary>
119
int Charge { get; }
1210

11+
/// <summary>The mass of the charge carrier.</summary>
12+
double ChargeCarrier { get; }
13+
1314
/// <summary>
1415
/// Clones the distribution with a subset of the most intense points.
1516
/// </summary>
@@ -20,7 +21,7 @@ public interface IChargedIsotopicDistribution : IMzIntensityData
2021
/// <summary>
2122
/// Clones the distribution and shifts it by an m/z (Th) value.
2223
/// </summary>
23-
/// <param name="shiftMz">The shift m/z in thomsons (Th).</param>
24+
/// <param name="shiftMz">The shift m/z in Thomsons (Th).</param>
2425
/// <returns></returns>
2526
IChargedIsotopicDistribution CloneAndShift(double shiftMz);
2627
}
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

3-
namespace TopDownProteomics.MassSpectrometry
4+
namespace TopDownProteomics.MassSpectrometry;
5+
6+
/// <summary>
7+
/// Neutral distribution of isotopes in a mass spectrometer.
8+
/// </summary>
9+
public interface IIsotopicDistribution
410
{
511
/// <summary>
6-
/// Neutral distribution of isotopes in a mass spectrometer.
12+
/// Gets the length.
13+
/// </summary>
14+
int Length { get; }
15+
16+
/// <summary>
17+
/// Gets the masses.
718
/// </summary>
8-
public interface IIsotopicDistribution
9-
{
10-
/// <summary>
11-
/// Gets the length.
12-
/// </summary>
13-
int Length { get; }
19+
IList<double> Masses { get; }
1420

15-
/// <summary>
16-
/// Gets the masses.
17-
/// </summary>
18-
IList<double> Masses { get; }
21+
/// <summary>
22+
/// Gets the intensities.
23+
/// </summary>
24+
IList<double> Intensities { get; }
1925

20-
/// <summary>
21-
/// Gets the intensities.
22-
/// </summary>
23-
IList<double> Intensities { get; }
26+
/// <summary>
27+
/// Creates a charged isotopic distribution.
28+
/// </summary>
29+
/// <param name="charge">The charge.</param>
30+
/// <param name="positiveCharge">if set to <c>true</c> [positive charge].</param>
31+
/// <returns>A charged isotopic distribution with the same abundances.</returns>
32+
[Obsolete("Use CreateChargedDistribution(int charge, double chargeCarrier) instead.")]
33+
IChargedIsotopicDistribution CreateChargedDistribution(int charge, bool positiveCharge);
2434

25-
/// <summary>
26-
/// Creates a charged isotopic distribution.
27-
/// </summary>
28-
/// <param name="charge">The charge.</param>
29-
/// <param name="positiveCharge">if set to <c>true</c> [positive charge].</param>
30-
/// <returns>A charged isotopic distribution with the same abundances.</returns>
31-
IChargedIsotopicDistribution CreateChargedDistribution(int charge, bool positiveCharge = true);
35+
/// <summary>
36+
/// Creates a charged isotopic distribution.
37+
/// </summary>
38+
/// <param name="charge">The charge.</param>
39+
/// <param name="chargeCarrier">The charge carrier.</param>
40+
/// <returns>A charged isotopic distribution with the same abundances.</returns>
41+
IChargedIsotopicDistribution CreateChargedDistribution(int charge, double chargeCarrier = Utility.Proton);
3242

33-
/// <summary>
34-
/// Clones the distribution and shifts it by a mass (Da) value.
35-
/// </summary>
36-
/// <param name="shift">The shift mass in daltons (Da).</param>
37-
/// <returns></returns>
38-
IIsotopicDistribution CloneAndShift(double shift);
39-
}
43+
/// <summary>
44+
/// Clones the distribution and shifts it by a mass (Da) value.
45+
/// </summary>
46+
/// <param name="shift">The shift mass in daltons (Da).</param>
47+
/// <returns>The cloned distribution shifted by the specified mass.</returns>
48+
IIsotopicDistribution CloneAndShift(double shift);
4049
}

src/TopDownProteomics/MassSpectrometry/IsotopicDistribution.cs

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Diagnostics;
23
using System.Linq;
34

45
namespace TopDownProteomics.MassSpectrometry
@@ -55,7 +56,19 @@ private double[] GetMz(int charge, bool positiveCharge)
5556
double[] mz = new double[this.Length];
5657

5758
for (int i = 0; i < this.Length; i++)
59+
#pragma warning disable CS0618 // Type or member is obsolete
5860
mz[i] = Utility.ConvertMassToMz(_masses[i], charge, positiveCharge);
61+
#pragma warning restore CS0618 // Type or member is obsolete
62+
63+
return mz;
64+
}
65+
66+
private double[] GetMz(int charge, double chargeCarrier)
67+
{
68+
double[] mz = new double[this.Length];
69+
70+
for (int i = 0; i < this.Length; i++)
71+
mz[i] = Utility.ConvertMassToMz(_masses[i], charge, chargeCarrier);
5972

6073
return mz;
6174
}
@@ -66,9 +79,26 @@ private double[] GetMz(int charge, bool positiveCharge)
6679
/// <param name="charge">The charge.</param>
6780
/// <param name="positiveCharge">if set to <c>true</c> [positive charge].</param>
6881
/// <returns></returns>
69-
public IChargedIsotopicDistribution CreateChargedDistribution(int charge, bool positiveCharge = true)
82+
public IChargedIsotopicDistribution CreateChargedDistribution(int charge, bool positiveCharge)
7083
{
71-
return new ChargedIsotopicDistribution(this.GetMz(charge, positiveCharge), _abundances, charge);
84+
Debug.Assert(charge > 0, "Charge must be greater than 0.");
85+
86+
return new ChargedIsotopicDistribution(this.GetMz(charge, positiveCharge), _abundances, charge, Utility.Proton);
87+
}
88+
89+
/// <summary>
90+
/// Creates a charged isotopic distribution.
91+
/// </summary>
92+
/// <param name="charge">The charge.</param>
93+
/// <param name="chargeCarrier">The charge carrier.</param>
94+
/// <returns>
95+
/// A charged isotopic distribution with the same abundances.
96+
/// </returns>
97+
public IChargedIsotopicDistribution CreateChargedDistribution(int charge, double chargeCarrier = Utility.Proton)
98+
{
99+
Debug.Assert(chargeCarrier > 0, "Charge carrier must be greater than 0.");
100+
101+
return new ChargedIsotopicDistribution(this.GetMz(charge, chargeCarrier), _abundances, charge, chargeCarrier);
72102
}
73103

74104
/// <summary>

0 commit comments

Comments
 (0)