diff --git a/cmake/modules/FindXercesC.cmake b/cmake/modules/FindXercesC.cmake index 1fb5e11424d..13ffc5bebe3 100644 --- a/cmake/modules/FindXercesC.cmake +++ b/cmake/modules/FindXercesC.cmake @@ -54,8 +54,10 @@ find_path( # Find the xerces libraries if (NOT XercesC_LIBRARIES) - find_library(XercesC_LIBRARY_RELEASE NAMES xerces-c xerces-c_3 xerces-c_3_1 xerces-c-3.1 xerces-c_3_2 xerces-c-3.2 ${_XercesC_PATHS} PATH_SUFFIXES lib) - find_library(XercesC_LIBRARY_DEBUG NAMES xerces-c xerces-c_3D xerces-c_3_1D xerces-c-3.1D xerces-c_3_2D xerces-c-3.2D ${_XercesC_PATHS} PATH_SUFFIXES lib) + ## The NAMES_PER_DIR option will make sure that the PATHS are the "outer for loop" when searching for the libraries. + ## We want that because we put the contrib as the first search path usually. + find_library(XercesC_LIBRARY_RELEASE NAMES xerces-c xerces-c_3 xerces-c_3_1 xerces-c-3.1 xerces-c_3_2 xerces-c-3.2 NAMES_PER_DIR ${_XercesC_PATHS} PATH_SUFFIXES lib) + find_library(XercesC_LIBRARY_DEBUG NAMES xerces-c_3D xerces-c_3_1D xerces-c-3.1D xerces-c_3_2D xerces-c-3.2D NAMES_PER_DIR ${_XercesC_PATHS} PATH_SUFFIXES lib) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(XercesC) diff --git a/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cpp b/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cpp index bea1fedaff7..c32d95af8cc 100644 --- a/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cpp +++ b/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFilter.cpp @@ -368,30 +368,42 @@ namespace OpenMS double MRMFeatureFilter::calculateIonRatio(const Feature & component_1, const Feature & component_2, const String & feature_name) { - double ratio = 0.0; - if (component_1.metaValueExists(feature_name) && component_2.metaValueExists(feature_name)) - { - double feature_1 = component_1.getMetaValue(feature_name); - double feature_2 = component_2.getMetaValue(feature_name); - ratio = feature_1/feature_2; - - } - else if (feature_name == "intensity") + // member feature_name access + if (feature_name == "intensity") { - const double feature_1 = component_1.getIntensity(); - const double feature_2 = component_2.getIntensity(); - ratio = feature_1 / feature_2; + if (component_1.metaValueExists("native_id") && component_2.metaValueExists("native_id")) + { + const double feature_1 = component_1.getIntensity(); + const double feature_2 = component_2.getIntensity(); + ratio = feature_1 / feature_2; + } + else if (component_1.metaValueExists("native_id")) + { + LOG_DEBUG << "Warning: no IS found for component " << component_1.getMetaValue("native_id") << "."; + const double feature_1 = component_1.getIntensity(); + ratio = feature_1; + } } - else if (component_1.metaValueExists(feature_name)) - { - LOG_INFO << "Warning: no ion pair found for transition_id " << component_1.getMetaValue("native_id") << "."; - double feature_1 = component_1.getMetaValue(feature_name); - ratio = feature_1; - } + // metaValue feature_name access else { - LOG_INFO << "Feature metaValue " << feature_name << " not found for transition_ids " << component_1.getMetaValue("native_id") << " and " << component_2.getMetaValue("native_id") << "."; + if (component_1.metaValueExists(feature_name) && component_2.metaValueExists(feature_name)) + { + const double feature_1 = component_1.getMetaValue(feature_name); + const double feature_2 = component_2.getMetaValue(feature_name); + ratio = feature_1/feature_2; + } + else if (component_1.metaValueExists(feature_name)) + { + LOG_DEBUG << "Warning: no IS found for component " << component_1.getMetaValue("native_id") << "."; + const double feature_1 = component_1.getMetaValue(feature_name); + ratio = feature_1; + } + else + { + LOG_DEBUG << "Feature metaValue " << feature_name << " not found for components " << component_1.getMetaValue("native_id") << " and " << component_2.getMetaValue("native_id") << "."; + } } return ratio; diff --git a/src/openms/source/ANALYSIS/OPENSWATH/PeakIntegrator.cpp b/src/openms/source/ANALYSIS/OPENSWATH/PeakIntegrator.cpp index e026c81ba99..ec1d590c33b 100644 --- a/src/openms/source/ANALYSIS/OPENSWATH/PeakIntegrator.cpp +++ b/src/openms/source/ANALYSIS/OPENSWATH/PeakIntegrator.cpp @@ -317,7 +317,7 @@ namespace OpenMS psm.baseline_delta_2_height = psm.slope_of_baseline / peak_height; // Source of tailing_factor and asymmetry_factor formulas: // USP 40 - NF 35 The United States Pharmacopeia and National Formulary - Supplementary - psm.tailing_factor = psm.width_at_5 / (peak_apex_pos - psm.start_position_at_5); + psm.tailing_factor = psm.width_at_5 / (2*(peak_apex_pos - psm.start_position_at_5)); psm.asymmetry_factor = (psm.end_position_at_10 - peak_apex_pos) / (peak_apex_pos - psm.start_position_at_10); return psm; } diff --git a/src/openms/source/ANALYSIS/QUANTITATION/AbsoluteQuantitation.cpp b/src/openms/source/ANALYSIS/QUANTITATION/AbsoluteQuantitation.cpp index a8dcd4ab52e..b26fdda075d 100644 --- a/src/openms/source/ANALYSIS/QUANTITATION/AbsoluteQuantitation.cpp +++ b/src/openms/source/ANALYSIS/QUANTITATION/AbsoluteQuantitation.cpp @@ -136,27 +136,41 @@ namespace OpenMS double AbsoluteQuantitation::calculateRatio(const Feature & component_1, const Feature & component_2, const String & feature_name) { double ratio = 0.0; - if (component_1.metaValueExists(feature_name) && component_2.metaValueExists(feature_name)) + // member feature_name access + if (feature_name == "intensity") { - double feature_1 = component_1.getMetaValue(feature_name); - double feature_2 = component_2.getMetaValue(feature_name); - ratio = feature_1/feature_2; - } - else if (feature_name == "intensity") - { - const double feature_1 = component_1.getIntensity(); - const double feature_2 = component_2.getIntensity(); - ratio = feature_1 / feature_2; - } - else if (component_1.metaValueExists(feature_name)) - { - LOG_DEBUG << "Warning: no IS found for component " << component_1.getMetaValue("native_id") << "."; - double feature_1 = component_1.getMetaValue(feature_name); - ratio = feature_1; + if (component_1.metaValueExists("native_id") && component_2.metaValueExists("native_id")) + { + const double feature_1 = component_1.getIntensity(); + const double feature_2 = component_2.getIntensity(); + ratio = feature_1 / feature_2; + } + else if (component_1.metaValueExists("native_id")) + { + LOG_DEBUG << "Warning: no IS found for component " << component_1.getMetaValue("native_id") << "."; + const double feature_1 = component_1.getIntensity(); + ratio = feature_1; + } } + // metaValue feature_name access else { - LOG_DEBUG << "Feature metaValue " << feature_name << " not found for components " << component_1.getMetaValue("native_id") << " and " << component_2.getMetaValue("native_id") << "."; + if (component_1.metaValueExists(feature_name) && component_2.metaValueExists(feature_name)) + { + const double feature_1 = component_1.getMetaValue(feature_name); + const double feature_2 = component_2.getMetaValue(feature_name); + ratio = feature_1/feature_2; + } + else if (component_1.metaValueExists(feature_name)) + { + LOG_DEBUG << "Warning: no IS found for component " << component_1.getMetaValue("native_id") << "."; + const double feature_1 = component_1.getMetaValue(feature_name); + ratio = feature_1; + } + else + { + LOG_DEBUG << "Feature metaValue " << feature_name << " not found for components " << component_1.getMetaValue("native_id") << " and " << component_2.getMetaValue("native_id") << "."; + } } return ratio; diff --git a/src/openms_gui/include/OpenMS/VISUAL/LayerData.h b/src/openms_gui/include/OpenMS/VISUAL/LayerData.h index ecc8b27e992..28d375d914a 100644 --- a/src/openms_gui/include/OpenMS/VISUAL/LayerData.h +++ b/src/openms_gui/include/OpenMS/VISUAL/LayerData.h @@ -138,6 +138,7 @@ namespace OpenMS gradient(), filters(), annotations_1d(), + peak_colors_1d(), modifiable(false), modified(false), label(L_NONE), @@ -308,6 +309,9 @@ namespace OpenMS /// Annotations of all spectra of the experiment (1D view) std::vector annotations_1d; + /// Peak colors of the currently shown spectrum + std::vector peak_colors_1d; + /// Flag that indicates if the layer data can be modified (so far used for features only) bool modifiable; diff --git a/src/openms_gui/source/VISUAL/Spectrum1DCanvas.cpp b/src/openms_gui/source/VISUAL/Spectrum1DCanvas.cpp index 25ca18da990..9fd6e4c20ff 100644 --- a/src/openms_gui/source/VISUAL/Spectrum1DCanvas.cpp +++ b/src/openms_gui/source/VISUAL/Spectrum1DCanvas.cpp @@ -748,6 +748,16 @@ namespace OpenMS { if (layer.filters.passes(spectrum, it - spectrum.begin())) { + + // use peak colors stored in the layer, if available + if (layer.peak_colors_1d.size() == spectrum.size()) + { + // find correct peak index + Size peak_index = std::distance(spectrum.begin(), it); + pen.setColor(layer.peak_colors_1d[peak_index]); + painter->setPen(pen); + } + dataToWidget(*it, end, layer.flipped); dataToWidget(it->getMZ(), 0.0f, begin, layer.flipped); diff --git a/src/openms_gui/source/VISUAL/TOPPViewIdentificationViewBehavior.cpp b/src/openms_gui/source/VISUAL/TOPPViewIdentificationViewBehavior.cpp index 70a08a00b18..934ad0cd533 100644 --- a/src/openms_gui/source/VISUAL/TOPPViewIdentificationViewBehavior.cpp +++ b/src/openms_gui/source/VISUAL/TOPPViewIdentificationViewBehavior.cpp @@ -935,24 +935,30 @@ namespace OpenMS ann_spectrum[i].getIntensity()); const String& label = labels[i]; QColor color; + QColor peak_color; + LayerData& annotated_layer = current_canvas->getCurrentLayer(); // XL-MS specific coloring of the labels, green for linear fragments and red for cross-linked fragments if (label.hasSubstring("[alpha|") || label.hasSubstring("[beta|")) { if (label.hasSubstring("|ci$")) { color = Qt::darkGreen; + peak_color = Qt::green; } else if (label.hasSubstring("|xi$")) { color = Qt::darkRed; + peak_color = Qt::red; } } else // different colors for left/right fragments (e.g. b/y ions) { color = (label.at(0) < 'n') ? Qt::darkRed : Qt::darkGreen; + peak_color = (label.at(0) < 'n') ? Qt::red : Qt::green; } Annotation1DItem* item = new Annotation1DPeakItem(position, label.toQString(), color); + annotated_layer.peak_colors_1d.push_back(peak_color); item->setSelected(false); tv_->getActive1DWidget()->canvas()->getCurrentLayer().getCurrentAnnotations().push_front(item); } diff --git a/src/pyOpenMS/CMakeLists.txt b/src/pyOpenMS/CMakeLists.txt index 746e83d9188..11427f1987b 100644 --- a/src/pyOpenMS/CMakeLists.txt +++ b/src/pyOpenMS/CMakeLists.txt @@ -353,17 +353,20 @@ if(WIN32) file(COPY ${_runtime} DESTINATION ${CMAKE_BINARY_DIR}/pyOpenMS/pyopenms NO_SOURCE_PERMISSIONS) endforeach() - set(FOUND_XERCES FALSE) - foreach(CONTRIB_PATH ${CMAKE_PREFIX_PATH}) - if(EXISTS ${CONTRIB_PATH}/lib/xerces-c_3_1.dll) - file(COPY ${CONTRIB_PATH}/lib/xerces-c_3_1.dll DESTINATION ${CMAKE_BINARY_DIR}/pyOpenMS/pyopenms) - set(FOUND_XERCES TRUE) - message(STATUS "found xerces-c-3_1_dll") - endif() - endforeach() - if(NOT FOUND_XERCES) - message(FATAL_ERROR "could not find xerces-c_3_1.dll in contrib dir") - endif() + find_package(XercesC) + if (XercesC_FOUND) + get_filename_component(XercesC_LIBRARY_RELEASE_DIR ${XercesC_LIBRARY_RELEASE} DIRECTORY) + get_filename_component(XercesC_LIBRARY_RELEASE_BASENAME ${XercesC_LIBRARY_RELEASE} NAME_WE) + message("-- Looking for Xerces in Path found by module: ${XercesC_LIBRARY_RELEASE_DIR}/${XercesC_LIBRARY_RELEASE_BASENAME}") + if(EXISTS "${XercesC_LIBRARY_RELEASE_DIR}/${XercesC_LIBRARY_RELEASE_BASENAME}.dll" ) + message("-- Found XercesC DLL. Assuming dynamic linkage. Copying.") + file(COPY "${XercesC_LIBRARY_RELEASE_DIR}/${XercesC_LIBRARY_RELEASE_BASENAME}.dll" DESTINATION ${CMAKE_BINARY_DIR}/pyOpenMS/pyopenms) + else() + message("-- XercesC found only with lib extension. Assuming static library. Not copying.") + endif() + else() + message(FATAL_ERROR "-- XercesC not found during pyOpenMS configure. If it went through the initial OpenMS configure, please report.") + endif() endif() find_boost() diff --git a/src/pyOpenMS/fix_pyopenms_dependencies_on_mac.sh b/src/pyOpenMS/fix_pyopenms_dependencies_on_mac.sh index f0f9f3724e7..ab709d872d8 100755 --- a/src/pyOpenMS/fix_pyopenms_dependencies_on_mac.sh +++ b/src/pyOpenMS/fix_pyopenms_dependencies_on_mac.sh @@ -8,7 +8,7 @@ # here we look at all of them and fix them using install_name_tool as seen below # -for TOFIX in $(find . -name pyopenms.so); do +for TOFIX in $(find . -name pyopenms*.so); do echo echo "fix $TOFIX now:" echo diff --git a/src/tests/class_tests/openms/source/AbsoluteQuantitation_test.cpp b/src/tests/class_tests/openms/source/AbsoluteQuantitation_test.cpp index 672b1761015..3a4702b3628 100644 --- a/src/tests/class_tests/openms/source/AbsoluteQuantitation_test.cpp +++ b/src/tests/class_tests/openms/source/AbsoluteQuantitation_test.cpp @@ -226,7 +226,7 @@ START_SECTION((double calculateRatio(const Feature & component_1, const Feature TEST_REAL_SIMILAR(absquant.calculateRatio(component_1,component_4,feature_name),5.0); TEST_REAL_SIMILAR(absquant.calculateRatio(component_3,component_4,feature_name),0.0); // feature_name == "intensity" - Feature component_5, component_6, component_7; + Feature component_5, component_6, component_7, component_8; feature_name = "intensity"; component_5.setMetaValue("native_id", "component5"); component_6.setMetaValue("native_id", "component6"); @@ -236,6 +236,7 @@ START_SECTION((double calculateRatio(const Feature & component_1, const Feature TEST_REAL_SIMILAR(absquant.calculateRatio(component_6, component_5, feature_name), 1.33333333333333); component_7.setMetaValue("native_id", "component7"); TEST_REAL_SIMILAR(absquant.calculateRatio(component_5, component_7, feature_name), inf); + TEST_REAL_SIMILAR(absquant.calculateRatio(component_5, component_8, feature_name), 3.0); END_SECTION START_SECTION((double calculateBias(const double & actual_concentration, const double & calculated_concentration))) diff --git a/src/tests/class_tests/openms/source/MRMFeatureFilter_test.cpp b/src/tests/class_tests/openms/source/MRMFeatureFilter_test.cpp index 66d9af44109..8bc902139c2 100644 --- a/src/tests/class_tests/openms/source/MRMFeatureFilter_test.cpp +++ b/src/tests/class_tests/openms/source/MRMFeatureFilter_test.cpp @@ -119,7 +119,8 @@ START_SECTION(double calculateIonRatio(const Feature & component_1, const Featur TEST_REAL_SIMILAR(mrmff.calculateIonRatio(component_1,component_4,feature_name),5.0); TEST_REAL_SIMILAR(mrmff.calculateIonRatio(component_3,component_4,feature_name),0.0); // feature_name == "intensity" - Feature component_5, component_6, component_7; + // feature_name == "intensity" + Feature component_5, component_6, component_7, component_8; feature_name = "intensity"; component_5.setMetaValue("native_id", "component5"); component_6.setMetaValue("native_id", "component6"); @@ -129,6 +130,7 @@ START_SECTION(double calculateIonRatio(const Feature & component_1, const Featur TEST_REAL_SIMILAR(mrmff.calculateIonRatio(component_6, component_5, feature_name), 1.33333333333333); component_7.setMetaValue("native_id", "component7"); TEST_REAL_SIMILAR(mrmff.calculateIonRatio(component_5, component_7, feature_name), inf); + TEST_REAL_SIMILAR(mrmff.calculateIonRatio(component_5, component_8, feature_name), 3.0); } END_SECTION diff --git a/src/tests/class_tests/openms/source/PeakIntegrator_test.cpp b/src/tests/class_tests/openms/source/PeakIntegrator_test.cpp index 362272b83a9..765574909ee 100644 --- a/src/tests/class_tests/openms/source/PeakIntegrator_test.cpp +++ b/src/tests/class_tests/openms/source/PeakIntegrator_test.cpp @@ -602,7 +602,7 @@ START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics( TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667) TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667) TEST_REAL_SIMILAR(psm.total_width, 0.540983333) - TEST_REAL_SIMILAR(psm.tailing_factor, 2.14352889450752) + TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376) TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539) TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454) TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033) @@ -652,7 +652,7 @@ START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics( TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667) TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667) TEST_REAL_SIMILAR(psm.total_width, 0.540983333) - TEST_REAL_SIMILAR(psm.tailing_factor, 2.14352889450752) + TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376) TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539) TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454) TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033) @@ -702,7 +702,7 @@ START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics( TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667) TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667) TEST_REAL_SIMILAR(psm.total_width, 0.540983333) - TEST_REAL_SIMILAR(psm.tailing_factor, 2.14352889450752) + TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376) TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539) TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454) TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033) @@ -752,7 +752,7 @@ START_SECTION(PeakShapeMetrics calculatePeakShapeMetrics( TEST_REAL_SIMILAR(psm.end_position_at_10, 2.779016667) TEST_REAL_SIMILAR(psm.end_position_at_50, 2.736266667) TEST_REAL_SIMILAR(psm.total_width, 0.540983333) - TEST_REAL_SIMILAR(psm.tailing_factor, 2.14352889450752) + TEST_REAL_SIMILAR(psm.tailing_factor, 1.07176444725376) TEST_REAL_SIMILAR(psm.asymmetry_factor, 1.16705821456539) TEST_REAL_SIMILAR(psm.slope_of_baseline, 2454) TEST_REAL_SIMILAR(psm.baseline_delta_2_height, 0.00253908735640033)