Skip to content

ENM Base class#22

Open
stratixs wants to merge 63 commits into
biotite-dev:masterfrom
stratixs:base-class
Open

ENM Base class#22
stratixs wants to merge 63 commits into
biotite-dev:masterfrom
stratixs:base-class

Conversation

@stratixs

@stratixs stratixs commented Jun 8, 2026

Copy link
Copy Markdown

Logical changes

  • Adds a base class ENM that handles common logic across GNM and ANM (specifically constructor, covariance calculation, calls to NMA). The goal is to reduce code duplications.
  • The covariance is calculated with np.linalg.pinv. Internally this method uses np.linalg.eigh to calculate the eigenvalues/-vectors and constructs the pseudo-inverse using the reciprocal eigenvalues. This change makes this calculation explicitly and stores the eigenvalues/-vectors in the process so that they can be easily reused for NMA calculations without recalculation.
  • Instead of relying on fixed number of trivial nodes the number of zero eigenvalues can be centrally calculated and returned alongside when calling the ENM.eigen() function.
  • Optimize NMA calculations to reduce complexity for maintainers. These changes are also a result from the common attributes introduced by the ENM base class.

Bug fixes

  • Use direct evaluation of coord difference between atoms instead of calling struc.displacement as the latter one forces float32 precision but float64 is desired.

Housekeeping

  • Switches to hatch build system (the same as the biotite parent project)
  • Extends/corrects docstrings to adhere to numpydoc standard (uses the same numpydoc lint rules as the parent project)
  • Adds type information to attributes and return values so that users can utilize IDE's static analyzers when calling the functions
  • Switches from .pdb to .cif files for tests because RCSB will phase out the old format.
  • Boost test coverage from
Name                             Stmts   Miss Branch BrPart  Cover
------------------------------------------------------------------
src/springcraft/__init__.py          8      0      0      0   100%
src/springcraft/anm.py              79     18     24      4    73%
src/springcraft/forcefield.py      249     25     64     17    86%
src/springcraft/gnm.py              70     17     24      4    71%
src/springcraft/interaction.py      61      3     18      3    92%
src/springcraft/nma.py             151     44     58     10    66%
------------------------------------------------------------------
TOTAL                              618    107    188     38    78%

to

Name                             Stmts   Miss Branch BrPart  Cover
------------------------------------------------------------------
src/springcraft/__init__.py          8      0      0      0   100%
src/springcraft/anm.py              61      2      8      0    97%
src/springcraft/enm.py             112      5     28      2    95%
src/springcraft/forcefield.py      276     18     64     10    91%
src/springcraft/gnm.py              51      0      8      0   100%
src/springcraft/interaction.py      62      3     18      3    92%
src/springcraft/nma.py             109     35     42      7    62%
------------------------------------------------------------------
TOTAL                              679     63    168     22    88%

stratixs added 30 commits May 1, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant