read_score.cpp 1.84 KB
Newer Older
Mikael Salson's avatar
Mikael Salson committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#include "read_score.h"

KmerAffectReadScore::KmerAffectReadScore(IKmerStore<KmerAffect> &idx, 
                                         float unambiguous_score,
                                         float ambiguous_score, 
                                         float unknown_score)
  :index(idx), unambiguous_score(unambiguous_score), ambiguous_score(ambiguous_score),
   unknown_score(unknown_score){}

KmerAffectReadScore::~KmerAffectReadScore() {}

float KmerAffectReadScore::getScore(const string &sequence) const {
  vector<KmerAffect> answers = index.getResults(sequence);
  float score = 0;
  for (size_t i = 0; i < answers.size(); i++) {
    if (answers[i].affect == AFFECT_AMBIGUOUS)
      score += ambiguous_score;
    else if (answers[i].affect == AFFECT_UNKNOWN) 
      score += unknown_score;
    else 
      score += unambiguous_score;
  }
  return score;
}

// Getters
float KmerAffectReadScore::getAmbiguousScore() const {
  return ambiguous_score;
}

const IKmerStore<KmerAffect> &KmerAffectReadScore::getIndex() const {
  return index;
}

float KmerAffectReadScore::getUnambiguousScore() const {
  return unambiguous_score;
}

float KmerAffectReadScore::getUnknownScore() const {
  return unknown_score;
}

// Setters

void KmerAffectReadScore::setAmbiguousScore(float score) {
  ambiguous_score = score;
}

void KmerAffectReadScore::setUnambiguousScore(float score) {
  unambiguous_score = score;
}

void KmerAffectReadScore::setUnknownScore(float score) {
  unknown_score = score;
}
Mathieu Giraud's avatar
Mathieu Giraud committed
56 57 58 59 60 61 62 63 64 65 66


////////////////////////////////////////////////////////////////////////////////
//////////////////////////////  ReadLengthScore  ///////////////////////////////
////////////////////////////////////////////////////////////////////////////////

ReadLengthScore::ReadLengthScore(){}

float ReadLengthScore::getScore(const string &sequence) const {
  return sequence.size();
}