Skip to content

Commit e57be2a

Browse files
authored
fix: ensure that the Index condition's default annotation respects its mask (#50)
* fix: ensure that the Index condition's default annotation respects its mask * fix: bugfix * fix: switch to using -1 for masked indices, and add a class attribute for this value --------- Co-authored-by: Rafi Brent <rafi.brent@gmail.com>
1 parent 554ec22 commit e57be2a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/atomworks/ml/conditions/conditions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Index(ConditionBase):
6666
n_body = 1
6767
level = Level.RESIDUE
6868
dtype = int
69+
MASKED_INDEX = -1
6970

7071
@classmethod
7172
def default_mask(cls, atom_array: AtomArray) -> np.ndarray:
@@ -74,7 +75,12 @@ def default_mask(cls, atom_array: AtomArray) -> np.ndarray:
7475
@classmethod
7576
def default_annotation(cls, atom_array: AtomArray) -> np.ndarray:
7677
ensure_annotations(atom_array, "within_chain_res_idx")
77-
return atom_array.get_annotation("within_chain_res_idx")
78+
indices = atom_array.get_annotation("within_chain_res_idx").copy()
79+
if cls.mask_name in atom_array.get_annotation_categories():
80+
# ... if mask exists, use it to get the indices
81+
mask = cls.mask(atom_array, default="raise")
82+
indices[~mask] = cls.MASKED_INDEX
83+
return indices
7884

7985

8086
class Distance(ConditionBase):

0 commit comments

Comments
 (0)