/** * 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); }
private void modifyAndLabel(Octahedral oc) { List<IAtom> atoms = oc.normalize().getCarriers(); List<IBond> bonds = new ArrayList<>(4); IBond bond = container.getBond(oc.getFocus(), atom); IAtom focus = oc.getFocus(); Point2d fp = focus.getPoint2d(); for (IAtom atom : container.atoms())
@Test public void normalizeOh() throws InvalidSmilesException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C[Co@OH8](F)(Br)(Cl)(I)S"); Iterator<IStereoElement> ses = mol.stereoElements().iterator(); assertTrue(ses.hasNext()); IStereoElement se = ses.next(); assertThat(se, instanceOf(Octahedral.class)); assertThat(se.getConfigOrder(), is(8)); Octahedral oh = (Octahedral) se; Octahedral ohNorm = oh.normalize(); assertThat(ohNorm.getCarriers(), is(Arrays.asList( mol.getAtom(0), mol.getAtom(2), mol.getAtom(4), mol.getAtom(3), mol.getAtom(5), mol.getAtom(6) ))); }
/** * {@inheritDoc} */ @Override protected Octahedral create(IAtom focus, List<IAtom> carriers, int cfg) { return new Octahedral(focus, carriers.toArray(new IAtom[6]), cfg); } }
/** * Create a new octahedral configuration. * @param focus the focus * @param carriers the carriers * @param order the order of the configuration 0-30. */ public Octahedral(IAtom focus, IAtom[] carriers, int order) { super(focus, carriers, IStereoElement.OC | (order & 0xff)); if (getConfigOrder() < 0 || getConfigOrder() > 30) throw new IllegalArgumentException("Invalid configuration order!" + "Should be in range 1-30"); }
private void modifyAndLabel(Octahedral oc) { List<IAtom> atoms = oc.normalize().getCarriers(); List<IBond> bonds = new ArrayList<>(4); IBond bond = container.getBond(oc.getFocus(), atom); IAtom focus = oc.getFocus(); Point2d fp = focus.getPoint2d(); for (IAtom atom : container.atoms())
/** * {@inheritDoc} */ @Override protected Octahedral create(IAtom focus, List<IAtom> carriers, int cfg) { return new Octahedral(focus, carriers.toArray(new IAtom[6]), cfg); } }
/** * Create a new octahedral configuration. * @param focus the focus * @param carriers the carriers * @param order the order of the configuration 0-30. */ public Octahedral(IAtom focus, IAtom[] carriers, int order) { super(focus, carriers, IStereoElement.OC | (order & 0xff)); if (getConfigOrder() < 0 || getConfigOrder() > 30) throw new IllegalArgumentException("Invalid configuration order!" + "Should be in range 1-30"); }
/** * 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); }
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); } }