bool overlaps_(const Feature& feature, const double rt, const double pc_mz, const double rt_tolerance) const { if (feature.getConvexHulls().empty()) { LOG_WARN << "HighResPrecursorMassCorrector warning: at least one feature has no convex hull - omitting feature for matching" << std::endl; } // get bounding box and extend by retention time tolerance DBoundingBox<2> box = feature.getConvexHull().getBoundingBox(); DPosition<2> extend_rt(rt_tolerance, 0.01); box.setMin(box.minPosition() - extend_rt); box.setMax(box.maxPosition() + extend_rt); DPosition<2> pc_pos(rt, pc_mz); if (box.encloses(pc_pos)) { return true; } else { return false; } }
double ITRAQLabeler::getRTProfileIntensity_(const Feature& f, const double MS2_RT_time) const { // compute intensity correction factor for feature from RT profile const DoubleList& elution_bounds = f.getMetaValue("elution_profile_bounds"); const DoubleList& elution_ints = f.getMetaValue("elution_profile_intensities"); // check that RT is within the elution bound: OPENMS_POSTCONDITION(f.getConvexHull().getBoundingBox().encloses(MS2_RT_time, f.getMZ()), "The MS2 spectrum has wrong parent features! The feature does not touch the spectrum's RT!") if (MS2_RT_time < elution_bounds[1] || elution_bounds[3] < MS2_RT_time) { LOG_WARN << "Warn: requesting MS2 RT for " << MS2_RT_time << ", but bounds are only from [" << elution_bounds[1] << "," << elution_bounds[3] << "]\n"; return 0; } // do linear interpolation double width = elution_bounds[3] - elution_bounds[1]; double offset = MS2_RT_time - elution_bounds[1]; Int index = floor(offset / (width / (elution_ints.size() - 1)) + 0.5); OPENMS_POSTCONDITION(index < (Int)elution_ints.size(), "Wrong index computation! (Too large)") return elution_ints[index]; }
TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[0][0],1.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[0][1],2.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[1][0],3.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[1][1],4.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[0][0],0.5) TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[0][1],0.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[1][0],1.0) TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[1][1],1.0) END_SECTION START_SECTION((ConvexHull2D& getConvexHull() const)) Feature tmp; tmp.setConvexHulls(hulls); //check if the bounding box is ok DBoundingBox<2> bb = tmp.getConvexHull().getBoundingBox(); TEST_REAL_SIMILAR(bb.minPosition()[0],0.5) TEST_REAL_SIMILAR(bb.minPosition()[1],0.0) TEST_REAL_SIMILAR(bb.maxPosition()[0],3.0) TEST_REAL_SIMILAR(bb.maxPosition()[1],4.0) //check the convex hull points TEST_EQUAL(tmp.getConvexHull().getHullPoints().size(),4) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[0][0],0.5) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[0][1],0.0) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[1][0],3.0) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[1][1],0.0) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[2][0],3.0) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[2][1],4.0) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[3][0],0.5) TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[3][1],4.0)