Skip to content

Commit

Permalink
Fix attribute referencing for conformational ensemble
Browse files Browse the repository at this point in the history
  • Loading branch information
smcolby committed Jan 24, 2025
1 parent 2f9429e commit e29779b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
19 changes: 7 additions & 12 deletions isicle/conformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,10 @@ def _check_attributes(self, attr):
If all members do not have `attr`.
'''

value = [x.get___dict__() for x in self]
for key in safelist(attr):
if not all(key in x for x in value):
raise AttributeError('"{}" not found for all conformational '
'ensemble members.'.format(attr))
value = [x.get(key) for x in value]

if not all(hasattr(x, attr) for x in self):
raise AttributeError('"{}" not found for all conformational '
'ensemble members.'.format(attr))

def reduce(self, attr, func='boltzmann', **kwargs):
'''
Expand Down Expand Up @@ -438,9 +435,7 @@ def reduce(self, attr, func='boltzmann', **kwargs):
self._check_attributes('energy')

# Extract (possibly nested) value attribute
value = [x.get___dict__() for x in self]
for key in safelist(attr):
value = [x.get(key) for x in value]
value = [getattr(x, attr) for x in self]

# Check nested values
if isinstance(value[0], dict):
Expand All @@ -463,7 +458,7 @@ def reduce(self, attr, func='boltzmann', **kwargs):
value = np.array([x['mean'] for x in value]).flatten()

else:
value = np.array([x[attr] for x in value]).flatten()
value = np.array([getattr(x, attr) for x in value]).flatten()

# Not nested
else:
Expand All @@ -474,7 +469,7 @@ def reduce(self, attr, func='boltzmann', **kwargs):
# Extract energy attribute
if _energy_based(f):
energy = np.array(
[np.repeat(x.get___dict__()['energy'], pad) for x in self])
[np.repeat(getattr(x, 'energy'), pad) for x in self])
energy = energy.flatten()

# Exectue energy-based method
Expand Down
15 changes: 0 additions & 15 deletions isicle/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Geometry(GeometryInterface):
"_connectivity",
"_formal_charge",
"_ccs",
"_ccs_std"
]
_default_value = None

Expand Down Expand Up @@ -171,20 +170,6 @@ def ccs(self):

return self._ccs

@property
def ccs_std(self):
"""
Get standard deviation of CCS prediction of the molecule.
Returns
-------
float
Standard deviation of collision cross section.
"""

return self._ccs_std

def view(self):
"""
View internal rdkit mol object representation.
Expand Down
3 changes: 1 addition & 2 deletions isicle/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,7 @@ def parse(self):
elif "standard deviation (percent)" in line:
done = True
if done is True:
self.result["ccs"] = ccs_mn
self.result["ccs_std"] = ccs_std
self.result["ccs"] = {"mean": ccs_mn, "std": ccs_std}

self.result["geometry"] = self.data["geometry"]

Expand Down

0 comments on commit e29779b

Please sign in to comment.