Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Apr 24, 2023
2 parents 894b998 + 921b732 commit 88269a1
Show file tree
Hide file tree
Showing 90 changed files with 5,099 additions and 3,710 deletions.
2 changes: 1 addition & 1 deletion mzLib/Chemistry/ChemicalFormula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void Add(Element element, int count)
else
{
Elements[element] += count;
if (Elements[element] <= 0)
if (Elements[element] == 0)
Elements.Remove(element);
}
formulaString = null;
Expand Down
90 changes: 90 additions & 0 deletions mzLib/Development/Deconvolution/SinglePeakDeconvolutionTestCase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using MassSpectrometry;
using MzLibUtil;
using SpectralAveraging;
using Readers;

namespace Development.Deconvolution
{
/// <summary>
/// Contains the expected results from deconvolution a single isotopic peak as well as information on the sample
/// </summary>
public class SinglePeakDeconvolutionTestCase
{
/// <summary>
/// Instantiate a SinglePeakDeconvolutionTestCase
/// </summary>
/// <param name="deconvoluter">The object which will be performing the deconvolution when tested</param>
/// <param name="sampleInformation">Quick information relevant to the sample, will be visible on test failing. Use this field to allow other to quickly identify which tests are failing</param>
/// <param name="spectrumPath">path to the spectrum of interest, current implementation expects the file to </param>
/// <param name="scanNumber">One based scan number of spectrum to deconvolute</param>
/// <param name="expectedMostAbundantObservedIsotopicMass">Expected mass from deconvolution result</param>
/// <param name="expectedIonChargeState">Expected charge state from deconvolution result</param>
/// <param name="selectedIonMz">M/z of peak to deconvolute from spectrum</param>
/// <param name="precursorPpmMassTolerance">Tolerance which deconvolution results must match expected value</param>
public SinglePeakDeconvolutionTestCase(Deconvoluter deconvoluter, string sampleInformation, string spectrumPath, int scanNumber,
double expectedMostAbundantObservedIsotopicMass, int expectedIonChargeState, double selectedIonMz, double precursorPpmMassTolerance)
{
Deconvoluter = deconvoluter;
SampleInformation = sampleInformation;
ExpectedMostAbundantObservedIsotopicMass = expectedMostAbundantObservedIsotopicMass;
ExpectedIonChargeState = expectedIonChargeState;
SelectedIonMz = selectedIonMz;
DeconvolutionPPmTolerance = new PpmTolerance(precursorPpmMassTolerance);
SpectrumToDeconvolute = MsDataFileReader.GetDataFile(spectrumPath)
.LoadAllStaticData()
.GetAllScansList()
.First(p => p.OneBasedScanNumber == scanNumber).MassSpectrum;

// 8.5 was selected as this is the magic number found in Classic Deconvolution
RangeToDeconvolute = new MzRange(selectedIonMz - 8.5, selectedIonMz + 8.5);
}

/// <summary>
/// The object which will be performing the deconvolution when tested
/// </summary>
public Deconvoluter Deconvoluter { get; set; }

/// <summary>
/// Quick information relevant to the sample, will be visible on test failing
/// Use this field to allow other to quickly identify which tests are failing
/// </summary>
public string SampleInformation { get; init; }

/// <summary>
/// Expected mass from deconvolution result
/// </summary>
public double ExpectedMostAbundantObservedIsotopicMass { get; init; }

/// <summary>
/// Expected charge state from deconvolution result
/// </summary>
public int ExpectedIonChargeState { get; init; }

/// <summary>
/// M/z of peak to deconvolute from spectrum
/// </summary>
public double SelectedIonMz { get; init; }

/// <summary>
/// Range within the spectrum to deconvolute
/// Currently set to +- 8.5 mz from SelectedIonMz per MetaMorpheus default heuristic
/// </summary>
public MzRange RangeToDeconvolute { get; init; }

/// <summary>
/// Spectrum to Deconvolute
/// </summary>
public MzSpectrum SpectrumToDeconvolute { get; init; }

/// <summary>
/// Tolerance which deconvolution results must match expected value
/// </summary>
public PpmTolerance DeconvolutionPPmTolerance { get; init; }

public override string ToString()
{
return $"{Deconvoluter.DeconvolutionType}: {SampleInformation} Charge: {ExpectedIonChargeState}";
}
}
}

Loading

0 comments on commit 88269a1

Please sign in to comment.