1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.ui;
39
40 import ffx.potential.MolecularAssembly;
41 import ffx.potential.bonded.Atom;
42 import ffx.utilities.Keyword;
43 import java.io.File;
44 import java.io.Serial;
45 import java.util.Hashtable;
46 import org.apache.commons.configuration2.CompositeConfiguration;
47 import org.apache.commons.io.FilenameUtils;
48
49
50
51
52
53
54 public class FFXSystem extends MolecularAssembly {
55
56 @Serial
57 private static final long serialVersionUID = 1L;
58
59
60 public static final int MultiScaleLevel = 4;
61
62 private File logFile;
63
64 private File keyFile;
65 private Hashtable<String, Keyword> keywords = new Hashtable<String, Keyword>();
66 private final CompositeConfiguration properties;
67 private String commandDescription;
68
69 private Trajectory trajectory = null;
70
71 private boolean closing = false;
72
73
74
75
76
77
78
79
80 public FFXSystem(File file, String description, CompositeConfiguration properties) {
81 super(FilenameUtils.getBaseName(file.getName()));
82 setFile(file);
83 commandDescription = description;
84 this.properties = properties;
85 }
86
87
88
89
90
91
92 public void addKeyword(Keyword k) {
93 if (keywords.containsKey(k.getKeyword())) {
94 return;
95 }
96 keywords.put(k.getKeyword(), k);
97 }
98
99
100 @Override
101 public boolean destroy() {
102 setClosing(true);
103 return super.destroy();
104 }
105
106
107
108
109
110
111 public File getKeyFile() {
112 return keyFile;
113 }
114
115
116
117
118
119
120 public void setKeyFile(File f) {
121 keyFile = f;
122 }
123
124
125
126
127
128
129
130 public Keyword getKeyword(String k) {
131 return keywords.get(k);
132 }
133
134
135
136
137
138
139 public Hashtable<String, Keyword> getKeywords() {
140 return keywords;
141 }
142
143
144
145
146
147
148 public void setKeywords(Hashtable<String, Keyword> k) {
149 keywords = k;
150 }
151
152
153
154
155
156
157 public File getLogFile() {
158 if (logFile == null) {
159 if (getFile() == null) {
160 return null;
161 }
162 String fileName = getFile().getName();
163 int dot = fileName.lastIndexOf(".");
164 fileName = fileName.subSequence(0, dot) + ".log";
165 logFile = new File(fileName);
166 }
167 return logFile;
168 }
169
170
171
172
173
174
175 public void setLogFile(File f) {
176 logFile = f;
177 }
178
179
180
181
182
183
184 @Override
185 public CompositeConfiguration getProperties() {
186 return properties;
187 }
188
189
190
191
192
193
194 public Trajectory getTrajectory() {
195 return trajectory;
196 }
197
198
199
200
201
202
203 public void setTrajectory(Trajectory t) {
204 trajectory = t;
205 }
206
207
208
209
210
211
212 public boolean isClosing() {
213 return closing;
214 }
215
216
217
218
219
220
221 public void setClosing(boolean b) {
222 closing = b;
223 }
224
225
226
227
228
229
230 public boolean isStale() {
231 for (Atom a : getAtomList()) {
232 if (a.isStale()) {
233 return true;
234 }
235 }
236 return false;
237 }
238
239
240
241
242
243
244 public void removeKeyword(Keyword kd) {
245 if (keywords.containsKey(kd.getKeyword())) {
246 keywords.remove(kd.getKeyword());
247 }
248 }
249
250
251
252
253
254
255 public void setCommandDescription(String command) {
256 commandDescription = command;
257 }
258
259
260
261
262
263
264 public String toFFString() {
265 StringBuilder sb = new StringBuilder(toString());
266 if (forceField != null) {
267 String ff = forceField.toString("forcefield");
268 if (ff != null) {
269 ff = ff.substring(10).trim();
270 sb.append(" (");
271 sb.append(ff);
272 sb.append(")");
273 }
274 }
275 return sb.toString();
276 }
277
278
279
280
281
282
283 public String toFileString() {
284 if (getFile() == null) {
285 return toFFString();
286 }
287 StringBuilder sb = new StringBuilder(getFile().getAbsolutePath());
288 if (forceField != null) {
289 String ff = forceField.toString("forcefield");
290 if (ff != null) {
291 ff = ff.substring(10).trim();
292 sb.append(" (");
293 sb.append(ff);
294 sb.append(")");
295 }
296 }
297 return sb.toString();
298 }
299
300
301 @Override
302 public String toString() {
303 if (getFile() != null) {
304 if (commandDescription != null) {
305 return getFile().getName() + " (" + commandDescription + ")";
306 }
307 return getFile().getName();
308 }
309 if (getName() != null) {
310 if (commandDescription != null) {
311 return getName() + commandDescription;
312 }
313 return getName();
314 }
315 return "FFX System";
316 }
317 }