vash
Fast genetic similarity estimation with hash tables
|
Similarity matrix. More...
#include <similarityMatrix.hpp>
Public Member Functions | |
SimilarityMatrix () noexcept=default | |
Default constructor. | |
SimilarityMatrix (const SimilarityMatrix &toCopy)=default | |
Copy constructor. | |
SimilarityMatrix & | operator= (const SimilarityMatrix &toCopy)=default |
Copy assignment operator. | |
SimilarityMatrix (SimilarityMatrix &&toMove) noexcept=default | |
Move constructor. | |
SimilarityMatrix & | operator= (SimilarityMatrix &&toMove) noexcept=default |
Move assignment operator. | |
~SimilarityMatrix ()=default | |
Destructor. | |
size_t | objectSize () const noexcept |
Object size in bytes. | |
size_t | nElements () const noexcept |
Number of elements in the matrix. | |
void | insert (const RowColIdx &rowColPair, const JaccardPair &jaccardCounts) |
Insert a value (updating the index) | |
void | merge (SimilarityMatrix &toMerge) |
Merge two matrices. | |
void | save (const std::string &outFileName, const size_t &nThreads, const std::string &locusNameFile="") const |
Save to file. | |
Static Public Member Functions | |
static size_t | elementSize () noexcept |
Matrix element size. | |
Similarity matrix.
A representation of a square symmetric similarity matrix, excluding the diagonal. Stores only the values present in the lower triangle by row. The representation is memory efficient if the matrix is sparse and attempts to strike a compromise between memory use and matrix manipulation speed.
|
default |
Copy constructor.
[in] | toCopy | object to copy |
|
defaultnoexcept |
Move constructor.
[in] | toMove | object to move |
|
inlinestaticnoexcept |
Matrix element size.
void BayesicSpace::SimilarityMatrix::insert | ( | const RowColIdx & | rowColPair, |
const JaccardPair & | jaccardCounts ) |
Insert a value (updating the index)
Inserts a new value into the matrix. Addresses the lower triangle of the similarity matrix, therefore the row index must be larger than the column index. If not, the values are swapped. If the indexes are equal or the row index is 0, throws an exception. Inserts a quantized value of the Jaccard similarity calculated from the intersection and union counts provided.
[in] | rowColPair | row and index pair |
[in] | jaccardCounts | intersection and union counts for Jaccard similarity |
void BayesicSpace::SimilarityMatrix::merge | ( | SimilarityMatrix & | toMerge | ) |
Merge two matrices.
Merge a matrix with the current object, destroying the donor object. Duplicated indexes are discarded even if they differ in similarity values.
[in] | toMerge | object to merge |
|
inlinenoexcept |
Number of elements in the matrix.
|
inlinenoexcept |
Object size in bytes.
|
default |
|
defaultnoexcept |
void BayesicSpace::SimilarityMatrix::save | ( | const std::string & | outFileName, |
const size_t & | nThreads, | ||
const std::string & | locusNameFile = "" ) const |
Save to file.
Uses multi-threaded data prep to speed up saving. If the output file already exists, appends to it.
[in] | outFileName | output file name |
[in] | nThreads | number of threads |
[in] | locusNameFile | name of the file with locus names (empty by default) |