예제 #1
0
 unsigned int DiscreteValueVect::getVal(unsigned int i) const {
   if(i >= d_length){
     throw IndexErrorException(i);
   }
   unsigned int shift = d_bitsPerVal*(i%d_valsPerInt);
   unsigned int intId = i/d_valsPerInt;
   return ( (d_data[intId] >> shift) & d_mask);
 }
예제 #2
0
 void UniformGrid3D::getGridIndices(unsigned int idx,unsigned int &xi, unsigned int &yi, unsigned int &zi) const {
   if(idx >= d_numX*d_numY*d_numZ){
     throw IndexErrorException(idx);
   }
   xi = idx%d_numX;
   yi = (idx%(d_numX*d_numY))/d_numX;
   zi = idx/(d_numX*d_numY);
 }
예제 #3
0
// """ -------------------------------------------------------
//
//  Operator[]
//   Returns the state of the ith bit.
//
//   **C++ NOTE** The state of BitVects cannot be changed using
//    operator&.  So this will not work:
//     SBV[i] = 0;
//    In Python this type of assignment **is** valid.
//
// """ -------------------------------------------------------
bool SparseBitVect::operator[](const unsigned int which) const {
  if (which >= d_size) {
    throw IndexErrorException(which);
  }
  if (dp_bits->count(which))
    return true;
  else
    return false;
}
예제 #4
0
// """ -------------------------------------------------------
//
// getBit(const IntSetIter which)  (C++ SPECIFIC)
//   Returns the state of bit which
//
// """ -------------------------------------------------------
bool SparseBitVect::getBit(const IntSetIter which) const {
  if (*which < 0 || static_cast<unsigned int>(*which) >= d_size) {
    throw IndexErrorException(*which);
  }
  if (dp_bits->count(*which))
    return true;
  else
    return false;
}
예제 #5
0
// """ -------------------------------------------------------
//
// setBit(const IntSetIter which)  (C++ SPECIFIC)
//  Sets bit which to be on.
//
//  Returns the original state of the bit
//
// """ -------------------------------------------------------
bool SparseBitVect::setBit(const IntSetIter which) {
  if (!dp_bits) {
    throw ValueErrorException("BitVect not properly initialized.");
  }
  std::pair<IntSetIter, bool> res;
  if (*which < 0 || static_cast<unsigned int>(*which) >= d_size) {
    throw IndexErrorException(*which);
  }
  res = dp_bits->insert(*which);
  return !(res.second);
}
예제 #6
0
 Point3D UniformGrid3D::getGridPointLoc(unsigned int pointId) const {
   if(pointId >= d_numX*d_numY*d_numZ){
     throw IndexErrorException(pointId);
   }
   Point3D res;
   res.x = (pointId%d_numX)*d_spacing;
   res.y = ((pointId%(d_numX*d_numY))/d_numX)*d_spacing;
   res.z = (pointId/(d_numX*d_numY))*d_spacing;
   res += d_offSet; //d_origin;
   return res;
 }
예제 #7
0
 bool ExplicitBitVect::unsetBit(const unsigned int which){
   if(which >= d_size){
     throw IndexErrorException(which);
   }
   if((bool)(*dp_bits)[which]){
     (*dp_bits)[which] = 0;
     --d_numOnBits;
     return true;
   } else {
     return false;
   }
 };
예제 #8
0
 void DiscreteValueVect::setVal(unsigned int i, unsigned int val) {
   if(i >= d_length){
     throw IndexErrorException(i);
   }
   if ((val & d_mask) != val) {
     throw ValueErrorException("Value out of range");
   }
   unsigned int shift = d_bitsPerVal*(i%d_valsPerInt);
   unsigned int intId = i/d_valsPerInt;
   unsigned int mask = ((1<<d_bitsPerVal) -1) << shift;
   mask = ~mask;
   d_data[intId] = (d_data[intId]&mask)|(val << shift);
 }
예제 #9
0
// """ -------------------------------------------------------
//
//  Sets bit which to be off.
//
//  Returns the original state of the bit
//
// """ -------------------------------------------------------
bool SparseBitVect::unsetBit(const unsigned int which) {
  if (!dp_bits) {
    throw ValueErrorException("BitVect not properly initialized.");
  }
  if (which >= d_size) {
    throw IndexErrorException(which);
  }

  if (dp_bits->count(which)) {
    dp_bits->erase(dp_bits->find(which));
    return true;
  } else {
    return false;
  }
}
예제 #10
0
FeatSPtr getMolFeature(const MolChemicalFeatureFactory &factory,
                       const ROMol &mol, int idx, std::string includeOnly = "",
                       bool recompute = true) {
  static FeatSPtrList feats;
  if (recompute) {
    feats = factory.getFeaturesForMol(mol, includeOnly.c_str());
  }
  if (idx < 0 || idx >= static_cast<int>(feats.size())) {
    throw IndexErrorException(idx);
  }

  FeatSPtrList_I fi = feats.begin();
  for (int i = 0; i < idx; ++i) {
    ++fi;
  }
  return (*fi);
}
예제 #11
0
파일: rdchem.cpp 프로젝트: ASKCOS/rdkit
void tossit() { throw IndexErrorException(1); }
예제 #12
0
 bool ExplicitBitVect::getBit(const unsigned int which) const {
   if(which >= d_size){
     throw IndexErrorException(which);
   }
   return((bool)(*dp_bits)[which]);
 };