Skip to content

Commit 59a6efe

Browse files
feature: change sign of the charge_range based on polarity peak list attribute in deconvolute_peaks (#34)
* updated the sign of the charge_range based on polairty of the scan in deconvolute_peaks function --------- Co-authored-by: Joshua Klein <[email protected]>
1 parent 1c2206e commit 59a6efe

File tree

1 file changed

+8
-2
lines changed
  • src/ms_deisotope/deconvolution

1 file changed

+8
-2
lines changed

src/ms_deisotope/deconvolution/api.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def deconvolute_peaks(peaklist: PeakListTypes,
6464
Parameters to use to initialize the deconvoluter instance produced by
6565
``deconvoluter_type``
6666
charge_range : tuple of integers, optional
67-
The range of charge states to consider. The range is inclusive.
67+
The range of charge states to consider. The range is inclusive. Sensitive to sign of the charge/polarity.
6868
error_tolerance : float, optional
6969
PPM error tolerance to use to match experimental to theoretical peaks
7070
priority_list : list, optional
@@ -136,11 +136,17 @@ def deconvolute_peaks(peaklist: PeakListTypes,
136136
decon_config.setdefault("scale_method", SCALE_METHOD)
137137
decon_config.setdefault("use_quick_charge", use_quick_charge)
138138

139+
# Update the charge range with the proper sign, considering the polarity when
140+
# the `polarity` attribute is defined on `peaklist`.
141+
if hasattr(peaklist, 'polarity'):
142+
polarity = int(peaklist.polarity)
143+
if polarity < 0 and max(charge_range) > 0:
144+
charge_range = tuple(c * polarity for c in charge_range)
145+
139146
peaklist = prepare_peaklist(peaklist)
140147

141148
decon = deconvoluter_type(peaklist=peaklist, **decon_config)
142149

143-
144150
if verbose_priorities or verbose:
145151
decon.verbose = True
146152

0 commit comments

Comments
 (0)