From 182bb671e67073ccf89e526a8b93bdc9f78e9d1a Mon Sep 17 00:00:00 2001 From: kasrat93 Date: Wed, 23 Jun 2021 13:29:47 +0200 Subject: [PATCH 1/5] change interface --- .../OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.h | 2 +- .../OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.h | 2 +- .../OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmSimilarity.h | 2 +- .../source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp | 8 +++++--- .../source/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.cpp | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.h b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.h index 32b367497d5..1bf7fb3bca4 100644 --- a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.h +++ b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.h @@ -69,7 +69,7 @@ namespace OpenMS void updateMembers_() override; /// Sequence similarity based on matching ions - double getSimilarity_(AASequence seq1, AASequence seq2) override; + double getSimilarity_(const AASequence& seq1, const AASequence& seq2) override; }; diff --git a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.h b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.h index aa990feddfb..61586419794 100644 --- a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.h +++ b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.h @@ -68,7 +68,7 @@ namespace OpenMS ConsensusIDAlgorithmPEPMatrix& operator=(const ConsensusIDAlgorithmPEPMatrix&); /// Sequence similarity based on substitution matrix (ignores PTMs) - double getSimilarity_(AASequence seq1, AASequence seq2) override; + double getSimilarity_(const AASequence& seq1, const AASequence& seq2) override; // Docu in base class void updateMembers_() override; diff --git a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmSimilarity.h b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmSimilarity.h index 93a87af2b83..f3e60999487 100644 --- a/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmSimilarity.h +++ b/src/openms/include/OpenMS/ANALYSIS/ID/ConsensusIDAlgorithmSimilarity.h @@ -71,7 +71,7 @@ namespace OpenMS @return Similarity between two sequences in the range [0, 1] */ - virtual double getSimilarity_(AASequence seq1, AASequence seq2) = 0; + virtual double getSimilarity_(const AASequence& seq1, const AASequence& seq2) = 0; private: /// Not implemented diff --git a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp index 5074fb33059..e2c83d968c6 100644 --- a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp +++ b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp @@ -66,12 +66,14 @@ namespace OpenMS } - double ConsensusIDAlgorithmPEPIons::getSimilarity_(AASequence seq1, - AASequence seq2) + double ConsensusIDAlgorithmPEPIons::getSimilarity_(const AASequence& seq1, + const AASequence& seq2) { if (seq1 == seq2) return 1.0; // order of sequences matters for cache look-up: - if (seq2 < seq1) std::swap(seq1, seq2); // "operator>" not defined + String unmod_seq1 = seq1.toUnmodifiedString(); //for swap, not to throw errors with const + String unmod_seq2 = seq1.toUnmodifiedString(); + if (seq2 < seq1) std::swap(unmod_seq1, unmod_seq2); // "operator>" not defined pair seq_pair = make_pair(seq1, seq2); SimilarityCache::iterator pos = similarities_.find(seq_pair); if (pos != similarities_.end()) return pos->second; // score found in cache diff --git a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.cpp b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.cpp index 9db76575608..aa4426c19ac 100644 --- a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.cpp +++ b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPMatrix.cpp @@ -74,8 +74,8 @@ namespace OpenMS similarities_.clear(); } - double ConsensusIDAlgorithmPEPMatrix::getSimilarity_(AASequence seq1, - AASequence seq2) + double ConsensusIDAlgorithmPEPMatrix::getSimilarity_(const AASequence& seq1, + const AASequence& seq2) { // here we cannot take modifications into account: String unmod_seq1 = seq1.toUnmodifiedString(); From 56b3f7618aaf182c68fc098877c8eb595de99362 Mon Sep 17 00:00:00 2001 From: kasrat93 Date: Tue, 29 Jun 2021 21:06:02 +0200 Subject: [PATCH 2/5] remove swap --- .../source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp index e2c83d968c6..01b66d7a092 100644 --- a/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp +++ b/src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithmPEPIons.cpp @@ -70,10 +70,8 @@ namespace OpenMS const AASequence& seq2) { if (seq1 == seq2) return 1.0; - // order of sequences matters for cache look-up: - String unmod_seq1 = seq1.toUnmodifiedString(); //for swap, not to throw errors with const - String unmod_seq2 = seq1.toUnmodifiedString(); - if (seq2 < seq1) std::swap(unmod_seq1, unmod_seq2); // "operator>" not defined + // order of sequences matters for cache look-up: + if (seq2 < seq1) getSimilarity_(seq2, seq1); // "operator>" not defined pair seq_pair = make_pair(seq1, seq2); SimilarityCache::iterator pos = similarities_.find(seq_pair); if (pos != similarities_.end()) return pos->second; // score found in cache From 152a6e3bdf33aed7588fbc045795ffac4ac04f4f Mon Sep 17 00:00:00 2001 From: kasrat93 Date: Thu, 1 Jul 2021 16:45:22 +0200 Subject: [PATCH 3/5] remove std::move --- src/openms/source/FORMAT/FASTAFile.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/openms/source/FORMAT/FASTAFile.cpp b/src/openms/source/FORMAT/FASTAFile.cpp index 5e435a8adb8..743e7685d76 100644 --- a/src/openms/source/FORMAT/FASTAFile.cpp +++ b/src/openms/source/FORMAT/FASTAFile.cpp @@ -198,10 +198,6 @@ namespace OpenMS } ++entries_read_; - protein.identifier = std::move(id_); - protein.description = std::move(description_); - protein.sequence = std::move(seq_); - return true; } From d8e1cf27d85d73eb7896146083e24657affe59f2 Mon Sep 17 00:00:00 2001 From: kasrat93 Date: Fri, 2 Jul 2021 17:32:29 +0200 Subject: [PATCH 4/5] reset --- src/openms/source/FORMAT/FASTAFile.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openms/source/FORMAT/FASTAFile.cpp b/src/openms/source/FORMAT/FASTAFile.cpp index 743e7685d76..5e435a8adb8 100644 --- a/src/openms/source/FORMAT/FASTAFile.cpp +++ b/src/openms/source/FORMAT/FASTAFile.cpp @@ -198,6 +198,10 @@ namespace OpenMS } ++entries_read_; + protein.identifier = std::move(id_); + protein.description = std::move(description_); + protein.sequence = std::move(seq_); + return true; } From da3d0d8c9e3fe4685e7612dbbef9e0100258a047 Mon Sep 17 00:00:00 2001 From: kasrat93 Date: Fri, 2 Jul 2021 20:46:37 +0200 Subject: [PATCH 5/5] rm move --- src/openms/source/FORMAT/FASTAFile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openms/source/FORMAT/FASTAFile.cpp b/src/openms/source/FORMAT/FASTAFile.cpp index 5e435a8adb8..c6fe223f7dd 100644 --- a/src/openms/source/FORMAT/FASTAFile.cpp +++ b/src/openms/source/FORMAT/FASTAFile.cpp @@ -198,9 +198,9 @@ namespace OpenMS } ++entries_read_; - protein.identifier = std::move(id_); - protein.description = std::move(description_); - protein.sequence = std::move(seq_); + protein.identifier = id_; + protein.description = description_; + protein.sequence = seq_; return true; }