Commit 4f577854 authored by Mikaël Salson's avatar Mikaël Salson Committed by Mathieu Giraud

algo/tests/unit-tests: Use a deterministic scorer for the tests

It is hard to predict the result is not totally deterministic
(as is the case with the RandomScorer, which is now by default,
whose results depend on the pseudo-random generator that may
differ depending on the OSes)

See #3866
parent 2b6236fb
Pipeline #78577 failed with stages
in 10 minutes and 53 seconds
#include "core/bioreader.hpp"
#include "core/representative.h"
#include "core/read_score.h"
void testRepresentative() {
list<Sequence> reads = BioReader("data/representative.fq").getAll();
......@@ -13,7 +14,8 @@ void testRepresentative() {
krc.setCoverageReferenceLength(50);
krc.setRequiredSequence("CCGGGGGGGGGGTTT");
krc.compute();
ReadQualityScore vrs = ReadQualityScore();
krc.compute(vrs);
Sequence representative = krc.getRepresentative();
// Seq3 is the longest it should be taken when performing 0 extra iteration
......@@ -21,20 +23,20 @@ void testRepresentative() {
"If we take the first representative we should have seq3, and not at the beginning (" << representative.label << " instead)");
krc.setStabilityLimit(1);
krc.compute();
krc.compute(vrs);
representative = krc.getRepresentative();
TAP_TEST_EQUAL(representative.label.find("seq3-[37,73]"), 0, TEST_KMER_REPRESENTATIVE,
"When allowing one step before stability, we should still have seq3 (" << representative.label << " instead)");
krc.setStabilityLimit(2);
krc.compute();
krc.compute(vrs);
representative = krc.getRepresentative();
TAP_TEST_EQUAL(representative.label.find("seq1-[0,41]"), 0, TEST_KMER_REPRESENTATIVE,
"When allowing two steps before stability, we should reach seq1 (" << representative.label << " instead)");
krc.setRevcomp(true);
krc.setRequiredSequence("ATCGCGCCCT"); // revcomp
krc.compute();
krc.compute(vrs);
representative = krc.getRepresentative();
string quality = krc.getQuality();
TAP_TEST_EQUAL(representative.label.find("seq2-[33,52]"), 0, TEST_KMER_REPRESENTATIVE_REQUIRED_SEQ,
......@@ -47,7 +49,7 @@ void testRepresentative() {
krc.setRevcomp(false);
krc.compute();
krc.compute(vrs);
TAP_TEST(! krc.hasRepresentative(), TEST_KMER_REPRESENTATIVE_REQUIRED_SEQ,
"When requiring sequence AGGGCGCGAT and revcomp=false, we shouldn't find anything (the sequence is revcomp-ed)");
}
......
#include <core/windows.h>
#include <core/germline.h>
#include <core/bioreader.hpp>
#include <core/read_score.h>
#include <map>
void testWSAdd() {
......@@ -110,6 +111,8 @@ void testWSAdd() {
void testWSAddWithLimit() {
map<string, string> labels;
WindowsStorage ws(labels);
ReadQualityScore rqs;
ws.setScorer(&rqs);
ws.setMaximalNbReadsPerWindow(3);
ws.setBinParameters(1, 20);
Sequence seq = {"label", "l", "GATACATTAGACAGCT", "", 0};
......
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