-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* began neutral mz spectrum * Refactor visibility and clean up deconvolution code Changed `ClassicDeconvolutionAlgorithm`, `DeconvolutionAlgorithm`, and `ExampleNewDeconvolutionAlgorithmTemplate` classes and their members from `public` to `internal` to restrict visibility within the assembly. Added summary comment to `DeconvolutionAlgorithm` class. Refactored `Deconvoluter` class to remove unnecessary `using` directives and simplify the `Deconvolute` method by removing switch-case logic. Updated `IsotopicEnvelope` class by removing `MassIndex` and `StDev` properties, and modified constructor and `ScoreIsotopeEnvelope` method accordingly. Updated `MzSpectrum` class to use `StandardDeviation` extension method from `Easy.Common.Extensions`. Removed various unnecessary `using` directives from multiple files. * Finish NeutralMassSpectrum - Added `InternalsVisibleTo` entries for "Development" and "Test" in `MassSpectrometry.csproj`. - Changed `MostAbundantObservedIsotopicMass` to `internal` in `IsotopicEnvelope.cs`. - Added a new constructor to `IsotopicEnvelope` with monoisotopic mass, intensity, and charge. - Added XML documentation and changed `GeneratePeak` to `protected virtual` in `MzSpectrum.cs`. - Removed unused `using` directives in `MzSpectrum.cs` and `NeutralMzSpectrum.cs`. - Modified `NeutralMzSpectrum` constructor to validate array lengths. - Added `Charges` property to `NeutralMzSpectrum` and initialized it in the constructor. - Overrode `GeneratePeak` in `NeutralMzSpectrum` to convert to a charged spectrum using `Charges`. * Refactor Deconvoluter and rename NeutralMzSpectrum Added necessary using directives in Deconvoluter.cs. Modified Deconvoluter class for short-circuit deconvolution. Removed redundant lines in Deconvoluter.cs. Renamed NeutralMzSpectrum to NeutralMassSpectrum. Updated constructor and references accordingly. * added neutral mass file bool * Adjsuted and tested neutral mass spectra * Refactor Deconvoluter and add new tests Refactored Deconvoluter.cs to use a foreach loop for yielding IsotopicEnvelopes. Reformatted multiple test methods in TestDeconvolution.cs for better readability. Added new test methods to validate Deconvolute with NeutralMassSpectrum, ensuring correct processing of spectra with various charge states and ranges. * Make FirstX and LastX properties virtual; update tests - Changed FirstX and LastX properties in MzSpectrum to virtual. - Included MzLibUtil namespace in NeutralMassSpectrum class. - Updated NeutralMassSpectrum constructor to set FirstX and LastX. - Overrode FirstX and LastX in NeutralMassSpectrum class. - Added test NeutralMassSpectrum_MzRange to validate m/z range. * fixed nuspec * Update mzLib.nuspec --------- Co-authored-by: Nic Bollis <nbollis@wisc.edu>
- Loading branch information
Showing
11 changed files
with
417 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
mzLib/MassSpectrometry/Deconvolution/Algorithms/ExampleNewDeconvolutionAlgorithmTemplate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using Chemistry; | ||
|
||
namespace MassSpectrometry | ||
{ | ||
public class NeutralMassSpectrum : MzSpectrum | ||
{ | ||
public int[] Charges { get; init; } | ||
public NeutralMassSpectrum(double[,] monoisotopicMassesIntensities, int[] charges) : base(monoisotopicMassesIntensities) | ||
{ | ||
if (monoisotopicMassesIntensities.GetLength(0) != charges.Length) | ||
throw new ArgumentException("The lengths of monoisotopicMasses, intensities, and charges must be the same."); | ||
|
||
Charges = charges; | ||
|
||
double minMz = double.MaxValue; | ||
double maxMz = double.MinValue; | ||
for (int i = 0; i < monoisotopicMassesIntensities.GetLength(0); i++) | ||
{ | ||
var mz = monoisotopicMassesIntensities[i,0].ToMz(charges[i]); | ||
if (mz < minMz) | ||
minMz = mz; | ||
if (mz > maxMz) | ||
maxMz = mz; | ||
} | ||
|
||
FirstX = minMz; | ||
LastX = maxMz; | ||
} | ||
|
||
public NeutralMassSpectrum(double[] monoisotopicMasses, double[] intensities, int[] charges, bool shouldCopy) | ||
: base(monoisotopicMasses, intensities, shouldCopy) | ||
{ | ||
if (monoisotopicMasses.GetLength(0) != intensities.Length || monoisotopicMasses.Length != charges.Length) | ||
throw new ArgumentException("The lengths of monoisotopicMasses, intensities, and charges must be the same."); | ||
|
||
Charges = charges; | ||
|
||
double minMz = double.MaxValue; | ||
double maxMz = double.MinValue; | ||
for (int i = 0; i < monoisotopicMasses.Length; i++) | ||
{ | ||
var mz = monoisotopicMasses[i].ToMz(charges[i]); | ||
if (mz < minMz) | ||
minMz = mz; | ||
if (mz > maxMz) | ||
maxMz = mz; | ||
} | ||
|
||
FirstX = minMz; | ||
LastX = maxMz; | ||
} | ||
|
||
public override double? FirstX { get; } // in m/z | ||
public override double? LastX { get; } // in m/z | ||
|
||
/// <summary> | ||
/// Converts to a charged spectrum | ||
/// </summary> | ||
protected override MzPeak GeneratePeak(int index) | ||
{ | ||
return new MzPeak(XArray[index].ToMz(Charges[index]), YArray[index]); | ||
} | ||
} | ||
} |
Oops, something went wrong.