Commit 20adc88e authored by Marc Duez's avatar Marc Duez

vidjil.cpp : output similarity matrix

parent 95341e1a
......@@ -71,6 +71,7 @@ SimilarityMatrix compare_all(list <Sequence> sequences,
float identity = identity_percent(score);
matrix.setScore(num, num_num, identity);
matrix.setScore(num_num, num, identity);
}
......@@ -129,6 +130,7 @@ SimilarityMatrix compare_windows(WindowsStorage &windowsStorage, const Cost theC
//Put the score at position1 / position2 of the array
matrix.setScore(positionIt1, positionIt2, score);
matrix.setScore(positionIt2, positionIt1, score);
}
......
......@@ -189,18 +189,17 @@ JsonArray &operator<<(JsonArray &out, const JsonOutputSimilarityMatrix &outputMa
json &operator<<(json &out, const JsonOutputWindowsMatrix &outputMatrix) {
SimilarityMatrix &matrix = outputMatrix.matrix;
out = {
{"index", json::object()}, //index clone id > matrix row/column
{"matrix", json::array()} //2 dimensional array
};
for (int i = 0; i < matrix.size(); i++) {
//out["index"][] =
out["matrix"][i] = json::array();
for (int j = 0; j < matrix.size(); j++) {
if (i < j) {
//Creation of an edges objects array, which contains a source objet, a target object, and the length of the distance between them
json lineEdge;
lineEdge = {
{"source", i},
{"target", j},
{"len", fabs(matrix(i,j))}
};
out.push_back(lineEdge);
}
out["matrix"][i][j] = fabs(matrix(i,j));
}
}
return out;
......
......@@ -1437,7 +1437,7 @@ int main (int argc, char **argv)
}
//Added edges in the json output file
j["links"] = jsonLevenshtein;
j["similarity"] = jsonLevenshtein;
out_json << j.dump(2);
delete multigermline ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment