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.crystal.Crystal;
42 import ffx.crystal.ReflectionList;
43 import ffx.crystal.Resolution;
44 import ffx.numerics.Potential;
45 import ffx.potential.MolecularAssembly;
46 import ffx.utilities.FFXBinding;
47 import ffx.xray.DiffractionRefinementData;
48 import ffx.xray.parsers.CIFFilter;
49 import ffx.xray.parsers.MTZWriter;
50 import ffx.xray.parsers.MTZWriter.MTZType;
51 import picocli.CommandLine.Command;
52 import picocli.CommandLine.Parameters;
53
54 import java.io.File;
55 import java.util.List;
56
57 import static org.apache.commons.io.FilenameUtils.removeExtension;
58
59
60
61
62
63
64
65
66 @Command(description = " Convert a CIF file to MTZ format.", name = "xray.CIFtoMTZ")
67 public class CIFtoMTZ extends AlgorithmsCommand {
68
69
70
71
72 @Parameters(arity = "2", paramLabel = "file", description = "A PDB file and a CIF diffraction file.")
73 private List<String> filenames = null;
74
75 private MolecularAssembly[] molecularAssemblies;
76 private DiffractionRefinementData refinementData;
77
78
79
80
81 public CIFtoMTZ() {
82 super();
83 }
84
85
86
87
88
89
90 public CIFtoMTZ(String[] args) {
91 super(args);
92 }
93
94
95
96
97
98
99 public CIFtoMTZ(FFXBinding binding) {
100 super(binding);
101 }
102
103
104
105
106 @Override
107 public CIFtoMTZ run() {
108
109 if (!init()) {
110 return this;
111 }
112
113 String pdb = filenames.get(0);
114 String cif = filenames.get(1);
115
116 logger.info("\n Running CIF2MTZ on " + cif);
117 molecularAssemblies = algorithmFunctions.openAll(pdb);
118
119 CIFFilter cifFilter = new CIFFilter();
120 ReflectionList reflectionlist =
121 cifFilter.getReflectionList(new File(cif), molecularAssemblies[0].getProperties());
122
123 if (reflectionlist == null) {
124 logger.info(" Using crystal information from the PDB file to generate MTZ file.");
125
126 Crystal crystal = molecularAssemblies[0].getCrystal().getUnitCell();
127 double res = cifFilter.getResolution(new File(cif), crystal);
128 if (res < 0.0) {
129 logger.info(" The resolution could not be determined from the PDB and CIF files.");
130 return this;
131 }
132
133 Resolution resolution = new Resolution(res);
134 reflectionlist = new ReflectionList(crystal, resolution,
135 molecularAssemblies[0].getProperties());
136 }
137
138 refinementData = new DiffractionRefinementData(molecularAssemblies[0].getProperties(), reflectionlist);
139 cifFilter.readFile(new File(cif), reflectionlist, refinementData, molecularAssemblies[0].getProperties());
140
141 MTZWriter mtzwriter = new MTZWriter(reflectionlist, refinementData,
142 removeExtension(cif) + ".mtz", MTZType.DATAONLY);
143 mtzwriter.write();
144
145 return this;
146 }
147
148 @Override
149 public List<Potential> getPotentials() {
150 return getPotentialsFromAssemblies(molecularAssemblies);
151 }
152 }