Skip to content

Commit

Permalink
propagate anisous to other objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Nov 3, 2023
1 parent 476e178 commit 7ee0ed1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
21 changes: 21 additions & 0 deletions prody/atomic/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ def setCoords(self, coords):
self._ag._coords[acsi, self._index] = coords
self._ag._setTimeStamp(acsi)

def getAnisou(self):
"""Returns a copy of anisou of the atom from the active coordinate
set."""

if self._ag._anisous is not None:
return self._ag._anisous[self.getACSIndex(), self._index].copy()

def _getAnisou(self):
"""Returns a view of anisou of the atom from the active coordinate
set."""

if self._ag._anisous is not None:
return self._ag._anisous[self.getACSIndex(), self._index]

def setAnisou(self, anisou):
"""Set anisou of the atom in the active coordinate set."""

acsi = self.getACSIndex()
self._ag._anisous[acsi, self._index] = anisou
self._ag._setTimeStamp(acsi)

def getCoordsets(self, indices=None):
"""Returns a copy of coordinate set(s) at given *indices*."""

Expand Down
4 changes: 2 additions & 2 deletions prody/atomic/atomgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,8 @@ def setAnisous(self, anisous, label=''):
try:
checkAnisous(anisous, csets=True, dtype=(float, np.float32))
except TypeError:
raise TypeError('coords must be a numpy array or an '
'object with `getCoords` method')
raise TypeError('anisous must be a numpy array or an '
'object with `getAnisous` method')

self._setAnisous(anisous, label=label)

Expand Down
2 changes: 0 additions & 2 deletions prody/atomic/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ def getDocstr(self, meth, plural=True, selex=True):
'altloc': Field('altloc', DTYPE + '1',
doc='alternate location indicator',
selstr=('altloc A B', 'altloc _'),),
'anisou': Field('anisou', float, doc='anisotropic temperature factor',
ndim=2),
'chain': Field('chain', DTYPE + '6', doc='chain identifier',
meth='Chid', none=HVNONE, synonym='chid',
selstr=('chain A', 'chid A B C', 'chain _')),
Expand Down
7 changes: 7 additions & 0 deletions prody/atomic/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -2424,3 +2424,10 @@ def _getCoords(self):
if self._coords is None:
self._coords = self._atoms._getCoords()
return self._coords

def _getAnisous(self):
"""Returns anisous of atoms."""

if self._anisous is None:
self._anisous = self._atoms._getAnisous()
return self._anisous
16 changes: 16 additions & 0 deletions prody/atomic/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,29 @@ def getCoords(self):

_getCoords = getCoords

def getAnisous(self):
"""Returns a copy of anisous from the active coordinate set."""

if self._ag._anisous is not None:
# Since this is not slicing, a view is not returned
return self._ag._anisous[self.getACSIndex(), self._indices]

_getAnisous = getAnisous

def setCoords(self, coords):
"""Set coordinates in the active coordinate set."""

if self._ag._coords is not None:
self._ag._coords[self.getACSIndex(), self._indices] = coords
self._ag._setTimeStamp(self.getACSIndex())

def setAnisous(self, anisous):
"""Set anisous in the active coordinate set."""

if self._ag._anisous is not None:
self._ag._anisous[self.getACSIndex(), self._indices] = anisous
self._ag._setTimeStamp(self.getACSIndex())

def getCoordsets(self, indices=None):
"""Returns coordinate set(s) at given *indices*, which may be an integer
or a list/array of integers."""
Expand Down

0 comments on commit 7ee0ed1

Please sign in to comment.