Exemplo n.º 1
0
int mol_feat_morgan_bfp(Mol *pMol, int radius, Bfp **ppBfp)
{
  assert(pMol);

  int rc = SQLITE_OK;
  *ppBfp = 0;

  try {
    std::vector<u32> invars(pMol->getNumAtoms());
    RDKit::MorganFingerprints::getFeatureInvariants(*pMol, invars);
    ExplicitBitVect *bv 
      = RDKit::MorganFingerprints::getFingerprintAsBitVect(*pMol, radius,
							   MORGAN_FP_SIZE,
							   &invars);
    if (bv) {
      *ppBfp = new Bfp(BitVectToBinaryText(*bv));
      delete bv;
    }
    else {
      rc = SQLITE_ERROR;
    }
  } 
  catch (...) {
    // unknown exception
    rc = SQLITE_ERROR;
  }
        
  return rc;
}
Exemplo n.º 2
0
// Figure out the CIP ranks for the atoms of a molecule
void assignAtomCIPRanks(const ROMol &mol, UINT_VECT &ranks) {
  PRECONDITION((!ranks.size() || ranks.size() >= mol.getNumAtoms()),
               "bad ranks size");
  if (!ranks.size()) ranks.resize(mol.getNumAtoms());
  unsigned int numAtoms = mol.getNumAtoms();
#ifndef USE_NEW_STEREOCHEMISTRY
  // get the initial invariants:
  DOUBLE_VECT invars(numAtoms, 0);
  buildCIPInvariants(mol, invars);
  iterateCIPRanks(mol, invars, ranks, false);
#else
  Canon::chiralRankMolAtoms(mol, ranks);
#endif

  // copy the ranks onto the atoms:
  for (unsigned int i = 0; i < numAtoms; ++i) {
    mol[i]->setProp(common_properties::_CIPRank, ranks[i], 1);
  }
}