Commit fb575f32 authored by Mikaël Salson's avatar Mikaël Salson

read_score.{h,cpp} representative.cpp: Define a random score on a read and use it

Random score on a read makes possible to have a random sample of reads to compute the representative.
Thus the representative will be built on a really representative sample.

Our attempts to have a good quality sample have failed so far. Thus we attempt this solution.

Fix #3764
parent 0ae273fa
......@@ -101,3 +101,15 @@ float ReadQualityScore::getScore(const Sequence &sequence) const {
percent_quality = GOOD_QUALITY;
return percent_quality * sequence.sequence.size() / GOOD_QUALITY;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////// RandomScore ///////////////////////////////
////////////////////////////////////////////////////////////////////////////////
RandomScore::RandomScore(){srand(1);} // Ensures a deterministic output
RandomScore::~RandomScore(){}
float RandomScore::getScore(const Sequence &sequence) const {
UNUSED(sequence);
return rand() % 500;
}
......@@ -91,4 +91,17 @@ class ReadQualityScore: public VirtualReadScore {
*/
float getScore(const Sequence &sequence) const;
};
/**
* A very simple implementation of VirtualReadScore.
* The score is random.
*/
class RandomScore: public VirtualReadScore {
public:
RandomScore();
~RandomScore();
float getScore(const Sequence &sequence) const;
};
#endif
......@@ -114,8 +114,8 @@ void KmerRepresentativeComputer::compute(bool try_hard) {
index[i]->insert(it->sequence, it->label, false, 0, seeds[i]);
}
// Create a read chooser to have the sequences sorted by length
ReadQualityScore *rlc = new ReadQualityScore();
// Create a read chooser to have the sequences sorted on the criteria we want
VirtualReadScore *rlc = new RandomScore();
ReadChooser rc(sequences, *rlc);
delete rlc;
......
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