Пример #1
0
  protected synchronized void prepareKeySequences(List<String> keys, int nKeys) {
    smartsKeys = keys;
    IQueryAtomContainer query;
    sequences.clear();
    smartsQueries.clear();
    SmartsParser parser = new SmartsParser();
    for (int i = 0; i < nKeys; i++) {
      query = parser.parse(smartsKeys.get(i));

      // parser.setNeededDataFlags();       --> This should not be needed for the key smarts queries
      isoTester.setQuery(query);
      List<QuerySequenceElement> sequence = isoTester.transferSequenceToOwner();
      sequences.add(sequence);
      smartsQueries.add(query);
    }
  }
Пример #2
0
  public void match(String smarts, String smiles) throws Exception {
    // Testing the algorithm via SmartsManager
    IMolecule mol = SmartsHelper.getMoleculeFromSmiles(smiles);
    man.setUseCDKIsomorphismTester(false);
    man.setQuery(smarts);
    boolResult = man.searchIn(mol);

    // Direct test of class IsomorphismTester
    IQueryAtomContainer query = sp.parse(smarts);
    sp.setNeededDataFlags();
    String errorMsg = sp.getErrorMessages();
    if (!errorMsg.equals("")) {
      System.out.println("Smarts Parser errors:\n" + errorMsg);
      return;
    }

    isoTester.setQuery(query);
    sp.setSMARTSData(mol);
    List<Integer> pos = isoTester.getIsomorphismPositions(mol);
    mappingPosCount = pos.size();
  }
Пример #3
0
  protected synchronized BitSet getStructureKeyBits(IAtomContainer ac) {
    // quick workaround for aromatic compounds, to avoid matching non-aromatic keys
    // TODO remove this when isoTester/keys processing is fixed
    // isoTester is fixed, but CDK isomorphism tester still needs the workaround, should be fixed in
    // CDK nightly Mar 2010
    for (IBond bond : ac.bonds())
      if (bond.getFlag(CDKConstants.ISAROMATIC)) {
        for (IAtom a : bond.atoms()) a.setFlag(CDKConstants.ISAROMATIC, true);
        // in e.g. triazole the atoms are not set as aromatics, but bonds are!
        if (cleanKekuleBonds) bond.setOrder(Order.SINGLE);
      }
    // end of the workaround

    BitSet keys = new BitSet(nKeys);
    boolean res;
    for (int i = 0; i < nKeys; i++) {
      isoTester.setSequence(smartsQueries.get(i), sequences.get(i));
      res = isoTester.hasIsomorphism(ac);
      keys.set(i, res);
    }
    return (keys);
  }