emdbva 0.0.1.dev101__tar.gz → 0.0.1.dev103__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 (46) hide show
  1. {emdbva-0.0.1.dev101/emdbva.egg-info → emdbva-0.0.1.dev103}/PKG-INFO +1 -1
  2. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103/emdbva.egg-info}/PKG-INFO +1 -1
  3. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/mainva.py +1 -11
  4. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/inclusion.py +0 -1
  5. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/preparation.py +37 -20
  6. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/validationanalysis.py +27 -24
  7. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/version.py +1 -1
  8. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/LICENSE +0 -0
  9. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/MANIFEST.in +0 -0
  10. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/README.rst +0 -0
  11. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/emdbva.egg-info/SOURCES.txt +0 -0
  12. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/emdbva.egg-info/dependency_links.txt +0 -0
  13. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/emdbva.egg-info/entry_points.txt +0 -0
  14. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/emdbva.egg-info/requires.txt +0 -0
  15. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/emdbva.egg-info/top_level.txt +0 -0
  16. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/setup.cfg +0 -0
  17. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/setup.py +0 -0
  18. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/__init__.py +0 -0
  19. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/__init__.py +0 -0
  20. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/bars.py +0 -0
  21. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/connected_percentage.py +0 -0
  22. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/contour_level_predicator.py +0 -0
  23. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/emda_mmcc.py +0 -0
  24. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/emringer.py +0 -0
  25. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/phaserandomization.py +0 -0
  26. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/phenix_cc.py +0 -0
  27. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/phenix_mm.py +0 -0
  28. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/projections.py +0 -0
  29. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/qscore.py +0 -0
  30. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/residue_locres.py +0 -0
  31. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/resmap.py +0 -0
  32. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/smoc.py +0 -0
  33. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/strudel.py +0 -0
  34. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/surfaces.py +0 -0
  35. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/metrics/threedfsc.py +0 -0
  36. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/qscores.csv +0 -0
  37. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/Checker.py +0 -0
  38. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/ChimeraxViews.py +0 -0
  39. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/MapProcessor.py +0 -0
  40. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/Model.py +0 -0
  41. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/__init__.py +0 -0
  42. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/cl_weights.pth +0 -0
  43. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/log_utils.py +0 -0
  44. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/misc.py +0 -0
  45. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/rescolor.py +0 -0
  46. {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev103}/va/utils/stars.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: emdbva
3
- Version: 0.0.1.dev101
3
+ Version: 0.0.1.dev103
4
4
  Summary: CryoEM validation toolkit
5
5
  Home-page: https://test.pypi.org/project/va/
6
6
  Author: Zhe Wang
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: emdbva
3
- Version: 0.0.1.dev101
3
+ Version: 0.0.1.dev103
4
4
  Summary: CryoEM validation toolkit
5
5
  Home-page: https://test.pypi.org/project/va/
6
6
  Author: Zhe Wang
@@ -76,16 +76,6 @@ def allruns(validationobj, runs):
76
76
  if 'predictcontour' in runs:
77
77
  validationobj.cl_prediction()
78
78
 
79
- # # Central slice
80
- # if 'central' in runs:
81
- # validationobj.central_slice()
82
- # validationobj.rawmap_central_slice()
83
- #
84
- # # Largest variance
85
- # if 'largestvariance' in runs:
86
- # validationobj.largest_variance()
87
- # validationobj.rawmap_largest_variance()
88
-
89
79
  # Generate atom inclusion and residue inclusion json file
90
80
  if 'inclusion' in runs:
91
81
  validationobj.ai_bar()
@@ -347,7 +337,7 @@ def main():
347
337
  # Preparation
348
338
  # temp_logger, buffer = setup_temporary_logging()
349
339
  prepobj = prep()
350
- # path_to_logs = f'{prepobj.dir}/{prepobj.mapname}_va.log'
340
+ # path_to_logs = f'{prepobj.vadir}/{prepobj.mapname}_va.log'
351
341
  # reconfigure_logging(temp_logger, buffer, path_to_logs)
352
342
  position = prepobj.args.positions
353
343
 
@@ -18,7 +18,6 @@ class Inclusion:
18
18
  self.model = model
19
19
  self.workdir = workdir
20
20
  self.mapname = os.path.basename(map.fullname)
21
- print(self.mapname)
22
21
 
23
22
  # @execution_time('inclusion')
24
23
  # def atom_inclusion(self):
@@ -115,7 +115,7 @@ class PreParation:
115
115
  self.evenmap = inputdict_cif.get('even')
116
116
  self.oddmap = inputdict_cif.get('odd')
117
117
  self.resolution = inputdict_cif.get('resolution')
118
- self.method = methoddict.get(inputdict_cif.get('method', '').replace(" ", "").lower())
118
+ self.method = methoddict.get(inputdict_cif.get('method', '').replace(" ", ""))
119
119
  if 'mask' in inputdict_cif:
120
120
  mask_path = inputdict_cif['mask'] + 'map'
121
121
  self.masks = {mask_path: 1.0}
@@ -412,14 +412,13 @@ class PreParation:
412
412
  block = doc.sole_block()
413
413
 
414
414
  # Extract resolution and reconstruction method
415
- reconstruction_method = block.find_value('_em_experiment.reconstruction_method').replace("'", "") or None
415
+ reconstruction_method = block.find_value('_em_experiment.reconstruction_method').replace("'", "").lower() or None
416
416
  resolution = block.find_value('_em_3d_reconstruction.resolution')
417
+ resolution = float(resolution) if resolution and resolution != '?' else None
417
418
  if resolution is None:
418
419
  resolution_loop = block.find_loop('_em_3d_reconstruction.resolution')
419
420
  resolution = next(x for x in resolution_loop if x != '?')
420
421
 
421
- assert resolution is not None, "No resolution can be found."
422
-
423
422
  # Initialize map containers
424
423
  map_data = {'primary': {}, 'mask': {}, 'odd': {}, 'even': {}}
425
424
 
@@ -428,23 +427,41 @@ class PreParation:
428
427
  file_loop = block.find_loop('_em_map.file')
429
428
  map_type_loop = block.find_loop('_em_map.type')
430
429
 
431
- if contour_loop and file_loop:
432
- contour_levels = [row for row in contour_loop]
430
+ # If loops are present
431
+ if contour_loop and file_loop and map_type_loop:
432
+ contour_levels = [None if row == '?' else row for row in contour_loop]
433
433
  map_files = [row for row in file_loop]
434
- map_types = [row.replace("'","") for row in map_type_loop if "'" in row]
435
-
436
- for map_file, contour, map_type in zip(map_files, contour_levels, map_types):
437
- map_key = map_file[:-3] # Strip '.gz'
438
- contour = float(contour)
439
-
440
- if map_type == 'primary map':
441
- map_data['primary'] = {'primary': map_key, 'primary_contour': contour}
442
- if map_type =='half map' and 'half_map_1' in map_file:
443
- map_data['odd'] = {'odd': map_key, 'odd_contour': contour}
444
- if map_type == 'half map' and 'half_map_2' in map_file:
445
- map_data['even'] = {'even': map_key, 'even_contour': contour}
446
- if 'msk' in map_file:
447
- map_data['mask'] = {'mask': map_file, 'mask_contour': contour}
434
+ map_types = [row.replace("'", "") for row in map_type_loop]
435
+ else:
436
+ # Check if individual items exist instead
437
+ try:
438
+ contour_level = float(block.find_value('_em_map.contour_level'))
439
+ map_file = block.find_value('_em_map.file')[:-3]
440
+ map_type = block.find_value('_em_map.type').replace("'", "") # sanitize string
441
+
442
+ contour_levels = [contour_level]
443
+ map_files = [map_file]
444
+ map_types = [map_type]
445
+ except Exception as e:
446
+ # fallback or log error
447
+ contour_levels, map_files, map_types = [], [], []
448
+
449
+ # Parse combined map data
450
+ for map_file, contour, map_type in zip(map_files, contour_levels, map_types):
451
+ map_key = map_file[:-3] if map_file.endswith('.gz') else map_file
452
+ try:
453
+ contour = float(contour) if contour is not None else None
454
+ except:
455
+ continue # skip if contour is not valid
456
+
457
+ if map_type == 'primary map':
458
+ map_data['primary'] = {'primary': map_key, 'primary_contour': contour}
459
+ if map_type == 'half map' and 'half_map_1' in map_file:
460
+ map_data['odd'] = {'odd': map_key, 'odd_contour': contour}
461
+ if map_type == 'half map' and 'half_map_2' in map_file:
462
+ map_data['even'] = {'even': map_key, 'even_contour': contour}
463
+ if 'msk' in map_file:
464
+ map_data['mask'] = {'mask': map_file, 'mask_contour': contour}
448
465
 
449
466
  # Extract database cross-references
450
467
  db_ids = block.find_loop('_database_2.database_id')
@@ -220,7 +220,9 @@ class ValidationAnalysis:
220
220
  self.workdir = workdir
221
221
  self.check_dir = create_directory(f'{self.workdir}/checks/')
222
222
  self.get_resolution()
223
- self.relion_mask = self.get_relion_mask()
223
+ self.relion_mask = None
224
+ if self.rawmap:
225
+ self.relion_mask = self.get_relion_mask()
224
226
  # make a symbolic link for relion_mask in the va folder
225
227
  if self.relion_mask:
226
228
  mask_name = os.path.basename(self.relion_mask)
@@ -228,9 +230,10 @@ class ValidationAnalysis:
228
230
  create_symbolic_link(self.relion_mask, link_name)
229
231
  self.relion_mask = link_name
230
232
  # The read masked raw map here is only used in line 455 for produce the masked raw map glow image
231
- maskedrawmap = MapProcessor.mask_map(self.rawmap._iostream.name, self.relion_mask)
232
- self.masked_rawmap = mrcfile.mmap(maskedrawmap, mode='r+')
233
- self.masked_rawmap.fullname = maskedrawmap
233
+ if self.rawmap and self.relion_mask:
234
+ maskedrawmap = MapProcessor.mask_map(self.rawmap._iostream.name, self.relion_mask)
235
+ self.masked_rawmap = mrcfile.mmap(maskedrawmap, mode='r+')
236
+ self.masked_rawmap.fullname = maskedrawmap
234
237
 
235
238
 
236
239
  def get_resolution(self):
@@ -2207,7 +2210,8 @@ class ValidationAnalysis:
2207
2210
  # Primary map surface view
2208
2211
  primary_input_map = f'{self.workdir}{self.mapname}'
2209
2212
  primary_input_contour = self.cl
2210
- viewer.new_surface_view_chimerax(primary_input_map, primary_input_contour)
2213
+ if primary_input_contour is not None and self.met != 'tomo':
2214
+ viewer.new_surface_view_chimerax(primary_input_map, primary_input_contour)
2211
2215
 
2212
2216
  # Raw map surface view
2213
2217
  if self.hmodd is not None and self.hmeven is not None:
@@ -4802,31 +4806,30 @@ class ValidationAnalysis:
4802
4806
  @staticmethod
4803
4807
  def compute_surface_area_two(mrc_file, contour_level):
4804
4808
  """
4805
- Compute the surface area of a 3D cryo-EM density map at a given contour level.
4806
- - mrc_file (str): Path to the .mrc file.
4807
- - contour_level (float): The density threshold to define the surface.
4808
-
4809
+ Compute the surface area of a 3D cryo-EM density map at a given contour level.
4809
4810
  Returns:
4810
- - float: Surface area in arbitrary units.
4811
+ float: Surface area in arbitrary units, or None if failed.
4811
4812
  """
4813
+ try:
4814
+ with mrcfile.open(mrc_file, permissive=True) as mrc:
4815
+ volume = mrc.data.astype(np.float32)
4816
+ voxel_size = mrc.voxel_size['x']
4812
4817
 
4813
- with mrcfile.open(mrc_file, permissive=True) as mrc:
4814
- volume = mrc.data.astype(np.float32)
4815
- voxel_size = mrc.voxel_size['x']
4816
-
4817
- # Apply Marching Cubes algorithm to extract surface mesh
4818
- verts, faces, _, _ = measure.marching_cubes(volume, level=contour_level)
4819
-
4820
- # Compute surface area by summing the area of all mesh triangles
4821
- def triangle_area(v1, v2, v3):
4822
- return 0.5 * np.linalg.norm(np.cross(v2 - v1, v3 - v1))
4818
+ verts, faces, _, _ = measure.marching_cubes(volume, level=contour_level)
4823
4819
 
4824
- surface_area = sum(triangle_area(verts[f[0]], verts[f[1]], verts[f[2]]) for f in faces)
4820
+ def triangle_area(v1, v2, v3):
4821
+ return 0.5 * np.linalg.norm(np.cross(v2 - v1, v3 - v1))
4825
4822
 
4826
- # Convert area to real space (scaling by voxel size squared)
4827
- surface_area *= (voxel_size ** 2)
4823
+ surface_area = sum(triangle_area(verts[f[0]], verts[f[1]], verts[f[2]]) for f in faces)
4824
+ surface_area *= (voxel_size ** 2)
4825
+ return surface_area
4828
4826
 
4829
- return surface_area
4827
+ except MemoryError:
4828
+ print("Error: Not enough memory to compute surface area.")
4829
+ sys.exit(1)
4830
+ except Exception as e:
4831
+ print(f"Error during surface area computation: {e}")
4832
+ return None
4830
4833
 
4831
4834
  def compute_surface_ratios_two(self, map_one, map_two):
4832
4835
  """
@@ -28,4 +28,4 @@ under the License.
28
28
 
29
29
  """
30
30
 
31
- __version__ = '0.0.1.dev101'
31
+ __version__ = '0.0.1.dev103'
File without changes
File without changes
File without changes
File without changes
File without changes