libgunshotmatch 0.6.0__py3-none-any.whl → 0.7.1__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.6.0"
32
+ __version__: str = "0.7.1"
33
33
  __email__: str = "dominic@davis-foster.co.uk"
@@ -476,7 +476,7 @@ class ConsolidatedPeak:
476
476
  return cls(
477
477
  rt_list=d["rt_list"],
478
478
  area_list=d["area_list"],
479
- ms_list=d["ms_list"],
479
+ ms_list=[MassSpectrum.from_dict(msd) for msd in d["ms_list"]],
480
480
  meta=d["meta"],
481
481
  ms_comparison=d["ms_comparison"],
482
482
  hits=hits,
libgunshotmatch/peak.py CHANGED
@@ -422,15 +422,20 @@ def write_alignment(
422
422
  )
423
423
 
424
424
  rt_alignment = alignment.get_peak_alignment(require_all_expr=require_all_datafiles)
425
- rt_alignment.to_json(output_dir_p / f"{project_name}_alignment_rt.json")
425
+ rt_alignment_filename = output_dir_p / f"{project_name}_alignment_rt.json"
426
+ rt_alignment_filename.write_clean(rt_alignment)
426
427
 
427
428
  area_alignment = alignment.get_area_alignment(require_all_expr=require_all_datafiles)
428
- area_alignment.to_json(output_dir_p / f"{project_name}_alignment_area.json")
429
+ area_alignment_filename = output_dir_p / f"{project_name}_alignment_area.json"
430
+ area_alignment_filename.write_clean(area_alignment)
429
431
 
430
432
  ms_alignment = alignment.get_ms_alignment(require_all_expr=require_all_datafiles)
431
433
  # ms_alignment.to_json(output_dir_p / 'alignment_ms.json')
432
- with (output_dir_p / f"{project_name}_alignment_ms.json").open('w') as fp:
433
- sdjson.dump(ms_alignment.to_dict(), fp)
434
+ alignment_ms_filename = (output_dir_p / f"{project_name}_alignment_ms.json")
435
+ alignment_ms_filename.dump_json(
436
+ ms_alignment.to_dict(),
437
+ json_library=sdjson, # type: ignore
438
+ )
434
439
 
435
440
 
436
441
  def filter_aligned_peaks(
libgunshotmatch/utils.py CHANGED
@@ -28,7 +28,7 @@ Utility functions.
28
28
 
29
29
  # stdlib
30
30
  from decimal import Decimal
31
- from typing import Any, Iterable, List, Optional, Sequence, Type, TypeVar, Union
31
+ from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Sequence, Tuple, Type, TypeVar, Union
32
32
 
33
33
  # 3rd party
34
34
  import numpy
@@ -37,7 +37,11 @@ from mathematical.utils import rounders
37
37
  from pyms.Spectrum import MassSpectrum # type: ignore[import]
38
38
  from scipy.stats import truncnorm # type: ignore[import]
39
39
 
40
- __all__ = ("round_rt", "get_truncated_normal", "ms_comparison")
40
+ if TYPE_CHECKING:
41
+ # this package
42
+ from libgunshotmatch.project import Project
43
+
44
+ __all__ = ("round_rt", "get_truncated_normal", "ms_comparison", "get_rt_range")
41
45
 
42
46
 
43
47
  def round_rt(rt: Union[str, float, Decimal]) -> Decimal:
@@ -136,3 +140,29 @@ def _to_list(l: Iterable[str]) -> List[str]:
136
140
  """
137
141
 
138
142
  return list(l)
143
+
144
+
145
+ def get_rt_range(project: "Project") -> Tuple[float, float]:
146
+ """
147
+ Returns the minimum and maximum retention times (in minutes) across the repeats.
148
+
149
+ :param project:
150
+
151
+ :rtype:
152
+
153
+ ,, versionadded:: 0.7.0
154
+ """
155
+
156
+ # Get RT extremes from intensity matrix
157
+ min_rts, max_rts = [], []
158
+ for repeat in project.datafile_data.values():
159
+ im = repeat.datafile.intensity_matrix
160
+ assert im is not None
161
+ times = im.time_list
162
+ min_rts.append(times[0])
163
+ max_rts.append(times[-1])
164
+
165
+ min_rt = min(min_rts) / 60
166
+ max_rt = max(max_rts) / 60
167
+
168
+ return min_rt, max_rt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: libgunshotmatch
3
- Version: 0.6.0
3
+ Version: 0.7.1
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.6.0
138
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/GunShotMatch/libgunshotmatch/v0.7.1
139
139
  :target: https://github.com/GunShotMatch/libgunshotmatch/pulse
140
140
  :alt: GitHub commits since tagged version
141
141
 
@@ -1,18 +1,18 @@
1
- libgunshotmatch/consolidate/__init__.py,sha256=bFfxfF4MH9LMUCK4q2Js2z11ZR28qeJDpRU9a5KOHyA,22793
1
+ libgunshotmatch/consolidate/__init__.py,sha256=gOqPqFcoSkVob8hKOpcNobK84yADyCwB3UNBPJM3vAc,22834
2
2
  libgunshotmatch/consolidate/_fields.py,sha256=7gPIQaFaFySLZFrIuSMjwS84WEBHxZhCNhpXATlYjVw,2691
3
3
  libgunshotmatch/consolidate/_spectra.py,sha256=7q_xVPN_oASayLdyMDjwaBLG4maIybHCqkGhiMIO940,2343
4
4
  libgunshotmatch/method/__init__.py,sha256=k0Hs3c5Q13CENQHGtHVeDW2jQtR6UtiB1IVf_77lCT4,9432
5
5
  libgunshotmatch/method/_fields.py,sha256=GQNw9GdGhy9c_-0U_31eJDTXr1sG5_t5Lh0Z_nzE0RE,5025
6
- libgunshotmatch/__init__.py,sha256=0k-zbcVbpZIBMq4pzDOYJWmwZjs0XoWxjx-Xdj825Cc,1433
6
+ libgunshotmatch/__init__.py,sha256=7QhxNRtPqOz7VBUPCKPF9uaMe4uR0nnuoshgiINneig,1433
7
7
  libgunshotmatch/datafile.py,sha256=sKCatM0F3fmceHQYObwgYr3EX9whKA0U2lOj-xqLt4c,16276
8
8
  libgunshotmatch/gzip_util.py,sha256=vVGZLAhW1WmENt2kDXMY68UR72MHvsCBPaB-xCyVYbg,2250
9
- libgunshotmatch/peak.py,sha256=KUg3FHZzi6Zhd3fMGwWiM_52WfSlqNiBuXTDycxjLgk,16605
9
+ libgunshotmatch/peak.py,sha256=pn8eYS8dfBOCjCRr-rciU3v9k1EREvH6jYqQibdjdok,16777
10
10
  libgunshotmatch/project.py,sha256=t4YLCTKA1YYeRMiaXNz1-k21wYTtidN9FJM4aN9-rbw,6474
11
11
  libgunshotmatch/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  libgunshotmatch/search.py,sha256=qjIXuTo3OqvC_zSLdwZkEDHfza064iYCTZzGeAZoW5s,3137
13
- libgunshotmatch/utils.py,sha256=L5jf4kf-1bD9tOolUz97V2eyHkfT7pwAerZ_IKJsFpU,4251
14
- libgunshotmatch-0.6.0.dist-info/LICENSE,sha256=bFtJt-lyVJHV-88FeFa_r3BEOsmpna5qG2KOl9JUNfU,1064
15
- libgunshotmatch-0.6.0.dist-info/METADATA,sha256=QLB4AOTeadNfDxmPpWEqt_FJN-3gqm91GRsmCXo8rgs,6392
16
- libgunshotmatch-0.6.0.dist-info/WHEEL,sha256=3vSnEhs48RUlSXcCXKCl4DOHs_qqaP2dU3IGkMqN2oI,84
17
- libgunshotmatch-0.6.0.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- libgunshotmatch-0.6.0.dist-info/RECORD,,
13
+ libgunshotmatch/utils.py,sha256=H-Ikm6oEGCgRoPvuCo3H5p1iKz3B9PuUqcpcH-rhgYA,4917
14
+ libgunshotmatch-0.7.1.dist-info/LICENSE,sha256=bFtJt-lyVJHV-88FeFa_r3BEOsmpna5qG2KOl9JUNfU,1064
15
+ libgunshotmatch-0.7.1.dist-info/METADATA,sha256=rvRV47dgFsu7xqyZQ6OukhBY9icHJ7KpqD3QvjXwVEc,6392
16
+ libgunshotmatch-0.7.1.dist-info/WHEEL,sha256=3vSnEhs48RUlSXcCXKCl4DOHs_qqaP2dU3IGkMqN2oI,84
17
+ libgunshotmatch-0.7.1.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ libgunshotmatch-0.7.1.dist-info/RECORD,,