Skip to content

Commit 92d999b

Browse files
James BarbettiJames Barbetti
James Barbetti
authored and
James Barbetti
committed
Suppressing some warnings and adding some explanatory comments
1. declaring variables that can be const, const 2. declaring actual_clear (non-virtual clear) implementations in Matrix and SquareMatrix (to avoid warnings about virtual functions getting called in destructors!) 3. Running_DecentTree.md now mentions the -num parameter (it didn't!) 4. Detailed a few more missing examples in Command_Line_Examples.md
1 parent 10951da commit 92d999b

11 files changed

+52
-19
lines changed

clustertree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ template <class T> class ClusterTree: public std::vector<Cluster<T>>
281281
//For each (non-leaf) cluster...
282282
//1. calculate distances to all the
283283
// leaves, for each contributing cluster.
284-
Cluster<T>& node = at(h);
284+
const Cluster<T>& node = at(h);
285285
std::vector<LeafDistanceVector> subtrees;
286286
for (const Link<T>& link : node.links ) {
287287
LeafDistanceVector ldv;

decenttree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bool writeMSAOutputFile(const Sequences& sequences, const std::string& msaPath)
227227
}
228228
success = true;
229229
}
230-
catch (std::ios::failure& f) {
230+
catch (const std::ios::failure& f) {
231231
std::cerr << "I/O error trying to write"
232232
<< " MSA format file: " << msaPath << std::endl;
233233
}

distancematrix.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,17 @@ template <class T=double> class Matrix
9393
/**
9494
* @brief Release any allocated memory
9595
*/
96-
virtual void clear() {
96+
void actual_clear() {
9797
delete [] data;
9898
delete [] rows;
9999
data = nullptr;
100100
rows = nullptr;
101101
row_count = 0;
102102
column_count = 0;
103103
}
104+
virtual void clear() {
105+
actual_clear();
106+
}
104107
/**
105108
* @brief get a const reference to the pointer to the const
106109
* first element in the matrix, in the (r)th row.
@@ -443,13 +446,16 @@ template <class T=double> class SquareMatrix: public Matrix<T>
443446
assign(rhs);
444447
}
445448
virtual ~SquareMatrix() {
446-
clear();
449+
actual_clear();
447450
}
448-
virtual void clear() override {
449-
super::clear();
451+
void actual_clear() {
450452
delete [] rowTotals;
451453
rowTotals = nullptr;
452454
}
455+
virtual void clear() override {
456+
super::clear();
457+
actual_clear();
458+
}
453459
SquareMatrix& operator=(const SquareMatrix& rhs) {
454460
assign(rhs);
455461
return *this;
@@ -568,7 +574,10 @@ template <class F=std::stringstream, class M> intptr_t loadPartialRowFromLine
568574
}
569575

570576
/**
571-
* @brief
577+
* @brief if it hasn't been determined already, determine - from a single matrix
578+
* row that has just been read in, whether the matrix representation
579+
* in the file being read is square, upper triangle, or lower triangle.
580+
*
572581
* @tparam M the matrix type
573582
* @tparam P the type used to report progress (expected to implement
574583
* hide() and show() members).

doco/Command_Line_Examples.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Todo: Provide example command-lines for:
5757
<ul>
5858
<li>[todo: -msa-out]</li>
5959
<li>[todo: -strip-name] + [todo: -name-replace]</li>
60-
<li>[todo: -aln-out] Phylip Interleaved format</li>
60+
<li>[todo: -truncate-name-at] (truncation of long names)</li>
61+
<li>[todo: -num] (replacing names with numbered names, of the form A_i_ where _i_ is a number between 1 and _n_, the number of taxa)</li>
6162
</ul>
6263

6364
|Command Line|Explanation|
@@ -68,6 +69,13 @@ Todo: Provide example command-lines for:
6869

6970
<h2>Distance Matrices as outputs</h2>
7071

72+
Todo:
73+
<ul>
74+
<li>-no-matrix (if a distance matrix file is being generated, and a phylogenetic tree is not being inferred, -t NONE,
75+
it isn't strictly necessary to create an in-memory distance matrix, and this option tells decenttree to save memory
76+
by NOT allocating or using one).
77+
</ul>
78+
7179
|Command Line|Explanation|
7280
|------------|-----------|
7381
|decenttree -phylip ../example/example.phy -no-banner -dist example.dist -out-format upper -t NONE -no-out | Using the default distance matrix algorithm, infer a distance matrix, and write the distance matrix (in upper-triangle Phylip format) to the file, example.dist. -t NONE says *not* to use a phylogenetic inference algorithm. If no out-format parameter is provided the default is square. |

doco/Running_DecentTree.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
| -not-dna | | with -fasta, indicates input is (not) DNA |
1515
| -alphabet | list of characters | with -fasta, recognized nucleotide characters |
1616
| -unknown | list of characters | with -fasta, characters that indicate unknown |
17-
| -strip-name | list of characters | Characters to strip from taxon names (case sensitive) |
18-
| -name-replace | list of characters | Characters to replace the stripped characters with |
17+
| -strip-name | list of characters | Characters to strip from taxon names (case sensitive) |
18+
| -name-replace | list of characters | Characters to replace the stripped characters with |
1919
| -truncate-name-at | list of characters | Truncate taxon name on one of these characters |
20+
| -num | | Replace all taxon names with numbered names of the form A_i_ (_i_ is taxon number, starting at 1) |
2021
| -uncorrected | | with -fasta, do not apply Jukes-Cantor distance correction to calculated distances |
21-
| -filter | | with -fasta, Filter sequences that have zero distance |
22-
| -no-matrix | | with -fasta, save memory by *not* constructing the input matrix in memory |
22+
| -filter | | with -fasta, Filter sequences that have zero distances |
23+
| -no-matrix | | with -fasta, save memory by *not* constructing the input matrix in memory (only has an effect with -t NONE) |
2324
| -msa-out | msa output file path | given -fasta or -phylip, rewrite alignment in msa format |
2425
| -dist-out | distance matrix output file path | Use STDOUT to write it to standard output |
2526
| -t | algorithm name | Specify the algorithm to use to construct the tree (or none) |

flatmatrix.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,20 @@ class FlatMatrix {
111111
const std::string& file_name) const;
112112

113113
/**
114-
* @brief
114+
* @brief write the sequence names, and the distance matrix,
115+
* in one of the Phylip distance matrix formats, to the
116+
* file with the specified file stream.
115117
*
116118
* @tparam S the stream type
117119
* @tparam P the progress display class
118120
* @param format the format ("square", "upper", or "lower")
119121
* @param precision the precision (number of digits to use after decimal point)
120122
* @param out the output stream
121123
* @param progress pointer to the class instance used to report progress
124+
*
125+
* @note S is a template parameter because this function is used to
126+
* write a standard file output stream, or to a zipped file stream
127+
* (to std::ofstream or to ogzstream).
122128
*/
123129
template <class S /*stream type*/, class P /*progress display*/>
124130
void writeDistancesToOpenFile(const std::string& format,

nj.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ template <class T=NJFloat> class BIONJMatrix : public NJMatrix<T> {
526526

527527
#if USE_VECTORCLASS_LIBRARY
528528
/**
529-
* @brief
529+
* @brief Vectorizing shim for distance matrix algorithm classes
530+
* (Vectorized<X> yields a vectorized subclass of X,
531+
* if X meets the requirements, listed below).
530532
*
531533
* @tparam T the distance type
532534
* @tparam SUPER the superclass (in practice, NJMatrix<T>,

starttree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ namespace StartTree
180180
virtual bool setAppendFile(bool appendIt) = 0; //returns true if supported
181181

182182
/**
183-
* @brief
184-
*
183+
* @brief tell the distance matrix algorithm to avoid writing anything
184+
* to standard output (it may still write to standard error if
185+
* something goes wrong).
185186
*/
186187
virtual void beSilent() = 0;
187188

utils/argument.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class Argument {
1818
explicit Argument(const char* arg_name);
1919
virtual ~Argument() = default;
2020
/**
21-
* @brief
21+
* @brief Accept a recognized argument (found in the command-line)
22+
* (if the argument takes a parameter - or parameters -
23+
* this entails doing something with it; parsing it, possibly
24+
* validating it. The details vary between subclasses).
2225
* @param arg The argument that matched the name
2326
* @param nextArg The next argument
2427
* @param argv The command-line argument array

utils/hammingdistance.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ inline uint64_t countBitsSetInEither
239239

240240
//W is the number of bytes in a CV (or CBV)
241241
/**
242-
* @brief
242+
* @brief Determine hamming distance between two sequences
243+
* (using the specified vector types, supplied via
244+
* the template parameters).
245+
*
243246
* @tparam DV - distance vector type (of W/8 uint64_t)
244247
* @tparam CV - character vector type (of W characters)
245248
* @tparam CBV - boolean vector type (same rank as CV)

utils/my_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ inline void _my_assert(const char* expression, const char *func, const char* fil
3636
abort();
3737
}
3838

39-
inline void _my_assert(const std::string str_expression, const char *func, const char* file, int line) {
39+
inline void _my_assert(const std::string &str_expression, const char *func, const char* file, int line) {
4040
_my_assert(str_expression.c_str(), func, file, line);
4141
}
4242

0 commit comments

Comments
 (0)