pelmesha 0.0.1.dev1__tar.gz → 0.1.3.dev2__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.
Files changed (25) hide show
  1. pelmesha-0.1.3.dev2/.github/workflows/publish_to_pypi.yml +59 -0
  2. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/PKG-INFO +1 -1
  3. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_processing.ipynb +3 -3
  4. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/loaders.py +9 -6
  5. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/pspectra.py +26 -21
  6. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha.egg-info/PKG-INFO +1 -1
  7. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha.egg-info/SOURCES.txt +7 -7
  8. pelmesha-0.0.1.dev1/.github/workflows/publish_to_pypi.yml +0 -121
  9. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/LICENSE.txt +0 -0
  10. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_peaklist_grouping.ipynb +0 -0
  11. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_peaklist_grouping.pdf +0 -0
  12. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_processing.pdf +0 -0
  13. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_raw_spectra.ipynb +0 -0
  14. {pelmesha-0.0.1.dev1/tests → pelmesha-0.1.3.dev2/Pipelines}/MSI_Pipeline_raw_spectra.pdf +0 -0
  15. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/Pipfile +0 -0
  16. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/Pipfile.lock +0 -0
  17. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/README.md +0 -0
  18. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/pyproject.toml +0 -0
  19. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/setup.cfg +0 -0
  20. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/__init__.py +0 -0
  21. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/align.py +0 -0
  22. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/pfeats.py +0 -0
  23. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha/utilities.py +0 -0
  24. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha.egg-info/dependency_links.txt +0 -0
  25. {pelmesha-0.0.1.dev1 → pelmesha-0.1.3.dev2}/src/pelmesha.egg-info/top_level.txt +0 -0
@@ -0,0 +1,59 @@
1
+ name: Publish pelmesha distribution 📦 to PyPI
2
+
3
+ on:
4
+ push:
5
+ # tags:
6
+ # - "**"
7
+ branches:
8
+ - main
9
+
10
+
11
+ jobs:
12
+ build:
13
+ name: Build distribution 📦
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ persist-credentials: false
20
+ fetch-depth: 0
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.x"
25
+
26
+ - name: Install pypa/build
27
+ run: >-
28
+ python3 -m
29
+ pip install
30
+ build
31
+ --user
32
+ - name: Build a binary wheel and a source tarball
33
+ run: python3 -m build
34
+ - name: Store the distribution packages
35
+ uses: actions/upload-artifact@v4
36
+ with:
37
+ name: python-package-distributions
38
+ path: dist/
39
+ publish-to-pypi:
40
+ name: >-
41
+ Publish Python 🐍 distribution 📦 to PyPI
42
+ #if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
43
+
44
+ needs:
45
+ - build
46
+ runs-on: ubuntu-latest
47
+ environment:
48
+ name: pypi
49
+ url: https://pypi.org/p/pelmesha
50
+ permissions:
51
+ id-token: write # IMPORTANT: mandatory for trusted publishing
52
+ steps:
53
+ - name: Download all the dists
54
+ uses: actions/download-artifact@v4
55
+ with:
56
+ name: python-package-distributions
57
+ path: dist/
58
+ - name: Publish distribution 📦 to PyPI
59
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pelmesha
3
- Version: 0.0.1.dev1
3
+ Version: 0.1.3.dev2
4
4
  Summary: A package for proccesing and aligning peaklist Mass-spectrometry imaging data from .imzml files
5
5
  Author-email: Andrew Kuzin <Kuzya-90@bk.ru>
6
6
  License-Expression: Apache-2.0
@@ -458,7 +458,7 @@
458
458
  "from pelmesha.pspectra import Raw2peaklist\n",
459
459
  "path = r\"D:\\Testing\\Our_data\\Rapiflex\\roi8_e040\\roi8_e040.imzML\" # Write your path to the file \n",
460
460
  "\n",
461
- "Raw2peaklist(path, mz_diap4draw=(800,900), oversegmentationfilter=0.15,SNR_threshold=3.5,resample_to_dots=50000,smooth_algo='GA',smooth_window=0.2,Ram_GB = 10)"
461
+ "Raw2peaklist(path, mz_diap4draw=(800,900), oversegmentationfilter=0.15,SNR_threshold=3.5,resample_to_dots=50000,smooth_algo='GA',smooth_window=0.2,Ram_GB = 5)"
462
462
  ]
463
463
  },
464
464
  {
@@ -1157,7 +1157,7 @@
1157
1157
  ],
1158
1158
  "metadata": {
1159
1159
  "kernelspec": {
1160
- "display_name": "Python 3",
1160
+ "display_name": "Python 3 (ipykernel)",
1161
1161
  "language": "python",
1162
1162
  "name": "python3"
1163
1163
  },
@@ -1175,5 +1175,5 @@
1175
1175
  }
1176
1176
  },
1177
1177
  "nbformat": 4,
1178
- "nbformat_minor": 2
1178
+ "nbformat_minor": 4
1179
1179
  }
@@ -37,7 +37,7 @@ def hdf5_Load(path_list, file_end=''):
37
37
  Slide_data={}
38
38
  for path in hdf5path_list:
39
39
  Slide_name=os.path.basename(os.path.dirname(path))
40
- Slide_data[os.path.splitext(Slide_name)[0]] = File(path,"r")
40
+ Slide_data[Slide_name] = File(path,"r")
41
41
  if not hdf5path_list:
42
42
  warnings.warn(f"Data not readed due to missing hdf5 with spectra data (hdf5 with end \"{file_end}\" in the name is missing)", stacklevel=2)
43
43
  return Slide_data
@@ -420,11 +420,14 @@ def hdf5_close():
420
420
  """
421
421
  gc.collect()
422
422
  for obj in gc.get_objects(): # Browse through ALL objects
423
- if isinstance(obj, File): # Just HDF5 files
424
- try:
425
- obj.close()
426
- except:
427
- pass # Was already closed
423
+ try:
424
+ if isinstance(obj, File): # Just HDF5 files
425
+ try:
426
+ obj.close()
427
+ except:
428
+ pass # Was already closed
429
+ except:
430
+ pass
428
431
 
429
432
  ### utils functions
430
433
  def find_paths(path_list,file_end = '.imzML'):
@@ -104,18 +104,20 @@ def imzml2hdf5(path_list, dtypeconv='single', chunk_rowsize = "Auto", chunk_bsiz
104
104
  imzmlpath_list = find_paths(path_list) ## Поиск файлов imzml и создание списка корневых папок с файлами ".imzml"
105
105
  sample_tot_num = len(imzmlpath_list) # счётчик общего количества sample, используется для создания количества процессов не более этого значения (не критично, но оптимально вдруг, чтобы не создавать пул нерабочих процессов, что возможно ест ресурс компа)
106
106
  if sample_tot_num ==0:
107
- warning.warn("Sample total num is - 0. Couldn't find imzML files")
107
+ warnings.warn("Sample total num is - 0. Couldn't find imzML files")
108
108
  return
109
109
  ##
110
110
  ## Создание списков наименований слайдов, roi и рассчёт общего количества roi
111
- for path in imzmlpath_list:
112
- splitted_path=path.split("\\")
113
- Slides_path = '\\'.join(splitted_path[:-2]) #Определяем путь в root директорию. Это директория, где будут храниться данные обработки в hdf5 файле
111
+ for path in imzmlpath_list:
112
+
113
+ Slides_path=os.path.dirname(os.path.dirname(path)) #Определяем путь в root директорию. Это директория, где будут храниться данные обработки в hdf5 файле
114
+ Slide_name=os.path.basename(Slides_path) #Определяем имя слайда
115
+
114
116
  if all('_rawdata.hdf5' not in item for item in os.listdir(Slides_path)): # условие для выгрузки из imzml и конвертации данных в hdf5
115
117
  sample_imzmlpath_list.append([Slides_path,path])
116
118
  else:
117
119
  if reconv:
118
- os.remove(Slides_path+"\\"+splitted_path[-3]+"_rawdata.hdf5")
120
+ os.remove(Slides_path+"\\"+Slide_name+"_rawdata.hdf5")
119
121
  sample_imzmlpath_list.append([Slides_path,path])
120
122
  else:
121
123
  print(f"Data on the path {path} has hdf5 file for raw data. Change argument 'reconv' to True, if needed to reconvert")
@@ -1117,8 +1119,12 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1117
1119
  :return: None
1118
1120
  :rtype: Nonetype
1119
1121
  """
1120
- folder_path = foldersample_path[0]
1121
- sample = foldersample_path[1]
1122
+ Slide_folder_path = foldersample_path[0]
1123
+ Slide_name = os.path.basename(Slide_folder_path)
1124
+ sample_path2imzml = foldersample_path[1]
1125
+ folder_path2imzml = os.path.dirname(sample_path2imzml)
1126
+ sample_name = os.path.splitext(os.path.basename(sample_path2imzml))[0]
1127
+
1122
1128
  ## Извлечение из poslog физических координат
1123
1129
  sample_data={}
1124
1130
  count=0
@@ -1126,9 +1132,9 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1126
1132
  roi_idx = {}
1127
1133
 
1128
1134
  try:
1129
- sample_imzml=ImzMLParser(sample)
1135
+ sample_imzml=ImzMLParser(sample_path2imzml)
1130
1136
  except FileNotFoundError: #Если нет imzML файла в папке - пропуск
1131
- print_queue.put(f'No {sample} file in directory {folder_path}')
1137
+ print_queue.put(f'No {sample_path2imzml} file in directory {Slide_folder_path}')
1132
1138
  return
1133
1139
 
1134
1140
  try:
@@ -1140,7 +1146,7 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1140
1146
  roi_list = []
1141
1147
  dots_num={}
1142
1148
  try:
1143
- with open(sample[:-6]+"_poslog.txt") as f:
1149
+ with open(os.path.join(folder_path2imzml,sample_name)+"_poslog.txt") as f:
1144
1150
  data = f.readlines()
1145
1151
 
1146
1152
  ##первая итерация записи координат начиная с третьей строки
@@ -1215,7 +1221,7 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1215
1221
  for idx in range(numspectra):
1216
1222
  sample_data[roi_num]["xy"][idx,:] = sample_imzml.get_physical_coordinates(idx)
1217
1223
  else:
1218
- print_queue.put(f"Sample: {sample}\nThe data in the imzml file is not continuous. It will not be recorded in HDF5 format.")
1224
+ print_queue.put(f"Sample: {sample_path2imzml}\nThe data in the imzml file is not continuous. It will not be recorded in HDF5 format.")
1219
1225
  print_queue.put(True)
1220
1226
  return # Заглушка. Нет идей как грамотно впихнуть данные в hdf5, где надо пихать матрицы, а не листы с произвольным размером
1221
1227
  sample_data[roi_num]["mz"] = [0]*numspectra
@@ -1242,23 +1248,22 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1242
1248
 
1243
1249
 
1244
1250
  ## Автоматическое определение имени датасета
1245
- sample_names = sample.split("\\")
1246
- if sample_names[-1][:-6] == sample_names[-2]:
1247
- ds_name = sample_names[-2]
1251
+ folder_name=os.path.basename(folder_path2imzml)
1252
+ if sample_name == folder_name:
1253
+ ds_name = folder_name
1248
1254
  else:
1249
- ds_name=sample_names[-2]+"_"+sample_names[-1][:-6]
1255
+ ds_name=folder_name+"_"+sample_name
1250
1256
  ##
1251
1257
  ## Запись в hdf5
1252
1258
 
1253
1259
  temp = queue.get()
1254
- string_temp = "\\".join(sample_names[-3:])
1255
- print_queue.put(f"{string_temp} is waiting queue")
1256
- del string_temp
1257
- hdf5_raw=File(folder_path+'\\'+os.path.basename(folder_path)+"_rawdata.hdf5","a")
1260
+ print_queue.put(f"Slide {Slide_name} with sample {sample_name} is waiting queue")
1261
+
1262
+ hdf5_raw=File(os.path.join(Slide_folder_path,Slide_name)+"_rawdata.hdf5","a")
1258
1263
 
1259
1264
  if chunk_rowsize == "Full":
1260
1265
  for roi in roi_list:
1261
- print_queue.put("\\".join(sample_names[-3:])+" roi "+roi+" data writing is in progress")
1266
+ print_queue.put(f"Slide {Slide_name} with sample {sample_name}"+" roi "+roi+" data writing is in progress")
1262
1267
  #for type in ['/xy','/z']:
1263
1268
  #hdf5.create_dataset(ds_name+'/'+roi+type, data=sample_data[roi][type.replace("/","")])
1264
1269
 
@@ -1285,7 +1290,7 @@ def hdf5_writer(foldersample_path, queue,print_queue, dtypeconv,chunk_rowsize,ch
1285
1290
  hdf5_raw[ds_name][roi].attrs['continues'] =dcont #Data points type
1286
1291
  #hdf5.close()
1287
1292
  hdf5_raw.close()
1288
- print_queue.put(f"{sample} data writing is finished")
1293
+ print_queue.put(f"{sample_path2imzml} data writing is finished")
1289
1294
  print_queue.put(True)
1290
1295
  queue.put(True)
1291
1296
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pelmesha
3
- Version: 0.0.1.dev1
3
+ Version: 0.1.3.dev2
4
4
  Summary: A package for proccesing and aligning peaklist Mass-spectrometry imaging data from .imzml files
5
5
  Author-email: Andrew Kuzin <Kuzya-90@bk.ru>
6
6
  License-Expression: Apache-2.0
@@ -4,6 +4,12 @@ Pipfile.lock
4
4
  README.md
5
5
  pyproject.toml
6
6
  .github/workflows/publish_to_pypi.yml
7
+ Pipelines/MSI_Pipeline_peaklist_grouping.ipynb
8
+ Pipelines/MSI_Pipeline_peaklist_grouping.pdf
9
+ Pipelines/MSI_Pipeline_processing.ipynb
10
+ Pipelines/MSI_Pipeline_processing.pdf
11
+ Pipelines/MSI_Pipeline_raw_spectra.ipynb
12
+ Pipelines/MSI_Pipeline_raw_spectra.pdf
7
13
  src/pelmesha/__init__.py
8
14
  src/pelmesha/align.py
9
15
  src/pelmesha/loaders.py
@@ -13,10 +19,4 @@ src/pelmesha/utilities.py
13
19
  src/pelmesha.egg-info/PKG-INFO
14
20
  src/pelmesha.egg-info/SOURCES.txt
15
21
  src/pelmesha.egg-info/dependency_links.txt
16
- src/pelmesha.egg-info/top_level.txt
17
- tests/MSI_Pipeline_peaklist_grouping.ipynb
18
- tests/MSI_Pipeline_peaklist_grouping.pdf
19
- tests/MSI_Pipeline_processing.ipynb
20
- tests/MSI_Pipeline_processing.pdf
21
- tests/MSI_Pipeline_raw_spectra.ipynb
22
- tests/MSI_Pipeline_raw_spectra.pdf
22
+ src/pelmesha.egg-info/top_level.txt
@@ -1,121 +0,0 @@
1
- # name: Publish Python 🐍 distribution 📦 to PyPI
2
-
3
- # on:
4
- # push:
5
- # branches:
6
- # - main
7
-
8
- # jobs:
9
- # build:
10
- # name: Build distribution 📦
11
- # runs-on: ubuntu-latest
12
-
13
- # steps:
14
- # - uses: actions/checkout@v4
15
- # with:
16
- # persist-credentials: false
17
- # fetch-depth: 0
18
- # - name: Set up Python
19
- # uses: actions/setup-python@v5
20
- # with:
21
- # python-version: "3.x"
22
-
23
- # - name: Install pypa/build
24
- # run: >-
25
- # python3 -m
26
- # pip install
27
- # build
28
- # --user
29
- # - name: Build a binary wheel and a source tarball
30
- # run: python3 -m build
31
- # - name: Store the distribution packages
32
- # uses: actions/upload-artifact@v4
33
- # with:
34
- # name: python-package-distributions
35
- # path: dist/
36
- # publish-to-pypi:
37
- # name: Publish Python 🐍 distribution 📦 to PyPI
38
- # needs:
39
- # - build
40
- # runs-on: ubuntu-latest
41
-
42
- # environment:
43
- # name: pypi
44
- # url: https://pypi.org/p/pelmesha
45
-
46
- # permissions:
47
- # id-token: write # IMPORTANT: mandatory for trusted publishing
48
-
49
- # steps:
50
- # - name: Download all the dists
51
- # uses: actions/download-artifact@v4
52
- # with:
53
- # name: python-package-distributions
54
- # path: dist/
55
- # - name: Publish distribution 📦 to PyPI
56
- # uses: pypa/gh-action-pypi-publish@release/v1
57
-
58
- # # steps:
59
- # # - name: Download all the dists
60
- # # uses: actions/download-artifact@v4
61
- # # with:
62
- # # name: python-package-distributions
63
- # # path: dist/
64
- # # - name: Publish distribution 📦 to TestPyPI
65
- # # uses: pypa/gh-action-pypi-publish@release/v1
66
- # # with:
67
- # # repository-url: https://test.pypi.org/legacy/
68
- # # name: Publish Python 🐍 distribution 📦 to PyPI
69
-
70
- on:
71
- push:
72
- branches:
73
- - main
74
-
75
- jobs:
76
- build:
77
- name: Build distribution 📦
78
- runs-on: ubuntu-latest
79
-
80
- steps:
81
- - uses: actions/checkout@v4
82
- with:
83
- persist-credentials: false
84
- - name: Set up Python
85
- uses: actions/setup-python@v5
86
- with:
87
- python-version: "3.x"
88
-
89
- - name: Install pypa/build
90
- run: >-
91
- python3 -m
92
- pip install
93
- build
94
- --user
95
- - name: Build a binary wheel and a source tarball
96
- run: python3 -m build
97
- - name: Store the distribution packages
98
- uses: actions/upload-artifact@v4
99
- with:
100
- name: python-package-distributions
101
- path: dist/
102
- publish-to-pypi:
103
- name: >-
104
- Publish Python 🐍 distribution 📦 to PyPI
105
- # if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
106
- needs:
107
- - build
108
- runs-on: ubuntu-latest
109
- environment:
110
- name: pypi
111
- url: https://pypi.org/p/pelmesha
112
- permissions:
113
- id-token: write # IMPORTANT: mandatory for trusted publishing
114
- steps:
115
- - name: Download all the dists
116
- uses: actions/download-artifact@v4
117
- with:
118
- name: python-package-distributions
119
- path: dist/
120
- - name: Publish distribution 📦 to PyPI
121
- uses: pypa/gh-action-pypi-publish@release/v1
File without changes
File without changes
File without changes
File without changes