Skip to content

Commit

Permalink
Add base_peak_mass function
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed May 1, 2024
1 parent 0c3790d commit 7eb4656
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libgunshotmatch/peak.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"filter_peaks",
"peak_from_dict",
"write_alignment",
"base_peak_mass",
)


Expand Down Expand Up @@ -531,3 +532,23 @@ def _to_peak_list(a_list: List[Peak]) -> PeakList:
return a_list
else:
return PeakList(a_list)


def base_peak_mass(peak: Peak) -> float:
"""
Returns the mass of the largest fragment in the peak's mass spectrum.
:param peak: v0.11.0
"""

apex_mass_list = peak.mass_spectrum.mass_list
apex_mass_spec = peak.mass_spectrum.mass_spec

# Determine the intensity of the base peak in the mass spectrum
base_peak_intensity = max(apex_mass_spec)

# Determine the index of the base peak in the mass spectrum
base_peak_index = apex_mass_spec.index(base_peak_intensity)

# Finally, determine the mass of the base peak
return apex_mass_list[base_peak_index]

0 comments on commit 7eb4656

Please sign in to comment.