Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit e9e141d5 authored by Mikaël Salson's avatar Mikaël Salson Committed by Mathieu Giraud
Browse files

read_score.{h,cpp}: Use directly a Sequence rather than a string

parent 1bd6d4c2
......@@ -20,7 +20,7 @@ ReadChooser::ReadChooser(list<Sequence> &r, VirtualReadScore &scorer) {
size_t i = 0;
for (list <Sequence>::iterator it = r.begin(); it != r.end(); ++it) {
reads[i].score = scorer.getScore(it->sequence);
reads[i].score = scorer.getScore(*it);
reads[i].seq = &(*it);
i++;
}
......
......@@ -9,8 +9,8 @@ KmerAffectReadScore::KmerAffectReadScore(IKmerStore<KmerAffect> &idx,
KmerAffectReadScore::~KmerAffectReadScore() {}
float KmerAffectReadScore::getScore(const string &sequence) const {
vector<KmerAffect> answers = index.getResults(sequence);
float KmerAffectReadScore::getScore(const Sequence &sequence) const {
vector<KmerAffect> answers = index.getResults(sequence.sequence);
float score = 0;
for (size_t i = 0; i < answers.size(); i++) {
if (answers[i].affect == AFFECT_AMBIGUOUS)
......@@ -62,6 +62,6 @@ void KmerAffectReadScore::setUnknownScore(float score) {
ReadLengthScore::ReadLengthScore(){}
ReadLengthScore::~ReadLengthScore(){}
float ReadLengthScore::getScore(const string &sequence) const {
return sequence.size();
float ReadLengthScore::getScore(const Sequence &sequence) const {
return sequence.sequence.size();
}
......@@ -18,7 +18,7 @@ class VirtualReadScore {
* @return the score associated to the sequence.
* getScore(a) > getScore(b) ==> a is better than b
*/
virtual float getScore(const string &sequence)const = 0;
virtual float getScore(const Sequence &sequence)const = 0;
};
/**
......@@ -42,7 +42,7 @@ public:
* The score is computed using the affectation in the sequence and the scores
* that have been attributed (or the default ones).
*/
float getScore(const string &sequence) const;
float getScore(const Sequence &sequence) const;
// Getters
float getAmbiguousScore() const;
......@@ -69,6 +69,6 @@ class ReadLengthScore: public VirtualReadScore {
/**
* @return the sequence length
*/
float getScore(const string &sequence) const;
float getScore(const Sequence &sequence) const;
};
#endif
......@@ -44,7 +44,7 @@ BinReadStorage::~BinReadStorage() {
}
void BinReadStorage::addScore(Sequence &s) {
addScore(scorer->getScore(s.sequence));
addScore(scorer->getScore(s));
}
void BinReadStorage::addScore(float score) {
......@@ -58,7 +58,7 @@ void BinReadStorage::addScore(size_t bin, float score) {
}
void BinReadStorage::add(Sequence &s) {
float score = scorer->getScore(s.sequence);
float score = scorer->getScore(s);
size_t bin = scoreToBin(score);
addScore(bin, score);
if (nb_stored < getMaxNbReadsStored()) {
......@@ -88,7 +88,7 @@ size_t BinReadStorage::getNbInserted() const {
}
double BinReadStorage::getAverageScoreBySeq(Sequence &s) {
return getAverageScoreByScore(scorer->getScore(s.sequence));
return getAverageScoreByScore(scorer->getScore(s));
}
double BinReadStorage::getAverageScoreByScore(float score) {
......@@ -103,7 +103,7 @@ double BinReadStorage::getInvertedAverageScore(size_t bin) {
}
double BinReadStorage::getScoreBySeq(Sequence &s) {
return getScoreByScore(scorer->getScore(s.sequence));
return getScoreByScore(scorer->getScore(s));
}
double BinReadStorage::getScoreByScore(float score) {
......
......@@ -3,14 +3,17 @@
void testScore() {
// ReadLengthScore testing
ReadLengthScore rls;
TAP_TEST(rls.getScore("") == 0., TEST_LENGTH_SCORE,
"score should be 0, is " << rls.getScore(""));
TAP_TEST(rls.getScore("ATCGTTTACGTC") == 12., TEST_LENGTH_SCORE,
"score should be 12, is " << rls.getScore("ATCGTTTACGTC"));
Sequence seq1 = {"seq", "seq", "", "", NULL, 0};
TAP_TEST(rls.getScore(seq1) == 0., TEST_LENGTH_SCORE,
"score should be 0, is " << rls.getScore(seq1));
TAP_TEST(rls.getScore("A") == 1., TEST_LENGTH_SCORE,
"score should be 1, is " << rls.getScore("A"));
Sequence seq2 = {"seq", "seq", "ATCGTTTACGTC", "", NULL, 0};
TAP_TEST(rls.getScore(seq2) == 12., TEST_LENGTH_SCORE,
"score should be 12, is " << rls.getScore(seq2));
Sequence seq3 = {"seq", "seq", "A", "", NULL, 0};
TAP_TEST(rls.getScore(seq3) == 1., TEST_LENGTH_SCORE,
"score should be 1, is " << rls.getScore(seq3));
}
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