From d79796ea97757c117a8188f33f856fb86416e1bb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 10:41:21 +0000 Subject: [PATCH 01/27] Don't use int64_t --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ src/HDTFactory.cpp | 10 +++++----- src/RootedTreeFactory.cpp | 6 +++--- src/hdt_factory.h | 2 +- src/rooted_tree_factory.h | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 628e839b..6c97b74f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Quartet -Version: 1.0.0 -Date: 2019-01-09 +Version: 1.0.0.9000 +Date: 2019-01-21 Title: Comparison of Phylogenetic Trees Using Quartet and Bipartition Measures Description: Calculates the number of four-taxon subtrees consistent with a pair of cladograms, calculating the symmetric quartet distance of Bandelt & Dress (1986), diff --git a/NEWS.md b/NEWS.md index 2d0656ee..f4400a2c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Quartet v1.0.0.9000 +## Portability + - Improved portability of C++ code. + # Quartet v1.0.0 ## New features - Add functions to generate ternary plots from tree similarity measures. diff --git a/src/HDTFactory.cpp b/src/HDTFactory.cpp index 59fa47de..1c463ac3 100644 --- a/src/HDTFactory.cpp +++ b/src/HDTFactory.cpp @@ -179,9 +179,9 @@ TemplatedLinkedList* HDTFactory::getTemplatedLinkedList() return returnMe; } -int64_t HDTFactory::getSizeInRam() +INTTYPE_N4 HDTFactory::getSizeInRam() { - int64_t resultHDT = 0; + INTTYPE_N4 resultHDT = 0; { HDT *current = createdHDTs; while (current != NULL) @@ -191,7 +191,7 @@ int64_t HDTFactory::getSizeInRam() } } - int64_t resultLL = 0; + INTTYPE_N4 resultLL = 0; { CountingLinkedList *current = createdLL; while (current != NULL) @@ -201,7 +201,7 @@ int64_t HDTFactory::getSizeInRam() } } - int64_t resultLLNO = 0; + INTTYPE_N4 resultLLNO = 0; { CountingLinkedListNumOnly *current = createdLLNO; while (current != NULL) @@ -211,7 +211,7 @@ int64_t HDTFactory::getSizeInRam() } } - int64_t resultTLL = 0; + INTTYPE_N4 resultTLL = 0; { TemplatedLinkedList *current = createdTLL; while (current != NULL) diff --git a/src/RootedTreeFactory.cpp b/src/RootedTreeFactory.cpp index 8f292f0c..a5a9dd20 100644 --- a/src/RootedTreeFactory.cpp +++ b/src/RootedTreeFactory.cpp @@ -88,9 +88,9 @@ TemplatedLinkedList* RootedTreeFactory::getTemplatedLinkedList() return returnMe; } -int64_t RootedTreeFactory::getSizeInRam() +INTTYPE_N4 RootedTreeFactory::getSizeInRam() { - int64_t resultRT = 0; + INTTYPE_N4 resultRT = 0; { RootedTree *current = createdRT; while (current != NULL) @@ -100,7 +100,7 @@ int64_t RootedTreeFactory::getSizeInRam() } } - int64_t resultTLL = 0; + INTTYPE_N4 resultTLL = 0; { TemplatedLinkedList *current = createdTLL; while (current != NULL) diff --git a/src/hdt_factory.h b/src/hdt_factory.h index afd9c6a8..bc2edbe8 100644 --- a/src/hdt_factory.h +++ b/src/hdt_factory.h @@ -31,7 +31,7 @@ class HDTFactory CountingLinkedListNumOnly* getLLNO(); TemplatedLinkedList* getTemplatedLinkedList(); void deleteTemplatedLinkedList(); - int64_t getSizeInRam(); + INTTYPE_N4 getSizeInRam(); }; #endif \ No newline at end of file diff --git a/src/rooted_tree_factory.h b/src/rooted_tree_factory.h index b357eda7..61725d50 100644 --- a/src/rooted_tree_factory.h +++ b/src/rooted_tree_factory.h @@ -20,7 +20,7 @@ class RootedTreeFactory ~RootedTreeFactory(); RootedTree* getRootedTree(string name = ""); TemplatedLinkedList* getTemplatedLinkedList(); - int64_t getSizeInRam(); + INTTYPE_N4 getSizeInRam(); }; #endif \ No newline at end of file From eed1e2345ed65173dcd2d68882fb200c628f5b4b Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 10:58:10 +0000 Subject: [PATCH 02/27] Do not include --- src/hdt.h | 1 - src/int_stuff.cpp | 2 -- src/rooted_tree.h | 1 - src/unrooted_tree.h | 1 - 4 files changed, 5 deletions(-) diff --git a/src/hdt.h b/src/hdt.h index 4e05de02..5527a280 100644 --- a/src/hdt.h +++ b/src/hdt.h @@ -1,7 +1,6 @@ #ifndef HDT_H #define HDT_H -#include #include #include "int_stuff.h" #include "util.h" diff --git a/src/int_stuff.cpp b/src/int_stuff.cpp index 91e22e63..3eac7d8b 100644 --- a/src/int_stuff.cpp +++ b/src/int_stuff.cpp @@ -1,3 +1 @@ #include "int_stuff.h" -#include -#include diff --git a/src/rooted_tree.h b/src/rooted_tree.h index 46f8e959..bf91e9b2 100644 --- a/src/rooted_tree.h +++ b/src/rooted_tree.h @@ -1,7 +1,6 @@ #ifndef ROOTED_TREE_H #define ROOTED_TREE_H -#include #include #include #include diff --git a/src/unrooted_tree.h b/src/unrooted_tree.h index e989468e..9af43f56 100644 --- a/src/unrooted_tree.h +++ b/src/unrooted_tree.h @@ -1,7 +1,6 @@ #ifndef UNROOTED_TREE_H #define UNROOTED_TREE_H -#include #include #include #include From 6ef43ba8eab1f5a67ff461a4643f07bbc2f3470f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 10:58:52 +0000 Subject: [PATCH 03/27] Use int_fast64_t on all platforms Requires C++11 --- src/Makevars | 1 + src/int_stuff.h | 14 ++++---------- 2 files changed, 5 insertions(+), 10 deletions(-) create mode 100644 src/Makevars diff --git a/src/Makevars b/src/Makevars new file mode 100644 index 00000000..260d08c6 --- /dev/null +++ b/src/Makevars @@ -0,0 +1 @@ +PKG_CXXFLAGS = -std=c++11 diff --git a/src/int_stuff.h b/src/int_stuff.h index 6ed20b3b..214fdb03 100644 --- a/src/int_stuff.h +++ b/src/int_stuff.h @@ -2,15 +2,9 @@ #define INT_STUFF_H - #include - #include - - #ifdef _WIN32 - #define INTTYPE_N4 __int64 //previously long long, which fails -pedantic - #define INTTYPE_REST __int64 //previously long long, which fails -pedantic - #else - #define INTTYPE_N4 __int64_t //previously long long, which fails -pedantic - #define INTTYPE_REST __int64_t //previously long long, which fails -pedantic - #endif + #include + #define INTTYPE_N4 int_fast64_t // long long fails -pedantic + #define INTTYPE_REST int_fast64_t // long long fails -pedantic + #endif \ No newline at end of file From 6c9f540afa97f9e117b372490cfd2594ec7ff929 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 10:59:49 +0000 Subject: [PATCH 04/27] Don't include --- src/templated_linked_list.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/templated_linked_list.h b/src/templated_linked_list.h index a3ccffd8..58db15eb 100644 --- a/src/templated_linked_list.h +++ b/src/templated_linked_list.h @@ -1,8 +1,6 @@ #ifndef TEMPLATED_LINKED_LIST #define TEMPLATED_LINKED_LIST -#include - using namespace std; template From 12df27e41d662a08081f81c49dc2d34156a96106 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:01:26 +0000 Subject: [PATCH 05/27] Don't include --- src/NewickParser.cpp | 1 - src/unrooted_tree.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/NewickParser.cpp b/src/NewickParser.cpp index d4575f09..cbd5e44a 100644 --- a/src/NewickParser.cpp +++ b/src/NewickParser.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/src/unrooted_tree.h b/src/unrooted_tree.h index 9af43f56..68b49455 100644 --- a/src/unrooted_tree.h +++ b/src/unrooted_tree.h @@ -3,7 +3,6 @@ #include #include -#include #include "rooted_tree.h" #include "rooted_tree_factory.h" From 71ffcfdac5d07463e3ea7aa4022aff86fe3d3daa Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:03:41 +0000 Subject: [PATCH 06/27] Don't include unused or --- src/NewickParser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/NewickParser.cpp b/src/NewickParser.cpp index cbd5e44a..5ec3d7c0 100644 --- a/src/NewickParser.cpp +++ b/src/NewickParser.cpp @@ -2,9 +2,8 @@ #include #include -#include #include -#include + #include #include From 3ae2bbafd57806124ad7785e3ce0be10e9755ca1 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:30:38 +0000 Subject: [PATCH 07/27] #if __cplusplus <= 199711L --- src/int_stuff.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/int_stuff.h b/src/int_stuff.h index 214fdb03..cd4fbc99 100644 --- a/src/int_stuff.h +++ b/src/int_stuff.h @@ -2,9 +2,13 @@ #define INT_STUFF_H +#if __cplusplus <= 199711L + #define INTTYPE_N4 long long // fails -pedantic + #define INTTYPE_REST long long // fails -pedantic +#else #include - #define INTTYPE_N4 int_fast64_t // long long fails -pedantic #define INTTYPE_REST int_fast64_t // long long fails -pedantic +#endif #endif \ No newline at end of file From 9b2ab8307bdaadd03c2569c233439ba80a28f44e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:37:08 +0000 Subject: [PATCH 08/27] Allow no c++11 and don't warn re. long longs --- src/Makevars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makevars b/src/Makevars index 260d08c6..8515e47a 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1 +1 @@ -PKG_CXXFLAGS = -std=c++11 +PKG_CXXFLAGS = -Wno-long-long From 7fee8b9b203815ff2ea2fe4038ae8b255f9ec302 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:46:50 +0000 Subject: [PATCH 09/27] Include int_stuff first --- src/rTripletDist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rTripletDist.cpp b/src/rTripletDist.cpp index a0b776bc..7883f2ba 100644 --- a/src/rTripletDist.cpp +++ b/src/rTripletDist.cpp @@ -1,8 +1,8 @@ #include using namespace Rcpp; +#include "int_stuff.h" #include "TripletDistanceCalculator.h" -#include "int_stuff.h" #include #include From 5d9177d07479ab19f8aef21719906dae133b6dbe Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:53:01 +0000 Subject: [PATCH 10/27] Triplets: Use CharacterVector instead of SEXP --- src/RcppExports.cpp | 16 ++++++++-------- src/rTripletDist.cpp | 28 +++++++++++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index ab6354de..bbad59d7 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -76,36 +76,36 @@ BEGIN_RCPP END_RCPP } // tqdist_TripletDistance -IntegerVector tqdist_TripletDistance(SEXP file1, SEXP file2); +IntegerVector tqdist_TripletDistance(CharacterVector file1, CharacterVector file2); RcppExport SEXP _Quartet_tqdist_TripletDistance(SEXP file1SEXP, SEXP file2SEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< SEXP >::type file1(file1SEXP); - Rcpp::traits::input_parameter< SEXP >::type file2(file2SEXP); + Rcpp::traits::input_parameter< CharacterVector >::type file1(file1SEXP); + Rcpp::traits::input_parameter< CharacterVector >::type file2(file2SEXP); rcpp_result_gen = Rcpp::wrap(tqdist_TripletDistance(file1, file2)); return rcpp_result_gen; END_RCPP } // tqdist_PairsTripletDistance -IntegerVector tqdist_PairsTripletDistance(SEXP file1, SEXP file2); +IntegerVector tqdist_PairsTripletDistance(CharacterVector file1, CharacterVector file2); RcppExport SEXP _Quartet_tqdist_PairsTripletDistance(SEXP file1SEXP, SEXP file2SEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< SEXP >::type file1(file1SEXP); - Rcpp::traits::input_parameter< SEXP >::type file2(file2SEXP); + Rcpp::traits::input_parameter< CharacterVector >::type file1(file1SEXP); + Rcpp::traits::input_parameter< CharacterVector >::type file2(file2SEXP); rcpp_result_gen = Rcpp::wrap(tqdist_PairsTripletDistance(file1, file2)); return rcpp_result_gen; END_RCPP } // tqdist_AllPairsTripletDistance -IntegerMatrix tqdist_AllPairsTripletDistance(SEXP file); +IntegerMatrix tqdist_AllPairsTripletDistance(CharacterVector file); RcppExport SEXP _Quartet_tqdist_AllPairsTripletDistance(SEXP fileSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< SEXP >::type file(fileSEXP); + Rcpp::traits::input_parameter< CharacterVector >::type file(fileSEXP); rcpp_result_gen = Rcpp::wrap(tqdist_AllPairsTripletDistance(file)); return rcpp_result_gen; END_RCPP diff --git a/src/rTripletDist.cpp b/src/rTripletDist.cpp index 7883f2ba..c09ca3e5 100644 --- a/src/rTripletDist.cpp +++ b/src/rTripletDist.cpp @@ -13,7 +13,12 @@ using namespace Rcpp; //' @describeIn tqdist_QuartetDistance Triplet distance between two trees //' @export // [[Rcpp::export]] -IntegerVector tqdist_TripletDistance(SEXP file1, SEXP file2) { +IntegerVector tqdist_TripletDistance(CharacterVector file1, CharacterVector file2) { + int n1 = file1.size(), n2 = file2.size(); + if (n1 != 1 || n2 != 1) { + Rcpp::stop("file1 and file2 must be character vectors of length 1"); + } + const char *filename1; const char *filename2; @@ -25,14 +30,19 @@ IntegerVector tqdist_TripletDistance(SEXP file1, SEXP file2) { INTTYPE_REST res = tripletCalc.calculateTripletDistance(filename1, filename2); IntegerVector IV_res(1); - IV_res = res; + IV_res[0] = res; return IV_res; } //' @describeIn tqdist_QuartetDistance Triplet distance between pairs //' @export // [[Rcpp::export]] -IntegerVector tqdist_PairsTripletDistance(SEXP file1, SEXP file2) { +IntegerVector tqdist_PairsTripletDistance(CharacterVector file1, CharacterVector file2) { + int n1 = file1.size(), n2 = file2.size(); + if (n1 != 1 || n2 != 1) { + Rcpp::stop("file1 and file2 must be character vectors of length 1"); + } + const char * filename1; const char * filename2; @@ -40,6 +50,7 @@ IntegerVector tqdist_PairsTripletDistance(SEXP file1, SEXP file2) { filename2 = CHAR(STRING_ELT(file2, 0)); TripletDistanceCalculator tripletCalc; + std::vector res = tripletCalc.pairs_triplet_distance(filename1, filename2); IntegerVector IV_res(res.size()); @@ -52,16 +63,19 @@ IntegerVector tqdist_PairsTripletDistance(SEXP file1, SEXP file2) { //' @describeIn tqdist_QuartetDistance Triplet distance between all pairs //' @export // [[Rcpp::export]] -IntegerMatrix tqdist_AllPairsTripletDistance(SEXP file) { - const char * filename; +IntegerMatrix tqdist_AllPairsTripletDistance(CharacterVector file) { + int n = file.size(); + if (n != 1) { + Rcpp::stop("file must be a character vector of length 1"); + } + const char *filename; filename = CHAR(STRING_ELT(file, 0)); - TripletDistanceCalculator tripletCalc; + std::vector > res = tripletCalc.calculateAllPairsTripletDistance(filename); IntegerMatrix IM_res(res.size(), res.size()); - // int *ians = INTEGER(res_sexp); for (size_t r = 0; r < res.size(); ++r) { for (size_t c = 0; c < r; ++c) { From 19459108cb5ae3236912442e05b5f95268f3ede6 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 11:53:11 +0000 Subject: [PATCH 11/27] Unnecessary comment --- src/rQuartetDist.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rQuartetDist.cpp b/src/rQuartetDist.cpp index 8bfce3fa..834700fa 100644 --- a/src/rQuartetDist.cpp +++ b/src/rQuartetDist.cpp @@ -134,7 +134,6 @@ IntegerMatrix tqdist_AllPairsQuartetDistance(CharacterVector file) { std::vector > res = quartetCalc.calculateAllPairsQuartetDistance(filename); IntegerMatrix IM_res(res.size(), res.size()); -// int *ians = INTEGER(res_sexp); for (size_t r = 0; r < res.size(); r++) { for (size_t c = 0; c < r; c++) { From 8ead11f68af21f63522a4026bbe8773832681aab Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:00:53 +0000 Subject: [PATCH 12/27] Remove unnecessary incldes --- src/hdt.h | 2 +- src/rooted_tree.h | 1 - tests/testthat/test-1-tqdist.R | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hdt.h b/src/hdt.h index 5527a280..4e4eb2c6 100644 --- a/src/hdt.h +++ b/src/hdt.h @@ -5,7 +5,7 @@ #include "int_stuff.h" #include "util.h" #include "rooted_tree_factory.h" -//#include "counting_linked_list.h" + class RootedTree; // forward declaration class HDTFactory; // forward declaration class CountingLinkedList; // forward declaration diff --git a/src/rooted_tree.h b/src/rooted_tree.h index bf91e9b2..2596a824 100644 --- a/src/rooted_tree.h +++ b/src/rooted_tree.h @@ -2,7 +2,6 @@ #define ROOTED_TREE_H #include -#include #include #include "int_stuff.h" diff --git a/tests/testthat/test-1-tqdist.R b/tests/testthat/test-1-tqdist.R index 02595dff..dd61e659 100644 --- a/tests/testthat/test-1-tqdist.R +++ b/tests/testthat/test-1-tqdist.R @@ -1,4 +1,4 @@ -context("tqDist") +context("tqDist tests") test_that("tqDist returns correct quartet distances", { expect_true(file.exists("../trees/quartet1.new")) From 5fb41682545cfd9a0c6a31128d4c6777f44133e8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:01:04 +0000 Subject: [PATCH 13/27] Remove -Wno-long-long Non-portable... --- src/Makevars | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Makevars b/src/Makevars index 8515e47a..e69de29b 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1 +0,0 @@ -PKG_CXXFLAGS = -Wno-long-long From fea07fac0afcbfd0e51cc52e2cf93647a4705c3d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:06:00 +0000 Subject: [PATCH 14/27] doExtractAndContract is def'd; remove comments --- src/AbstractDistanceCalculator.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/AbstractDistanceCalculator.cpp b/src/AbstractDistanceCalculator.cpp index 812e69e7..be879671 100644 --- a/src/AbstractDistanceCalculator.cpp +++ b/src/AbstractDistanceCalculator.cpp @@ -12,10 +12,8 @@ void AbstractDistanceCalculator::count(RootedTree *v) { // This will make sure the entire subtree has color 0! v->colorSubtree(0); -/*#ifdef doExtractAndContract*/ delete hdt->factory; -/*#endif*/ - + return; } @@ -52,7 +50,6 @@ void AbstractDistanceCalculator::count(RootedTree *v) { hdt->updateCounters(); updateCounters(); -/*#ifdef doExtractAndContract*/ // Extract RootedTree** extractedVersions = new RootedTree*[v->numChildren - 1]; c = 0; @@ -68,7 +65,6 @@ void AbstractDistanceCalculator::count(RootedTree *v) { } c++; } -/*#endif*/ // Color to 0 for(TemplatedLinkedList *current = v->children->next; @@ -80,16 +76,11 @@ void AbstractDistanceCalculator::count(RootedTree *v) { RootedTree *firstChild = v->children->data; if (firstChild->isLeaf() || firstChild->n <= 2) { // Do "nothing" (except clean up and possibly color!) -/*#ifdef doExtractAndContract*/ // Notice no recoloring here... It's not neccesary as it is extracted and contracted away, // and will actually cause an error if called with firstChild->colorSubtree(0) as t2 is linked // to a non-existing hdt (as we just deleted it) (we could wait with deleting it, but as we don't need the coloring why bother) delete hdt->factory; -/*#else - firstChild->colorSubtree(0); -#endif*/ } else { -/*#ifdef doExtractAndContract*/ bool hdtTooBig = firstChild->n * CONTRACT_MAX_EXTRA_SIZE < hdt->leafCount(); if (hdtTooBig) { HDT *newHDT; @@ -103,9 +94,8 @@ void AbstractDistanceCalculator::count(RootedTree *v) { delete hdt->factory; hdt = newHDT; } -/*#endif*/ count(firstChild); - // HDT is deleted in recursive call! + // HDT is deleted in recursive call } // Color 1 and recurse @@ -113,22 +103,18 @@ void AbstractDistanceCalculator::count(RootedTree *v) { for(TemplatedLinkedList *current = v->children->next; current != NULL; current = current->next) { if (!current->data->isLeaf() && current->data->n > 2) { -/*#ifdef doExtractAndContract*/ hdt = HDT::constructHDT(extractedVersions[c], t1->maxDegree, dummyHDTFactory, true); delete extractedVersions[c]->factory; -/*#endif*/ - + current->data->colorSubtree(1); count(current->data); } c++; - // HDT is deleted on recursive calls! + // HDT is deleted on recursive call } -/*#ifdef doExtractAndContract*/ delete[] extractedVersions; -/*#endif*/ } void AbstractDistanceCalculator::countChildren(RootedTree *t) { From 1a0b4945aab18d9aa5c298427ab5c71f448cd330 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:11:19 +0000 Subject: [PATCH 15/27] Remove unnecessary include --- src/rQuartetDist.cpp | 1 - src/rooted_tree.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rQuartetDist.cpp b/src/rQuartetDist.cpp index 834700fa..c17b1b07 100644 --- a/src/rQuartetDist.cpp +++ b/src/rQuartetDist.cpp @@ -7,7 +7,6 @@ using namespace Rcpp; #include #include #include -#include #include //' Triplet and quartet distances with tqDist diff --git a/src/rooted_tree.h b/src/rooted_tree.h index 2596a824..b5b1b56a 100644 --- a/src/rooted_tree.h +++ b/src/rooted_tree.h @@ -7,8 +7,8 @@ #include "int_stuff.h" #include "templated_linked_list.h" -class HDT;// Forward declaration... -class RootedTreeFactory; // Forward declaration... +class HDT;// Forward declaration +class RootedTreeFactory; // Forward declaration using namespace std; From aaa7993d0f408f5397d941511dd6e46412d91ea9 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:15:54 +0000 Subject: [PATCH 16/27] Delete Makevars --- src/Makevars | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Makevars diff --git a/src/Makevars b/src/Makevars deleted file mode 100644 index e69de29b..00000000 From 53ab126370c90acb0b85cf617297a9ba1390d5d8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:18:59 +0000 Subject: [PATCH 17/27] Installation from CRAN --- README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9a29eff1..25f69706 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,20 @@ function `SplitStatus`). ## Using the package -The package will soon be compiled and uploaded to the CRAN repository. -Meanwhile, you can install the latest version of the package into R thus: +Install and load the library from CRAN as follows: +``` +install.packages('Quartet') +library('Quartet') +``` +If you're feeling brave, you can install the development version thus: ```r -# Install the devtools package from CRAN -install.packages('devtools') - -# Install the package from github -devtools::install_github('ms609/Quartet', args='--no-multiarch') - -# Load the package into R -library('Quartet') +if(!require(devtools)) install.packages("devtools") +devtools::install_github('ms609/Quartet') ``` -You will need [Rtools](https://cran.r-project.org/bin/windows/Rtools/) installed to allow R to build the package. +You will need [Rtools](https://cran.r-project.org/bin/windows/Rtools/) installed +in order to build the development version from source. ## References - Brodal G.S., Fagerberg R., Pedersen C.N.S. 2004. Computing the quartet From 2643d2ee41729f0d3a94212b6610ff7289468114 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:30:27 +0000 Subject: [PATCH 18/27] Remove unnecessary comments --- src/HDT.cpp | 43 ++++++------------------------- src/HDTCountingCCToC.cpp | 26 +++++-------------- src/HDTCountingCTransform.cpp | 20 +++----------- src/HDTCountingG.cpp | 20 -------------- src/HDTCountingIGToC.cpp | 4 --- src/HDTCountingLeaf.cpp | 4 --- src/HDTListUtils.cpp | 4 --- src/QuartetDistanceCalculator.cpp | 7 +---- src/TripletDistanceCalculator.cpp | 7 ++--- src/counting_linked_list.h | 9 +------ src/hdt.h | 8 ++---- 11 files changed, 24 insertions(+), 128 deletions(-) diff --git a/src/HDT.cpp b/src/HDT.cpp index bdaaf46b..b73fb133 100644 --- a/src/HDT.cpp +++ b/src/HDT.cpp @@ -19,13 +19,12 @@ void HDT::initialize(CountingLinkedList *countingVars, NodeType type, int numD, goBackVariable = NULL; tripResolved = 0; tripUnresolved = 0; -/*#ifdef quartetsToo*/ quartResolvedAgree = 0; quartResolvedAgreeDiag = 0; quartResolvedAgreeUpper = 0; // New sum for calculating E quartSumE = 0; -/*#endif*/ + up2date = altMarked = false; this->type = type; @@ -200,10 +199,7 @@ RootedTree* HDT::extractAndGoBackImpl(RootedTree *addToMe, RootedTreeFactory *fa void HDT::toDot() { - // cout << "digraph g {" << endl; - // << "node[shape=circle];" << endl; toDotImpl(); - // << "}" << endl; } void HDT::updateCounters() @@ -294,10 +290,11 @@ HDT* HDT::preFirstRound(RootedTree *t, int numD, bool doLink, HDTFactory *factor HDT* HDT::round(HDTFactory *factory) { - // NOTE: C -> G when parent I etc is moved down!! + // NOTE: C -> G when parent I etc is moved down. // Composition 3: If we're a C we only have 1 child. - // If that's a C, use CC->C, skip the child and go directly to that-one's child (if exists) + // If that's a C, use CC->C, skip the child and go directly to that-one's + // child (if it exists) if (type == C && children != NULL && children->next == NULL /*children.size() == 1*/) { HDT *child = children->data; @@ -310,7 +307,8 @@ HDT* HDT::round(HDTFactory *factory) newC->right = child; newC->right->parent = newC; - // If there's children, there's only 1. We recurse on that one and add the result to our children list. + // If there's children, there's only 1. + // We recurse on that one and add the result to our children list. if (child->children != NULL) { child = child->children->data; @@ -346,7 +344,8 @@ HDT* HDT::round(HDTFactory *factory) // We found 2 G's if (lastG != NULL) { - // Merge the two G's by removing one and replaceing the other with the new G that points to the two old ones + // Merge the two G's by removing one and replacing the other with the + // new G that points to the two old ones // Replace one with a new one with left, right and parent pointers set HDT *newG = factory->getHDT(G, NULL, false); @@ -409,38 +408,12 @@ bool HDT::isDownwardsClosed() void HDT::toDotImpl() { - /* - cout << "n" << this << "[label=\""; - if (convertedFrom != NotConverted) - { - switch(convertedFrom) - { - case I: cout << "I"; break; - case C: cout << "C"; break; - case G: cout << "G"; break; - case NotConverted: cout << "NotConverted"; break; // Shouldn't happen! - } - cout << " -> "; - } - switch(type) - { - case I: cout << "I"; break; - case C: cout << "C"; break; - case G: cout << "G"; break; - case NotConverted: cout << "NotConverted"; break; // Shouldn't happen! - } - if (link != NULL) cout << "; " << link->name; - if (type == G && convertedFrom == C && left == NULL && right == NULL) cout << "; 0's: " << numZeroes; - cout << "\"];" << endl; - */ if (left != NULL) { left->toDotImpl(); - // cout << "n" << this << " -> n" << left << ";" << endl; } if (right != NULL) { right->toDotImpl(); - // cout << "n" << this << " -> n" << right << ";" << endl; } } diff --git a/src/HDTCountingCCToC.cpp b/src/HDTCountingCCToC.cpp index 897c0e93..33df022b 100644 --- a/src/HDTCountingCCToC.cpp +++ b/src/HDTCountingCCToC.cpp @@ -21,7 +21,6 @@ void HDT::handleCCToC() n_circ_square = 0; // Quartets -/*#ifdef quartetsToo*/ // Initialize sums to 0 so we can increment it in the loop n_circ_circ = 0; n_square_paren_circ_circ = 0; @@ -35,7 +34,7 @@ void HDT::handleCCToC() n_0_circ = c1->n_0_circ + c2->n_0_circ; n_paren_0_circ = c1->n_paren_0_circ + c2->n_paren_0_circ; - // Added by us for filling out tables (initialize) + // Added by Sand et al. (2014) for filling out tables (initialize) n_bracket_circ_circ = 0; n_paren_circ_paren_square_square = 0; n_circ_arrow_circ = 0; @@ -65,7 +64,6 @@ void HDT::handleCCToC() // Fetch sum for calculating E from children quartSumE = c1->quartSumE + c2->quartSumE; -/*#endif*/ // Fetch the childrens "result counting data" tripResolved = c1->tripResolved + c2->tripResolved; @@ -79,7 +77,6 @@ void HDT::handleCCToC() CountingLinkedList *ourCount = countingVars; // Quartets -/*#ifdef quartetsToo*/ INTTYPE_REST c1Zero = 0; INTTYPE_REST c2Zero = 0; @@ -97,7 +94,6 @@ void HDT::handleCCToC() n_0_arrow_circ_circ = c1->n_0_arrow_circ_circ + c2->n_0_arrow_circ_circ + c1Zero * c2->n_circ_circ; // Not dependent on i (end) -/*#endif*/ while (c1Next != NULL || c2Next != NULL) { @@ -158,7 +154,6 @@ void HDT::handleCCToC() c1Count->n_i * (c2->n_circ - c2Count->n_i); // Quartets -/*#ifdef quartetsToo*/ // 2nd group in figure 12 (quartets only) ourCount->n_0_i = c1Count->n_0_i + c2Count->n_0_i; ourCount->n_ii = c1Count->n_ii + c2Count->n_ii; @@ -258,7 +253,7 @@ void HDT::handleCCToC() (c1->n_circ - c1Count->n_i) * c2Count->n_i_arrow_i + c1Count->n_circ_arrow_i * c2Count->n_i; - // Added by us! + // Added by Sand et al. (2014) ourCount->n_i_arrow_paren_circ_circ = c1Count->n_i_arrow_paren_circ_circ + c2Count->n_i_arrow_paren_circ_circ + c1Count->n_i * (c2->n_paren_circ_circ - c2Count->n_paren_ii); @@ -281,7 +276,7 @@ void HDT::handleCCToC() if (ourCount->n_j_arrow_i != NULL) ourCount->n_j_arrow_i->type = CountingLinkedListNumOnly::SkipAndEnd; if (ourCount->n_i_arrow_j != NULL) ourCount->n_i_arrow_j->type = CountingLinkedListNumOnly::SkipAndEnd; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A ourCount->n_bracket_i_paren_circ_circ = c1Count->n_bracket_i_paren_circ_circ + c2Count->n_bracket_i_paren_circ_circ + (c1->n_bracket_circ_circ - Util::binom2(c1Count->n_i)) * c2Count->n_i + c1Count->n_i * (c2->n_paren_circ_circ - c2Count->n_paren_ii); @@ -349,7 +344,7 @@ void HDT::handleCCToC() ourCount->n_bracket_i_circ_square += addThis; // E end - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables ourCount->n_bracket_i_paren_circ_circ += c1->countingVars->getIteratorValue(j)->n_i * getIteratorValueForNumList(c2Count->n_j_arrow_i, j); ourCount->n_bracket_i_paren_circ_square += c1->countingVars->getIteratorValue(j)->n_i * (c2Count->n_circ_arrow_i - getIteratorValueForNumList(c2Count->n_j_arrow_i, j)); ourCount->n_i_arrow_circ_arrow_circ += getIteratorValueForNumList(c1Count->n_i_arrow_j, j) * c2->countingVars->getIteratorValue(j)->n_i; @@ -361,7 +356,7 @@ void HDT::handleCCToC() ourCount->n_0_arrow_i_circ = c1Count->n_0_arrow_i_circ + c2Count->n_0_arrow_i_circ + c1Zero * c2Count->n_i_circ; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables ourCount->n_paren_i_paren_circ_circ = c1Count->n_paren_i_paren_circ_circ + c2Count->n_paren_i_paren_circ_circ; ourCount->n_paren_i_paren_circ_square = c1Count->n_paren_i_paren_circ_square + c2Count->n_paren_i_paren_circ_square; @@ -394,13 +389,11 @@ void HDT::handleCCToC() c1Zero * c2Count->n_i_circ + c1Count->n_i * (c2->n_0_circ - c2Count->n_0_i) + (c1->n_circ - c1Count->n_i) * c2Count->n_0_i; -/*#endif*/ // Sums and stuff n_circ_square += ourCount->n_i_circ; // Quartets -/*#ifdef quartetsToo*/ n_circ_circ += ourCount->n_ii; n_square_paren_circ_circ += ourCount->n_i_paren_circ_circ; n_paren_circ_circ += ourCount->n_paren_ii; @@ -408,10 +401,10 @@ void HDT::handleCCToC() n_circ_arrow_paren_square_square += ourCount->n_circ_arrow_paren_ii; // FIXED!! n_bracket_circ_square += ourCount->n_bracket_i_circ; - // Added by us + // Added by Sand et al. (2014) n_circ_arrow_square_square += ourCount->n_i_arrow_circ_circ; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A n_bracket_circ_circ += Util::binom2(ourCount->n_i); n_paren_circ_paren_square_square += ourCount->n_paren_i_paren_circ_circ; @@ -432,7 +425,6 @@ void HDT::handleCCToC() n_bracket_circ_square_triangle += ourCount->n_bracket_i_circ_square; n_bracket_0_circ_square += ourCount->n_bracket_0_i_circ; -/*#endif*/ // Update resolved/resolved and unresolved/unresolved // (Figure 10) @@ -442,7 +434,6 @@ void HDT::handleCCToC() tripUnresolved += c1Count->n_i * (c2->n_circ_square - c2Count->n_i_circ); // Quartets -/*#ifdef quartetsToo*/ //quartResolvedAgree & quartResolvedDisagree // alpha & alpha @@ -562,7 +553,6 @@ void HDT::handleCCToC() quartSumE += (INTTYPE_N4) c1Count->n_i * (c2->n_0_circ_arrow_square - c2Count->n_0_i_arrow_circ - c2Count->n_0_circ_arrow_i); quartSumE += (INTTYPE_N4) (c1->n_bracket_0_circ_square - c1Count->n_bracket_0_i_circ) * c2Count->n_i; quartSumE += (INTTYPE_N4) c1Count->n_i * (c2->n_paren_0_circ_square - c2Count->n_paren_0_i_circ); -/*#endif*/ // Go to next on children unless we're done if (c1Next == NULL && c2Next == NULL) @@ -578,7 +568,6 @@ void HDT::handleCCToC() n_circ_square /= 2; // Quartets -/*#ifdef quartetsToo*/ n_paren_circ_square /= 2; n_bracket_circ_square /= 2; @@ -617,5 +606,4 @@ void HDT::handleCCToC() Rcpp::warning("n_0_arrow_circ_square mod 2 check failed"); } n_0_arrow_circ_square /= 2; -/*#endif*/ } diff --git a/src/HDTCountingCTransform.cpp b/src/HDTCountingCTransform.cpp index 77109eb6..741a7835 100644 --- a/src/HDTCountingCTransform.cpp +++ b/src/HDTCountingCTransform.cpp @@ -10,7 +10,6 @@ void HDT::handleCTransform() n_circ_square = 0; // Quartets -/*#ifdef quartetsToo*/ // Sums initialized to 0, summed in loop below n_paren_circ_circ = 0; n_paren_circ_square = 0; @@ -27,15 +26,7 @@ void HDT::handleCTransform() n_paren_0_circ = gZero * n_circ; - /* - // Added by us for filling out tables (Actually undefined!) - n_circ_arrow_circ = 0; - n_circ_arrow_square = 0; - n_paren_circ_circ_arrow_square = 0; - n_circ_arrow_square_arrow_square = 0; - */ - - // Added by us for filling out tables (initialize) + // Added by Sand et al. (2014) for filling out tables (initialize) n_paren_circ_paren_square_square = 0; // Reset sums and stuff for calculating E @@ -43,7 +34,6 @@ void HDT::handleCTransform() n_0_circ_square = 0; n_paren_circ_square_triangle = 0; n_paren_0_circ_square = 0; -/*#endif*/ CountingLinkedList *current = countingVars; if (current->num == 0) @@ -60,7 +50,6 @@ void HDT::handleCTransform() current->n_paren_ii = Util::binom2(current->n_i); // Quartets -/*#ifdef quartetsToo*/ // 2nd group in figure 12 (quartets only) current->n_0_i = 0; current->n_ii = 0; @@ -84,12 +73,12 @@ void HDT::handleCTransform() // Figure 15 counters (part 1) if (current->n_i_j != NULL) current->n_i_j->type = CountingLinkedListNumOnly::SkipAndEnd; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A current->n_paren_i_paren_circ_circ = current->n_bracket_i_paren_circ_circ; current->n_paren_i_paren_circ_square = current->n_bracket_i_paren_circ_square; - // Added by us for filling out tables (sum) + // Added by Sand et al. (2014) for filling out tables (sum) // A n_paren_circ_paren_square_square += current->n_paren_i_paren_circ_circ; @@ -102,7 +91,6 @@ void HDT::handleCTransform() // New sums for E n_paren_circ_square_triangle += current->n_paren_i_circ_square; n_paren_0_circ_square += current->n_paren_0_i_circ; -/*#endif*/ // Go to next on children unless we're done if (current->type != CountingLinkedList::End) @@ -113,7 +101,6 @@ void HDT::handleCTransform() else current = NULL; } -/*#ifdef quartetsToo*/ // These are all based on stuff that is reset to 0 n_circ_circ = 0; n_square_paren_circ_circ = 0; @@ -134,5 +121,4 @@ void HDT::handleCTransform() Rcpp::stop("n_paren_0_circ_square mod 2 test... FAIL!!!"); } n_paren_0_circ_square /= 2; -/*#endif*/ } diff --git a/src/HDTCountingG.cpp b/src/HDTCountingG.cpp index 5314e4c7..846b8ecd 100644 --- a/src/HDTCountingG.cpp +++ b/src/HDTCountingG.cpp @@ -30,7 +30,6 @@ void HDT::handleG() CountingLinkedList *g2Count = NULL; CountingLinkedList *ourCount = countingVars; -/*#ifdef quartetsToo*/ INTTYPE_REST g1Zero = 0; INTTYPE_REST g2Zero = 0; @@ -73,7 +72,6 @@ void HDT::handleG() // Fetch sum for calculating E from children quartSumE = g1->quartSumE + g2->quartSumE; -/*#endif*/ while (g1Next != NULL || g2Next != NULL) { @@ -138,7 +136,6 @@ void HDT::handleG() //ourCount->n_i_arrow_circ = 0; // undefined actually! // Quartets -/*#ifdef quartetsToo*/ // 2nd group in figure 12 (quartets only) ourCount->n_0_i = g1Count->n_0_i + g2Count->n_0_i + g1Zero * g2Count->n_i + @@ -280,14 +277,6 @@ void HDT::handleG() g1Count->n_i * (g2->n_paren_circ_square - g2Count->n_paren_i_circ) + g2Count->n_i * (g1->n_paren_circ_square - g1Count->n_paren_i_circ); - /* - // Undefined :) - ourCount->n_i_arrow_circ_arrow_circ = 0; - ourCount->n_i_arrow_circ_arrow_square = 0; - ourCount->n_paren_circ_square_arrow_i = 0; - if (ourCount->n_i_arrow_j != NULL) ourCount->n_i_arrow_j->type = CountingLinkedListNumOnly::SkipAndEnd; - */ - // New counters for calculating E ourCount->n_paren_i_circ_square = g1Count->n_paren_i_circ_square + g2Count->n_paren_i_circ_square; @@ -300,13 +289,11 @@ void HDT::handleG() ourCount->n_bracket_0_i_circ = g1Count->n_bracket_0_i_circ + g2Count->n_bracket_0_i_circ + g1Count->n_0_i * (g2->n_circ - g2Count->n_i) + g1Count->n_i * (g2->n_0_circ - g2Count->n_0_i) + g1Count->n_i_circ * g2Zero + g2Count->n_0_i * (g1->n_circ - g1Count->n_i) + g2Count->n_i * (g1->n_0_circ - g1Count->n_0_i) + g2Count->n_i_circ * g1Zero; -/*#endif*/ // Sums and stuff n_circ_square += ourCount->n_i_circ; // Quartets -/*#ifdef quartetsToo*/ n_circ_circ += ourCount->n_ii; n_square_paren_circ_circ += ourCount->n_i_paren_circ_circ; n_paren_circ_circ += ourCount->n_paren_ii; @@ -324,7 +311,6 @@ void HDT::handleG() n_bracket_circ_square_triangle += ourCount->n_bracket_i_circ_square; n_bracket_0_circ_square += ourCount->n_bracket_0_i_circ; -/*#endif*/ // Update resolved/resolved and unresolved/unresolved // (Figure 10) @@ -335,7 +321,6 @@ void HDT::handleG() tripUnresolved += g2Count->n_i * (g1->n_circ_square - g1Count->n_i_circ); // Quartets -/*#ifdef quartetsToo*/ //quartResolvedAgree & quartResolvedDisagree // alpha & alpha @@ -436,7 +421,6 @@ void HDT::handleG() // epsilon & epsilon (part 2) quartSumE += (INTTYPE_N4) (g1->n_paren_0_circ_square - g1Count->n_paren_0_i_circ) * g2Count->n_i; quartSumE += (INTTYPE_N4) (g2->n_paren_0_circ_square - g2Count->n_paren_0_i_circ) * g1Count->n_i; -/*#endif*/ // Go to next on children unless we're done if (g1Next == NULL && g2Next == NULL) @@ -450,16 +434,13 @@ void HDT::handleG() } } -/*#ifdef quartetsToo*/ //gamma & beta (part 1) (continued from inside the loop) (figure 13) quartResolvedAgree += (INTTYPE_N4) g1Zero * g2->n_square_paren_circ_circ; quartResolvedAgree += (INTTYPE_N4) g2Zero * g1->n_square_paren_circ_circ; -/*#endif*/ n_circ_square /= 2; // Quartets -/*#ifdef quartetsToo*/ n_paren_circ_square /= 2; n_bracket_circ_square /= 2; @@ -497,5 +478,4 @@ void HDT::handleG() Rcpp::stop("n_bracket_0_circ_square mod 2 check failed"); } n_bracket_0_circ_square /= 2; -/*#endif*/ } diff --git a/src/HDTCountingIGToC.cpp b/src/HDTCountingIGToC.cpp index 8510b15c..38542651 100644 --- a/src/HDTCountingIGToC.cpp +++ b/src/HDTCountingIGToC.cpp @@ -18,7 +18,6 @@ void HDT::handleIGToC() n_circ_square = right->n_circ_square; // Quartets -/*#ifdef quartetsToo*/ // Fetch the childrens "result counting data" quartResolvedAgree = right->quartResolvedAgree; quartResolvedAgreeDiag = right->quartResolvedAgreeDiag; @@ -71,7 +70,6 @@ void HDT::handleIGToC() // Fetch sum for calculating E from children quartSumE = right->quartSumE; -/*#endif*/ CountingLinkedList *current = right->countingVars; CountingLinkedList *ourCount = countingVars; @@ -103,7 +101,6 @@ void HDT::handleIGToC() ourCount->n_i_arrow_circ = 0; // Not actually defined in G! IN G!!! (i.e. it *should* in fact be 0) // Quartets -/*#ifdef quartetsToo*/ // 2nd group in figure 12 (quartets only) ourCount->n_0_i = current->n_0_i; ourCount->n_ii = current->n_ii; @@ -199,7 +196,6 @@ void HDT::handleIGToC() ourCount->n_paren_0_i_circ = current->n_paren_0_i_circ; ourCount->n_bracket_i_circ_square = current->n_bracket_i_circ_square; ourCount->n_bracket_0_i_circ = current->n_bracket_0_i_circ; -/*#endif*/ // Go to next on children unless we're done if (ourCount->type != CountingLinkedList::End) diff --git a/src/HDTCountingLeaf.cpp b/src/HDTCountingLeaf.cpp index 64812d5c..f85b29c5 100644 --- a/src/HDTCountingLeaf.cpp +++ b/src/HDTCountingLeaf.cpp @@ -22,7 +22,6 @@ void HDT::handleLeaf() countingVars->n_i_arrow_circ = 0; // Quartets -/*#ifdef quartetsToo*/ countingVars->n_0_i = 0; countingVars->n_ii = 0; countingVars->n_0_paren_ii = 0; @@ -92,7 +91,6 @@ void HDT::handleLeaf() countingVars->n_paren_0_i_circ = 0; countingVars->n_bracket_i_circ_square = 0; countingVars->n_bracket_0_i_circ = 0; -/*#endif*/ countingVars->type = CountingLinkedList::End; @@ -102,7 +100,6 @@ void HDT::handleLeaf() n_circ_square = 0; // Sums (quartets) -/* ifdef quartetsToo*/ n_0_circ = 0; n_circ_circ = 0; n_square_paren_circ_circ = 0; @@ -141,5 +138,4 @@ void HDT::handleLeaf() n_paren_0_circ_square = 0; n_bracket_circ_square_triangle = 0; n_bracket_0_circ_square = 0; -/*#endif */ } diff --git a/src/HDTListUtils.cpp b/src/HDTListUtils.cpp index 91dfb1c3..2e5b992d 100644 --- a/src/HDTListUtils.cpp +++ b/src/HDTListUtils.cpp @@ -5,8 +5,6 @@ #include "counting_linked_list.h" #include "counting_linked_list_num_only.h" -/*#ifdef quartetsToo*/ - bool HDT::gotoIteratorValueForList(CountingLinkedList *list, unsigned int num) { if (list == NULL || list->iteratorHasEnded()) return false; @@ -62,5 +60,3 @@ void HDT::addToNumList(CountingLinkedList *parent, AddToType list, unsigned int theList->num = num; theList->value = value; } - -/*#endif*/ diff --git a/src/QuartetDistanceCalculator.cpp b/src/QuartetDistanceCalculator.cpp index 33c3b221..ef0239b5 100644 --- a/src/QuartetDistanceCalculator.cpp +++ b/src/QuartetDistanceCalculator.cpp @@ -228,18 +228,13 @@ AE QuartetDistanceCalculator::calculateQuartetAgreement(UnrootedTree *t1, Unroot count(this->t1); -/*#ifndef doExtractAndContract -// factory deleted in count if def. - delete hdt->factory; -#endif*/ - n = this->t1->n; res.a = resolvedQuartetsAgree + resolvedQuartetsAgreeDiag + resolvedQuartetsAgreeUpper; res.e = unresolvedQuartets; res.noQuartets = Util::binom4(n); - // HDT is deleted in count! + // HDT is deleted in count delete this->t1->factory; delete this->t2->factory; diff --git a/src/TripletDistanceCalculator.cpp b/src/TripletDistanceCalculator.cpp index 7f39ac12..40993d96 100644 --- a/src/TripletDistanceCalculator.cpp +++ b/src/TripletDistanceCalculator.cpp @@ -140,11 +140,8 @@ INTTYPE_REST TripletDistanceCalculator::calculateTripletDistance(RootedTree *t1, totalNoTriplets = Util::binom3(n); count(t1); - // HDT is deleted in count if extracting and contracting! -/*#ifndef doExtractAndContract - delete hdt->factory; -#endif*/ - + // HDT is deleted in count if extracting and contracting. + return totalNoTriplets - resolvedTriplets - unresolvedTriplets; } diff --git a/src/counting_linked_list.h b/src/counting_linked_list.h index fa09444f..122e3b09 100644 --- a/src/counting_linked_list.h +++ b/src/counting_linked_list.h @@ -12,7 +12,7 @@ class CountingLinkedList INTTYPE_REST n_i, n_i_circ, n_paren_ii, n_i_arrow_circ; // For quartets -/*#ifdef quartetsToo*/ + INTTYPE_REST n_0_i, n_ii, n_0_paren_ii, n_circ_paren_ii, n_i_paren_0_circ, n_i_paren_circ_circ, n_i_paren_circ_square; INTTYPE_REST n_bracket_i_circ; INTTYPE_REST n_paren_0_i, n_paren_i_circ, n_paren_0_paren_ii, n_paren_circ_paren_ii, n_paren_i_paren_0_circ; @@ -53,7 +53,6 @@ class CountingLinkedList INTTYPE_REST n_paren_0_i_circ; INTTYPE_REST n_bracket_i_circ_square; INTTYPE_REST n_bracket_0_i_circ; -/*#endif*/ // More general stuff unsigned int num; @@ -70,10 +69,8 @@ class CountingLinkedList void initialize() { next = NULL; -/*#ifdef quartetsToo*/ n_i_j = NULL; n_j_arrow_i = n_i_arrow_j = NULL; -/*#endif*/ } CountingLinkedList(bool dummy) @@ -87,7 +84,6 @@ class CountingLinkedList n_i_arrow_circ = 0; // Quartets -/*#ifdef quartetsToo*/ n_0_i = 0; n_ii = 0; n_0_paren_ii = 0; @@ -155,10 +151,8 @@ class CountingLinkedList n_paren_0_i_circ = 0; n_bracket_i_circ_square = 0; n_bracket_0_i_circ = 0; -/*#endif*/ } -/*#ifdef quartetsToo*/ void resetIterator() { iterator = this; @@ -199,7 +193,6 @@ class CountingLinkedList else iterator = iterator->next; return result; } -/*#endif*/ }; #endif diff --git a/src/hdt.h b/src/hdt.h index 4e4eb2c6..a93e57a8 100644 --- a/src/hdt.h +++ b/src/hdt.h @@ -80,7 +80,6 @@ class HDT INTTYPE_REST n_circ_square; // Quartets -/*#ifdef quartetsToo*/ INTTYPE_REST n_0_circ; INTTYPE_REST n_paren_0_circ; INTTYPE_REST n_circ_circ; @@ -93,10 +92,10 @@ class HDT INTTYPE_REST n_circ_arrow_0; INTTYPE_REST n_0_arrow_circ_circ; - // Added by us + // Added by Sand et al. (2014) INTTYPE_REST n_circ_arrow_square_square; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables INTTYPE_REST n_bracket_circ_circ; INTTYPE_REST n_paren_circ_paren_square_square; INTTYPE_REST n_circ_arrow_circ; @@ -117,7 +116,6 @@ class HDT INTTYPE_REST n_paren_0_circ_square; INTTYPE_REST n_bracket_circ_square_triangle; INTTYPE_REST n_bracket_0_circ_square; -/*#endif*/ // Summing resolved/resolved and unresolved/unresolved INTTYPE_REST tripResolved; @@ -137,14 +135,12 @@ class HDT void handleCTransform(); void handleG(); -/*#ifdef quartetsToo*/ bool gotoIteratorValueForList(CountingLinkedList *list, unsigned int num); enum AddToType {i_j, paren_i_j, j_arrow_i, i_arrow_j, i_paren_i_j, paren_i_paren_i_j, bracket_i_paren_i_j}; INTTYPE_REST getIteratorValueForNumList(CountingLinkedListNumOnly *list, unsigned int num); bool gotoIteratorValueForNumList(CountingLinkedListNumOnly *list, unsigned int num); bool hasIteratorForNumListEnded(CountingLinkedListNumOnly *list); void addToNumList(CountingLinkedList *parent, AddToType list, unsigned int num, INTTYPE_REST value); -/*#endif*/ }; #endif From 62684180c53148fb15aeb2a8b8c9fb3f43c30208 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 12:37:21 +0000 Subject: [PATCH 19/27] Added by Sand et al. Clarify "us". Resolves #29: yes, it is necessary --- src/HDTCountingCCToC.cpp | 6 +++--- src/HDTCountingG.cpp | 12 ++++++------ src/HDTCountingIGToC.cpp | 8 ++++---- src/HDTCountingLeaf.cpp | 8 ++++---- src/counting_linked_list.h | 6 +++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/HDTCountingCCToC.cpp b/src/HDTCountingCCToC.cpp index 33df022b..cae4bb6d 100644 --- a/src/HDTCountingCCToC.cpp +++ b/src/HDTCountingCCToC.cpp @@ -28,7 +28,7 @@ void HDT::handleCCToC() n_paren_circ_square = 0; n_circ_arrow_paren_square_square = 0; n_bracket_circ_square = 0; - n_circ_arrow_square_square = 0; // Added by us + n_circ_arrow_square_square = 0; // Added by Sand et al. (2014) // Not dependent on i n_0_circ = c1->n_0_circ + c2->n_0_circ; @@ -499,7 +499,7 @@ void HDT::handleCCToC() // // +------------------------------------------+ - // | New sums for calculating A (Added by us) | + // | New sums for calculating A (Added by Sand et al. (2014)) | // +------------------------------------------+ // @@ -531,7 +531,7 @@ void HDT::handleCCToC() // // +------------------------------------------+ - // | New sums for calculating E (Added by us) | + // | New sums for calculating E (Added by Sand et al. (2014)) | // +------------------------------------------+ // diff --git a/src/HDTCountingG.cpp b/src/HDTCountingG.cpp index 846b8ecd..7c118e62 100644 --- a/src/HDTCountingG.cpp +++ b/src/HDTCountingG.cpp @@ -52,7 +52,7 @@ void HDT::handleG() n_paren_circ_square = 0; n_bracket_circ_square = 0; - // Added by us for filling out tables (initialize) + // Added by Sand et al. (2014) for filling out tables (initialize) n_bracket_circ_circ = 0; n_paren_circ_paren_square_square = 0; n_bracket_circ_paren_square_square = 0; @@ -248,7 +248,7 @@ void HDT::handleG() // j > i // // +------------------------------------------+ - // | New sums for calculating E (Added by us) | + // | New sums for calculating E (Added by Sand et al. (2014)) | // +------------------------------------------+ // @@ -261,7 +261,7 @@ void HDT::handleG() lastJPlus1 = j+1; } - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A ourCount->n_paren_i_paren_circ_circ = g1Count->n_paren_i_paren_circ_circ + g2Count->n_paren_i_paren_circ_circ; @@ -300,7 +300,7 @@ void HDT::handleG() n_paren_circ_square += ourCount->n_paren_i_circ; n_bracket_circ_square += ourCount->n_bracket_i_circ; - // Added by us for filling out tables (initialize) + // Added by Sand et al. (2014) for filling out tables (initialize) n_bracket_circ_circ += Util::binom2(ourCount->n_i); n_paren_circ_paren_square_square += ourCount->n_paren_i_paren_circ_circ; n_bracket_circ_paren_square_square += ourCount->n_bracket_i_paren_circ_circ; @@ -373,7 +373,7 @@ void HDT::handleG() // // +------------------------------------------+ - // | New sums for calculating A (Added by us) | + // | New sums for calculating A (Added by Sand et al. (2014)) | // +------------------------------------------+ // @@ -397,7 +397,7 @@ void HDT::handleG() // // +------------------------------------------+ - // | New sums for calculating E (Added by us) | + // | New sums for calculating E (Added by Sand et al. (2014)) | // +------------------------------------------+ // diff --git a/src/HDTCountingIGToC.cpp b/src/HDTCountingIGToC.cpp index 38542651..e9e0f19e 100644 --- a/src/HDTCountingIGToC.cpp +++ b/src/HDTCountingIGToC.cpp @@ -33,7 +33,7 @@ void HDT::handleIGToC() // Sums // Not actually defined in G! IN G!!! (i.e. it *should* in fact be 0) n_circ_arrow_paren_square_square = 0; - n_circ_arrow_square_square = 0; // Added by us + n_circ_arrow_square_square = 0; // Added by Sand et al. (2014) // Not dependent on i n_0_circ = right->n_0_circ; @@ -45,7 +45,7 @@ void HDT::handleIGToC() n_circ_arrow_0 = 0; n_0_arrow_circ_circ = 0; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables n_bracket_circ_circ = right->n_bracket_circ_circ; n_paren_circ_paren_square_square = right->n_paren_circ_paren_square_square; n_circ_arrow_circ = 0; @@ -146,7 +146,7 @@ void HDT::handleIGToC() ourCount->n_i_arrow_0_arrow_circ = 0; ourCount->n_circ_arrow_i_arrow_i = 0; - // Added by us + // Added by Sand et al. (2014) ourCount->n_i_arrow_paren_circ_circ = 0; ourCount->n_0_arrow_ii = 0; ourCount->n_paren_0_circ_arrow_i = 0; @@ -172,7 +172,7 @@ void HDT::handleIGToC() ourCount->n_0_arrow_i_circ = 0; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A ourCount->n_paren_i_paren_circ_circ = current->n_paren_i_paren_circ_circ; ourCount->n_bracket_i_paren_circ_circ = current->n_bracket_i_paren_circ_circ; diff --git a/src/HDTCountingLeaf.cpp b/src/HDTCountingLeaf.cpp index f85b29c5..91232a28 100644 --- a/src/HDTCountingLeaf.cpp +++ b/src/HDTCountingLeaf.cpp @@ -61,7 +61,7 @@ void HDT::handleLeaf() countingVars->n_i_arrow_0_arrow_circ = 0; countingVars->n_circ_arrow_i_arrow_i = 0; - // Added by us + // Added by Sand et al. (2014) countingVars->n_i_arrow_paren_circ_circ = 0; countingVars->n_0_arrow_ii = 0; countingVars->n_paren_0_circ_arrow_i = 0; @@ -69,7 +69,7 @@ void HDT::handleLeaf() //countingVars->n_i_j = NULL; // it already is! countingVars->n_0_arrow_i_circ = 0; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A countingVars->n_paren_i_paren_circ_circ = 0; countingVars->n_bracket_i_paren_circ_circ = 0; @@ -113,10 +113,10 @@ void HDT::handleLeaf() n_circ_arrow_0 = 0; n_0_arrow_circ_circ = 0; - // Added by us + // Added by Sand et al. (2014) n_circ_arrow_square_square = 0; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables n_bracket_circ_circ = 0; n_paren_circ_paren_square_square = 0; n_circ_arrow_circ = 0; diff --git a/src/counting_linked_list.h b/src/counting_linked_list.h index 122e3b09..f63d50e2 100644 --- a/src/counting_linked_list.h +++ b/src/counting_linked_list.h @@ -22,14 +22,14 @@ class CountingLinkedList n_i_arrow_circ_square, n_circ_arrow_ii, n_paren_ii_arrow_0, n_paren_ii_arrow_circ, n_paren_circ_circ_arrow_i, n_0_arrow_i_arrow_i, n_i_arrow_circ_arrow_0, n_i_arrow_0_arrow_circ, n_circ_arrow_i_arrow_i; - // Added by us + // Added by Sand et al. (2014) INTTYPE_REST n_i_arrow_paren_circ_circ, n_0_arrow_ii, n_paren_0_circ_arrow_i; // Figure 15 counters (part 1) CountingLinkedListNumOnly *n_i_j; // also used for E calculation INTTYPE_REST n_0_arrow_i_circ; // also used for E calculation - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A INTTYPE_REST n_paren_i_paren_circ_circ; INTTYPE_REST n_bracket_i_paren_circ_circ; @@ -129,7 +129,7 @@ class CountingLinkedList n_0_arrow_i_circ = 0; - // Added by us for filling out tables + // Added by Sand et al. (2014) for filling out tables // A n_paren_i_paren_circ_circ = 0; n_bracket_i_paren_circ_circ = 0; From 601bbb21491204bd2795a8c6ad0f3d8ce8392d03 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 14:01:56 +0000 Subject: [PATCH 20/27] Try long int --- src/int_stuff.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/int_stuff.h b/src/int_stuff.h index cd4fbc99..428c8e3a 100644 --- a/src/int_stuff.h +++ b/src/int_stuff.h @@ -3,8 +3,8 @@ #define INT_STUFF_H #if __cplusplus <= 199711L - #define INTTYPE_N4 long long // fails -pedantic - #define INTTYPE_REST long long // fails -pedantic + #define INTTYPE_N4 long int // long long fails -pedantic + #define INTTYPE_REST long int // long long fails -pedantic #else #include #define INTTYPE_N4 int_fast64_t // long long fails -pedantic From 94b4f740d5b96bdb75e3065015db57d301c53279 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 14:02:06 +0000 Subject: [PATCH 21/27] Update cran-comments.md --- cran-comments.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 74267b1e..d18a97ca 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,25 +2,25 @@ * local Windows 10 install, R 3.5.2 * win-builder, with `check_win_devel()` * Ubuntu 14.04.5 LTS, R 3.4 and devel, via [Travis CI](https://travis-ci.org/ms609/Quartet) -* R-hub, with `check_rhub()` +* R-hub, with `check_rhub(platforms = platforms())` * Installation failed with PREPERROR on rhub/ubuntu-gcc-release and - rhub/fedora-clang-devel, on account of failures to install the required - packages (`phangorn`; `git2r`). This seems to be an issue outside + rhub/fedora-clang-devel, on account of failures to install a required + dependency (`phangorn`). This seems to be an issue outside of my control; the Debian rhub installation reports success. - ## R CMD check results There were no ERRORs or WARNINGs. -There was 1 NOTE: +There was one NOTE: + + > Days since last update: 5 -* checking CRAN incoming feasibility ... NOTE - Maintainer: 'Smith Martin R. ' - - New submission - -This package is a new submission. +This release comes soon after the release of v1.0.0 on 2019-01-16, which failed +certain CRAN package checks -- Brian Ripley requested that these be fixed +immediately. After following Prof. Ripley's suggestions and testing the +errant platforms using `check_rhub`, it appears that the issues have been +resolved. ## Downstream dependencies There are currently no downstream dependencies for this package. From 2b660be14d03a28cd69825613b7798d8f8b113fb Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 21 Jan 2019 16:55:32 +0000 Subject: [PATCH 22/27] v1.0.0.9001 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6c97b74f..8e996383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: Quartet -Version: 1.0.0.9000 +Version: 1.0.0.9001 Date: 2019-01-21 Title: Comparison of Phylogenetic Trees Using Quartet and Bipartition Measures Description: Calculates the number of four-taxon subtrees consistent with a pair From a38929cc47e9212675ad1d514e8a1f078e40b512 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 22 Jan 2019 08:57:36 +0000 Subject: [PATCH 23/27] Update cran-comments.md --- cran-comments.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index d18a97ca..281fb8d0 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -5,22 +5,27 @@ * R-hub, with `check_rhub(platforms = platforms())` * Installation failed with PREPERROR on rhub/ubuntu-gcc-release and - rhub/fedora-clang-devel, on account of failures to install a required - dependency (`phangorn`). This seems to be an issue outside - of my control; the Debian rhub installation reports success. + rhub/fedora-clang-devel (and other platforms), on account of failures + to install a required dependency (`phangorn`). + This seems to be an issue outside of my control. + * Installation failed with ERROR on x86_64-pc-linux-gnu: + > "there is no package called `lattice`" + The failure to install the dependency `lattice` seems to be outwith my + control. ## R CMD check results There were no ERRORs or WARNINGs. There was one NOTE: - > Days since last update: 5 + > Days since last update: 6 -This release comes soon after the release of v1.0.0 on 2019-01-16, which failed +This release comes on the heels of v1.0.0 on 2019-01-16, which failed certain CRAN package checks -- Brian Ripley requested that these be fixed -immediately. After following Prof. Ripley's suggestions and testing the -errant platforms using `check_rhub`, it appears that the issues have been -resolved. +immediately and kindly proposed some suggestions for how portability could be +improved. +After implementing these and testing the relevant platforms using `check_rhub`, +I believe that the issues have been resolved. ## Downstream dependencies There are currently no downstream dependencies for this package. From 36d7229fb9fc593e6147bf3e5e86170d2b90139f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 22 Jan 2019 12:14:10 +0000 Subject: [PATCH 24/27] Use https: --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 25f69706..75b67aa5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -[![Project Status: Inactive.](http://www.repostatus.org/badges/latest/inactive.svg)](http://www.repostatus.org/#inactive) +[![Project Status: Inactive.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive) [![Build Status](https://travis-ci.org/ms609/Quartet.svg?branch=master)](https://travis-ci.org/ms609/Quartet) [![codecov](https://codecov.io/gh/ms609/Quartet/branch/master/graph/badge.svg)](https://codecov.io/gh/ms609/Quartet) -[![CRAN Status Badge](http://www.r-pkg.org/badges/version/Quartet)](https://cran.r-project.org/package=Quartet) -[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/Quartet)](https://cran.r-project.org/package=Quartet) +[![CRAN Status Badge](https://www.r-pkg.org/badges/version/Quartet)](https://cran.r-project.org/package=Quartet) +[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/Quartet)](https://cran.r-project.org/package=Quartet) [![DOI](https://zenodo.org/badge/80424189.svg)](https://zenodo.org/badge/latestdoi/80424189) # Quartet From 8bbe6b70c088252a2040cfd9b9c249708ea5475c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 22 Jan 2019 12:32:54 +0000 Subject: [PATCH 25/27] Platform detail --- cran-comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index 281fb8d0..052782e4 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -8,7 +8,7 @@ rhub/fedora-clang-devel (and other platforms), on account of failures to install a required dependency (`phangorn`). This seems to be an issue outside of my control. - * Installation failed with ERROR on x86_64-pc-linux-gnu: + * Installation failed with ERROR on ubuntu-gcc-devel and debian-gcc-patched: > "there is no package called `lattice`" The failure to install the dependency `lattice` seems to be outwith my control. From bcabec5f49d3bea7668141d7b12b95285c202123 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 22 Jan 2019 12:33:15 +0000 Subject: [PATCH 26/27] Remove unnecessary includes --- src/rQuartetDist.cpp | 5 +---- src/rTripletDist.cpp | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/rQuartetDist.cpp b/src/rQuartetDist.cpp index c17b1b07..a04131dc 100644 --- a/src/rQuartetDist.cpp +++ b/src/rQuartetDist.cpp @@ -1,12 +1,9 @@ #include using namespace Rcpp; -#include "int_stuff.h" +#include "int_stuff.h" #include "QuartetDistanceCalculator.h" -#include -#include -#include #include //' Triplet and quartet distances with tqDist diff --git a/src/rTripletDist.cpp b/src/rTripletDist.cpp index c09ca3e5..a8c82e02 100644 --- a/src/rTripletDist.cpp +++ b/src/rTripletDist.cpp @@ -1,13 +1,9 @@ #include using namespace Rcpp; -#include "int_stuff.h" +#include "int_stuff.h" #include "TripletDistanceCalculator.h" -#include -#include -#include -#include #include //' @describeIn tqdist_QuartetDistance Triplet distance between two trees From 70385f87b0c119a4fc40db3742f637aa8f6dd971 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" Date: Tue, 22 Jan 2019 15:03:31 +0000 Subject: [PATCH 27/27] Discuss alternative metrics Fixes #28 --- .zenodo.json | 2 +- DESCRIPTION | 4 +- NEWS.md | 2 +- R/TreeManipulation.R | 2 +- inst/REFERENCES.bib | 68 +++++++++++++++++++++++++++++ man/UnshiftTree.Rd | 2 +- src/Quartet-init.c | 2 +- vignettes/Tree-distance-metrics.Rmd | 30 +++++++++++++ 8 files changed, 105 insertions(+), 7 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index c4ef2f05..7f396558 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -2,7 +2,7 @@ "description": "An R package that calculates distances between phylogenetic topologies, integrating the tqDist algorithm for quartet distances", "license": "gpl-3.0", "title": "Quartet: Comparison of Phylogenetic Trees Using Quartet and Bipartition Measures", - "version": "v1.0.0", + "version": "v1.0.1", "upload_type": "software", "creators": [ { diff --git a/DESCRIPTION b/DESCRIPTION index 8d52cf56..9d3f7971 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Quartet -Version: 1.0.0.9001 -Date: 2019-01-21 +Version: 1.0.1 +Date: 2019-01-22 Title: Comparison of Phylogenetic Trees Using Quartet and Bipartition Measures Description: Calculates the number of four-taxon subtrees consistent with a pair of cladograms, calculating the symmetric quartet distance of Bandelt & Dress (1986), diff --git a/NEWS.md b/NEWS.md index f4400a2c..b95458e4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# Quartet v1.0.0.9000 +# Quartet v1.0.1 ## Portability - Improved portability of C++ code. diff --git a/R/TreeManipulation.R b/R/TreeManipulation.R index b4f3f364..9dd89f60 100644 --- a/R/TreeManipulation.R +++ b/R/TreeManipulation.R @@ -1,4 +1,4 @@ -#' Unshift Tree +#' Add Tree to Start of List #' #' Add a tree to the start of a list of trees #' diff --git a/inst/REFERENCES.bib b/inst/REFERENCES.bib index 1178ad16..9c0f6d7d 100644 --- a/inst/REFERENCES.bib +++ b/inst/REFERENCES.bib @@ -1,3 +1,60 @@ +@article{Bluis2003, + author = {Bluis, John and Shin, Dong Guk}, + doi = {10.1109/BIBE.2003.1188933}, + journal = {Proceedings - 3rd IEEE Symposium on BioInformatics and BioEngineering, BIBE 2003}, + pages = {87--94}, + publisher = {IEEE}, + title = {{Nodal distance algorithm: Calculating a phylogenetic tree comparison metric}}, + year = {2003} +} + +@incollection{Bocker2013, + address = {Berlin, Heidelberg}, + author = {B{\"{o}}cker, Sebastian and Canzar, Stefan and Klau, Gunnar W.}, + booktitle = {Algorithms in Bioinformatics. WABI 2013. Lecture Notes in Computer Science, vol 8126}, + doi = {10.1007/978-3-642-40453-5_13}, + editor = {Darling, A. and Stoye, J.}, + pages = {156--169}, + publisher = {Springer}, + title = {{The generalized Robinson-Foulds metric}}, + year = {2013} +} + + +@article{Bogdanowicz2012, + author = {Bogdanowicz, Damian and Giaro, Krzysztof}, + doi = {10.1109/TCBB.2011.48}, + issn = {15455963}, + journal = {IEEE/ACM Transactions on Computational Biology and Bioinformatics}, + number = {1}, + pages = {150--160}, + title = {{Matching split distance for unrooted binary phylogenetic trees}}, + volume = {9}, + year = {2012} +} + +@article{Bogdanowicz2013, + author = {Bogdanowicz, Damian and Giaro, Krzysztof}, + doi = {10.2478/amcs-2013-0050}, + journal = {International Journal of Applied Mathematics and Computer Science}, + number = {3}, + pages = {669--684}, + title = {{On a matching distance between rooted phylogenetic trees}}, + volume = {23}, + year = {2013} +} + +@article{Bogdanowicz2017, + author = {Bogdanowicz, Damian and Giaro, Krzysztof}, + doi = {10.1089/cmb.2016.0204}, + journal = {Journal of Computational Biology}, + number = {5}, + pages = {422--435}, + title = {{Comparing phylogenetic trees by matching nodes using the transfer distance between partitions}}, + volume = {24}, + year = {2017} +} + @article{Brodal2013, author = {Brodal, Gerth St{\o}lting and Fagerberg, Rolf and Mailund, Thomas and Pedersen, Christian N. S. and Sand, Andreas}, doi = {10.1137/1.9781611973105.130}, @@ -61,6 +118,17 @@ @article{Marczewski1958 year = {1958} } +@article{Nye2006, + author = {Nye, Tom M W and Li{\`{o}}, Pietro and Gilks, Walter R.}, + doi = {10.1093/bioinformatics/bti720}, + journal = {Bioinformatics}, + number = {1}, + pages = {117--119}, + title = {{A novel algorithm and web-based tool for comparing two alternative phylogenetic trees}}, + volume = {22}, + year = {2006} +} + @article{Penny1985, author = {Penny, David and Hendy, M. D.}, doi = {10.2307/2413347}, diff --git a/man/UnshiftTree.Rd b/man/UnshiftTree.Rd index 2191d2ce..d2ca7e9f 100644 --- a/man/UnshiftTree.Rd +++ b/man/UnshiftTree.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/TreeManipulation.R \name{UnshiftTree} \alias{UnshiftTree} -\title{Unshift Tree} +\title{Add Tree to Start of List} \usage{ UnshiftTree(add, treeList) } diff --git a/src/Quartet-init.c b/src/Quartet-init.c index 893f9f4d..7d5f27ce 100644 --- a/src/Quartet-init.c +++ b/src/Quartet-init.c @@ -1,5 +1,5 @@ #include -#include +#include /* for SEXP */ #include /* for NULL */ #include diff --git a/vignettes/Tree-distance-metrics.Rmd b/vignettes/Tree-distance-metrics.Rmd index 9d711d53..54c13d82 100644 --- a/vignettes/Tree-distance-metrics.Rmd +++ b/vignettes/Tree-distance-metrics.Rmd @@ -74,6 +74,8 @@ each pair of tips. The path difference metric [@Steel1993; `r Phangorn('path.dist')`] is the square root of the sum of squares of each of these differences. +The related nodal distance [@Bluis2003] is not considered further here. + ## Partition metric The Robinson-Foulds (RF or 'partition') metric [@Robinson1981; @Steel1993; phangorn's `r Phangorn('RF.dist')` or this package's `RobinsonFoulds`] @@ -372,5 +374,33 @@ all of the following desiderata: - Identifies pairs of trees that are more random than expected by chance - Does not reach its maximum value after relatively trivial rearrangements +# Improvements to partition metrics + +The primary issue with the Robinson-Foulds distance is its conservative +pairing of clades: a grouping is either identical in both trees, or is +treated as different. +This makes no account for the possibility that one tree contains a grouping that +is similar (though not quite identical) to a grouping in another. + +In order to incorporate some measure of similar-but-not-quite-identical clades, +it is necessary to construct an optimal matching that pairs each clade in each +tree with either a suitable clade in the other, or with no clade at all. + +Various approaches to this problem have been proposed; these typically search +for a matching that minimises the total dissimilarity summed for all pairings. +Approaches differ in how they penalize differences between paired groups. +Bogdanowicz and Giaro [-@Bogdanowicz2012;-@Bogdanowicz2013;-@Bogdanowicz2017] +calculate the size +of the largest bipartition that is consistent with both input groups; +Nye _et al_. [-@Nye2006] normalize this number using the Jaccard index; +Böcker _et al_. [-@Bocker2013] raise this value to an arbitrary exponent, and +add a constraint that prohibits pairings that comprise contradictory groups. + +These approaches represent a refinement of the Robinson-Foulds metric, +circumventing many of the issues raised above. They are, however, more +computationally expensive, and lack an objective measure of clade similarity. +I am not presently aware of an R implementation of any of these measures, +though a related metric is planned for a future version of this package. + # References \ No newline at end of file