Skip to content

Commit bcbdb24

Browse files
authored
Merge pull request #107 from CCPBioSim/104-integrating-waterentropy
Integration of `waterEntropy` into `CodeEntropy`
2 parents d4fae5f + e235cf3 commit bcbdb24

File tree

7 files changed

+421
-99
lines changed

7 files changed

+421
-99
lines changed

CodeEntropy/config/arg_config_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
"force_partitioning": {"type": float, "help": "Force partitioning", "default": 0.5},
6262
"water_entropy": {
6363
"type": bool,
64-
"help": "Calculate water entropy",
65-
"default": False,
64+
"help": "If set to False, disables the calculation of water entropy",
65+
"default": True,
6666
},
6767
}
6868

CodeEntropy/config/data_logger.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import re
34

45
from tabulate import tabulate
56

@@ -23,13 +24,19 @@ def save_dataframes_as_json(self, molecule_df, residue_df, output_file):
2324
with open(output_file, "w") as out:
2425
json.dump(data, out, indent=4)
2526

26-
def add_results_data(self, molecule, level, type, S_molecule):
27+
def clean_residue_name(self, resname):
28+
"""Ensures residue names are stripped and cleaned before being stored"""
29+
return re.sub(r"[-–—]", "", str(resname))
30+
31+
def add_results_data(self, resname, level, entropy_type, value):
2732
"""Add data for molecule-level entries"""
28-
self.molecule_data.append([molecule, level, type, f"{S_molecule}"])
33+
resname = self.clean_residue_name(resname)
34+
self.molecule_data.append((resname, level, entropy_type, value))
2935

30-
def add_residue_data(self, molecule, residue, type, S_trans_residue):
36+
def add_residue_data(self, resid, resname, level, entropy_type, value):
3137
"""Add data for residue-level entries"""
32-
self.residue_data.append([molecule, residue, type, f"{S_trans_residue}"])
38+
resname = self.clean_residue_name(resname)
39+
self.residue_data.append([resid, resname, level, entropy_type, value])
3340

3441
def log_tables(self):
3542
"""Log both tables at once"""
@@ -38,8 +45,10 @@ def log_tables(self):
3845
logger.info("Molecule Data Table:")
3946
table_str = tabulate(
4047
self.molecule_data,
41-
headers=["Molecule ID", "Level", "Type", "Result (J/mol/K)"],
48+
headers=["Residue Name", "Level", "Type", "Result (J/mol/K)"],
4249
tablefmt="grid",
50+
numalign="center",
51+
stralign="center",
4352
)
4453
logger.info(f"\n{table_str}")
4554

@@ -48,7 +57,15 @@ def log_tables(self):
4857
logger.info("Residue Data Table:")
4958
table_str = tabulate(
5059
self.residue_data,
51-
headers=["Molecule ID", "Residue", "Type", "Result (J/mol/K)"],
60+
headers=[
61+
"Residue ID",
62+
"Residue Name",
63+
"Level",
64+
"Type",
65+
"Result (J/mol/K)",
66+
],
5267
tablefmt="grid",
68+
numalign="center",
69+
stralign="center",
5370
)
5471
logger.info(f"\n{table_str}")

0 commit comments

Comments
 (0)