StructureDiagramGenerator { public double getBondLength() { return bondLength; } StructureDiagramGenerator(); private  StructureDiagramGenerator(IdentityTemplateLibrary identityLibrary);  StructureDiagramGenerator(IAtomContainer molecule); final void generateCoordinates(IAtomContainer mol); final void generateCoordinates(final IReaction reaction); void setMolecule(IAtomContainer mol, boolean clone); void setMolecule(IAtomContainer mol, boolean clone, Set<IAtom> afix, Set<IBond> bfix); @Deprecated void setUseTemplates(boolean useTemplates); void setUseIdentityTemplates(boolean use); @Deprecated boolean getUseTemplates(); @Deprecated void setTemplateHandler(TemplateHandler templateHandler); @Deprecated TemplateHandler getTemplateHandler(); void setMolecule(IAtomContainer molecule); void setAlignMappedReaction(boolean align); IAtomContainer getMolecule(); @Deprecated void generateExperimentalCoordinates(); @Deprecated void generateExperimentalCoordinates(Vector2d firstBondVector); void generateCoordinates(Vector2d firstBondVector); void generateCoordinates(); @Deprecated void setBondLength(double bondLength); double getBondLength(); IAtom getOtherBondAtom(IAtom atom, IBond bond); static final Comparator<IAtomContainer> LARGEST_FIRST_COMPARATOR; }
@Test public void ionicBondsInAlCl3() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[Al+3].[Cl-].[Cl-].[Cl-]"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(1).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(2).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(3).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); }
@Test public void ionicBondsInK2CO3() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[K+].[O-]C(=O)[O-].[K+]"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(1).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); assertThat(mol.getAtom(4).getPoint2d().distance(mol.getAtom(5).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); }
@Test public void ionicBondsInLiAlH4() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[Li+].[Al+3].[Cl-].[Cl-].[Cl-].[Cl-]"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); for (int i = 2; i < 5; i++) { double distLi = mol.getAtom(0).getPoint2d().distance(mol.getAtom(i).getPoint2d()); double distAl = mol.getAtom(1).getPoint2d().distance(mol.getAtom(i).getPoint2d()); double diffLi = distLi - 1.5*SDG.getBondLength(); double diffAl = distAl - 1.5*SDG.getBondLength(); if (Math.abs(diffLi) > 0.001 && Math.abs(diffAl) > 0.001) fail("Chlorine must be bond length from Al or Li atoms"); } }
@Test public void ionicBondsInSodiumBenzoate() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[Na+].[O-]C(=O)c1ccccc1"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(1).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); }
@Test public void chembl12276() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[Cl-].C(C1=CC=CC2=C(C=CC=C12)[N+](=O)[O-])[N+](C)(CCCl)CCCl"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); assertThat(mol.getAtom(0).getAtomicNumber(), is(17)); assertThat(mol.getAtom(15).getAtomicNumber(), is(7)); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(15).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); }
@Test public void calciumOxide() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[Ca+2].[O-2]"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); assertThat(mol.getAtom(0).getPoint2d().distance(mol.getAtom(1).getPoint2d()), closeTo(1.5*SDG.getBondLength(), 0.001)); }
@Test public void multipleSalts() throws Exception { SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[K+].[Al+3].[Cl-].[Cl-].[K+].[Cl-].[Cl-].[Al+3].[Cl-].[Pt+2]([NH3])[NH3].[Cl-].[Cl-].[Cl-].[O-][C+]([O-])[O-]"); layout(mol); for (IAtom atom : mol.atoms()) assertNotNull(atom.getPoint2d()); IAtom platinum = null; Set<IAtom> aluminiums = new HashSet<>(); Set<IAtom> potassiums = new HashSet<>(); Set<IAtom> chlorines = new HashSet<>(); Set<IAtom> oxygens = new HashSet<>(); for (IAtom atom : mol.atoms()) { if (atom.getSymbol().equals("Cl")) chlorines.add(atom); else if (atom.getSymbol().equals("O")) oxygens.add(atom); else if (atom.getSymbol().equals("Al")) aluminiums.add(atom); else if (atom.getSymbol().equals("K")) potassiums.add(atom); else if (atom.getSymbol().equals("Pt")) platinum = atom; } assertNotNull(platinum); assertThat(potassiums.size(), is(2)); assertThat(oxygens.size(), is(3)); assertThat(chlorines.size(), is(8)); int ptFound = 0; for (IAtom chlorine : chlorines) { double delta = chlorine.getPoint2d().distance(platinum.getPoint2d()) - 1.5*SDG.getBondLength(); if (Math.abs(delta) < 0.01) ptFound++; } assertThat(ptFound, is(2)); for (IAtom potassium : potassiums) { int kFound = 0; for (IAtom oxygen : oxygens) { double delta = oxygen.getPoint2d().distance(potassium.getPoint2d()) - 1.5*SDG.getBondLength(); if (Math.abs(delta) < 0.01) kFound++; } assertThat(kFound, is(1)); } for (IAtom aluminium : aluminiums) { int clFound = 0; for (IAtom chlorine : chlorines) { double delta = chlorine.getPoint2d().distance(aluminium.getPoint2d()) - 1.5*SDG.getBondLength(); if (Math.abs(delta) < 0.01) clFound++; } assertThat(clFound, is(3)); } }
@Test public void dihydroazine() throws Exception { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("N=N.N=N"); layout(mol); assertThat(mol.getAtom(2).getPoint2d().x - mol.getAtom(1).getPoint2d().x, is(greaterThan(SDG.getBondLength()))); }
@Test public void NH4OH() throws Exception { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("[NH4+].[OH-]"); layout(mol); assertThat(mol.getAtom(1).getPoint2d().x - mol.getAtom(0).getPoint2d().x, is(greaterThan(SDG.getBondLength()))); }