Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions python/BioSimSpace/FreeEnergy/_relative.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,15 +1064,16 @@ def _somd2_extract(parquet_file, T=None, estimator="MBAR"):
lam = float(metadata["lambda"])
except:
raise ValueError("Parquet metadata does not contain 'lambda'.")
try:
lambda_array = metadata["lambda_array"]
except:
raise ValueError("Parquet metadata does not contain 'lambda array'")
if not is_mbar:
try:
lambda_grad = metadata["lambda_grad"]
except:
raise ValueError("Parquet metadata does not contain 'lambda grad'")
else:
try:
lambda_grad = metadata["lambda_grad"]
except:
lambda_grad = []

# Make sure that the temperature is correct.
if not T == temperature:
Expand All @@ -1085,8 +1086,8 @@ def _somd2_extract(parquet_file, T=None, estimator="MBAR"):
df = table.to_pandas()

if is_mbar:
# Extract the columns correspodning to the lambda array.
df = df[[x for x in lambda_array]]
# Extract all columns other than those used for the gradient.
df = df[[x for x in df.columns if x not in lambda_grad]]

# Subtract the potential at the simulated lambda.
df = df.subtract(df[lam], axis=0)
Expand Down Expand Up @@ -1311,10 +1312,21 @@ def _analyse_internal(files, temperatures, lambdas, engine, estimator, **kwargs)

# Preprocess the data.
try:
processed_data = Relative._preprocess_data(data, estimator, **kwargs)
processed_data = _alchemlyb.concat(processed_data)
except:
_warnings.warn("Could not preprocess the data!")
preprocess = kwargs.pop("preprocess", True)
except KeyError:
preprocess = True

if not isinstance(preprocess, bool):
raise TypeError("'preprocess' must be of type 'bool'.")

if preprocess:
try:
processed_data = Relative._preprocess_data(data, estimator, **kwargs)
processed_data = _alchemlyb.concat(processed_data)
except:
_warnings.warn("Could not preprocess the data!")
processed_data = _alchemlyb.concat(data)
else:
processed_data = _alchemlyb.concat(data)

mbar_method = None
Expand Down
Loading