@Test
  public void testAtomPermutation() throws CDKException {
    IAtomContainer pamine = makePropylAmine();
    ShortestPathFingerprinter fp = new ShortestPathFingerprinter();
    IBitFingerprint bs1 = fp.getBitFingerprint(pamine);

    AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);
    while (acp.hasNext()) {
      IAtomContainer container = acp.next();
      IBitFingerprint bs2 = fp.getBitFingerprint(container);
      Assert.assertTrue(bs1.equals(bs2));
    }
  }
  @Test
  public void testFingerprinter_int_int() throws java.lang.Exception {
    ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024);
    Assert.assertNotNull(fingerprinter);

    IAtomContainer mol = TestMoleculeFactory.makeIndole();
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet();
    IAtomContainer frag1 = TestMoleculeFactory.makePyrrole();
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(frag1);
    BitSet bs1 = fingerprinter.getBitFingerprint(frag1).asBitSet();
    Assert.assertTrue(FingerprinterTool.isSubset(bs, bs1));
  }
  /**
   * @cdk.bug 2819557
   * @throws org.openscience.cdk.exception.CDKException
   */
  @Test
  public void testBug2819557() throws CDKException {
    IAtomContainer butane = makeButane();
    IAtomContainer propylAmine = makePropylAmine();

    ShortestPathFingerprinter fp = new ShortestPathFingerprinter();
    BitSet b1 = fp.getBitFingerprint(butane).asBitSet();
    BitSet b2 = fp.getBitFingerprint(propylAmine).asBitSet();

    Assert.assertFalse(FingerprinterTool.isSubset(b2, b1));
    Assert.assertFalse(
        "butane should not be a substructure of propylamine", FingerprinterTool.isSubset(b2, b1));
  }
  @Test
  public void testAtomPermutation2() throws CDKException {
    IAtomContainer pamine = TestMoleculeFactory.makeCyclopentane();
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(pamine);
    ShortestPathFingerprinter fp = new ShortestPathFingerprinter();
    IBitFingerprint bs1 = fp.getBitFingerprint(pamine);

    AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);
    while (acp.hasNext()) {
      IAtomContainer container = acp.next();
      IBitFingerprint bs2 = fp.getBitFingerprint(container);
      Assert.assertTrue(bs1.equals(bs2));
    }
  }
 @Test
 public void testRegression() throws Exception {
   IAtomContainer mol1 = TestMoleculeFactory.makeIndole();
   IAtomContainer mol2 = TestMoleculeFactory.makePyrrole();
   AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol1);
   AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol2);
   ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter();
   IBitFingerprint bs1 = fingerprinter.getBitFingerprint(mol1);
   Assert.assertEquals(
       "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!",
       22,
       bs1.cardinality());
   IBitFingerprint bs2 = fingerprinter.getBitFingerprint(mol2);
   Assert.assertEquals(
       "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!",
       11,
       bs2.cardinality());
 }
 @Test
 public void testFingerprinterBitSetSize() throws Exception {
   ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024);
   Assert.assertNotNull(fingerprinter);
   IAtomContainer mol = TestMoleculeFactory.makeIndole();
   AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
   BitSet bs = fingerprinter.getBitFingerprint(mol).asBitSet();
   Assert.assertEquals(1024, bs.length()); // highest set bit
   Assert.assertEquals(1024, bs.size()); // actual bit set size
 }
  @Test
  public void testgetBitFingerprint_IAtomContainer() throws java.lang.Exception {
    ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter();

    IAtomContainer mol = TestMoleculeFactory.makeIndole();
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    IBitFingerprint bs = fingerprinter.getBitFingerprint(mol);
    Assert.assertNotNull(bs);
    Assert.assertEquals(fingerprinter.getSize(), bs.size());
  }
  @Test
  public void testGenerateFingerprintNaphthalene() throws InvalidSmilesException, Exception {

    String smiles = "C1=CC2=CC=CC=C2C=C1";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer molecule = smilesParser.parseSmiles(smiles);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
    Aromaticity.cdkLegacy().apply(molecule);
    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprint1;
    fingerprint1 = fingerprint.getBitFingerprint(molecule).asBitSet();
    org.junit.Assert.assertEquals(8, fingerprint1.cardinality());
  }
  /**
   * Test of ShortestPathFingerprinter method
   *
   * @throws InvalidSmilesException
   * @throws CDKException
   */
  @Test
  public void testGenerateFingerprintIsSubset() throws InvalidSmilesException, CDKException {

    String smilesT = "NC(=O)C1=C2C=CC(Br)=CC2=C(Cl)C=C1";
    String smilesQ = "CC1=C2C=CC(Br)=CC2=C(Cl)C=C1";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IAtomContainer moleculeQ = smilesParser.parseSmiles(smilesQ);
    IAtomContainer moleculeT = smilesParser.parseSmiles(smilesT);

    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeQ);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeT);

    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprintQ;
    BitSet fingerprintT;
    fingerprintQ = fingerprint.getBitFingerprint(moleculeQ).asBitSet();
    fingerprintT = fingerprint.getBitFingerprint(moleculeT).asBitSet();

    org.junit.Assert.assertTrue(FingerprinterTool.isSubset(fingerprintT, fingerprintQ));
  }
Ejemplo n.º 10
0
  /**
   * Test of ShortestPathFingerprinter method
   *
   * @throws InvalidSmilesException
   * @throws CDKException
   * @throws FileNotFoundException
   */
  @Test
  public void testGenerateFingerprintIsNotASubset1()
      throws InvalidSmilesException, CDKException, FileNotFoundException, FileNotFoundException {

    String smilesT = "O[C@H]1[C@H](O)[C@@H](O)[C@H](O)[C@H](O)[C@@H]1O";
    String smilesQ = "OC[C@@H](O)[C@@H](O)[C@H](O)[C@@H](O)C(O)=O";
    SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    smilesParser.kekulise(false);
    IAtomContainer moleculeQ = smilesParser.parseSmiles(smilesQ);

    IAtomContainer moleculeT = smilesParser.parseSmiles(smilesT);

    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeQ);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeT);

    ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
    BitSet fingerprintQ;
    BitSet fingerprintT;
    fingerprintQ = fingerprint.getBitFingerprint(moleculeQ).asBitSet();
    fingerprintT = fingerprint.getBitFingerprint(moleculeT).asBitSet();
    org.junit.Assert.assertFalse(FingerprinterTool.isSubset(fingerprintT, fingerprintQ));
  }