From: Benjamin Buchfink <buchfink@gmail.com>
Date: Mon, 17 Feb 2020 13:51:26 +0100
Subject: [PATCH] Fixed #324
Forwarded: https://github.com/bbuchfink/diamond/commit/aea535c07e09fd41c5ab48ae72b6901d01d8decb
--- diamond-aligner.orig/src/basic/masking.cpp
+++ diamond-aligner/src/basic/masking.cpp
@@ -53,12 +53,12 @@
 
 void Masking::operator()(Letter *seq, size_t len) const
 {
-	Util::tantan::mask(seq, len, (const float**)probMatrixPointersf_, 0.005f, 0.05f, 1.0f / 0.9f, config.tantan_minMaskProb, mask_table_x_);
+	Util::tantan::mask(seq, (int)len, (const float**)probMatrixPointersf_, 0.005f, 0.05f, 1.0f / 0.9f, (float)config.tantan_minMaskProb, mask_table_x_);
 }
 
 void Masking::mask_bit(Letter *seq, size_t len) const
 {
-	Util::tantan::mask(seq, len, (const float**)probMatrixPointersf_, 0.005f, 0.05f, 1.0f / 0.9f, config.tantan_minMaskProb, mask_table_bit_);
+	Util::tantan::mask(seq, (int)len, (const float**)probMatrixPointersf_, 0.005f, 0.05f, 1.0f / 0.9f, (float)config.tantan_minMaskProb, mask_table_bit_);
 }
 
 void Masking::bit_to_hard_mask(Letter *seq, size_t len, size_t &n) const
--- diamond-aligner.orig/src/test/simulate.cpp
+++ diamond-aligner/src/test/simulate.cpp
@@ -1,3 +1,23 @@
+/****
+DIAMOND protein aligner
+Copyright (C) 2013-2020 Max Planck Society for the Advancement of Science e.V.
+                        Benjamin Buchfink
+                        Eberhard Karls Universitaet Tuebingen
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+****/
+
 #include <string>
 #include "test.h"
 #include "../util/util.h"
--- /dev/null
+++ diamond-aligner/src/test/test_cases.cpp
@@ -0,0 +1,33 @@
+/****
+DIAMOND protein aligner
+Copyright (C) 2013-2020 Max Planck Society for the Advancement of Science e.V.
+                        Benjamin Buchfink
+                        Eberhard Karls Universitaet Tuebingen
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+****/
+
+#include "test.h"
+
+namespace Test {
+
+const TestCase test_cases[] = {
+	{ "blastp (default)", "blastp" }
+};
+
+const uint64_t ref_hashes[] = {
+	0
+};
+
+}
\ No newline at end of file
--- diamond-aligner.orig/src/tools/roc.cpp
+++ diamond-aligner/src/tools/roc.cpp
@@ -122,7 +122,7 @@
 			}
 			stats = QueryStats(r.qseqid, families);
 		}
-		if (r.qseqid.empty() || r.sseqid.empty() || std::isnan(r.evalue) || !std::isfinite(r.evalue) || r.evalue > 100.0 || r.evalue < 0.0)
+		if (r.qseqid.empty() || r.sseqid.empty() || std::isnan(r.evalue) || !std::isfinite(r.evalue) || r.evalue < 0.0)
 			throw std::runtime_error("Format error.");
 		stats.add(r, acc2fam);
 		++n;
--- diamond-aligner.orig/src/util/string/string.h
+++ diamond-aligner/src/util/string/string.h
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <algorithm>
 #include <ostream>
+#include <vector>
 
 inline bool ends_with(const std::string &s, const char *t) {
 	const size_t l = strlen(t);
@@ -28,6 +29,15 @@
 	return l;
 }
 
+template<typename _it>
+inline std::vector<const char*> charp_array(_it begin, _it end) {
+	std::vector<const char*> v;
+	v.reserve(end - begin);
+	for (auto i = begin; i != end; ++i)
+		v.push_back(i->c_str());
+	return v;
+}
+
 #define MAX_LEN(A) max_len(A, sizeof(A)/sizeof(A[0]))
 
 std::string convert_size(size_t size);
--- diamond-aligner.orig/src/util/tantan.cpp
+++ diamond-aligner/src/util/tantan.cpp
@@ -35,20 +35,20 @@
 
 void mask(char *seq,
 	int len,
-	const float_t **likelihood_ratio_matrix,
-	float_t p_repeat,
-	float_t p_repeat_end,
-	float_t repeat_growth,
-	float_t p_mask,
+	const float **likelihood_ratio_matrix,
+	float p_repeat,
+	float p_repeat_end,
+	float repeat_growth,
+	float p_mask,
 	const char *mask_table) {
 	constexpr int WINDOW = 50, RESERVE = 50000;
 
-	thread_local std::array<Array<float_t, Dynamic, 1>, AMINO_ACID_COUNT> e;
-	thread_local Array<float_t, Dynamic, 1> pb;
-	thread_local Array<float_t, Dynamic, 1> scale;
-	Array<float_t, WINDOW, 1> f(0.0), d, t;
-	const float_t b2b = 1 - p_repeat, f2f = 1 - p_repeat_end, b2f0 = p_repeat * (1 - repeat_growth) / (1 - pow(repeat_growth, WINDOW));
-	float_t b = 1.0;
+	thread_local std::array<Array<float, Dynamic, 1>, AMINO_ACID_COUNT> e;
+	thread_local Array<float, Dynamic, 1> pb;
+	thread_local Array<float, Dynamic, 1> scale;
+	Array<float, WINDOW, 1> f(0.0), d, t;
+	const float b2b = 1 - p_repeat, f2f = 1 - p_repeat_end, b2f0 = p_repeat * (1 - repeat_growth) / (1 - pow(repeat_growth, WINDOW));
+	float b = 1.0;
 	
 	d[WINDOW - 1] = b2f0;
 	for (int i = WINDOW - 2; i >= 0; --i)
@@ -59,15 +59,15 @@
 
 	for (int i = 0; i < (int)AMINO_ACID_COUNT; ++i) {
 		e[i].resize(std::max(RESERVE, len + WINDOW));
-		const float_t *l = likelihood_ratio_matrix[i];
-		float_t* p = &e[i][len - 1];
+		const float *l = likelihood_ratio_matrix[i];
+		float* p = &e[i][len - 1];
 		for (int j = 0; j < len; ++j)
 			*(p--) = l[(size_t)seq[j]];
-		std::fill(e[i].data() + len, e[i].data() + len + WINDOW, (float_t)0.0);
+		std::fill(e[i].data() + len, e[i].data() + len + WINDOW, (float)0.0);
 	}	
 
 	for (int i = 0; i < len; ++i) {
-		const float_t s = f.sum();
+		const float s = f.sum();
 		t = b;
 		t *= d;
 		f *= f2f;
@@ -76,7 +76,7 @@
 		b = b * b2b + s * p_repeat_end;
 
 		if ((i & 15) == 15) {
-			const float_t s = 1 / b;
+			const float s = 1 / b;
 			scale[i / 16] = s;
 			b *= s;
 			f *= s;
@@ -85,15 +85,15 @@
 		pb[i] = b;
 	}
 
-	const float_t z = b * b2b + f.sum() * p_repeat_end;
+	const float z = b * b2b + f.sum() * p_repeat_end;
 	b = b2b;
 	f = p_repeat_end;
 
 	for (int i = len - 1; i >= 0; --i) {
-		const float_t pf = 1 - (pb[i] * b / z);
+		const float pf = 1 - (pb[i] * b / z);
 
 		if ((i & 15) == 15) {
-			const float_t s = scale[i / 16];
+			const float s = scale[i / 16];
 			b *= s;
 			f *= s;
 		}
--- diamond-aligner.orig/src/util/tantan.h
+++ diamond-aligner/src/util/tantan.h
@@ -25,9 +25,7 @@
 
 namespace Util { namespace tantan {
 
-typedef float float_t;
-
-DECL_DISPATCH(void, mask, (char *seq, int len, const float_t **likelihood_ratio_matrix, float_t p_repeat, float_t p_repeat_end, float_t repeat_decay, float_t p_mask, const char *maskTable))
+DECL_DISPATCH(void, mask, (char *seq, int len, const float **likelihood_ratio_matrix, float p_repeat, float p_repeat_end, float repeat_decay, float p_mask, const char *maskTable))
 
 }}
 
