read_score.h 2.4 KB
Newer Older
Mikaël Salson's avatar
Mikaël Salson committed
1 2 3 4 5 6 7
#ifndef READ_SCORE_H
#define READ_SCORE_H

#include <string>
#include "kmerstore.h"
#include "kmeraffect.h"

8 9 10
#define MAX_QUALITY 50          /* Maximal value for the quality */
#define GOOD_QUALITY 30         /* Min value considered as a good quality */

Mikaël Salson's avatar
Mikaël Salson committed
11 12 13 14 15 16
/**
 * This virtual class contains a single method that allows to compute a score
 * for a string.
 */
class VirtualReadScore {
 public:
17 18
  virtual ~VirtualReadScore() {}

Mikaël Salson's avatar
Mikaël Salson committed
19 20 21 22 23
  /**
   * @param sequence: some text
   * @return the score associated to the sequence.
   *         getScore(a) > getScore(b) ==> a is better than b
   */
24
  virtual float getScore(const Sequence &sequence)const = 0;
Mikaël Salson's avatar
Mikaël Salson committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
};

/**
 * This implementation of VirtualReadScore computes a score for a sequence
 * given the affectation found in this sequence.
 * The more affectation will be found, the better the score will be.
 */
class KmerAffectReadScore : public VirtualReadScore {
private:
  IKmerStore<KmerAffect> &index;
  float unambiguous_score, ambiguous_score, unknown_score;
public:
  /**
   * @param idx: The KmerAffect index for computing the score.
   */
  KmerAffectReadScore(IKmerStore<KmerAffect> &idx, float unambiguous_score=1.,
                      float ambiguous_score=0.5, float unknown_score=0.);
  ~KmerAffectReadScore();
  
  /**
   * The score is computed using the affectation in the sequence and the scores
   * that have been attributed (or the default ones).
   */
48
  float getScore(const Sequence &sequence) const;
Mikaël Salson's avatar
Mikaël Salson committed
49 50 51 52 53 54 55 56 57 58 59 60 61

  // Getters
  float getAmbiguousScore() const;
  const IKmerStore<KmerAffect> &getIndex() const;
  float getUnambiguousScore() const;
  float getUnknownScore() const;

  // Setters

  void setAmbiguousScore(float score) ;
  void setUnambiguousScore(float score) ;
  void setUnknownScore(float score) ;
};
Mathieu Giraud's avatar
Mathieu Giraud committed
62 63 64 65 66 67 68 69

/**
 * A simple implementation of VirtualReadScore.
 * The score is the length of the read
 */
class ReadLengthScore: public VirtualReadScore {
 public:
  ReadLengthScore();
70
  ~ReadLengthScore();
Mathieu Giraud's avatar
Mathieu Giraud committed
71 72 73 74

  /**
   * @return the sequence length
   */
75
  float getScore(const Sequence &sequence) const;
Mathieu Giraud's avatar
Mathieu Giraud committed
76
};
77 78 79 80 81 82

/**
 * A simple implementation of VirtualReadScore.
 * The score is a trade-off between quality and length of the read
 */
class ReadQualityScore: public VirtualReadScore {
83 84
 private:
  static size_t qualities[MAX_QUALITY];
85 86 87 88 89 90 91 92 93
 public:
  ReadQualityScore();
  ~ReadQualityScore();

  /**
   * @return the sequence quality
   */
  float getScore(const Sequence &sequence) const;
};
Mikaël Salson's avatar
Mikaël Salson committed
94
#endif