libgunshotmatch 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of libgunshotmatch might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libgunshotmatch
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Base library for GunShotMatch.
5
5
  Author-email: Dominic Davis-Foster <dominic@davis-foster.co.uk>
6
6
  License: MIT
@@ -135,7 +135,7 @@ libgunshotmatch
135
135
  .. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
136
136
  :alt: GitHub top language
137
137
 
138
- .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.4.0
138
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.5.0
139
139
  :target: https://github.com/GunShotMatch/libgunshotmatch/pulse
140
140
  :alt: GitHub commits since tagged version
141
141
 
@@ -91,7 +91,7 @@ libgunshotmatch
91
91
  .. |language| image:: https://img.shields.io/github/languages/top/GunShotMatch/libgunshotmatch
92
92
  :alt: GitHub top language
93
93
 
94
- .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.4.0
94
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.5.0
95
95
  :target: https://github.com/GunShotMatch/libgunshotmatch/pulse
96
96
  :alt: GitHub commits since tagged version
97
97
 
@@ -29,5 +29,5 @@ Base library for GunShotMatch.
29
29
  __author__: str = "Dominic Davis-Foster"
30
30
  __copyright__: str = "2020-2023 Dominic Davis-Foster"
31
31
  __license__: str = "MIT License"
32
- __version__: str = "0.4.0"
32
+ __version__: str = "0.5.0"
33
33
  __email__: str = "dominic@davis-foster.co.uk"
@@ -548,13 +548,15 @@ def match_counter(
548
548
  aligned_peaks = []
549
549
  consolidated_peaks = []
550
550
 
551
- for n in peak_numbers:
551
+ for idx, peak_no in enumerate(peak_numbers):
552
+ # idx relates to the position in the QualifiedPeak lists for each repeat.
553
+ # peak_no correlates to the ``peak_number`` attribute of the QualifiedPeak objects
552
554
  row: List[Optional[QualifiedPeak]] = []
553
555
  # for experiment in project.alignment.expr_code:
554
556
  for experiment in qualified_peaks:
555
557
  assert experiment is not None
556
558
  for peak in experiment:
557
- if peak.peak_number == n:
559
+ if peak.peak_number == peak_no:
558
560
  row.append(peak)
559
561
  break
560
562
  else:
@@ -648,8 +650,8 @@ def match_counter(
648
650
  area_data,
649
651
  ms_data,
650
652
  hits=hits_data,
651
- ms_comparison=ms_comp_data.loc[n],
652
- meta={"peak_number": n}
653
+ ms_comparison=ms_comp_data.loc[peak_no],
654
+ meta={"peak_number": idx} # The position of the peaks in the QualifiedPeak lists
653
655
  )
654
656
 
655
657
  # consolidated_peak.hits = hits_data # [:n_hits]
@@ -472,6 +472,7 @@ class Repeat:
472
472
  datafile = Datafile.from_dict(d["datafile"])
473
473
 
474
474
  peaks = PeakList(peak_from_dict(peak) for peak in d["peaks"])
475
+ peaks.datafile_name = datafile.name
475
476
 
476
477
  qualified_peaks_as_list = d["qualified_peaks"]
477
478
  if qualified_peaks_as_list is None:
@@ -148,7 +148,8 @@ class IntensityMatrixMethod(MethodBase):
148
148
  #: The range of masses to which the GC-MS data should be limited to.
149
149
  crop_mass_range: Optional[Tuple[int, int]] = attr.field(default=(50, 500), converter=convert_crop_mass_range)
150
150
 
151
- #: Whether to perform Savitzky-Golay smoothing.
151
+ # Whether to perform Savitzky-Golay smoothing.
152
+ #: Settings for Savitzky-Golay smoothing.
152
153
  savitzky_golay: SavitzkyGolayMethod = attr.field(
153
154
  default=SavitzkyGolayMethod(),
154
155
  converter=_convert_sg_method,
@@ -438,7 +438,7 @@ def filter_aligned_peaks(
438
438
  Filter aligned peaks by minimum average peak area, and to the top ``n`` largest peaks.
439
439
 
440
440
  :param alignment:
441
- :param top_n_peaks: Filter to the largest ``n`` peaks.
441
+ :param top_n_peaks: Filter to the largest ``n`` peaks. If ``0`` all peaks are included.
442
442
  :param min_peak_area: Exclude aligned peaks with an average peak area below this threshold.
443
443
 
444
444
  :returns: :class:`pandas.DataFrame` giving the retention times of the aligned peaks.
@@ -458,17 +458,22 @@ def filter_aligned_peaks(
458
458
  area_alignment = area_alignment.sort_values(by="mean")
459
459
 
460
460
  ########
461
-
462
- print(f"Filtering to the largest {top_n_peaks} peaks with an average peak area above {min_peak_area}")
463
-
464
461
  # Get indices of largest n peaks based on `ident_top_peaks`
465
462
  top_peaks_indices = []
466
- # print("tail of area_alignment=", area_alignment.tail(top_n_peaks))
467
463
 
468
- # Limit to the largest `ident_top_peaks` peaks
469
- for peak_no, areas in area_alignment.tail(top_n_peaks).iterrows():
470
- # Ignore peak if average peak area is less then min_peak_area
471
- if areas["mean"] >= min_peak_area:
464
+ if top_n_peaks:
465
+ print(f"Filtering to the largest {top_n_peaks} peaks with an average peak area above {min_peak_area}")
466
+
467
+ # print("tail of area_alignment=", area_alignment.tail(top_n_peaks))
468
+
469
+ # Limit to the largest `ident_top_peaks` peaks
470
+ for peak_no, areas in area_alignment.tail(top_n_peaks).iterrows():
471
+ # Ignore peak if average peak area is less then min_peak_area
472
+ if areas["mean"] >= min_peak_area:
473
+ top_peaks_indices.append(peak_no)
474
+
475
+ else:
476
+ for peak_no, _ in area_alignment.iterrows():
472
477
  top_peaks_indices.append(peak_no)
473
478
 
474
479
  # Remove peaks from rt_alignment if they are not in top_peaks_indices,
@@ -4,7 +4,7 @@ build-backend = "whey"
4
4
 
5
5
  [project]
6
6
  name = "libgunshotmatch"
7
- version = "0.4.0"
7
+ version = "0.5.0"
8
8
  description = "Base library for GunShotMatch."
9
9
  readme = "README.rst"
10
10
  keywords = []
File without changes