/** * {@inheritDoc} */ @Override protected Octahedral create(IAtom focus, List<IAtom> carriers, int cfg) { return new Octahedral(focus, carriers.toArray(new IAtom[6]), cfg); } }
/** * {@inheritDoc} */ @Override protected Octahedral create(IAtom focus, List<IAtom> carriers, int cfg) { return new Octahedral(focus, carriers.toArray(new IAtom[6]), cfg); } }
private IStereoElement newOctahedral(int u, int[] vs, IAtom[] atoms, Configuration c) { if (vs.length != 6) return null; int order = 1 + c.ordinal() - Configuration.OH1.ordinal(); if (order < 1 || order > 30) return null; return new Octahedral(atoms[u], new IAtom[]{atoms[vs[0]], atoms[vs[1]], atoms[vs[2]], atoms[vs[3]], atoms[vs[4]], atoms[vs[5]]}, order); }
@Test(expected = IllegalArgumentException.class) public void tooManyCarriers() { IAtom a0 = Mockito.mock(IAtom.class); IAtom a1 = Mockito.mock(IAtom.class); IAtom a2 = Mockito.mock(IAtom.class); IAtom a3 = Mockito.mock(IAtom.class); IAtom a4 = Mockito.mock(IAtom.class); IAtom a5 = Mockito.mock(IAtom.class); IAtom a6 = Mockito.mock(IAtom.class); IAtom a7 = Mockito.mock(IAtom.class); new Octahedral(a0, new IAtom[]{a1,a2,a3,a4,a5,a6,a7}, 1); }
@Test(expected = IllegalArgumentException.class) public void badConfigurationOrder() { IAtom a0 = Mockito.mock(IAtom.class); IAtom a1 = Mockito.mock(IAtom.class); IAtom a2 = Mockito.mock(IAtom.class); IAtom a3 = Mockito.mock(IAtom.class); IAtom a4 = Mockito.mock(IAtom.class); IAtom a5 = Mockito.mock(IAtom.class); IAtom a6 = Mockito.mock(IAtom.class); new Octahedral(a0, new IAtom[]{a1,a2,a3,a4,a5,a6}, 32); } }
/** * Normalize the configuration to the lowest order (1). For example * <pre>C[Co@OH8](F)(Br)(Cl)(I)S</pre> * is the same as * <pre>C[Co@OH1](F)(Cl)(Br)(I)S</pre>. The normalised form is easy to * work with as the first and last carriers form an axis, the middle four * equatorial carriers are arranged anti-clockwise looking from the first carrier. * @return the normalized form */ public Octahedral normalize() { int cfg = getConfigOrder(); if (cfg == 1) return this; if (cfg < 1 || cfg > 30) throw new IllegalArgumentException( "Invalid config order: " + cfg + ", octahedral should be" + "1 <= order <= 30!"); IAtom[] carriers = invapply(getCarriers().toArray(new IAtom[6]), PERMUTATIONS[cfg-1]); return new Octahedral(getFocus(), carriers, 1); }
/** * Normalize the configuration to the lowest order (1). For example * <pre>C[Co@OH8](F)(Br)(Cl)(I)S</pre> * is the same as * <pre>C[Co@OH1](F)(Cl)(Br)(I)S</pre>. The normalised form is easy to * work with as the first and last carriers form an axis, the middle four * equatorial carriers are arranged anti-clockwise looking from the first carrier. * @return the normalized form */ public Octahedral normalize() { int cfg = getConfigOrder(); if (cfg == 1) return this; if (cfg < 1 || cfg > 30) throw new IllegalArgumentException( "Invalid config order: " + cfg + ", octahedral should be" + "1 <= order <= 30!"); IAtom[] carriers = invapply(getCarriers().toArray(new IAtom[6]), PERMUTATIONS[cfg-1]); return new Octahedral(getFocus(), carriers, 1); }