Skip to content

Commit d906f94

Browse files
James BarbettiJames Barbetti
James Barbetti
authored and
James Barbetti
committed
Added doxygen-style comments to flatmatrix.cpp.
1 parent e1bf4d7 commit d906f94

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

flatmatrix.cpp

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
#include <fstream> //for std::ofstream
4141
#endif
4242

43-
FlatMatrix::FlatMatrix(): rowCount(0), distanceMatrix(nullptr), borrowed(false) {
43+
FlatMatrix::FlatMatrix(): rowCount(0), distanceMatrix(nullptr),
44+
borrowed(false) {
4445
}
4546

4647
FlatMatrix::FlatMatrix(const StrVector& sequence_names,
@@ -77,6 +78,10 @@ void FlatMatrix::setSequenceName(intptr_t i,
7778
sequenceNames[i] = new_name;
7879
}
7980

81+
/**
82+
* @brief set the rank of the matrix and make it square
83+
* @param rows
84+
*/
8085
void FlatMatrix::setSize(intptr_t rows) {
8186
if (!borrowed) {
8287
delete [] distanceMatrix;
@@ -107,6 +112,21 @@ void FlatMatrix::addCluster(const std::string& clusterName) {
107112
sequenceNames.emplace_back(clusterName);
108113
}
109114

115+
/**
116+
* @brief Write a distance matrix, to the specified file, with the
117+
* specified format, using the specified precision for representing
118+
* distances, the specified (gzip/zlib) compression. Possibly
119+
* reporting progress as the file is written.
120+
* @param format - "upper", "lower", or "square"
121+
* OR "upper.gz", "lower.gz", or "square.gz",
122+
* to ask for gzip compression.
123+
* @param precision - the number of digits after the decimal point
124+
* @param compression_level - the level of compression (0 through 9)
125+
* @param report_progress - true if progress is to be reported
126+
* @param file_name - the path of the file
127+
* @return true - on success
128+
* @return false - on failure (error messages will be written to std::cerr)
129+
*/
110130
bool FlatMatrix::writeToDistanceFile(const std::string& format,
111131
int precision,
112132
int compression_level,
@@ -159,6 +179,25 @@ bool FlatMatrix::writeToDistanceFile(const std::string& format,
159179
return true;
160180
}
161181

182+
/**
183+
* @brief write a distance matrix, in the specifed format, with the specified
184+
* precision, to an output stream (possibly reporting progress while
185+
* doing so)
186+
* @tparam S - the type of the output stream
187+
* @tparam P - the type of the progress-display instance
188+
* that progress points to
189+
* @param format - "upper", "lower", or "square" (no ".gz" on the end!)
190+
* @param precision - the number of digits to use, after the decimal point
191+
* for each distance in the distance matrix.
192+
* if this is more than 10, it will be ignored and 10
193+
* will be used.
194+
* @param out - the output stream (might by an std::iostream or a
195+
* std::stringstream)
196+
* @param progress - true if progress is to be reported as the write proceeds
197+
* @note Doesn't detect errors. Exceptions will be thrown.
198+
* The caller expects any such exceptions will be caught by
199+
* a catch ( const std::ios::failure & ) {} block.
200+
*/
162201
template <class S, class P>
163202
void FlatMatrix::writeDistancesToOpenFile(const std::string& format,
164203
int precision, S &out,
@@ -191,6 +230,14 @@ void FlatMatrix::writeDistancesToOpenFile(const std::string& format,
191230
out.flush();
192231
}
193232

233+
/**
234+
* @brief Write distances, in a row of a distance matrix, to a stringstream
235+
* @param nseqs - the number of sequences (used for calculating indices)
236+
* @param seq1 - the row number
237+
* @param rowStart - the first column, for which to write a distance in the row
238+
* @param rowStop - the first column, NOT to write a distance to, in the row
239+
* @param line - the stringstream (for the line being constructed)
240+
*/
194241
void FlatMatrix::appendRowDistancesToLine(intptr_t nseqs, intptr_t seq1,
195242
intptr_t rowStart, intptr_t rowStop,
196243
std::stringstream& line) const {
@@ -204,6 +251,11 @@ void FlatMatrix::appendRowDistancesToLine(intptr_t nseqs, intptr_t seq1,
204251
}
205252
}
206253

254+
/**
255+
* @brief Return the maximum length of a sequence name, over all of the
256+
* sequences.
257+
* @return size_t - the maximum length
258+
*/
207259
size_t FlatMatrix::getMaxSeqNameLength() const {
208260
size_t len = 0;
209261
intptr_t nseqs = sequenceNames.size();

0 commit comments

Comments
 (0)