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.numerics.Potential;
42 import ffx.potential.MolecularAssembly;
43 import ffx.potential.bonded.Atom;
44 import ffx.potential.bonded.MSNode;
45 import ffx.potential.bonded.Molecule;
46 import ffx.utilities.FFXBinding;
47 import picocli.CommandLine.Command;
48 import picocli.CommandLine.Parameters;
49
50 import java.io.File;
51 import java.util.Collections;
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 = " Deuterate exchangable hydrogen of the PDB model.", name = "xray.Deuterate")
64 public class Deuterate extends AlgorithmsCommand {
65
66
67
68
69 @Parameters(arity = "1..*", paramLabel = "files", description = "PDB input file.")
70 private List<String> filenames;
71
72
73
74
75 public Deuterate() {
76 super();
77 }
78
79
80
81
82
83 public Deuterate(String[] args) {
84 super(args);
85 }
86
87
88
89
90
91 public Deuterate(FFXBinding binding) {
92 super(binding);
93 }
94
95
96
97
98 @Override
99 public Deuterate run() {
100
101 if (!init()) {
102 return this;
103 }
104
105 MolecularAssembly[] molecularAssemblies;
106 String filename;
107 if (filenames != null && !filenames.isEmpty()) {
108 molecularAssemblies = algorithmFunctions.openAll(filenames.get(0));
109 activeAssembly = molecularAssemblies[0];
110 filename = filenames.get(0);
111 } else if (activeAssembly == null) {
112 logger.info(helpString());
113 return this;
114 } else {
115 molecularAssemblies = new MolecularAssembly[]{activeAssembly};
116 filename = activeAssembly.getFile().getAbsolutePath();
117 }
118
119 logger.info("\n Running xray.Deuterate on " + filename);
120
121 for (int i = 0; i < molecularAssemblies.length; i++) {
122 Atom[] atoms = molecularAssemblies[i].getAtomArray();
123 for (Atom a : atoms) {
124 if (a.getAtomicNumber() == 1) {
125 Atom b = a.getBonds().get(0).get1_2(a);
126
127
128 if (b.getAtomicNumber() == 7
129 || b.getAtomicNumber() == 8) {
130 String name = a.getName().replaceFirst("H", "D");
131 a.setName(name);
132 }
133 }
134 }
135
136 List<MSNode> water = molecularAssemblies[i].getWater();
137 for (MSNode node : water) {
138 Molecule wat = (Molecule) node;
139 wat.setName("DOD");
140 }
141 }
142
143 algorithmFunctions.saveAsPDB(molecularAssemblies, new File(removeExtension(filename) + "_deuterate.pdb"));
144
145 return this;
146 }
147
148 @Override
149 public List<Potential> getPotentials() {
150 return Collections.emptyList();
151 }
152 }