Commit 6def2c4c authored by Mikaël Salson's avatar Mikaël Salson Committed by Mathieu Giraud
Browse files

core/representative: The required sequence is now mandatory.

With the previous implementation we could find a representative without
the required sequence serving as an anchor. Now it is more difficult
and therefore it becomes mandatory. This is not a problem as in
practice we always have a required sequence (the window).
parent 8f6f8bd1
......@@ -83,6 +83,7 @@ KmerRepresentativeComputer::KmerRepresentativeComputer(list<Sequence> &r,
void KmerRepresentativeComputer::compute(bool try_hard) {
assert(coverage_reference_length > 0);
assert(required.length() > 0);
is_computed = false;
string seed = getSeed();
......
......@@ -55,6 +55,7 @@ public:
/**
* Compute the representative depending on the parameters set by the functions
* @pre setRequiredSequence() must have been called (with a non-empty string).
*/
virtual void compute(bool try_hard=false) = 0;
......@@ -86,7 +87,7 @@ public:
/**
* Sequence that the representative must contain absolutely.
* This sequence should appear only once in a read.
* Setting the sequence is not required and it can be empty.
* Calling this method is mandatory.
*/
void setRequiredSequence(string sequence);
......
......@@ -11,6 +11,7 @@ void testRepresentative() {
krc.setMinCover(1);
krc.setPercentCoverage(0.5);
krc.setCoverageReferenceLength(50);
krc.setRequiredSequence("CCGGGGGGGGGGTTT");
krc.compute();
Sequence representative = krc.getRepresentative();
......@@ -49,13 +50,6 @@ void testRepresentative() {
krc.compute();
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)");
krc.setRequiredSequence("");
krc.setMinCover(4);
krc.compute();
TAP_TEST(! krc.hasRepresentative(), TEST_KMER_REPRESENTATIVE,
"When requiring 4 reads to support the representative, we should not find any solution.");
}
void testRevcompRepresentative() {
......@@ -64,6 +58,7 @@ void testRevcompRepresentative() {
KmerRepresentativeComputer krc(reads, "##############");
krc.setOptions(false, 3, 0.5);
krc.setCoverageReferenceLength(50);
krc.setRequiredSequence("ACATGGTATAACGACGG");
krc.compute();
Sequence representative = krc.getRepresentative();
......@@ -75,6 +70,7 @@ void testRevcompRepresentative() {
KmerRepresentativeComputer krc2(reads, "##############");
krc2.setOptions(false, 3, 0.5);
krc2.setCoverageReferenceLength(50);
krc2.setRequiredSequence("CCGTCGTTATACCATGT");
krc2.compute();
Sequence representative2 = krc2.getRepresentative();
......
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