22import static org.junit.jupiter.api.Assertions.assertEquals;
23import static org.junit.jupiter.api.Assertions.assertFalse;
24import static org.junit.jupiter.api.Assertions.assertTrue;
26import java.util.ArrayList;
27import java.util.Collections;
31import org.junit.jupiter.api.Test;
32import org.openscience.cdk.Atom;
33import org.openscience.cdk.interfaces.IAtomContainer;
34import org.openscience.cdk.interfaces.IChemObjectBuilder;
35import org.openscience.cdk.silent.SilentChemObjectBuilder;
49 private IChemObjectBuilder
builder = SilentChemObjectBuilder.getInstance();
56 String formula =
"H2 O";
72 formula =
"O H2 C3 W2 Ca";
74 assertEquals(
"C 3.0 Ca 1.0 H 2.0 O 1.0 W 2.0",
83 String formula =
"H2 O";
99 formula =
"O H2 C3 W2 Ca";
101 assertEquals(
"C 3.0 3.0 Ca 1.0 1.0 H 2.0 2.0 O 1.0 1.0 W 2.0 2.0",
104 formula =
"H2 O, C2 H6 O";
106 assertEquals(
"C 0.0 2.0 0.0 2.0 2.0 "
107 +
"H 2.0 6.0 2.0 6.0 8.0 "
108 +
"O 1.0 1.0 1.0 1.0 2.0",
111 formula =
"C2 H6 O 2-";
113 assertEquals(
"C 2.0 2.0 H 6.0 6.0 O 1.0 1.0",
116 formula =
"2(C16 H36 N1 1+),C8 Au1 N4 S4 2-,2(C3 H6 O1)";
119 "Au 0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 "
120 +
"C 16.0 8.0 3.0 32.0 8.0 6.0 40.0 46.0 "
121 +
"H 36.0 0.0 6.0 72.0 0.0 12.0 72.0 84.0 "
122 +
"N 1.0 4.0 0.0 2.0 4.0 0.0 6.0 6.0 "
123 +
"O 0.0 0.0 1.0 0.0 0.0 2.0 0.0 2.0 "
124 +
"S 0.0 4.0 0.0 0.0 4.0 0.0 4.0 4.0",
127 formula =
"F5 Pd1,0.25(Br),0.5(Cl2)";
130 "Br 0.0 1.0 0.0 0.0 1.0 0.0 1.0 1.0 "
131 +
"Cl 0.0 0.0 2.0 0.0 0.0 2.0 0.0 2.0 "
132 +
"F 5.0 0.0 0.0 5.0 0.0 0.0 5.0 5.0 "
133 +
"Pd 1.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0",
136 formula =
"(H2 O)n,6n(N),2n(C),2n(F2)";
139 "C 0.0 0.0 1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 0.0 0.0 0.0 2.0 4.0 6.0 8.0 10.0 2.0 4.0 6.0 8.0 10.0 "
140 +
"F 0.0 0.0 0.0 2.0 0.0 0.0 0.0 4.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4.0 8.0 12.0 16.0 20.0 "
141 +
"H 2.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 2.0 4.0 6.0 8.0 10.0 2.0 4.0 6.0 8.0 10.0 2.0 4.0 6.0 8.0 10.0 "
142 +
"N 0.0 1.0 0.0 0.0 0.0 6.0 0.0 0.0 6.0 12.0 18.0 24.0 30.0 6.0 12.0 18.0 24.0 30.0 6.0 12.0 18.0 24.0 30.0 "
143 +
"O 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0",
151 List<String> els =
new ArrayList<String>();
152 els.addAll(elCounts.keySet());
153 Collections.sort(els);
154 StringBuilder sb =
new StringBuilder();
155 for (String el : els)
157 sb.append(
" ").append(el);
160 return sb.toString().trim();
167 List<String> els =
new ArrayList<String>();
168 els.addAll(elCounts.keySet());
169 Collections.sort(els);
170 StringBuilder sb =
new StringBuilder();
171 for (String el : els)
173 sb.append(
" ").append(el);
174 for (Double v : elCounts.get(el))
179 return sb.toString().trim();
187 String formula =
"H2 O";
188 IAtomContainer mol =
builder.newAtomContainer();
189 mol.addAtom(
new Atom(
"H"));
190 mol.addAtom(
new Atom(
"H"));
191 mol.addAtom(
new Atom(
"O"));
194 mol.addAtom(
new Atom(
"O"));
198 mol =
builder.newAtomContainer();
199 mol.addAtom(
new Atom(
"H"));
200 mol.addAtom(
new Atom(
"H"));
201 mol.addAtom(
new Atom(
"O"));
202 mol.addAtom(
new Atom(
"H"));
203 mol.addAtom(
new Atom(
"H"));
204 mol.addAtom(
new Atom(
"O"));
205 mol.addAtom(
new Atom(
"H"));
206 mol.addAtom(
new Atom(
"H"));
207 mol.addAtom(
new Atom(
"O"));
210 formula =
"C6 H6,2(H2 O)";
211 mol =
builder.newAtomContainer();
212 mol.addAtom(
new Atom(
"C"));
213 mol.addAtom(
new Atom(
"H"));
214 mol.addAtom(
new Atom(
"C"));
215 mol.addAtom(
new Atom(
"H"));
216 mol.addAtom(
new Atom(
"C"));
217 mol.addAtom(
new Atom(
"H"));
218 mol.addAtom(
new Atom(
"C"));
219 mol.addAtom(
new Atom(
"H"));
220 mol.addAtom(
new Atom(
"C"));
221 mol.addAtom(
new Atom(
"H"));
222 mol.addAtom(
new Atom(
"C"));
223 mol.addAtom(
new Atom(
"H"));
226 formula =
"(C6 H6)n,2n(H2 O),n(C2 H4)";
227 mol =
builder.newAtomContainer();
228 mol.addAtom(
new Atom(
"C"));
229 mol.addAtom(
new Atom(
"H"));
230 mol.addAtom(
new Atom(
"C"));
231 mol.addAtom(
new Atom(
"H"));
232 mol.addAtom(
new Atom(
"C"));
233 mol.addAtom(
new Atom(
"H"));
234 mol.addAtom(
new Atom(
"C"));
235 mol.addAtom(
new Atom(
"H"));
236 mol.addAtom(
new Atom(
"C"));
237 mol.addAtom(
new Atom(
"H"));
238 mol.addAtom(
new Atom(
"C"));
239 mol.addAtom(
new Atom(
"H"));
240 mol.addAtom(
new Atom(
"H"));
241 mol.addAtom(
new Atom(
"H"));
242 mol.addAtom(
new Atom(
"O"));
243 mol.addAtom(
new Atom(
"H"));
244 mol.addAtom(
new Atom(
"H"));
245 mol.addAtom(
new Atom(
"O"));
246 mol.addAtom(
new Atom(
"C"));
247 mol.addAtom(
new Atom(
"H"));
248 mol.addAtom(
new Atom(
"H"));
249 mol.addAtom(
new Atom(
"C"));
250 mol.addAtom(
new Atom(
"H"));
251 mol.addAtom(
new Atom(
"H"));
static String getEnglishFormattedDecimal(String pattern, int decimals, double value)
Formats a decimal number using the given pattern but with English format as for separators.