Commit 38cbe4db authored by Mathieu Giraud's avatar Mathieu Giraud

core/representative.{h,cpp}: the coverage info takes into account all the reads

Previously, it tooks only into account the top reads, giving erroneous information when
there were some chimeric reads.

Now coverage_reference_length is given by stats_by_window[]
+ remove ad-hoc stats computation in representative.cpp.
parent 5b324520
......@@ -50,6 +50,10 @@ void RepresentativeComputer::setRequiredSequence(string sequence) {
required = sequence;
}
void RepresentativeComputer::setCoverageReferenceLength(float coverage_reference_length) {
this->coverage_reference_length = coverage_reference_length;
}
string KmerRepresentativeComputer::getSeed() const{
return seed;
}
......@@ -94,13 +98,9 @@ void KmerRepresentativeComputer::compute() {
Sequence sequence_longest_run;
size_t k = getSeed().length();
Stats stats_length;
for (size_t seq = 1; seq <= sequences.size() && seq <= seq_index_longest_run + stability_limit ; seq++) {
Sequence sequence = rc.getithBest(seq);
stats_length.insert(sequence.sequence.size());
if (sequence.sequence.size() <= length_longest_run) {
continue;
}
......@@ -159,11 +159,10 @@ void KmerRepresentativeComputer::compute() {
representative.quality = "";
int length = stats_length.getAverage();
coverage = (float) length_longest_run / length;
coverage = (float) length_longest_run / coverage_reference_length;
coverage_info = string_of_int(length_longest_run) + " bp"
+ " (" + string_of_int(100 * coverage) + "% of " + string_of_int(length) + " bp)";
+ " (" + string_of_int(100 * coverage) + "% of " + fixed_string_of_float(coverage_reference_length, 1) + " bp)";
representative.label += " - " + coverage_info ;
}
......
......@@ -22,6 +22,7 @@ protected:
float percent_cover;
bool revcomp;
string required;
float coverage_reference_length;
float coverage;
string coverage_info;
public:
......@@ -83,6 +84,11 @@ public:
* Setting the sequence is not required and it can be empty.
*/
void setRequiredSequence(string sequence);
/**
* @param coverage_reference_length: reference length used to compute the coverage
*/
void setCoverageReferenceLength(float coverage_reference_length);
};
/**
......
......@@ -70,6 +70,7 @@ KmerRepresentativeComputer WindowsStorage::getRepresentativeComputer(junction wi
repComp.setMinCover(min_cover);
repComp.setPercentCoverage(percent_cover);
repComp.setRequiredSequence(window);
repComp.setCoverageReferenceLength(stats_by_window[window].getAverage());
repComp.compute();
// We should always have a representative, because
......
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