MoleculeSignature extends AbstractGraphSignature { @Override public String signatureStringForVertex(int vertexIndex) { AtomSignature atomSignature; int height = super.getHeight(); if (height == -1) { atomSignature = new AtomSignature(vertexIndex, this.molecule); } else { atomSignature = new AtomSignature(vertexIndex, height, this.molecule); } return atomSignature.toCanonicalString(); } MoleculeSignature(IAtomContainer molecule);  MoleculeSignature(IAtomContainer molecule, int height); @Override /** {@inheritDoc} */ String signatureStringForVertex(int vertexIndex); @Override /** {@inheritDoc} */ String signatureStringForVertex(int vertexIndex, int height); @Override /** {@inheritDoc} */ AbstractVertexSignature signatureForVertex(int vertexIndex); List<Orbit> calculateOrbits(); static IAtomContainer fromSignatureString(String signatureString, IChemObjectBuilder coBuilder); String toCanonicalSignatureString(int height);  }
@Test public void getSignatureStringForVertexTest() { Assert.assertEquals("[C]([C])", molSig.signatureStringForVertex(0)); }
@Test public void getSignatureStringForVertexTest_height() { Assert.assertEquals("[C]", molSig.signatureStringForVertex(0, 0)); }
@Test public void testBenzeneWithDoubleBonds() { IAtomContainer benzene = builder.newInstance(IAtomContainer.class); AbstractSignatureTest.addCarbons(benzene, 6); for (int i = 0; i < 6; i++) { AbstractSignatureTest.addHydrogens(benzene, i, 1); } benzene.addBond(0, 1, IBond.Order.SINGLE); benzene.addBond(1, 2, IBond.Order.DOUBLE); benzene.addBond(2, 3, IBond.Order.SINGLE); benzene.addBond(3, 4, IBond.Order.DOUBLE); benzene.addBond(4, 5, IBond.Order.SINGLE); benzene.addBond(5, 0, IBond.Order.DOUBLE); MoleculeSignature signature = new MoleculeSignature(benzene); String carbonSignature = signature.signatureStringForVertex(0); for (int i = 1; i < 6; i++) { String carbonSignatureI = signature.signatureStringForVertex(i); Assert.assertEquals(carbonSignature, carbonSignatureI); } }
@Test public void methyleneCyclopropeneTest() { IAtomContainer mol = builder.newInstance(IAtomContainer.class); AbstractSignatureTest.addCarbons(mol, 4); AbstractSignatureTest.addHydrogens(mol, 1, 2); AbstractSignatureTest.addHydrogens(mol, 2, 1); AbstractSignatureTest.addHydrogens(mol, 3, 1); mol.addBond(0, 1, IBond.Order.DOUBLE); mol.addBond(0, 2, IBond.Order.SINGLE); mol.addBond(0, 3, IBond.Order.SINGLE); mol.addBond(2, 3, IBond.Order.DOUBLE); MoleculeSignature molSig = new MoleculeSignature(mol); String sigFor2Height1 = molSig.signatureStringForVertex(2, 1); String sigFor3Height1 = molSig.signatureStringForVertex(3, 1); Assert.assertTrue("Height 1 signatures for atoms 2 and 3" + " should be the same", sigFor2Height1.equals(sigFor3Height1)); String sigFor2Height2 = molSig.signatureStringForVertex(2, 1); String sigFor3Height2 = molSig.signatureStringForVertex(3, 1); Assert.assertTrue("Height 2 signatures for atoms 2 and 3" + " should be the same", sigFor2Height2.equals(sigFor3Height2)); }
@Test public void fusedSquareMultipleBondTest() { IAtomContainer mol = builder.newInstance(IAtomContainer.class); String expected = "[C]([C]([C,1])[C]([C,0])[C](=[C,1])[C](=[C,0]))"; AbstractSignatureTest.addCarbons(mol, 7); mol.addBond(0, 1, IBond.Order.SINGLE); mol.addBond(0, 2, IBond.Order.SINGLE); mol.addBond(0, 3, IBond.Order.SINGLE); mol.addBond(0, 4, IBond.Order.SINGLE); mol.addBond(1, 5, IBond.Order.DOUBLE); mol.addBond(2, 5, IBond.Order.SINGLE); mol.addBond(3, 6, IBond.Order.SINGLE); mol.addBond(4, 6, IBond.Order.DOUBLE); MoleculeSignature molSig = new MoleculeSignature(mol); String sigFor0 = molSig.signatureStringForVertex(0); Assert.assertEquals(expected, sigFor0); }
@Test public void methylFerroceneTest() throws Exception { String smiles = "CC12C3C4C5C1[Fe]23456789C%10C6C7C8C9%10"; IAtomContainer mol = parser.parseSmiles(smiles); MoleculeSignature molSig = new MoleculeSignature(mol); int feIndex = findFirstAtomIndexForSymbol(mol, "Fe"); String sigForIron = molSig.signatureStringForVertex(feIndex); String expected = "[Fe]([C]([C,3][C,4])[C,3]([C,1])[C,4]([C,0])" + "[C]([C,5][C,6])[C,5]([C,2])[C,6]([C,7])" + "[C,7]([C][C,2])[C,0]([C,1])[C,1][C,2])"; Assert.assertEquals(expected, sigForIron); }
@Test public void cycleWheelTest() { IAtomContainer mol = AbstractSignatureTest.makeCycleWheel(3, 3); String expected = "[C]([C]([C]([C,2])[C,2])" + "[C]([C]([C,1])[C,1])" + "[C]([C]([C,0])[C,0]))"; MoleculeSignature molSig = new MoleculeSignature(mol); String centralSignature = molSig.signatureStringForVertex(0); Assert.assertEquals(expected, centralSignature); }
@Test @Category(SlowTest.class) public void ttprTest() { String expected = "[Rh]([P]([C]([C]([C]([C,6]))" + "[C]([C]([C,6])))[C]([C]([C]([C,3]))" + "[C]([C]([C,3])))[C]([C]([C]([C,2]))" + "[C]([C]([C,2]))))[P]([C]([C]([C]([C,7]))" + "[C]([C]([C,7])))[C]([C]([C]([C,4]))" + "[C]([C]([C,4])))[C]([C]([C]([C,1]))" + "[C]([C]([C,1]))))[P]([C]([C]([C]([C,8]))" + "[C]([C]([C,8])))[C]([C]([C]([C,5]))" + "[C]([C]([C,5])))[C]([C]([C]([C,0]))" + "[C]([C]([C,0])))))"; int phosphateCount = 3; int ringCount = 3; IAtomContainer ttpr = AbstractSignatureTest.makeRhLikeStructure(phosphateCount, ringCount); MoleculeSignature molSig = new MoleculeSignature(ttpr); String centralSignature = molSig.signatureStringForVertex(0); Assert.assertEquals(expected, centralSignature); }
@Test public void napthaleneSkeletonHeightTest() { IAtomContainer napthalene = builder.newInstance(IAtomContainer.class); for (int i = 0; i < 10; i++) { napthalene.addAtom(builder.newInstance(IAtom.class, "C")); } napthalene.addBond(0, 1, IBond.Order.SINGLE); napthalene.addBond(0, 5, IBond.Order.SINGLE); napthalene.addBond(1, 2, IBond.Order.SINGLE); napthalene.addBond(1, 6, IBond.Order.SINGLE); napthalene.addBond(2, 3, IBond.Order.SINGLE); napthalene.addBond(2, 9, IBond.Order.SINGLE); napthalene.addBond(3, 4, IBond.Order.SINGLE); napthalene.addBond(4, 5, IBond.Order.SINGLE); napthalene.addBond(6, 7, IBond.Order.SINGLE); napthalene.addBond(7, 8, IBond.Order.SINGLE); napthalene.addBond(8, 9, IBond.Order.SINGLE); MoleculeSignature molSig = new MoleculeSignature(napthalene); int height = 2; Map<String, Orbit> orbits = new HashMap<String, Orbit>(); for (int i = 0; i < napthalene.getAtomCount(); i++) { String signatureString = molSig.signatureStringForVertex(i, height); Orbit orbit; if (orbits.containsKey(signatureString)) { orbit = orbits.get(signatureString); } else { orbit = new Orbit(signatureString, height); orbits.put(signatureString, orbit); } orbit.addAtom(i); } Assert.assertEquals(3, orbits.size()); }