File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
openmmdl/openmmdl_simulation/scripts Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,16 @@ def _has_pbc(ts):
104104 dims = np .asarray (dims [:3 ], dtype = float )
105105 return np .all (np .isfinite (dims )) and np .all (dims > 0.0 )
106106
107+ def _can_unwrap (ag ):
108+ """unwrap() needs fragments -> fragments needs bonds."""
109+ if ag .n_atoms == 0 :
110+ return False
111+ try :
112+ _ = ag .fragments # triggers NoDataError if no bonds
113+ return True
114+ except Exception :
115+ return False
116+
107117 def reimage_to_reference (mobile_ag , ref_ag ):
108118 """
109119 Translate mobile_ag so its COM is minimum-image to ref_ag COM.
@@ -185,12 +195,14 @@ def _apply_pre_alignment_transforms(u):
185195
186196 # Make protein whole, keep chains together
187197 if protein .n_atoms :
188- transforms .append (trans .unwrap (protein ))
198+ if _can_unwrap (protein ):
199+ transforms .append (trans .unwrap (protein ))
189200 transforms .append (reimage_segments_to_reference (protein ))
190201
191202 # Keep ligand in same protein image
192203 if lig .n_atoms and protein .n_atoms :
193- transforms .append (trans .unwrap (lig ))
204+ if _can_unwrap (lig ):
205+ transforms .append (trans .unwrap (lig ))
194206 transforms .append (reimage_to_reference (lig , protein ))
195207
196208 # Keep lipids around protein image (optional)
You can’t perform that action at this time.
0 commit comments