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