multixem 0.3.2__tar.gz → 0.3.3__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.
@@ -1,4 +1,6 @@
1
1
  include multixem/data/*.json
2
+ include multixem/scripts/*.py
3
+
2
4
  prune dist
3
5
  prune build
4
6
  prune __venv__
@@ -11,7 +13,6 @@ prune docs_backup
11
13
  prune scripts_backup
12
14
  prune multixem_tmp
13
15
  prune multixem_*
14
- prune multixem/scripts
15
16
  prune multixem/prototypes
16
17
 
17
18
  global-exclude *.py[cod]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multixem
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Refinement pipeline for multiple data sets in structure biology
5
5
  Author-email: Martin Maly <martin.maly.mm@email.cz>
6
6
  License: MIT
@@ -3,4 +3,4 @@
3
3
 
4
4
  Refinement pipeline for multiple data sets in structure biology
5
5
  """
6
- __version__ = "0.3.2"
6
+ __version__ = "0.3.3"
@@ -0,0 +1,62 @@
1
+ import gemmi
2
+ import numpy
3
+ from pprint import pprint
4
+ import json
5
+ from collections import OrderedDict
6
+
7
+
8
+ def get_Rrot_sum_eigen():
9
+ """
10
+ Compute the sum of rotation symmetry operation matrices and its
11
+ eigen decomposition for the highest-numbered space group in each point group.
12
+ Save results to Rrot_sum_eigen.json.
13
+ """
14
+ # Find the highest space group per point group
15
+ point_group_to_sg = {}
16
+ # Iterate over all 230 space groups
17
+ for sg in gemmi.spacegroup_table():
18
+ pg = sg.point_group_hm()
19
+ # Keep the space group with the highest number per point group
20
+ if pg not in point_group_to_sg or sg.number > point_group_to_sg[pg].number:
21
+ point_group_to_sg[pg] = sg
22
+
23
+ print("Point groups:", list(point_group_to_sg.keys()))
24
+
25
+ point_group_results = OrderedDict({})
26
+ # Iterate over the selected space groups, one each for a point group
27
+ for pg, sg in point_group_to_sg.items():
28
+ ops = sg.operations()
29
+ # Keep rotation matrices as integers to avoid numerical artifacts
30
+ rots = [numpy.array(op.rot, dtype=int) for op in ops.sym_ops]
31
+ Rsum = numpy.array(numpy.sum(rots, axis=0) / 24, dtype=int)
32
+ # Eigen decomposition
33
+ eigvals, eigvecs = numpy.linalg.eig(Rsum)
34
+ eigvals_all = numpy.round(eigvals).astype(int)
35
+ eigvecs_all = numpy.round(eigvecs).astype(int)
36
+ # Get eigenvalues and related eigenvectors that are truly non-zero
37
+ nonzero_idx = numpy.where(numpy.abs(eigvals) > 1e-12)[0]
38
+ subspace_dim = len(nonzero_idx)
39
+ eigvals_nonzero = numpy.round(eigvals[nonzero_idx]).astype(int)
40
+ eigvecs_nonzero = numpy.round(eigvecs[:, nonzero_idx]).astype(int).T
41
+ point_group_results[pg] = OrderedDict(
42
+ {
43
+ "space_group_highest": sg.hm,
44
+ "space_group_highest_number": sg.number,
45
+ "Rrot_sum": Rsum.tolist(),
46
+ "eigenindices_nonzero": nonzero_idx.tolist(),
47
+ "eigenvalues": eigvals_all.tolist(),
48
+ "eigenvectors": eigvecs_all.tolist(),
49
+ "subspace_dimension": subspace_dim,
50
+ "eigenvalues_nonzero": eigvals_nonzero.tolist(),
51
+ "eigenvectors_nonzero": eigvecs_nonzero.tolist(),
52
+ }
53
+ )
54
+
55
+ pprint(point_group_results)
56
+ with open("Rrot_sum_eigen.json", "w") as f:
57
+ json.dump(point_group_results, f, indent=2)
58
+ print("Rrot_sum_eigen.json written with results for each point group.")
59
+
60
+
61
+ if __name__ == "__main__":
62
+ get_Rrot_sum_eigen()
@@ -12,5 +12,6 @@ multixem/bootstrap_structures.py
12
12
  multixem/run.py
13
13
  multixem/tools.py
14
14
  multixem/data/Rrot_sum_eigen.json
15
+ multixem/scripts/Rrot_sum_eigen.py
15
16
  tests/test_argparse.py
16
17
  tests/test_integration.py
@@ -48,7 +48,7 @@ exclude = [
48
48
  ]
49
49
 
50
50
  [tool.setuptools.package-data]
51
- multixem = ["data/*.json"]
51
+ multixem = ["data/*.json", "scripts/*.py"]
52
52
 
53
53
  [build-system]
54
54
  requires = ["setuptools>=68", "wheel"]
File without changes
File without changes
File without changes
File without changes
File without changes