예제 #1
0
 static Graph convert(
     IAtomContainer ac,
     boolean perceiveAromaticity,
     boolean isomeric,
     boolean aromatic,
     boolean atomClasses)
     throws Exception {
   AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac);
   CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()).addImplicitHydrogens(ac);
   if (perceiveAromaticity) Aromaticity.cdkLegacy().apply(ac);
   return new CDKToBeam(isomeric, aromatic, atomClasses).toBeamGraph(ac);
 }
  @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());
  }
예제 #3
0
  /**
   * Generates a shortest path based BitSet fingerprint for the given AtomContainer.
   *
   * @param ac The AtomContainer for which a fingerprint is generated
   * @exception CDKException if there error in aromaticity perception or other CDK functions
   * @return A {@link BitSet} representing the fingerprint
   */
  @Override
  public IBitFingerprint getBitFingerprint(IAtomContainer ac) throws CDKException {

    IAtomContainer atomContainer = null;
    try {
      atomContainer = (IAtomContainer) ac.clone();
    } catch (CloneNotSupportedException ex) {
      logger.error("Failed to clone the molecule:", ex);
    }
    Aromaticity.cdkLegacy().apply(atomContainer);
    BitSet bitSet = new BitSet(fingerprintLength);
    if (!ConnectivityChecker.isConnected(atomContainer)) {
      IAtomContainerSet partitionedMolecules =
          ConnectivityChecker.partitionIntoMolecules(atomContainer);
      for (IAtomContainer container : partitionedMolecules.atomContainers()) {
        addUniquePath(container, bitSet);
      }
    } else {
      addUniquePath(atomContainer, bitSet);
    }
    return new BitSetFingerprint(bitSet);
  }
예제 #4
0
 private void prepareInput(IAtomContainer input) throws CDKException {
   SmartsMatchers.prepare(input, true);
   arom.apply(input);
 }