emdbva 0.0.1.dev101__tar.gz → 0.0.1.dev102__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.
- {emdbva-0.0.1.dev101/emdbva.egg-info → emdbva-0.0.1.dev102}/PKG-INFO +1 -1
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102/emdbva.egg-info}/PKG-INFO +1 -1
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/mainva.py +1 -1
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/inclusion.py +0 -1
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/preparation.py +37 -20
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/validationanalysis.py +26 -24
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/version.py +1 -1
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/LICENSE +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/MANIFEST.in +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/README.rst +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/emdbva.egg-info/SOURCES.txt +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/emdbva.egg-info/dependency_links.txt +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/emdbva.egg-info/entry_points.txt +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/emdbva.egg-info/requires.txt +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/emdbva.egg-info/top_level.txt +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/setup.cfg +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/setup.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/__init__.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/__init__.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/bars.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/connected_percentage.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/contour_level_predicator.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/emda_mmcc.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/emringer.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/phaserandomization.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/phenix_cc.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/phenix_mm.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/projections.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/qscore.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/residue_locres.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/resmap.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/smoc.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/strudel.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/surfaces.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/metrics/threedfsc.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/qscores.csv +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/Checker.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/ChimeraxViews.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/MapProcessor.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/Model.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/__init__.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/cl_weights.pth +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/log_utils.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/misc.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/rescolor.py +0 -0
- {emdbva-0.0.1.dev101 → emdbva-0.0.1.dev102}/va/utils/stars.py +0 -0
|
@@ -347,7 +347,7 @@ def main():
|
|
|
347
347
|
# Preparation
|
|
348
348
|
# temp_logger, buffer = setup_temporary_logging()
|
|
349
349
|
prepobj = prep()
|
|
350
|
-
# path_to_logs = f'{prepobj.
|
|
350
|
+
# path_to_logs = f'{prepobj.vadir}/{prepobj.mapname}_va.log'
|
|
351
351
|
# reconfigure_logging(temp_logger, buffer, path_to_logs)
|
|
352
352
|
position = prepobj.args.positions
|
|
353
353
|
|
|
@@ -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(" ", "")
|
|
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
|
-
|
|
432
|
-
|
|
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
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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,8 @@ class ValidationAnalysis:
|
|
|
220
220
|
self.workdir = workdir
|
|
221
221
|
self.check_dir = create_directory(f'{self.workdir}/checks/')
|
|
222
222
|
self.get_resolution()
|
|
223
|
-
|
|
223
|
+
if self.rawmap:
|
|
224
|
+
self.relion_mask = self.get_relion_mask()
|
|
224
225
|
# make a symbolic link for relion_mask in the va folder
|
|
225
226
|
if self.relion_mask:
|
|
226
227
|
mask_name = os.path.basename(self.relion_mask)
|
|
@@ -228,9 +229,10 @@ class ValidationAnalysis:
|
|
|
228
229
|
create_symbolic_link(self.relion_mask, link_name)
|
|
229
230
|
self.relion_mask = link_name
|
|
230
231
|
# The read masked raw map here is only used in line 455 for produce the masked raw map glow image
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
if self.rawmap and self.relion_mask:
|
|
233
|
+
maskedrawmap = MapProcessor.mask_map(self.rawmap._iostream.name, self.relion_mask)
|
|
234
|
+
self.masked_rawmap = mrcfile.mmap(maskedrawmap, mode='r+')
|
|
235
|
+
self.masked_rawmap.fullname = maskedrawmap
|
|
234
236
|
|
|
235
237
|
|
|
236
238
|
def get_resolution(self):
|
|
@@ -2207,7 +2209,8 @@ class ValidationAnalysis:
|
|
|
2207
2209
|
# Primary map surface view
|
|
2208
2210
|
primary_input_map = f'{self.workdir}{self.mapname}'
|
|
2209
2211
|
primary_input_contour = self.cl
|
|
2210
|
-
|
|
2212
|
+
if primary_input_contour is not None and self.met != 'tomo':
|
|
2213
|
+
viewer.new_surface_view_chimerax(primary_input_map, primary_input_contour)
|
|
2211
2214
|
|
|
2212
2215
|
# Raw map surface view
|
|
2213
2216
|
if self.hmodd is not None and self.hmeven is not None:
|
|
@@ -4802,31 +4805,30 @@ class ValidationAnalysis:
|
|
|
4802
4805
|
@staticmethod
|
|
4803
4806
|
def compute_surface_area_two(mrc_file, contour_level):
|
|
4804
4807
|
"""
|
|
4805
|
-
|
|
4806
|
-
- mrc_file (str): Path to the .mrc file.
|
|
4807
|
-
- contour_level (float): The density threshold to define the surface.
|
|
4808
|
-
|
|
4808
|
+
Compute the surface area of a 3D cryo-EM density map at a given contour level.
|
|
4809
4809
|
Returns:
|
|
4810
|
-
|
|
4810
|
+
float: Surface area in arbitrary units, or None if failed.
|
|
4811
4811
|
"""
|
|
4812
|
+
try:
|
|
4813
|
+
with mrcfile.open(mrc_file, permissive=True) as mrc:
|
|
4814
|
+
volume = mrc.data.astype(np.float32)
|
|
4815
|
+
voxel_size = mrc.voxel_size['x']
|
|
4812
4816
|
|
|
4813
|
-
|
|
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))
|
|
4817
|
+
verts, faces, _, _ = measure.marching_cubes(volume, level=contour_level)
|
|
4823
4818
|
|
|
4824
|
-
|
|
4819
|
+
def triangle_area(v1, v2, v3):
|
|
4820
|
+
return 0.5 * np.linalg.norm(np.cross(v2 - v1, v3 - v1))
|
|
4825
4821
|
|
|
4826
|
-
|
|
4827
|
-
|
|
4822
|
+
surface_area = sum(triangle_area(verts[f[0]], verts[f[1]], verts[f[2]]) for f in faces)
|
|
4823
|
+
surface_area *= (voxel_size ** 2)
|
|
4824
|
+
return surface_area
|
|
4828
4825
|
|
|
4829
|
-
|
|
4826
|
+
except MemoryError:
|
|
4827
|
+
print("Error: Not enough memory to compute surface area.")
|
|
4828
|
+
sys.exit(1)
|
|
4829
|
+
except Exception as e:
|
|
4830
|
+
print(f"Error during surface area computation: {e}")
|
|
4831
|
+
return None
|
|
4830
4832
|
|
|
4831
4833
|
def compute_surface_ratios_two(self, map_one, map_two):
|
|
4832
4834
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|