double WeightWrapper::getWeight(const EmpiricalFormula & ef) const { if (weight_mode_ == WeightWrapper::MONO) return ef.getMonoWeight(); else return ef.getAverageWeight(); }
EmpiricalFormula ef1("C2+"); TEST_EQUAL(ef1.getCharge(), 1) EmpiricalFormula ef2("C2+3"); TEST_EQUAL(ef2.getCharge(), 3) END_SECTION START_SECTION(bool isCharged() const) TEST_EQUAL(e_ptr->isCharged(), true) e_ptr->setCharge(0); TEST_EQUAL(e_ptr->isCharged(), false) END_SECTION START_SECTION(double getAverageWeight() const) EmpiricalFormula ef("C2"); const Element* e = db->getElement("C"); TEST_REAL_SIMILAR(ef.getAverageWeight(), e->getAverageWeight() * 2) END_SECTION START_SECTION(double getMonoWeight() const) EmpiricalFormula ef("C2"); const Element* e = db->getElement("C"); TEST_REAL_SIMILAR(ef.getMonoWeight(), e->getMonoWeight() * 2) TEST_REAL_SIMILAR(EmpiricalFormula("OH").getMonoWeight(), EmpiricalFormula("HO").getMonoWeight()); TEST_REAL_SIMILAR(EmpiricalFormula("").getMonoWeight(), 0.0) END_SECTION START_SECTION(String toString() const) EmpiricalFormula ef("C2H5"); String str = ef.toString(); TEST_EQUAL(String(str).hasSubstring("H5"), true) TEST_EQUAL(String(str).hasSubstring("C2"), true)
delete e_ptr; END_SECTION ResidueDB* db = ResidueDB::getInstance(); e_ptr = new Residue(*db->getResidue("LYS")); EmpiricalFormula h2o("H2O"); START_SECTION((static const EmpiricalFormula& getInternalToFull())) TEST_EQUAL(e_ptr->getInternalToFull(), h2o) END_SECTION TOLERANCE_ABSOLUTE(0.001) START_SECTION((static double getInternalToFullAverageWeight())) TEST_REAL_SIMILAR(e_ptr->getInternalToFullAverageWeight(), h2o.getAverageWeight()) END_SECTION START_SECTION((static double getInternalToFullMonoWeight())) TEST_REAL_SIMILAR(e_ptr->getInternalToFullMonoWeight(), 18.0106) END_SECTION START_SECTION((static const EmpiricalFormula& getNTerminalToFull())) TEST_EQUAL(e_ptr->getNTerminalToFull() == EmpiricalFormula("OH"), true) END_SECTION START_SECTION((static double getNTerminalToFullAverageWeight())) TEST_REAL_SIMILAR(e_ptr->getNTerminalToFullAverageWeight(), 17.0073) END_SECTION START_SECTION((static double getNTerminalToFullMonoWeight()))