Skip to content

Commit 88b02bc

Browse files
committed
Merge branch 'feature_focused_sampling' into feature_ff19sb
2 parents eb9ff4a + 10187b3 commit 88b02bc

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

python/BioSimSpace/FreeEnergy/_relative.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,15 +1064,16 @@ def _somd2_extract(parquet_file, T=None, estimator="MBAR"):
10641064
lam = float(metadata["lambda"])
10651065
except:
10661066
raise ValueError("Parquet metadata does not contain 'lambda'.")
1067-
try:
1068-
lambda_array = metadata["lambda_array"]
1069-
except:
1070-
raise ValueError("Parquet metadata does not contain 'lambda array'")
10711067
if not is_mbar:
10721068
try:
10731069
lambda_grad = metadata["lambda_grad"]
10741070
except:
10751071
raise ValueError("Parquet metadata does not contain 'lambda grad'")
1072+
else:
1073+
try:
1074+
lambda_grad = metadata["lambda_grad"]
1075+
except:
1076+
lambda_grad = []
10761077

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

10871088
if is_mbar:
1088-
# Extract the columns corresponding to the lambda array.
1089-
df = df[[x for x in lambda_array]]
1089+
# Extract all columns other than those used for the gradient.
1090+
df = df[[x for x in df.columns if x not in lambda_grad]]
10901091

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

13121313
# Preprocess the data.
13131314
try:
1314-
processed_data = Relative._preprocess_data(data, estimator, **kwargs)
1315-
processed_data = _alchemlyb.concat(processed_data)
1316-
except:
1317-
_warnings.warn("Could not preprocess the data!")
1315+
preprocess = kwargs.pop("preprocess", True)
1316+
except KeyError:
1317+
preprocess = True
1318+
1319+
if not isinstance(preprocess, bool):
1320+
raise TypeError("'preprocess' must be of type 'bool'.")
1321+
1322+
if preprocess:
1323+
try:
1324+
processed_data = Relative._preprocess_data(data, estimator, **kwargs)
1325+
processed_data = _alchemlyb.concat(processed_data)
1326+
except:
1327+
_warnings.warn("Could not preprocess the data!")
1328+
processed_data = _alchemlyb.concat(data)
1329+
else:
13181330
processed_data = _alchemlyb.concat(data)
13191331

13201332
mbar_method = None

0 commit comments

Comments
 (0)