Commit 7113617c authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

core/representative.{h,cpp}: export the coverage to .json as a float

parent 2d643a0e
......@@ -9,7 +9,7 @@ using namespace std;
RepresentativeComputer::RepresentativeComputer(list<Sequence> &r)
:sequences(r),is_computed(false),representative(),min_cover(1),
percent_cover(0.5),revcomp(true),required(""),coverage("") {
percent_cover(0.5),revcomp(true),required(""),coverage(0.0),coverage_info("") {
}
Sequence RepresentativeComputer::getRepresentative() const{
......@@ -54,10 +54,14 @@ string KmerRepresentativeComputer::getSeed() const{
return seed;
}
string KmerRepresentativeComputer::getCoverage() const{
float KmerRepresentativeComputer::getCoverage() const{
return coverage;
}
string KmerRepresentativeComputer::getCoverageInfo() const{
return coverage_info;
}
void KmerRepresentativeComputer::setStabilityLimit(int limit) {
stability_limit = limit;
}
......@@ -156,12 +160,12 @@ void KmerRepresentativeComputer::compute() {
representative.quality = "";
int length = stats_length.getAverage();
float ratio = (float) length_longest_run / length;
coverage = (float) length_longest_run / length;
coverage = string_of_int(length_longest_run) + " bp"
+ " (" + string_of_int(100 * ratio) + "% of " + string_of_int(length) + " bp)";
coverage_info = string_of_int(length_longest_run) + " bp"
+ " (" + string_of_int(100 * coverage) + "% of " + string_of_int(length) + " bp)";
representative.label += " - " + coverage ;
representative.label += " - " + coverage_info ;
}
delete index;
}
......@@ -22,7 +22,8 @@ protected:
float percent_cover;
bool revcomp;
string required;
string coverage;
float coverage;
string coverage_info;
public:
RepresentativeComputer(list<Sequence> &r);
......@@ -97,7 +98,8 @@ public:
// Getters, setters
string getSeed() const;
string getCoverage() const;
float getCoverage() const;
string getCoverageInfo() const;
/**
* @param limit: maximal number of iterations to be performed before reaching
......
......@@ -1221,6 +1221,10 @@ int main (int argc, char **argv)
json_coverage.add(repComp.getCoverage());
json_clone.add("_coverage", json_coverage);
JsonArray json_coverage_info;
json_coverage_info.add(repComp.getCoverageInfo());
json_clone.add("_coverage_info", json_coverage_info);
// From FineSegmenter
json_clone.add("sequence", seg.getSequence().sequence);
......
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