libgunshotmatch 0.10.0__py3-none-any.whl → 0.11.0__py3-none-any.whl

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.

@@ -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.10.0"
32
+ __version__: str = "0.11.0"
33
33
  __email__: str = "dominic@davis-foster.co.uk"
@@ -27,7 +27,7 @@ Functions for combining peak identifications across aligned peaks into a single
27
27
  #
28
28
 
29
29
  # stdlib
30
- from collections import Counter
30
+ from collections import Counter, defaultdict
31
31
  from fnmatch import fnmatch
32
32
  from itertools import permutations
33
33
  from multiprocessing import Pool
@@ -61,6 +61,7 @@ __all__ = (
61
61
  "pairwise_ms_comparisons",
62
62
  "ConsolidatedPeakFilter",
63
63
  "InvertedFilter",
64
+ "combine_spectra",
64
65
  )
65
66
 
66
67
 
@@ -804,3 +805,31 @@ class InvertedFilter(ConsolidatedPeakFilter):
804
805
  filtered_consolidated_peaks.append(cp)
805
806
 
806
807
  return filtered_consolidated_peaks
808
+
809
+
810
+ def combine_spectra(peak: ConsolidatedPeak) -> Tuple[List[int], List[float]]:
811
+ """
812
+ Sum the intensities across all mass spectra in the given peak.
813
+
814
+ :param peak:
815
+
816
+ :returns: List of masses and list of corresponding intensities.
817
+
818
+ .. versionadded:: v0.11.0
819
+ """
820
+
821
+ combined_ms_data: Dict[int, float] = defaultdict(float)
822
+
823
+ for ms in peak.ms_list:
824
+ if ms is not None:
825
+ for mass, intensity in zip(ms.mass_list, ms.intensity_list):
826
+ combined_ms_data[mass] += intensity
827
+
828
+ mass_list, intensity_list = [], []
829
+ for mass, intensity in combined_ms_data.items():
830
+ mass_list.append(mass)
831
+ intensity_list.append(intensity)
832
+
833
+ # mass_list, intensity_list = zip(*combined_ms_data.items())
834
+
835
+ return mass_list, intensity_list
libgunshotmatch/peak.py CHANGED
@@ -55,6 +55,7 @@ __all__ = (
55
55
  "filter_peaks",
56
56
  "peak_from_dict",
57
57
  "write_alignment",
58
+ "base_peak_mass",
58
59
  )
59
60
 
60
61
 
@@ -429,11 +430,11 @@ def write_alignment(
429
430
 
430
431
  rt_alignment = alignment.get_peak_alignment(require_all_expr=require_all_datafiles)
431
432
  rt_alignment_filename = output_dir_p / f"{project_name}_alignment_rt.json"
432
- rt_alignment_filename.write_clean(rt_alignment)
433
+ rt_alignment_filename.write_clean(rt_alignment.to_json())
433
434
 
434
435
  area_alignment = alignment.get_area_alignment(require_all_expr=require_all_datafiles)
435
436
  area_alignment_filename = output_dir_p / f"{project_name}_alignment_area.json"
436
- area_alignment_filename.write_clean(area_alignment)
437
+ area_alignment_filename.write_clean(area_alignment.to_json())
437
438
 
438
439
  ms_alignment = alignment.get_ms_alignment(require_all_expr=require_all_datafiles)
439
440
  # ms_alignment.to_json(output_dir_p / 'alignment_ms.json')
@@ -531,3 +532,25 @@ def _to_peak_list(a_list: List[Peak]) -> PeakList:
531
532
  return a_list
532
533
  else:
533
534
  return PeakList(a_list)
535
+
536
+
537
+ def base_peak_mass(peak: Peak) -> float:
538
+ """
539
+ Returns the mass of the largest fragment in the peak's mass spectrum.
540
+
541
+ :param peak:
542
+
543
+ .. versionadded:: v0.11.0
544
+ """
545
+
546
+ apex_mass_list = peak.mass_spectrum.mass_list
547
+ apex_mass_spec = peak.mass_spectrum.mass_spec
548
+
549
+ # Determine the intensity of the base peak in the mass spectrum
550
+ base_peak_intensity = max(apex_mass_spec)
551
+
552
+ # Determine the index of the base peak in the mass spectrum
553
+ base_peak_index = apex_mass_spec.index(base_peak_intensity)
554
+
555
+ # Finally, determine the mass of the base peak
556
+ return apex_mass_list[base_peak_index]
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: libgunshotmatch
3
- Version: 0.10.0
3
+ Version: 0.11.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.10.0
138
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.11.0
139
139
  :target: https://github.com/GunShotMatch/libgunshotmatch/pulse
140
140
  :alt: GitHub commits since tagged version
141
141
 
@@ -2,21 +2,21 @@ libgunshotmatch/comparison/__init__.py,sha256=g-KDfzG-oyRf2aeXlMaJJ3aWfQtQkr5-bG
2
2
  libgunshotmatch/comparison/_utils.py,sha256=aZ6fnFM4M_vTsKq5t79V4tfven1eVdG4EUCuYFuXMVs,1895
3
3
  libgunshotmatch/comparison/projects.py,sha256=Dq294cDndmQI2FnIcVXwleCQF0mF2m8U5wWnO5_aD9A,3356
4
4
  libgunshotmatch/comparison/unknowns.py,sha256=kvJJDtfpMp-c3hjCOz7YtvuuDR0YksWmyUuaSBC_5Jg,2710
5
- libgunshotmatch/consolidate/__init__.py,sha256=zdnqx7YzV3MiW5IVFEiPSJZT43BdcOmlRqkIKOEBqPg,23816
5
+ libgunshotmatch/consolidate/__init__.py,sha256=ezF2MwUykNSzB5s3X8HiPohTef_kS4gXtRBKG1p6zwc,24567
6
6
  libgunshotmatch/consolidate/_fields.py,sha256=0kfPXJ0EG7GhdFiNzvcmd6W4i1x6Y0s2Y58z3RltPiA,2759
7
7
  libgunshotmatch/consolidate/_spectra.py,sha256=24aDoPwGWEyIFCH-fwRa4nifNMPqUyd-qTogk3BMeLY,2319
8
8
  libgunshotmatch/method/__init__.py,sha256=TP_3rvv3WEbV6Y5E_QWd2lcORPFnbXV4YRKGwXDa4ds,9423
9
9
  libgunshotmatch/method/_fields.py,sha256=HBFl0XmHBaAOHYdABs2NRbjtngGEw7kY0xP6D2Fl7h4,4941
10
- libgunshotmatch/__init__.py,sha256=_8fk8Y_s16QckNbYhOXc8zxn6HIK0f_3TRYEIkYEYr4,1434
10
+ libgunshotmatch/__init__.py,sha256=OXM6TubGh5_DlwFy9SnXURf9fzbaz9cy-gNRZIAhimw,1434
11
11
  libgunshotmatch/datafile.py,sha256=4C4BiR95PBfIUbiUKQzVfh57tgZu_l6rLS8bIgrgPUs,16246
12
12
  libgunshotmatch/gzip_util.py,sha256=PcfT4QC4TM0KI3uCGetRpjChbTXTGmNEJBr7BghO3i8,2414
13
- libgunshotmatch/peak.py,sha256=huZ1hObIFcQpMPXyU6lYe7B-FFT-djSeG4jII7CgWAE,16923
13
+ libgunshotmatch/peak.py,sha256=qe3-y0EsA37W2qMlMVruEOFRRxSG7NVWDcd8TvjZaqY,17546
14
14
  libgunshotmatch/project.py,sha256=ch8v8egvcULjYk7_40KywgM-_j3mf2tvRTzAsIC6Kp0,6904
15
15
  libgunshotmatch/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  libgunshotmatch/search.py,sha256=GMP7_DMnXFq3TG8AT1WARIn4ObCfOGfTDakpGeKzJYw,3123
17
17
  libgunshotmatch/utils.py,sha256=8wrdSk1ZWIgIu6eN9QEDF23goxN7z2VszxcDYZZ8ov0,5729
18
- libgunshotmatch-0.10.0.dist-info/LICENSE,sha256=bFtJt-lyVJHV-88FeFa_r3BEOsmpna5qG2KOl9JUNfU,1064
19
- libgunshotmatch-0.10.0.dist-info/METADATA,sha256=B26beZpWIdl-1YRu3Bl51SqsjWIOd0Y4vy2C1Osy7oA,6394
20
- libgunshotmatch-0.10.0.dist-info/WHEEL,sha256=3vSnEhs48RUlSXcCXKCl4DOHs_qqaP2dU3IGkMqN2oI,84
21
- libgunshotmatch-0.10.0.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- libgunshotmatch-0.10.0.dist-info/RECORD,,
18
+ libgunshotmatch-0.11.0.dist-info/LICENSE,sha256=bFtJt-lyVJHV-88FeFa_r3BEOsmpna5qG2KOl9JUNfU,1064
19
+ libgunshotmatch-0.11.0.dist-info/METADATA,sha256=8TbC-eZngXagQbCQ_G5iStuzriCjYSvGD5umtsxjkAo,6394
20
+ libgunshotmatch-0.11.0.dist-info/WHEEL,sha256=pUf8gZsdmDXXTtqZfolZFpfoEwFoEdADIuUvQVl5qAY,83
21
+ libgunshotmatch-0.11.0.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ libgunshotmatch-0.11.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: whey (0.0.24)
2
+ Generator: whey (0.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any