emdbva 0.0.1.dev146__tar.gz → 0.0.1.dev148__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 (56) hide show
  1. {emdbva-0.0.1.dev146/emdbva.egg-info → emdbva-0.0.1.dev148}/PKG-INFO +1 -1
  2. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148/emdbva.egg-info}/PKG-INFO +1 -1
  3. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/emdbva.egg-info/SOURCES.txt +1 -0
  4. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/mainva.py +4 -0
  5. emdbva-0.0.1.dev148/va/metrics/map_map_cc.py +139 -0
  6. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/phaserandomization.py +3 -3
  7. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/preparation.py +2 -2
  8. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/prepareandrun_codon_airflow.py +0 -0
  9. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/stars.py +691 -102
  10. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/validationanalysis.py +39 -2
  11. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/version.py +1 -1
  12. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/LICENSE +0 -0
  13. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/MANIFEST.in +0 -0
  14. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/README.rst +0 -0
  15. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/emdbva.egg-info/dependency_links.txt +0 -0
  16. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/emdbva.egg-info/entry_points.txt +0 -0
  17. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/emdbva.egg-info/requires.txt +0 -0
  18. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/emdbva.egg-info/top_level.txt +0 -0
  19. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/setup.cfg +0 -0
  20. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/setup.py +0 -0
  21. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/PATHS_codon_airflow.py +0 -0
  22. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/__init__.py +0 -0
  23. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/audit/__init__.py +0 -0
  24. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/audit/cif_revision.py +0 -0
  25. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/__init__.py +0 -0
  26. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/bars.py +0 -0
  27. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/connected_percentage.py +0 -0
  28. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/contour_level_predicator.py +0 -0
  29. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/emda_mmcc.py +0 -0
  30. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/emringer.py +0 -0
  31. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/inclusion.py +0 -0
  32. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/map_data_validation.py +0 -0
  33. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/overlap_percentage.py +0 -0
  34. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/phenix_cc.py +0 -0
  35. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/phenix_mm.py +0 -0
  36. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/projections.py +0 -0
  37. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/qscore.py +0 -0
  38. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/residue_locres.py +0 -0
  39. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/resmap.py +0 -0
  40. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/smoc.py +0 -0
  41. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/strudel.py +0 -0
  42. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/surfaces.py +0 -0
  43. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/metrics/threedfsc.py +0 -0
  44. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/qscores.csv +0 -0
  45. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/schemas/__init__.py +0 -0
  46. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/schemas/emdb_entry_full.schema.json +0 -0
  47. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/schemas/loader.py +0 -0
  48. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/Checker.py +0 -0
  49. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/ChimeraxViews.py +0 -0
  50. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/MapProcessor.py +0 -0
  51. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/Model.py +0 -0
  52. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/__init__.py +0 -0
  53. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/cl_weights.pth +0 -0
  54. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/log_utils.py +0 -0
  55. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/misc.py +0 -0
  56. {emdbva-0.0.1.dev146 → emdbva-0.0.1.dev148}/va/utils/rescolor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: emdbva
3
- Version: 0.0.1.dev146
3
+ Version: 0.0.1.dev148
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.dev146
3
+ Version: 0.0.1.dev148
4
4
  Summary: CryoEM validation toolkit
5
5
  Home-page: https://test.pypi.org/project/va/
6
6
  Author: Zhe Wang
@@ -26,6 +26,7 @@ va/metrics/emda_mmcc.py
26
26
  va/metrics/emringer.py
27
27
  va/metrics/inclusion.py
28
28
  va/metrics/map_data_validation.py
29
+ va/metrics/map_map_cc.py
29
30
  va/metrics/overlap_percentage.py
30
31
  va/metrics/phaserandomization.py
31
32
  va/metrics/phenix_cc.py
@@ -119,6 +119,10 @@ def allruns(validationobj, runs):
119
119
  validationobj.fscs()
120
120
  # validationobj.surface_ratios()
121
121
 
122
+ # PHENIX map-map correlation
123
+ if 'mapmapcc' in runs:
124
+ validationobj.map_map_cc()
125
+
122
126
  # mmFSC
123
127
  if 'mmfsc' in runs:
124
128
  validationobj.phenix_mmfsc()
@@ -0,0 +1,139 @@
1
+ """PHENIX map-map correlation metric helpers."""
2
+
3
+ import os
4
+ import re
5
+ import subprocess
6
+ from distutils.spawn import find_executable
7
+
8
+
9
+ _MAP_MAP_CC_PATTERN = re.compile(
10
+ r"Map-map CC is\s+([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)"
11
+ )
12
+
13
+
14
+ def parse_map_map_cc_output(stdout_text):
15
+ """Extract the map-map correlation value from PHENIX output.
16
+
17
+ Args:
18
+ stdout_text (str): Combined standard output and error text from
19
+ ``phenix.map_correlations``.
20
+
21
+ Returns:
22
+ float or None: The parsed correlation, or ``None`` when the expected
23
+ result line is absent or cannot be converted to a number.
24
+ """
25
+ if not isinstance(stdout_text, str):
26
+ return None
27
+ match = _MAP_MAP_CC_PATTERN.search(stdout_text)
28
+ if match is None:
29
+ return None
30
+ try:
31
+ return float(match.group(1))
32
+ except (TypeError, ValueError):
33
+ return None
34
+
35
+
36
+ def run_map_map_cc(map1_path, map2_path, output_path, echo=True):
37
+ """Run PHENIX map-map correlation for two map files.
38
+
39
+ Args:
40
+ map1_path (str): Path to the first map.
41
+ map2_path (str): Path to the second map.
42
+ output_path (str): Directory for the PHENIX stdout diagnostic file.
43
+ echo (bool): Whether to print captured PHENIX output.
44
+
45
+ Returns:
46
+ tuple: ``(errlist, result, stdout_text)``. ``result`` is empty when
47
+ the executable, inputs, subprocess, or parser fails.
48
+ """
49
+ errlist = []
50
+ result = {}
51
+ stdout_text = ""
52
+
53
+ phenix_path = find_executable("phenix.map_correlations")
54
+ if phenix_path is None:
55
+ return ["Phenix executable phenix.map_correlations is not available."], result, stdout_text
56
+
57
+ if not os.path.isfile(map1_path):
58
+ errlist.append("Map file does not exist: {}".format(map1_path))
59
+ if not os.path.isfile(map2_path):
60
+ errlist.append("Map file does not exist: {}".format(map2_path))
61
+ if errlist:
62
+ return errlist, result, stdout_text
63
+
64
+ try:
65
+ os.makedirs(output_path, exist_ok=True)
66
+ except OSError as exc:
67
+ return ["Could not create output directory {}: {}".format(output_path, exc)], result, stdout_text
68
+
69
+ command = [phenix_path, map1_path, map2_path]
70
+ try:
71
+ completed = subprocess.run(
72
+ command,
73
+ cwd=output_path,
74
+ stdout=subprocess.PIPE,
75
+ stderr=subprocess.STDOUT,
76
+ text=True,
77
+ check=False,
78
+ )
79
+ stdout_text = completed.stdout or ""
80
+ except OSError as exc:
81
+ return ["Failed to run phenix.map_correlations: {}".format(exc)], result, stdout_text
82
+ finally:
83
+ log_path = os.path.join(output_path, "map_correlations.stdout")
84
+ try:
85
+ with open(log_path, "w", encoding="utf-8") as log_file:
86
+ log_file.write(stdout_text)
87
+ except OSError as exc:
88
+ errlist.append("Could not write {}: {}".format(log_path, exc))
89
+
90
+ if echo:
91
+ print(stdout_text, end="")
92
+ if completed.returncode != 0:
93
+ errlist.append("phenix.map_correlations exited with code {}".format(completed.returncode))
94
+ if "error" in stdout_text.lower():
95
+ errlist.extend(
96
+ line.strip() for line in stdout_text.splitlines() if "error" in line.lower()
97
+ )
98
+
99
+ correlation = parse_map_map_cc_output(stdout_text)
100
+ if correlation is None:
101
+ errlist.append("Could not parse 'Map-map CC is ...' from PHENIX output.")
102
+
103
+ if not errlist:
104
+ map1_name = os.path.basename(map1_path)
105
+ map2_name = os.path.basename(map2_path)
106
+ result = {"name": [map1_name, map2_name], "value": correlation}
107
+ return errlist, result, stdout_text
108
+
109
+
110
+ def write_map_map_cc_json(map1_path, map2_path, correlation, output_path):
111
+ """Write a successful map-map correlation result as a JSON fragment.
112
+
113
+ Args:
114
+ map1_path (str): Path to the first map.
115
+ map2_path (str): Path to the second map.
116
+ correlation (float): Parsed map-map correlation value.
117
+ output_path (str): Directory in which to write the fragment.
118
+
119
+ Returns:
120
+ str: Path to the written JSON file.
121
+ """
122
+ import json
123
+
124
+ os.makedirs(output_path, exist_ok=True)
125
+ map1_name = os.path.basename(map1_path)
126
+ map2_name = os.path.basename(map2_path)
127
+ pair_name = "{}_{}".format(map1_name, map2_name)
128
+ output_file = os.path.join(output_path, pair_name + "_cc.json")
129
+ data = {
130
+ "map_map_cc": {
131
+ pair_name: {
132
+ "names": [map1_name, map2_name],
133
+ "value": correlation,
134
+ }
135
+ }
136
+ }
137
+ with open(output_file, "w", encoding="utf-8") as handle:
138
+ json.dump(data, handle, indent=2)
139
+ return output_file
@@ -89,7 +89,7 @@ def relion_mask(raw_map, out_dir, mapname=None):
89
89
  print(f'Relion mask command: {relion_mask_cmd}')
90
90
  # Produce my own mask to compare with relion mask and time
91
91
  try:
92
- ownmask_loose = os.path.join(out_dir, f'{mapname}_ownmask.mrc')
92
+ ownmask_loose = os.path.join(out_dir, f'{mapname}_mask.mrc')
93
93
  relion_auto_mask(original_input_mrc, ownmask_loose, float(max_val_thirty), dilatepx, softpx)
94
94
  print(f'Relion auto mask command: {relion_auto_mask.__name__}')
95
95
  except Exception as e:
@@ -97,7 +97,7 @@ def relion_mask(raw_map, out_dir, mapname=None):
97
97
  ownmask_loose = None
98
98
 
99
99
  if angpix and max_val_thirty and dilatepx and softpx and input_mrc:
100
- subprocess.run(relion_mask_cmd, shell=True)
100
+ # subprocess.run(relion_mask_cmd, shell=True)
101
101
  if not MapProcessor.check_map_starts(mask_loose, original_input_mrc):
102
102
  print('Relion mask does not have the same nstarts as the original map.')
103
103
  MapProcessor.update_map_starts(original_input_mrc, mask_loose)
@@ -221,7 +221,7 @@ def relion_auto_mask_fast(data, threshold, extend_pixels, edge_width, verbose=Tr
221
221
  steps = []
222
222
  if verbose:
223
223
  steps = tqdm(total=3, desc="Masking Steps", unit="step")
224
-
224
+
225
225
  # Step 1: Initial binary mask
226
226
  mask = (data >= threshold).astype(np.float32)
227
227
  if verbose:
@@ -910,7 +910,7 @@ class PreParation:
910
910
  'volume': False, 'fsc': False, 'raps': False, 'mapmodel': False, 'inclusion': False,
911
911
  'largestvariance': False, 'mask': False, 'symmetry': False, 'rmmcc': False, 'smoc': False,
912
912
  'resccc': False, 'emringer': False, 'strudel': False, '3dfsc': False, 'locres': False,
913
- 'phrand': False, 'predictcontour': False}
913
+ 'phrand': False, 'predictcontour': False, 'mapmapcc': False}
914
914
  for key in resdict.keys():
915
915
  if key in runs:
916
916
  resdict[key] = True
@@ -924,7 +924,7 @@ class PreParation:
924
924
  if self.mapname is not None:
925
925
  runlist.extend(['projection', 'central', 'surface', 'volume', 'density', 'raps', 'largestvariance',
926
926
  'mask', 'fsc', 'mmfsc', 'rmmcc', 'symmetry', 'qscore', 'strudel', 'emringer', '3dfsc',
927
- 'smoc', 'resccc', 'locres', 'phrand', 'predictcontour',
927
+ 'smoc', 'resccc', 'locres', 'phrand', 'predictcontour', 'mapmapcc',
928
928
  ])
929
929
 
930
930
  if self.masks is None: