Skip to content

Commit 59a19aa

Browse files
committed
Refactoring parameter names
1 parent 7e40074 commit 59a19aa

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

domhmm/analysis/base.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ class LeafletAnalysisBase(AnalysisBase):
6060
fraction of box length in x and y outside the unit cell considered for Voronoi calculation
6161
p_value: float
6262
p_value for z_score calculation
63-
leaflet_frame_rate: Union[None, int]
63+
lipid_leaflet_rate: Union[None, int]
6464
Frame rate for checking lipids leaflet assignments via LeafletFinder
65-
sterol_frame_rate: int
65+
sterol_leaflet_rate: int
6666
Frame rate for checking sterols leaflet assignments via LeafletFinder
6767
asymmetric_membrane: bool
6868
Asymmetric membrane option to train models by separated data w.r.t. leaflets
@@ -76,6 +76,8 @@ class LeafletAnalysisBase(AnalysisBase):
7676
User-specific HMM (e.g., pre-trained on another simulation)
7777
do_clustering: bool
7878
Perform the hierarchical clustering for each frame
79+
n_init_hmm: int
80+
Number of repeats for HMM model trainings
7981
8082
Attributes
8183
----------
@@ -117,15 +119,15 @@ def __init__(
117119
tmd_protein_list: Union[None, "AtomGroup", str, list] = None,
118120
frac: float = 0.5,
119121
p_value: float = 0.05,
120-
leaflet_frame_rate: Union[None, int] = None,
121-
sterol_frame_rate: int = 1,
122+
lipid_leaflet_rate: Union[None, int] = None,
123+
sterol_leaflet_rate: int = 1,
122124
asymmetric_membrane: bool = False,
123125
verbose: bool = False,
124126
result_plots: bool = False,
125127
trained_hmms: Dict[str, Any] = {},
126128
n_init_hmm: int = 2,
127129
save_plots: bool = False,
128-
do_clustering = True,
130+
do_clustering: bool = True,
129131
**kwargs
130132
):
131133
# the below line must be kept to initialize the AnalysisBase class!
@@ -145,8 +147,8 @@ def __init__(
145147
self.tails = tails
146148
self.sterol_heads = sterol_heads
147149
self.sterol_tails = sterol_tails
148-
self.leaflet_frame_rate = leaflet_frame_rate
149-
self.sterol_frame_rate = sterol_frame_rate
150+
self.lipid_leaflet_rate = lipid_leaflet_rate
151+
self.sterol_leaflet_rate = sterol_leaflet_rate
150152
self.frac = frac
151153
self.p_value = p_value
152154
self.asymmetric_membrane = asymmetric_membrane
@@ -244,8 +246,9 @@ def __init__(
244246
"where 0 for lower leaflet and 1 for upper leaflet.")
245247
for leaflet, query in each.items():
246248
if leaflet not in ["0", "1"]:
247-
raise ValueError("Entry for each TDM protein should be a dictionary in the format {'0': ..., '1': ...} "
248-
"where 0 for lower leaflet and 1 for upper leaflet.")
249+
raise ValueError(
250+
"Entry for each TDM protein should be a dictionary in the format {'0': ..., '1': ...} "
251+
"where 0 for lower leaflet and 1 for upper leaflet.")
249252
if isinstance(query, AtomGroup):
250253
# Take center of geometry of three positions
251254
cog = np.mean(query.positions, axis=0)
@@ -260,15 +263,17 @@ def __init__(
260263
except Exception as e:
261264
raise ValueError("Please provide a valid MDAnalysis selection string!") from e
262265
else:
263-
raise ValueError("TDM Protein list should contain AtomGroup from MDAnalysis universe or a string "
264-
"query for MDAnalysis selection.")
266+
raise ValueError(
267+
"TDM Protein list should contain AtomGroup from MDAnalysis universe or a string "
268+
"query for MDAnalysis selection.")
265269
self.tmd_protein["0"] = np.array(self.tmd_protein["0"])
266270
self.tmd_protein["1"] = np.array(self.tmd_protein["1"])
267271
elif tmd_protein_list is not None:
268272
# An unknown argument is provided for tdm_protein_list
269273
raise ValueError(
270274
"Please provide tdm_protein_list in list format such as [{'0': upper leaflet related 3 atom, "
271-
"'1': lower leaflet related 3 atom }, {'0': ..., '1': ...}]. Every dictionary stands for an individual transmembrane protein.")
275+
"'1': lower leaflet related 3 atom }, {'0': ..., '1': ...}]. Every dictionary stands for an "
276+
"individual transmembrane protein.")
272277
# -----------------------------------------------------------------HMMs--------------------------------------- #
273278

274279
# Check for user-specified trained HMM

domhmm/analysis/domhmm.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,15 @@ def _single_frame(self):
273273
self.index = ( self.frame - self.start ) // self.step
274274

275275
# Update leaflet assignment (if leaflet_frame_rate is None, leaflets will never get updated during analysis)
276-
if self.leaflet_frame_rate is not None and not self.index % self.leaflet_frame_rate:
276+
if self.lipid_leaflet_rate is not None and not self.index % self.lipid_leaflet_rate:
277277
# Call leaflet assignment functions for non-sterol and sterol compounds
278278
self.leaflet_selection_no_sterol = self.get_leaflets()
279279
self.leaflet_selection = self.get_leaflets_sterol()
280280

281281
# Write assignments to array
282-
assignment_index = int(self.index / self.leaflet_frame_rate)
283-
start_index = assignment_index * self.leaflet_frame_rate
284-
end_index = (assignment_index + 1) * self.leaflet_frame_rate
282+
assignment_index = int(self.index / self.lipid_leaflet_rate)
283+
start_index = assignment_index * self.lipid_leaflet_rate
284+
end_index = (assignment_index + 1) * self.lipid_leaflet_rate
285285
if end_index > self.leaflet_assignment.shape[1]:
286286
end_index = self.leaflet_assignment.shape[1]
287287

@@ -293,15 +293,15 @@ def _single_frame(self):
293293
self.leaflet_assignment[self.lidx, start_index:end_index] = 1
294294

295295
# Update sterol assignment. Don't do the update if it was already done in the if-statement before
296-
if not self.index % self.sterol_frame_rate and (
297-
self.leaflet_frame_rate is None or self.index % self.leaflet_frame_rate):
296+
if not self.index % self.sterol_leaflet_rate and (
297+
self.lipid_leaflet_rate is None or self.index % self.lipid_leaflet_rate):
298298
# Call leaflet assignment function for sterol compounds
299299
self.leaflet_selection = self.get_leaflets_sterol()
300300

301301
# Write assignments to array
302-
assignment_index = int(self.index / self.sterol_frame_rate)
303-
start_index = assignment_index * self.sterol_frame_rate
304-
end_index = (assignment_index + 1) * self.sterol_frame_rate
302+
assignment_index = int(self.index / self.sterol_leaflet_rate)
303+
start_index = assignment_index * self.sterol_leaflet_rate
304+
end_index = (assignment_index + 1) * self.sterol_leaflet_rate
305305
if end_index > self.leaflet_assignment.shape[1]:
306306
end_index = self.leaflet_assignment.shape[1]
307307

domhmm/tests/test_domhmm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def analysis_reuse_hmm_model(self, universe):
7676
sterol_tails=sterol_tails,
7777
tails=tails,
7878
tmd_protein_list=mock_tmd_protein_list,
79-
leaflet_frame_rate=2,
79+
lipid_leaflet_rate=2,
8080
result_plots=True,
8181
save_plots=True,
8282
trained_hmms=trained_hmm)

0 commit comments

Comments
 (0)