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.xray.commands;
39
40 import ffx.algorithms.cli.AlgorithmsCommand;
41 import ffx.potential.MolecularAssembly;
42 import ffx.potential.bonded.Atom;
43 import ffx.potential.bonded.Residue;
44 import ffx.utilities.FFXBinding;
45 import ffx.xray.DiffractionData;
46 import ffx.xray.cli.XrayOptions;
47 import org.apache.commons.configuration2.CompositeConfiguration;
48 import picocli.CommandLine.Command;
49 import picocli.CommandLine.Mixin;
50 import picocli.CommandLine.Parameters;
51
52 import java.util.List;
53
54 import static org.apache.commons.io.FilenameUtils.removeExtension;
55
56
57
58
59
60
61
62
63 @Command(description = " Discrete optimization using a many-body expansion and elimination expressions.", name = "xray.SaveConformerPDB")
64 public class SaveConformerPDB extends AlgorithmsCommand {
65
66 @Mixin
67 private XrayOptions xrayOptions;
68
69
70
71
72 @Parameters(arity = "1..*", paramLabel = "files", description = "PDB and Real Space input files.")
73 private List<String> filenames;
74 private MolecularAssembly[] molecularAssemblies;
75 private DiffractionData diffractionData;
76
77
78
79
80 public SaveConformerPDB() {
81 super();
82 }
83
84
85
86
87
88 public SaveConformerPDB(String[] args) {
89 super(args);
90 }
91
92
93
94
95
96 public SaveConformerPDB(FFXBinding binding) {
97 super(binding);
98 }
99
100 @Override
101 public SaveConformerPDB run() {
102 if (!init()) {
103 return this;
104 }
105
106 xrayOptions.init();
107
108 String filename;
109 if (filenames != null && !filenames.isEmpty()) {
110
111 molecularAssemblies = algorithmFunctions.openAll(filenames.get(0));
112 activeAssembly = molecularAssemblies[0];
113 filename = filenames.get(0);
114 } else if (activeAssembly == null) {
115 logger.info(helpString());
116 return this;
117 } else {
118 molecularAssemblies = new MolecularAssembly[]{activeAssembly};
119 filename = activeAssembly.getFile().getAbsolutePath();
120 }
121
122 if (molecularAssemblies.length == 1) {
123 logger.info("No alternate conformers");
124 return this;
125 }
126
127
128 CompositeConfiguration properties = activeAssembly.getProperties();
129 xrayOptions.setProperties(parseResult, properties);
130
131
132 diffractionData = xrayOptions.getDiffractionData(filenames, molecularAssemblies, properties);
133 diffractionData.scaleBulkFit();
134 diffractionData.printStats();
135 algorithmFunctions.energy(molecularAssemblies);
136
137 List<Residue> residuesA = molecularAssemblies[0].getResidueList();
138 List<Residue> residuesB = molecularAssemblies[1].getResidueList();
139
140 for (int j = 0; j < residuesA.size(); j++) {
141 List<Atom> atomsA = residuesA.get(j).getAtomList();
142 List<Atom> atomsB = residuesB.get(j).getAtomList();
143 for (int i = 0; i < atomsA.size(); i++) {
144 Atom atomA = atomsA.get(i);
145 Atom atomB = atomsB.get(i);
146
147 if (atomA.getAltLoc() == null || atomA.getAltLoc() == ' ') {
148 atomA.setAltLoc('A');
149 }
150 if (atomB.getAltLoc() == null || atomB.getAltLoc() == ' ') {
151 atomB.setAltLoc('B');
152 }
153 }
154 }
155
156 logger.info(" ");
157 diffractionData.writeModel(removeExtension(filename) + ".pdb");
158 diffractionData.writeData(removeExtension(filename) + ".mtz");
159
160 return this;
161 }
162 }