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.algorithms.commands.test;
39
40 import ffx.algorithms.cli.AlgorithmsCommand;
41 import ffx.algorithms.cli.DynamicsOptions;
42 import ffx.algorithms.dynamics.MolecularDynamics;
43 import ffx.algorithms.dynamics.WeightedEnsembleManager;
44 import ffx.algorithms.dynamics.WeightedEnsembleManager.OneDimMetric;
45 import ffx.numerics.Potential;
46 import ffx.potential.MolecularAssembly;
47 import ffx.potential.cli.AtomSelectionOptions;
48 import ffx.potential.cli.WriteoutOptions;
49 import ffx.utilities.FFXBinding;
50 import picocli.CommandLine.Command;
51 import picocli.CommandLine.Mixin;
52 import picocli.CommandLine.Option;
53 import picocli.CommandLine.Parameters;
54
55 import java.io.File;
56
57
58
59
60
61
62
63
64 @Command(description = " Runs parallel simulations with intermittent resampling.", name = "test.WeightedEnsemble")
65 public class WeightedEnsemble extends AlgorithmsCommand {
66
67 @Mixin
68 private AtomSelectionOptions atomSelectionOptions;
69
70 @Mixin
71 private DynamicsOptions dynamicsOptions;
72
73 @Mixin
74 private WriteoutOptions writeOutOptions;
75
76 @Option(names = {"--stepsPer"}, paramLabel = "10000", defaultValue = "10000",
77 description = "Number of steps to take between resampling cycles.")
78 private int stepsPer;
79
80 @Option(names = {"--initDynamics"}, paramLabel = "10000", defaultValue = "10000",
81 description = "Number of initialization steps to take before windows start. This is good for getting diverse starting structures.")
82 private int initDynamics;
83
84 @Option(names = {"--numPerBin"}, paramLabel = "2", defaultValue = "2",
85 description = "Number of walkers per bin.")
86 private int numPerBin;
87
88 @Option(names = {"--oneDimensionalMetric"}, paramLabel = "RMSD", defaultValue = "RMSD",
89 description = "Bin across this metric. Options: RMSD, POTENTIAL, RESIDUE_DISTANCE, ATOM_DISTANCE, COM_DISTANCE, RADIUS_OF_GYRATION")
90 private String oneDimensionalMetric;
91
92
93
94
95 @Parameters(arity = "1..*", paramLabel = "files",
96 description = "XYZ or PDB input files.")
97 private String filename;
98
99
100
101
102 public WeightedEnsemble() {
103 super();
104 }
105
106
107
108
109
110 public WeightedEnsemble(FFXBinding binding) {
111 super(binding);
112 }
113
114
115
116
117
118 public WeightedEnsemble(String[] args) {
119 super(args);
120 }
121
122
123
124
125 @Override
126 public WeightedEnsemble run() {
127 if (!init()) {
128 return this;
129 }
130 dynamicsOptions.init();
131
132
133 MolecularAssembly assembly = getActiveAssembly(filename);
134 File file = assembly.getFile();
135 if (file == null) {
136 logger.severe(" No file found for assembly: " + assembly);
137 } else {
138 logger.info(" Running Weighted Ensemble on " + file);
139 }
140 Potential potential = assembly.getPotentialEnergy();
141 double[] x = new double[potential.getNumberOfVariables()];
142 potential.getCoordinates(x);
143 potential.energy(x, true);
144 MolecularDynamics md = dynamicsOptions.getDynamics(writeOutOptions, potential, assembly, algorithmListener);
145
146
147 OneDimMetric metric = null;
148 try {
149 metric = OneDimMetric.valueOf(oneDimensionalMetric);
150 } catch (IllegalArgumentException e) {
151 logger.severe(" Invalid oneDimensionalMetric: " + oneDimensionalMetric);
152 return this;
153 }
154 WeightedEnsembleManager weightedEnsemble = new WeightedEnsembleManager(metric, numPerBin, md, file, true);
155 weightedEnsemble.run(dynamicsOptions.getSteps(), stepsPer, dynamicsOptions.getTemperature(), dynamicsOptions.getDt());
156
157 return this;
158 }
159 }