Commit 0a9ee9f1 authored by Marc Duez's avatar Marc Duez
Browse files
parents 4051342b 6f5718f6
......@@ -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("") {
percent_cover(0.5),revcomp(true),required(""),coverage("") {
}
Sequence RepresentativeComputer::getRepresentative() const{
......@@ -54,6 +54,10 @@ string KmerRepresentativeComputer::getSeed() const{
return seed;
}
string KmerRepresentativeComputer::getCoverage() const{
return coverage;
}
void KmerRepresentativeComputer::setStabilityLimit(int limit) {
stability_limit = limit;
}
......@@ -150,9 +154,12 @@ void KmerRepresentativeComputer::compute() {
representative.quality = "";
int length = stats_length.getAverage();
float ratio = length_longest_run / length;
representative.label += " - " + string_of_int(length_longest_run) + " bp"
float ratio = (float) length_longest_run / length;
coverage = string_of_int(length_longest_run) + " bp"
+ " (" + string_of_int(100 * ratio) + "% of " + string_of_int(length) + " bp)";
representative.label += " - " + coverage ;
}
delete index;
}
......@@ -22,6 +22,7 @@ protected:
float percent_cover;
bool revcomp;
string required;
string coverage;
public:
RepresentativeComputer(list<Sequence> &r);
......@@ -96,6 +97,7 @@ public:
// Getters, setters
string getSeed() const;
string getCoverage() const;
/**
* @param limit: maximal number of iterations to be performed before reaching
......
......@@ -57,7 +57,7 @@ list<Sequence> WindowsStorage::getReads(junction window) {
return seqs_by_window[window].getReads();
}
Sequence WindowsStorage::getRepresentative(junction window,
KmerRepresentativeComputer WindowsStorage::getRepresentativeComputer(junction window,
string seed, size_t min_cover,
float percent_cover,
size_t nb_sampled,
......@@ -79,7 +79,7 @@ Sequence WindowsStorage::getRepresentative(junction window,
if (!repComp.hasRepresentative())
throw invalid_argument("No representative for junction " + window);
return repComp.getRepresentative();
return repComp;
}
list<Sequence> WindowsStorage::getSample(junction window, size_t nb_sampled,
......
......@@ -20,6 +20,7 @@
#include "germline.h"
#include "read_storage.h"
#include "read_score.h"
#include "representative.h"
#define NB_BINS 15
#define MAX_VALUE_BINS 500
......@@ -84,10 +85,10 @@ class WindowsStorage {
* algorithm.
* @param nb_buckets: Number of buckets for sampling (see SequenceSampler)
* @pre nb_sampled <= getMaximalNbReadsPerWindow() if hasLimitForReadsPerWindow()
* @return the representative sequence of a window or NULL_SEQUENCE if we
* cannot find any representative
* @return the representative computer
*/
Sequence getRepresentative(junction window, string seed, size_t min_cover,
KmerRepresentativeComputer getRepresentativeComputer(junction window, string seed, size_t min_cover,
float percent_cover, size_t nb_sampled,
size_t nb_buckets=HISTOGRAM_SIZE_AUDITIONED);
......
......@@ -1162,12 +1162,14 @@ int main (int argc, char **argv)
cout << auditioned.size() << " auditioned sequences, avg length " << total_length / auditioned.size() << endl ;
}
Sequence representative
= windowsStorage->getRepresentative(it->first, seed,
KmerRepresentativeComputer repComp
= windowsStorage->getRepresentativeComputer(it->first, seed,
min_cover_representative,
ratio_representative,
max_auditionned);
Sequence representative = repComp.getRepresentative();
// Store the representative and its label
representatives.push_back(representative);
representatives_labels.push_back(string_of_int(num_clone));
......@@ -1204,6 +1206,8 @@ int main (int argc, char **argv)
JsonList json_clone;
JsonList json_seg;
json_clone.add("coverage", repComp.getCoverage());
// 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