Skip to content

Commit 45194e3

Browse files
authored
Merge pull request #466 from OpenBioSim/feature_refactor
Switch to new Sire API and refactor imports
2 parents 0850575 + 40ba29d commit 45194e3

File tree

219 files changed

+5144
-3257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+5144
-3257
lines changed

doc/source/tutorials/crystal_water.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Firstly, let's load the PDB structure:
2020
>>> import BioSimSpace as BSS
2121
>>> tyk2_xtal = BSS.IO.readMolecules(
2222
... BSS.IO.expand(
23-
... BSS.IO.tutorialUrl(), "tyk2_xtal.pdb"
23+
... BSS.tutorialUrl(), "tyk2_xtal.pdb"
2424
... )
2525
...)[0]
2626

doc/source/tutorials/molecular_editing.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ SireMol::AtomCharges( size=9
108108

109109
.. Note::
110110
To see the full list of properties available for a molecule, you can use the
111-
``propertyKeys()`` method on the underlying Sire molecule object, e.g.
112-
``ethanol._sire_object.propertyKeys()``.
111+
``property_keys()`` method on the underlying Sire molecule object, e.g.
112+
``ethanol._sire_object.property_keys()``.
113113

114114
Editing bonds
115115
-------------
@@ -122,7 +122,7 @@ constant for all existing bonds:
122122
>>> bonds = TwoAtomFunctions(ethanol._sire_object.info())
123123
>>> for bond in ethanol._sire_object.property("bond").potentials():
124124
... amber_bond = AmberBond(0, 0)
125-
... bonds.set(bond.atom0(), bond.atom1(), amber_bond.toExpression(Symbol("r")))
125+
... bonds.set(bond.atom0(), bond.atom1(), amber_bond.to_expression(Symbol("r")))
126126
>>> cursor = ethanol._sire_object.cursor()
127127
>>> cursor["bond"] = bonds
128128
>>> ethanol._sire_object = cursor.commit()
@@ -163,7 +163,7 @@ and modifying the desired angle:
163163
>>> for angle in ethanol._sire_object.property("angle").potentials():
164164
... if ethanol._sire_object.atom(angle.atom1()).name().value() == "O3":
165165
... amber_angle = AmberAngle(100, 1.5)
166-
... angles.set(angle.atom0(), angle.atom1(), angle.atom2(), amber_angle.toExpression(Symbol("theta")))
166+
... angles.set(angle.atom0(), angle.atom1(), angle.atom2(), amber_angle.to_expression(Symbol("theta")))
167167
... else:
168168
... angles.set(angle.atom0(), angle.atom1(), angle.atom2(), angle.function())
169169

@@ -247,7 +247,7 @@ A regular AMBER-style dihedral series where all terms have positive cosine facto
247247
>>> d = AmberDihedral(f, Phi)
248248
>>> print("AMBER:", d)
249249
AMBER: AmberDihedral( k[0] = 0.3, periodicity[0] = 1, phase[0] = 0, k[1] = 0.8, periodicity[1] = 4, phase[1] = 0 )
250-
>>> assert d.toExpression(Phi) == f
250+
>>> assert d.to_expression(Phi) == f
251251

252252
An AMBER-style dihedral containing positive and negative cosine factors, which
253253
can appear in the CHARMM force field:
@@ -256,7 +256,7 @@ can appear in the CHARMM force field:
256256
>>> d = AmberDihedral(f, Phi)
257257
>>> print("CHARMM:", d)
258258
CHARMM: AmberDihedral( k[0] = 0.3, periodicity[0] = 1, phase[0] = 0, k[1] = -0.8, periodicity[1] = 4, phase[1] = 0 )
259-
>>> assert d.toExpression(Phi) == f
259+
>>> assert d.to_expression(Phi) == f
260260

261261
An AMBER-style dihedral containing positive and negative cosine factors, with
262262
the negative of the form ``k [1 - Cos(Phi)]`` rather than ``-k [1 + Cos(Phi)]``.
@@ -269,7 +269,7 @@ GROMACS: AmberDihedral( k[0] = 0.3, periodicity[0] = 1, phase[0] = 0, k[1] = 0.8
269269
>>> from math import isclose
270270
>>> from sire.legacy.CAS import SymbolValue, Values
271271
>>> val = Values(SymbolValue(Phi.ID(), 2.0))
272-
>>> assert isclose(f.evaluate(val), d.toExpression(Phi).evaluate(val))
272+
>>> assert isclose(f.evaluate(val), d.to_expression(Phi).evaluate(val))
273273

274274
Finally, a three-term expression that mixes all formats:
275275

@@ -280,7 +280,7 @@ Finally, a three-term expression that mixes all formats:
280280
... + 0.8 * (1 - Cos(4 * Phi))
281281
... )
282282
>>> d = AmberDihedral(f, Phi)
283-
>>> assert isclose(f.evaluate(val), d.toExpression(Phi).evaluate(val))
283+
>>> assert isclose(f.evaluate(val), d.to_expression(Phi).evaluate(val))
284284

285285
.. Note::
286286
Impropers are also stored as ``FourAtomFunction`` objects, which can be
@@ -428,17 +428,17 @@ the editor, reparenting them to the appropriate chain, then adding the atoms:
428428
... cg = editor.add(sr.legacy.Mol.CGName(str(i)))
429429
... new_res = editor.add(res.number())
430430
... new_res.rename(res.name())
431-
... new_res.reparent(chain_ids[i // 3])
432-
... for j, atom in enumerate(res.atoms()):
431+
... new_res.reparent(sr.legacy.Mol.ChainName(chain_ids[i]))
432+
... for atom in res.atoms():
433433
... new_atom = cg.add(atom.number())
434434
... new_atom.rename(atom.name())
435435
... new_atom.reparent(res.index())
436436
... editor = editor.commit().edit()
437437

438438
Next we need to copy across the molecular properties, e.g. charges and bonded terms.
439439

440-
>>> for prop in ala._sire_object.propertKeys():
441-
... editor = editor.setProperty(prop, ala._sire_object.property(prop)).molecule()
440+
>>> for prop in ala._sire_object.property_keys():
441+
... editor = editor.set_property(prop, ala._sire_object.property(prop)).molecule()
442442

443443
Finally, we can commit the changes to create the new molecule:
444444

python/BioSimSpace/Align/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@
4040
viewMapping
4141
"""
4242

43+
import sire as _sr
44+
45+
_sr.use_new_api()
46+
del _sr
47+
4348
from ._align import *
49+
from . import _squash

0 commit comments

Comments
 (0)