Commit 20a1d400 authored by Mikael Salson's avatar Mikael Salson

windows: getAverageLength() gives the average read length with a given window

parent c1eeb275
...@@ -23,6 +23,11 @@ string WindowsStorage::getLabel(junction window) { ...@@ -23,6 +23,11 @@ string WindowsStorage::getLabel(junction window) {
return windows_labels[window]; return windows_labels[window];
} }
float WindowsStorage::getAverageLength(junction window) {
assert(hasWindow(window));
return stats_by_window[window].getAverage();
}
Germline *WindowsStorage::getGermline(junction window) { Germline *WindowsStorage::getGermline(junction window) {
map<junction, Germline *>::iterator result = germline_by_window.find(window); map<junction, Germline *>::iterator result = germline_by_window.find(window);
if (result == germline_by_window.end()) if (result == germline_by_window.end())
...@@ -70,7 +75,7 @@ KmerRepresentativeComputer WindowsStorage::getRepresentativeComputer(junction wi ...@@ -70,7 +75,7 @@ KmerRepresentativeComputer WindowsStorage::getRepresentativeComputer(junction wi
repComp.setMinCover(min_cover); repComp.setMinCover(min_cover);
repComp.setPercentCoverage(percent_cover); repComp.setPercentCoverage(percent_cover);
repComp.setRequiredSequence(window); repComp.setRequiredSequence(window);
repComp.setCoverageReferenceLength(stats_by_window[window].getAverage()); repComp.setCoverageReferenceLength(getAverageLength(window));
repComp.compute(); repComp.compute();
// We should always have a representative, because // We should always have a representative, because
......
...@@ -61,6 +61,11 @@ class WindowsStorage { ...@@ -61,6 +61,11 @@ class WindowsStorage {
JsonList statusToJson(junction window); JsonList statusToJson(junction window);
/**
* @return the average read length of the reads segmented with the given window
*/
float getAverageLength(junction window);
/** /**
* @return the maximal number of reads that can be stored for a window. * @return the maximal number of reads that can be stored for a window.
*/ */
......
...@@ -1270,6 +1270,11 @@ int main (int argc, char **argv) ...@@ -1270,6 +1270,11 @@ int main (int argc, char **argv)
json_coverage.add(repComp.getCoverage()); json_coverage.add(repComp.getCoverage());
json_clone.add("_coverage", json_coverage); json_clone.add("_coverage", json_coverage);
JsonArray json_avg_length;
float average_read_length = windowsStorage->getAverageLength(it->first);
json_avg_length.add(average_read_length);
json_clone.add("_average_read_length", json_avg_length);
JsonArray json_coverage_info; JsonArray json_coverage_info;
json_coverage_info.add(repComp.getCoverageInfo()); json_coverage_info.add(repComp.getCoverageInfo());
json_clone.add("_coverage_info", json_coverage_info); json_clone.add("_coverage_info", json_coverage_info);
......
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