From b0882b223b5ecaea0a79c7f108c31bf7be06ab17 Mon Sep 17 00:00:00 2001 From: Mathieu Giraud Date: Sat, 1 Nov 2014 20:02:26 +0100 Subject: [PATCH] core/kmeraffect.{h,cpp}: remove KmerStringAffect KmerStringAffect is no more used in the code. If one day we would like to "store more things" in the affectations, we could still extend KmerAffect with a pointer to something else. --- algo/core/kmeraffect.cpp | 106 --------------------------------------- algo/core/kmeraffect.h | 90 --------------------------------- 2 files changed, 196 deletions(-) diff --git a/algo/core/kmeraffect.cpp b/algo/core/kmeraffect.cpp index e22cdf70a..7cc350a9f 100644 --- a/algo/core/kmeraffect.cpp +++ b/algo/core/kmeraffect.cpp @@ -166,109 +166,3 @@ ostream &operator<<(ostream &os, const KmerAffect &kmer) { return os; } -////////////////////////////////////////////////// - -KmerStringAffect::KmerStringAffect() { - label = ""; - strand = 0; -} - -KmerStringAffect::KmerStringAffect(const KmerStringAffect &ksa): - label(ksa.label),strand(ksa.strand){} - - -KmerStringAffect::KmerStringAffect(const string &label, - int strand) { - this->label = label; - this->strand = strand; -} - -KmerStringAffect &KmerStringAffect::operator+=(const KmerStringAffect &kmer) { - if (*this != kmer) { - if (*this == KSA_UNKNOWN) - // Not defined yet - *this = kmer; - else if (*this != KSA_AMBIGUOUS) { - if (this->label == kmer.label) - // Different strand but same label, put ambiguous - *this = KSA_AMBIGUOUS; - else - // Ambiguous: different labels - *this = KSA_AMBIGUOUS; - } // else we are already ambiguous, stay as is. - } - return *this; -} - -KmerStringAffect &KmerStringAffect::operator=(const KmerStringAffect &ka) { - label = ka.label; - strand = ka.strand; - return *this; -} - -KmerStringAffect KmerStringAffect::getAmbiguous() { - return KSA_AMBIGUOUS; -} - -int KmerStringAffect::getStrand() const { - return (isUnknown() || isAmbiguous()) ? 0 : strand; -} - -string KmerStringAffect::getLabel() const { - return label; -} - -KmerStringAffect KmerStringAffect::getUnknown() { - return KSA_UNKNOWN; -} - -bool KmerStringAffect::isAmbiguous() const { - return *this == KSA_AMBIGUOUS; -} - -bool KmerStringAffect::isUnknown() const { - return *this == KSA_UNKNOWN; -} - -string KmerStringAffect::toString() const { - if (isUnknown()) { - return " _"; - } - - switch(strand) { - case 1: - return "+"+label; - case -1: - return "-"+label; - default: - return " ?"; - } -} - -bool operator==(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return k1.strand == k2.strand && (k1.label == k2.label || k1.strand == 0); -} -bool operator!=(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return ! (k1 == k2); -} -bool operator<(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return k1.label < k2.label || (k1.label == k2.label && k1.strand < k2.strand); -} -bool operator>(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return k1.label > k2.label || (k1.label == k2.label && k1.strand > k2.strand); -} -bool operator<=(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return ! (k1 > k2); -} -bool operator>=(const KmerStringAffect &k1, const KmerStringAffect &k2) { - return ! (k1 < k2); -} - -ostream &operator<<(ostream &os, const KmerStringAffect &kmer) { - os << kmer.toString(); - return os; -} - -bool KmerStringAffect::hasRevcompSymetry() { - return false; -} diff --git a/algo/core/kmeraffect.h b/algo/core/kmeraffect.h index 0c9e4b1a4..8677a48fe 100644 --- a/algo/core/kmeraffect.h +++ b/algo/core/kmeraffect.h @@ -160,94 +160,4 @@ const KmerAffect AFFECT_J_BWD = KmerAffect("J", -1); //////////////////////////////////////////////////////////////////////////////////////////////////// -/** - * This class represents the affectation with a string for the label. Two - * constants are defined representing affectation that are either unknown - * (KSA_UNKNOWN) or ambiguous (KSA_AMBIGUOUS). - */ -class KmerStringAffect { -public: - string label; - int strand; - - /** - * Construct an unknown affectation. - * @post isUnknown() - */ - KmerStringAffect(); - KmerStringAffect(const KmerStringAffect &); - /** - * Construct an affectation as stated by the parameters - * @post affect_strand(affect) == strand AND affect_char(affect) == kmer[0] - */ - KmerStringAffect(const string &label, int strand=1); - /** - * Add another affectation to the current one. - * @post The current affectation is not modified if the parameter is the same - * affectation as the current one. - * If the current affectation is unknown, the affectation is set to the - * parameter. - * If the label is the same but the strand is different, the strand is - * arbitrarily put to forward. - * In the other cases, the affectation is set to ambiguous. - */ - KmerStringAffect &operator+=(const KmerStringAffect &); - - /** - * Affectation - */ - KmerStringAffect &operator=(const KmerStringAffect &ka); - - /** - * @return the ambiguous affectation - */ - static KmerStringAffect getAmbiguous(); - - /** - * @return the strand of the affectation - * -1 for backward - * 1 for forward - * 0 for unknown or ambiguous - */ - int getStrand() const; - - /** - * @return the label of the affectation. - */ - string getLabel() const; - - /** - * @return the unknown affectation - */ - static KmerStringAffect getUnknown(); - - /** - * @return true iff the class does not take care of the strand - * (false in our case). - */ - static bool hasRevcompSymetry(); - - /** - * @return true iff the affectation should be considered as ambiguous. - */ - bool isAmbiguous() const; - - /** - * @return true iff the affectation is unkwown yet. - */ - bool isUnknown() const; - - string toString() const; -}; -bool operator!=(const KmerStringAffect &k1, const KmerStringAffect &k2); -bool operator==(const KmerStringAffect &k1, const KmerStringAffect &k2); -bool operator<(const KmerStringAffect &k1, const KmerStringAffect &k2); -bool operator>(const KmerStringAffect &k1, const KmerStringAffect &k2); -bool operator<=(const KmerStringAffect &k1, const KmerStringAffect &k2); -bool operator>=(const KmerStringAffect &k1, const KmerStringAffect &k2); -ostream &operator<<(ostream &os, const KmerStringAffect &kmer); - -const KmerStringAffect KSA_UNKNOWN = KmerStringAffect(); -const KmerStringAffect KSA_AMBIGUOUS = KmerStringAffect("", 2); - #endif -- GitLab