void InfoBitRanker::accumulateVotes(const ExplicitBitVect &bv, unsigned int label) { RANGE_CHECK(0, label, d_classes-1); CHECK_INVARIANT(bv.getNumBits() == d_dims, "Incorrect bit vector size"); d_nInst += 1; d_clsCount[label] += 1; for (unsigned int i=0;i<bv.getNumBits();i++){ if( (*bv.dp_bits)[i] && (!dp_maskBits || dp_maskBits->getBit(i)) ){ d_counts[label][i] += 1; } } }
//' map a molecule to a maccs fingerprints //' //' @param xp a molecule //' @return a vector // [[Rcpp::export]] IntegerVector mol2maccs( SEXP xp){ int i; RWMol *mol = p_getMol(xp); if( mol ){ ExplicitBitVect *bv = MACCSFingerprints::getFingerprintAsBitVect ( *mol ); if(bv){ IntegerVector v = IntegerVector( bv->getNumBits ()); for( i = 0; i< bv->getNumBits ();i++ ){ v(i) = bv->getBit(i)?1:0; } return v; } } return IntegerVector(0); }
//' map a molecule to a morgan fingerprints (atom environement) //' //' @param xp a molecule //' @param radius radius of scaffold //' @param nBits final length //' @param useFeatures useFeatures //' @return a vector // [[Rcpp::export]] IntegerVector mol2morgan( SEXP xp , unsigned int radius=2,unsigned int nBits=2048, bool useFeatures=false){ // radius = 2 => ecfp4 2^2 // radius = 2 & useFeatures=True => fcfp4 int i; RWMol *mol = p_getMol(xp); if( mol ){ ExplicitBitVect *bv = MorganFingerprints::getFingerprintAsBitVect ( *mol , radius,nBits, 0,0,false,useFeatures,false,0); if(bv){ IntegerVector v = IntegerVector( bv->getNumBits ()); for( i = 0; i< bv->getNumBits ();i++ ){ v(i) = bv->getBit(i)?1:0; } delete bv; return v; } } return IntegerVector(0); }
void reaccsToFingerprint(struct reaccs_molecule_t *molPtr, ExplicitBitVect &res, unsigned int bitFlags = 32767U, bool isQuery = false, bool resetVect = true, unsigned int nBytes = 64) { PRECONDITION(molPtr, "bad molecule"); PRECONDITION(res.getNumBits() >= nBytes * 8U, "res too small"); if (resetVect) res.clearBits(); char *fingerprint = getFp(molPtr, bitFlags, isQuery, nBytes); for (unsigned int i = 0; i < nBytes; ++i) { char byte = fingerprint[i]; if (byte) { char mask = 1; for (int j = 0; j < 8; ++j) { if (byte & mask) { res.setBit(i * 8 + j); } mask = mask << 1; } } } MyFree(fingerprint); };
int NumBitsInCommon(const ExplicitBitVect& bv1, const ExplicitBitVect& bv2) { return bv1.getNumBits() - ((*bv1.dp_bits) ^ (*bv2.dp_bits)).count(); }