Esempio n. 1
0
double Bond::getValenceContrib(const Atom *atom) const {
  switch(getBondType()){
  case UNSPECIFIED: return 0; break;
  case IONIC: return 0; break;
  case SINGLE: return 1; break;
  case DOUBLE: return 2; break;
  case TRIPLE: return 3; break;
  case QUADRUPLE: return 4; break;
  case QUINTUPLE: return 5; break;
  case HEXTUPLE: return 6; break;
  case ONEANDAHALF: return 1.5; break;
  case TWOANDAHALF: return 2.5; break;
  case THREEANDAHALF: return 3.5; break;
  case FOURANDAHALF: return 4.5; break;
  case FIVEANDAHALF: return 5.5; break;
  case AROMATIC: return 1.5; break;
  case DATIVEONE:
    if(atom->getIdx()==getEndAtomIdx())return 1.0;
    else return 0.0;
    break;
  case DATIVE:
    if(atom->getIdx()==getEndAtomIdx())return 1.0;
    else return 0.0;
    break;
  case ZERO: return 0; break; 
  default:
    UNDER_CONSTRUCTION("Bad bond type");

  }
}
Esempio n. 2
0
  d_saps.push_back({aIdx, lvIdx, idStr});
}

//! check if the bond is SubstanceGroup XBOND or CBOND
SubstanceGroup::BondType SubstanceGroup::getBondType(
    unsigned int bondIdx) const {
  PRECONDITION(
      std::find(d_bonds.begin(), d_bonds.end(), bondIdx) != d_bonds.end(),
      "bond is not part of the SubstanceGroup")

  auto bond = dp_mol->getBondWithIdx(bondIdx);
  bool begin_atom_in_sgroup =
      std::find(d_atoms.begin(), d_atoms.end(), bond->getBeginAtomIdx()) !=
      d_atoms.end();
  bool end_atom_in_sgroup = std::find(d_atoms.begin(), d_atoms.end(),
                                      bond->getEndAtomIdx()) != d_atoms.end();

  if (begin_atom_in_sgroup && end_atom_in_sgroup) {
    return SubstanceGroup::BondType::CBOND;
  } else if (begin_atom_in_sgroup || end_atom_in_sgroup) {
    return SubstanceGroup::BondType::XBOND;
  } else {
    std::ostringstream errout;
    errout << "Neither beginning nor ending atoms of bond " << bond->getIdx()
           << " is in this SubstanceGroup.";
    throw SubstanceGroupException(errout.str());
  }
}

bool SubstanceGroupChecks::isValidType(const std::string &type) {
  return std::find(SubstanceGroupChecks::sGroupTypes.begin(),