Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neutral Mass Spectrum #806

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

nbollis
Copy link
Contributor

@nbollis nbollis commented Oct 12, 2024

Created a 'NeutralMassSpectrum' class to represent a spectrum read off of a deconvoluted file by deriving the MzSpectrum. This allows it to be easily swapped into an MsDataScan.

If this scan is deconvoltuted. Deconvolution will short circuit and return the neutral masses.

PR Summary

This pull request refines code visibility, improves readability, and adds new test cases to enhance code maintainability and functionality.

  • ClassicDeconvolutionAlgorithm, DeconvolutionAlgorithm, and ExampleNewDeconvolutionAlgorithmTemplate classes changed from public to internal.
  • Deconvoluter class refactored to streamline deconvolution logic and handle NeutralMassSpectrum.
  • TestDeconvolution.cs reformatted and new test cases added for NeutralMassSpectrum.Deconvolute.
  • TestSpectra.cs updated with new test methods for NeutralMassSpectrum constructor and properties.
  • MassSpectrometry.csproj updated with InternalsVisibleTo attributes for "Development" and "Test" assemblies.

nbollis and others added 9 commits October 11, 2024 00:16
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.
- 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`.
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.
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.
- 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.
Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.55%. Comparing base (6c18e9f) to head (8a6fc81).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #806      +/-   ##
==========================================
+ Coverage   76.48%   76.55%   +0.06%     
==========================================
  Files         211      212       +1     
  Lines       31960    32011      +51     
  Branches     3286     3297      +11     
==========================================
+ Hits        24446    24507      +61     
+ Misses       6954     6945       -9     
+ Partials      560      559       -1     
Files with missing lines Coverage Δ
...lution/Algorithms/ClassicDeconvolutionAlgorithm.cs 96.92% <100.00%> (ø)
...Deconvolution/Algorithms/DeconvolutionAlgorithm.cs 100.00% <ø> (ø)
...Lib/MassSpectrometry/Deconvolution/Deconvoluter.cs 100.00% <100.00%> (ø)
mzLib/MassSpectrometry/MsDataFile.cs 94.84% <ø> (ø)
...Lib/MassSpectrometry/MzSpectra/IsotopicEnvelope.cs 91.17% <100.00%> (+0.85%) ⬆️
mzLib/MassSpectrometry/MzSpectra/MzSpectrum.cs 91.20% <100.00%> (+2.00%) ⬆️
.../MassSpectrometry/MzSpectra/NeutralMassSpectrum.cs 100.00% <100.00%> (ø)

@nbollis nbollis added Maintenance The user isn't impacted by it, it's purely behind the scenes New Feature labels Oct 12, 2024
@nbollis nbollis changed the title [WIP] Neutral Mass Spectrum Neutral Mass Spectrum Oct 15, 2024
@@ -79,7 +58,22 @@ public static IEnumerable<IsotopicEnvelope> Deconvolute(MzSpectrum spectrum,
default: throw new MzLibException("DeconvolutionType not yet supported");
}

return deconAlgorithm.Deconvolute(spectrum, rangeToGetPeaksFrom);
// Short circuit deconvolution if it is called on a neutral mass spectrum
if (spectrum is NeutralMassSpectrum newt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good variable name

@nbollis nbollis marked this pull request as ready for review October 17, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance The user isn't impacted by it, it's purely behind the scenes New Feature ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants