Skip to content

Commit

Permalink
Merge branch 'more_doc' of https://github.com/cbielow/OpenMS into mor…
Browse files Browse the repository at this point in the history
…e_doc
  • Loading branch information
cbielow committed Mar 18, 2024
2 parents a929d59 + 9643475 commit f8d0db3
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 187 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/openms_ci_matrix_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,14 @@ jobs:
fi
fi
if [[ "${{ matrix.os }}" == macos-* ]]; then
if [[ "${{ matrix.os }}" == macos-* ]]; then
## Needed for Qt. Install before to overwrite the default softlinks on the GH runners
brew install python3 --force --overwrite
brew install --quiet ccache autoconf automake libtool ninja && brew link --overwrite ccache
brew install libsvm xerces-c boost eigen sqlite coinutils cbc cgl clp qt@5
echo "cmake_prefix=$(brew --prefix qt@5)/lib/cmake;$(brew --prefix qt@5)" >> $GITHUB_OUTPUT
echo "Qt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5" >> $GITHUB_ENV
if [[ "${{ steps.set-vars.outputs.pkg_type }}" != "none" ]]; then
brew install python3 --force --overwrite
brew install --quiet doxygen ghostscript graphviz
fi
fi
Expand Down
6 changes: 3 additions & 3 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ if(ENABLE_DOCS)
#------------------------------------------------------------------------------
# add virtual dependency of doc_minimal on TOPP
# this is not necessary but defers the generation of doc_minimal to a later
# stage to avoid confusion if doc_minimal is build first
# stage to avoid confusion if doc_minimal is built first
add_dependencies(doc_minimal TOPP)

if (DOXYGEN_DOT_FOUND OR DOXYGEN_DOT_EXECUTABLE)
Expand Down Expand Up @@ -381,9 +381,9 @@ if(ENABLE_DOCS)
message(STATUS "Build C++ tutorials: ${BUILD_EXAMPLES} (-DBUILD_EXAMPLES=ON/OFF);")
if(BUILD_EXAMPLES AND "${PACKAGE_TYPE}" STREQUAL "none")
add_subdirectory(code_examples)
message(STATUS " --> Tutorials in '${PROJECT_SOURCE_DIR}/code_examples' will be build!")
message(STATUS " --> Tutorials in '${PROJECT_SOURCE_DIR}/code_examples' will be built!")
else()
message(STATUS " --> Tutorials in '${PROJECT_SOURCE_DIR}/code_examples' will NOT be build! (since PACKAGE_TYPE=${PACKAGE_TYPE}, but must be 'none')")
message(STATUS " --> Tutorials in '${PROJECT_SOURCE_DIR}/code_examples' will NOT be built! (since PACKAGE_TYPE=${PACKAGE_TYPE}, but must be 'none')")
endif()


Expand Down
100 changes: 35 additions & 65 deletions src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ namespace OpenMS
* @ingroup Datastructures
*/
template <typename Value>
class Matrix
class Matrix : public Eigen::Matrix<Value, Eigen::Dynamic, Eigen::Dynamic>
{
public:
/**
* @brief Eigen matrix type.
*/
using EigenMatrixType = Eigen::Matrix<Value, Eigen::Dynamic, Eigen::Dynamic>;
using EigenMatrixType::fill;
using EigenMatrixType::innerStride;
using EigenMatrixType::outerStride;

// Default constructor. Creates the "null" matrix.
Matrix() = default;
Expand All @@ -61,33 +64,9 @@ namespace OpenMS
* @param cols Number of columns in the matrix.
* @param value Initial value to fill the matrix.
*/
Matrix(Size rows, Size cols, Value value = Value()) : data_(rows, cols)
Matrix(Size rows, Size cols, Value value = Value()) : EigenMatrixType(rows, cols)
{
data_.fill(value);
}

/**
* @brief Accessor to get the value at the specified position in the matrix.
*
* @param i Row index.
* @param j Column index.
* @return reference to the value at the specified position.
*/
const Value& operator()(int i, int j) const
{
return data_(i, j);
}

/**
* @brief Accessor to get the value at the specified position in the matrix.
*
* @param i Row index.
* @param j Column index.
* @return const reference to the value at the specified position.
*/
Value& operator()(int i, int j)
{
return data_(i, j);
fill(value);
}

/*
Expand All @@ -96,7 +75,7 @@ namespace OpenMS
*/
const Value& getValue(size_t const i, size_t const j) const
{
return data_(i, j);
return *this(i, j);
}

/*
Expand All @@ -105,7 +84,7 @@ namespace OpenMS
*/
Value& getValue(size_t const i, size_t const j)
{
return data_(i, j);
return this->operator()(i, j);
}

/*
Expand All @@ -114,23 +93,28 @@ namespace OpenMS
*/
void setValue(size_t const i, size_t const j, const Value& value)
{
data_(i, j) = value;
this->operator()(i, j) = value;
}

/**
* @brief Number of rows
*/
size_t rows() const
{
return data_.rows();
// apparently needed for cython
void resize(size_t rows, size_t cols)
{
EigenMatrixType::resize(rows, cols);
}

/**
* @brief Number of columns
*/
size_t cols() const
{
return data_.cols();
int innerStride() const
{
return EigenMatrixType::innerStride();
}

int outerStride() const
{
return EigenMatrixType::outerStride();
}

bool rowMajor() const
{
return EigenMatrixType::IsRowMajor;
}

/**
Expand All @@ -145,15 +129,15 @@ namespace OpenMS
* @tparam COLS The number of columns in the matrix.
* @param array The 2D array containing the values to be assigned to the matrix.
*/
template <typename T, int ROWS, int COLS>
template <typename T, long int ROWS, long int COLS>
void setMatrix(T const (&array)[ROWS][COLS])
{
data_.resize(ROWS, COLS);
resize(ROWS, COLS);
for (int i = 0; i < ROWS; ++i)
{
for (int j = 0; j < COLS; ++j)
{
data_(i, j) = array[i][j];
this->operator()(i, j) = array[i][j];
}
}
}
Expand All @@ -164,20 +148,8 @@ namespace OpenMS
* @param rhs The matrix to be compared.
* @return True if matrices are equal, false otherwise.
*/
bool operator==(const Matrix& rhs) const
{
return data_ == rhs.data_;
}

/**
* @brief Get the total number of elements in the matrix. Useful for checking if the matrix is empty
* or iterating over raw data.
*
* @return The total number of elements.
*/
size_t size() const
{
return data_.size();
bool operator==(const Matrix& rhs) const {
return EigenMatrixType::operator==(rhs);
}

/**
Expand All @@ -189,9 +161,9 @@ namespace OpenMS
*/
friend std::ostream& operator<<(std::ostream& os, const Matrix<Value>& matrix)
{
for (size_t i = 0; i < matrix.rows(); ++i)
for (long int i = 0; i < matrix.rows(); ++i)
{
for (size_t j = 0; j < matrix.cols(); ++j)
for (long int j = 0; j < matrix.cols(); ++j)
{
os << std::setprecision(6) << std::setw(6) << matrix(i, j) << ' ';
}
Expand All @@ -207,7 +179,7 @@ namespace OpenMS
*/
const EigenMatrixType& getEigenMatrix() const
{
return data_;
return *this;
}

/**
Expand All @@ -217,9 +189,7 @@ namespace OpenMS
*/
EigenMatrixType& getEigenMatrix()
{
return data_;
return *this;
}
private:
EigenMatrixType data_; ///< Eigen matrix storing the actual data.
};
} // namespace OpenMS
48 changes: 24 additions & 24 deletions src/openms/source/ANALYSIS/OPENSWATH/MRMScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_matrix_max_peak_.rows() > 1, "Expect cross-correlation matrix of at least 2x2");

OpenSwath::mean_and_stddev msc;
for (std::size_t i = 0; i < xcorr_matrix_max_peak_.rows(); i++)
for (long int i = 0; i < xcorr_matrix_max_peak_.rows(); i++)
{
for (std::size_t j = i; j < xcorr_matrix_max_peak_.rows(); j++)
for (long int j = i; j < xcorr_matrix_max_peak_.rows(); j++)
{
// first is the X value (RT), should be an int
//deltas.push_back(std::abs(Scoring::xcorrArrayGetMaxPeak(xcorr_matrix_.getValue(i, j))->first));
Expand All @@ -281,7 +281,7 @@ namespace OpenSwath
double weights = 0;
#endif
double deltas{0};
for (std::size_t i = 0; i < xcorr_matrix_max_peak_.rows(); i++)
for (long int i = 0; i < xcorr_matrix_max_peak_.rows(); i++)
{
deltas += (xcorr_matrix_max_peak_(i, i)//std::abs(Scoring::xcorrArrayGetMaxPeak(xcorr_matrix_.getValue(i, i))->first)
* normalized_library_intensity[i]
Expand All @@ -291,7 +291,7 @@ namespace OpenSwath
normalized_library_intensity[i] * normalized_library_intensity[i] << std::endl;
weights += normalized_library_intensity[i] * normalized_library_intensity[i];
#endif
for (std::size_t j = i + 1; j < xcorr_matrix_max_peak_.rows(); j++)
for (long int j = i + 1; j < xcorr_matrix_max_peak_.rows(); j++)
{
// first is the X value (RT), should be an int
deltas += (xcorr_matrix_max_peak_(i, j)//std::abs(Scoring::xcorrArrayGetMaxPeak(xcorr_matrix_.getValue(i, j))->first)
Expand All @@ -318,10 +318,10 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_contrast_matrix_.rows() > 0 && xcorr_contrast_matrix_.cols() > 1, "Expect cross-correlation matrix of at least 1x2");

std::vector<double > deltas;
for (std::size_t i = 0; i < xcorr_contrast_matrix_.rows(); i++)
for (long int i = 0; i < xcorr_contrast_matrix_.rows(); i++)
{
double deltas_id = 0;
for (std::size_t j = 0; j < xcorr_contrast_matrix_.cols(); j++)
for (long int j = 0; j < xcorr_contrast_matrix_.cols(); j++)
{
// first is the X value (RT), should be an int
auto x = Scoring::xcorrArrayGetMaxPeak(xcorr_contrast_matrix_(i, j));
Expand All @@ -341,9 +341,9 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_precursor_matrix_.rows() > 1, "Expect cross-correlation matrix of at least 2x2");

OpenSwath::mean_and_stddev msc;
for (std::size_t i = 0; i < xcorr_precursor_matrix_.rows(); i++)
for (long int i = 0; i < xcorr_precursor_matrix_.rows(); i++)
{
for (std::size_t j = i; j < xcorr_precursor_matrix_.rows(); j++)
for (long int j = i; j < xcorr_precursor_matrix_.rows(); j++)
{
// first is the X value (RT), should be an int
auto x = Scoring::xcorrArrayGetMaxPeak(xcorr_precursor_matrix_(i, j));
Expand Down Expand Up @@ -416,9 +416,9 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_precursor_combined_matrix_.rows() > 1, "Expect cross-correlation matrix of at least 2x2");

OpenSwath::mean_and_stddev msc;
for (std::size_t i = 0; i < xcorr_precursor_combined_matrix_.rows(); i++)
for (long int i = 0; i < xcorr_precursor_combined_matrix_.rows(); i++)
{
for (std::size_t j = i; j < xcorr_precursor_combined_matrix_.rows(); j++)
for (long int j = i; j < xcorr_precursor_combined_matrix_.rows(); j++)
{
// first is the X value (RT), should be an int
auto x = Scoring::xcorrArrayGetMaxPeak(xcorr_precursor_combined_matrix_(i, j));
Expand Down Expand Up @@ -448,9 +448,9 @@ namespace OpenSwath

size_t element_number{0};
double intensities{0};
for (std::size_t i = 0; i < xcorr_matrix_max_peak_sec_.rows(); i++)
for (long int i = 0; i < xcorr_matrix_max_peak_sec_.rows(); i++)
{
for (std::size_t j = i; j < xcorr_matrix_max_peak_sec_.rows(); j++)
for (long int j = i; j < xcorr_matrix_max_peak_sec_.rows(); j++)
{
// second is the Y value (intensity)
intensities += xcorr_matrix_max_peak_sec_(i, j);
Expand All @@ -469,7 +469,7 @@ namespace OpenSwath
// see _calc_weighted_xcorr_shape_score in MRM_pgroup.pm
// -- they only multiply up the intensity once
double intensities{0};
for (std::size_t i = 0; i < xcorr_matrix_max_peak_sec_.rows(); i++)
for (long int i = 0; i < xcorr_matrix_max_peak_sec_.rows(); i++)
{
intensities += (xcorr_matrix_max_peak_sec_(i, i)
* normalized_library_intensity[i]
Expand All @@ -478,7 +478,7 @@ namespace OpenSwath
std::cout << "_xcorr_weighted " << i << " " << i << " " << Scoring::xcorrArrayGetMaxPeak(xcorr_matrix_[i][i])->second << " weight " <<
normalized_library_intensity[i] * normalized_library_intensity[i] << std::endl;
#endif
for (std::size_t j = i + 1; j < xcorr_matrix_max_peak_sec_.rows(); j++)
for (long int j = i + 1; j < xcorr_matrix_max_peak_sec_.rows(); j++)
{
intensities += (xcorr_matrix_max_peak_sec_(i, j)
* normalized_library_intensity[i]
Expand All @@ -504,10 +504,10 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_contrast_matrix_max_peak_sec_.rows() > 0 && xcorr_contrast_matrix_max_peak_sec_.cols() > 1, "Expect cross-correlation matrix of at least 1x2");

std::vector<double> intensities;
for (std::size_t i = 0; i < xcorr_contrast_matrix_max_peak_sec_.rows(); i++)
for (long int i = 0; i < xcorr_contrast_matrix_max_peak_sec_.rows(); i++)
{
double intensities_id = 0;
for (std::size_t j = 0; j < xcorr_contrast_matrix_max_peak_sec_.cols(); j++)
for (long int j = 0; j < xcorr_contrast_matrix_max_peak_sec_.cols(); j++)
{
// second is the Y value (intensity)
intensities_id += xcorr_contrast_matrix_max_peak_sec_(i,j);
Expand All @@ -523,9 +523,9 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_precursor_matrix_.rows() > 1, "Expect cross-correlation matrix of at least 2x2");

double intensities{0};
for(size_t i = 0; i < xcorr_precursor_matrix_.rows(); i++)
for(long int i = 0; i < xcorr_precursor_matrix_.rows(); i++)
{
for(size_t j = i; j < xcorr_precursor_matrix_.cols(); j++)
for(long int j = i; j < xcorr_precursor_matrix_.cols(); j++)
{
auto x = Scoring::xcorrArrayGetMaxPeak(xcorr_precursor_matrix_(i, j));
intensities += x->second;
Expand Down Expand Up @@ -573,9 +573,9 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(xcorr_precursor_combined_matrix_.rows() > 1, "Expect cross-correlation matrix of at least 2x2");

double intensities{0};
for(size_t i = 0; i < xcorr_precursor_combined_matrix_.rows(); i++)
for(long int i = 0; i < xcorr_precursor_combined_matrix_.rows(); i++)
{
for(size_t j = i; j < xcorr_precursor_combined_matrix_.cols(); j++)
for(long int j = i; j < xcorr_precursor_combined_matrix_.cols(); j++)
{
auto x = Scoring::xcorrArrayGetMaxPeak(xcorr_precursor_combined_matrix_(i, j));
intensities += x->second;
Expand Down Expand Up @@ -837,7 +837,7 @@ namespace OpenSwath
OPENSWATH_PRECONDITION(mi_matrix_.rows() > 1, "Expect mutual information matrix of at least 2x2");

double mi_scores{0};
for (std::size_t i = 0; i < mi_matrix_.rows(); i++)
for (long int i = 0; i < mi_matrix_.rows(); i++)
{
mi_scores += mi_matrix_(i, i)
* normalized_library_intensity[i]
Expand All @@ -846,7 +846,7 @@ namespace OpenSwath
std::cout << "_mi_weighted " << i << " " << i << " " << mi_matrix_[i][i] << " weight " <<
normalized_library_intensity[i] * normalized_library_intensity[i] << std::endl;
#endif
for (std::size_t j = i + 1; j < mi_matrix_.rows(); j++)
for (long int j = i + 1; j < mi_matrix_.rows(); j++)
{
mi_scores += mi_matrix_(i, j)
* normalized_library_intensity[i]
Expand Down Expand Up @@ -900,10 +900,10 @@ namespace OpenSwath

std::vector<double> mi_scores;
mi_scores.resize(mi_contrast_matrix_.rows());
for (std::size_t i = 0; i < mi_contrast_matrix_.rows(); i++)
for (long int i = 0; i < mi_contrast_matrix_.rows(); i++)
{
double mi_scores_id = 0;
for (std::size_t j = 0; j < mi_contrast_matrix_.cols(); j++)
for (long int j = 0; j < mi_contrast_matrix_.cols(); j++)
{
mi_scores_id += mi_contrast_matrix_(i, j);
}
Expand Down
Loading

0 comments on commit f8d0db3

Please sign in to comment.