Example #1
0
  @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));
  }
Example #2
0
  @Test
  public void cyclobuteneTest() {
    String expectedA = "[C]([C]([C,0])=[C]([C,0]))";
    String expectedB = "[C]([C]([C,0])[C](=[C,0]))";
    IAtomContainer cyclobutene = builder.newInstance(IAtomContainer.class);
    AbstractSignatureTest.addCarbons(cyclobutene, 4);
    cyclobutene.addBond(0, 1, IBond.Order.SINGLE);
    cyclobutene.addBond(0, 2, IBond.Order.SINGLE);
    cyclobutene.addBond(1, 3, IBond.Order.DOUBLE);
    cyclobutene.addBond(2, 3, IBond.Order.SINGLE);
    Assert.assertEquals(expectedA, canonicalStringFromMolecule(cyclobutene));

    String expectedFullString = "2" + expectedA + " + 2" + expectedB;
    String actualFullString = fullStringFromMolecule(cyclobutene);
    Assert.assertEquals(expectedFullString, actualFullString);
  }
Example #3
0
 @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);
 }
Example #4
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);
    }
  }