/** * 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); }
private void modifyAndLabel(Octahedral oc) { List<IAtom> atoms = oc.normalize().getCarriers(); List<IBond> bonds = new ArrayList<>(4);
private void modifyAndLabel(Octahedral oc) { List<IAtom> atoms = oc.normalize().getCarriers(); List<IBond> bonds = new ArrayList<>(4);
@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) ))); }