Skip to content

Commit

Permalink
Update to unit cell matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsbond committed Nov 28, 2024
1 parent 4dce7ed commit 9ab6f1d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org).

## [5.0.0] - Unreleased
## [5.0.1] - 2024-11-28

## Changed

- Gemmi fractionalization_matrix to frac.mat and orthogonalization_matrix to orth.mat.

## [5.0.0] - 2024-11-08

### Added

Expand Down
2 changes: 1 addition & 1 deletion modelcraft/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.0.0"
__version__ = "5.0.1"

from .cell import max_distortion as max_cell_distortion
from .cell import remove_scale
Expand Down
4 changes: 2 additions & 2 deletions modelcraft/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def remove_scale(structure: gemmi.Structure) -> None:

def max_distortion(old_cell: gemmi.UnitCell, new_cell: gemmi.UnitCell) -> float:
"Return the maximum distortion between two cells as a fraction"
frac1 = old_cell.fractionalization_matrix
orth2 = new_cell.orthogonalization_matrix
frac1 = old_cell.frac.mat
orth2 = new_cell.orth.mat
identity = gemmi.Mat33()
matrix = np.array(identity) - np.array(orth2.multiply(frac1))
eigenvalues, _ = scipy.linalg.eig(matrix)
Expand Down
4 changes: 2 additions & 2 deletions modelcraft/tests/ccp4/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def test_1ana():
urllib.request.urlretrieve(url, "1ana.cif.gz")
structure = read_structure("1ana.cif.gz")
assert structure.cell.parameters == (41.1, 41.1, 26.7, 90, 90, 90)
assert structure.cell.fractionalization_matrix.tolist()[0][0] == 0
assert structure.cell.frac.mat.tolist()[0][0] == 0
remove_scale(structure)
assert structure.cell.fractionalization_matrix.tolist()[0][0] != 0
assert structure.cell.frac.mat.tolist()[0][0] != 0
new_parameters = (41, 41, 27, 90, 90, 90)
new_cell = gemmi.UnitCell(*new_parameters)
assert max_distortion(structure.cell, new_cell) < 0.05
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
gemmi >=0.5.4
gemmi >=0.5.5
numpy
pandas
requests
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="modelcraft",
version="5.0.0",
version="5.0.1",
author="Paul Bond",
author_email="[email protected]",
description="Automated model building pipeline for X-ray crystallography",
Expand All @@ -26,7 +26,7 @@
],
python_requires="~=3.7",
install_requires=[
"gemmi >=0.5.4",
"gemmi >=0.5.5",
"numpy",
"pandas",
"requests",
Expand Down

0 comments on commit 9ab6f1d

Please sign in to comment.