#ifndef REPRESENTATIVE_H
#define REPRESENTATIVE_H
#include
#include
#include
#include "fasta.h"
using namespace std;
#define DEFAULT_STABILITY_LIMIT 30
/**
* Compute a representative sequence from a list of sequences.
* The sequences are supposed to share a common juction.
*/
class RepresentativeComputer {
protected:
list &sequences;
bool is_computed;
Sequence representative;
public:
RepresentativeComputer(list &r);
/**
* @pre hasRepresentative()
* @return the representative sequence of the set of sequences.
* The representative meets the criteria given to compute().
* The label of the sequence is composed of the read labels used for that
* purpose, plus the positions that have been extracted.
*/
Sequence getRepresentative() const;
/**
* @return the input sequences we are working on
*/
list& getSequenceList() const;
/**
* @return true iff compute() has been called and the criteria have been met.
*/
bool hasRepresentative() const;
/**
* Compute the representative depending on the specified parameters.
* @param do_revcomp: true iff sequences may be coming from any strand, and
* therefore should be revcomp-ed
* @param min_cover: minimal number of reads supporting each position of the
* representative
* @param percent_cover: minimal percent of the maximal coverage that is
* admissible for covering the representative.
* Any position is covered by at least percent_cover %
* of the maximal coverage.
*/
virtual void compute(bool do_revcomp, size_t min_cover, float percent_cover) = 0;
};
/**
* The representative is computed from the list of sequences. Those sequences
* must all share a common factor whose length is greater or equal to k.
*/
class KmerRepresentativeComputer : public RepresentativeComputer {
protected:
int k;
int stability_limit;
public:
KmerRepresentativeComputer(list &r, int k);
// Getters, setters
int getK() const;
/**
* Sets the length of the k-mer used for computing the representative
*/
void setK(int k);
int getStabilityLimit() const;
/**
* @param limit: maximal number of iterations to be performed before reaching
* stability. If after limit number of iterations, the length
* of the representative didn't improve, we keep it.
*/
void setStabilityLimit(int limit);
// Actions
void compute(bool do_revcomp, size_t min_cover, float percent_cover);
};
#endif