From ce106457b4142339c6692d46e6cddd4d3de8f91c Mon Sep 17 00:00:00 2001 From: fuji Date: Fri, 21 Jan 2022 08:53:27 +0900 Subject: [PATCH 1/3] fix: Use std::sort instead of QSortInt --- src/hhalignment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hhalignment.cpp b/src/hhalignment.cpp index 88f5a05f..72549278 100755 --- a/src/hhalignment.cpp +++ b/src/hhalignment.cpp @@ -1677,7 +1677,7 @@ int Alignment::Filter2(char keep[], int coverage, int qid, float qsc, ksort = new int[N_in]; // never reuse alignment object for new alignment with more sequences for (k = 0; k < N_in; ++k) ksort[k] = k; - QSortInt(nres, ksort, kfirst + 1, N_in - 1, -1); //Sort sequences after kfirst (query) in descending order + std::sort(ksort + kfirst + 1 , ksort+ N_in, [this](int a, int b){ return nres[a] > nres[b];}); //Sort sequences after kfirst (query) in descending order } for (kk = 0; kk < N_in; ++kk) { inkk[kk] = in[ksort[kk]]; From 5ae14ea7f384e5d41f53c678c34daf62b1770618 Mon Sep 17 00:00:00 2001 From: fuji8 Date: Fri, 21 Jan 2022 16:16:21 +0900 Subject: [PATCH 2/3] fix: sort->stable_sort --- src/hhalignment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hhalignment.cpp b/src/hhalignment.cpp index 72549278..6de36aba 100755 --- a/src/hhalignment.cpp +++ b/src/hhalignment.cpp @@ -1677,7 +1677,7 @@ int Alignment::Filter2(char keep[], int coverage, int qid, float qsc, ksort = new int[N_in]; // never reuse alignment object for new alignment with more sequences for (k = 0; k < N_in; ++k) ksort[k] = k; - std::sort(ksort + kfirst + 1 , ksort+ N_in, [this](int a, int b){ return nres[a] > nres[b];}); //Sort sequences after kfirst (query) in descending order + std::stable_sort(ksort + kfirst + 1 , ksort+ N_in, [this](int a, int b){ return nres[a] > nres[b];}); //Sort sequences after kfirst (query) in descending order } for (kk = 0; kk < N_in; ++kk) { inkk[kk] = in[ksort[kk]]; From 90ddfb860c533e38be597f5ecaf5bb81babfaab4 Mon Sep 17 00:00:00 2001 From: fuji Date: Tue, 1 Feb 2022 05:53:46 +0900 Subject: [PATCH 3/3] fix: Do not use lambda expression --- src/hhalignment.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hhalignment.cpp b/src/hhalignment.cpp index 6de36aba..d95d967e 100755 --- a/src/hhalignment.cpp +++ b/src/hhalignment.cpp @@ -1673,11 +1673,20 @@ int Alignment::Filter2(char keep[], int coverage, int qid, float qsc, } // Sort sequences according to length; afterwards, nres[ksort[kk]] is sorted by size + + struct sortDesc + { + int* _nres; + sortDesc(int* nres) : _nres(nres){} + bool operator()(int left, int right) { + return _nres[left] > _nres[right]; + } + }; if (ksort == NULL) { ksort = new int[N_in]; // never reuse alignment object for new alignment with more sequences for (k = 0; k < N_in; ++k) ksort[k] = k; - std::stable_sort(ksort + kfirst + 1 , ksort+ N_in, [this](int a, int b){ return nres[a] > nres[b];}); //Sort sequences after kfirst (query) in descending order + std::stable_sort(ksort + kfirst + 1 , ksort+ N_in, sortDesc(nres)); //Sort sequences after kfirst (query) in descending order } for (kk = 0; kk < N_in; ++kk) { inkk[kk] = in[ksort[kk]];