kmerstore.cpp 2.15 KB
Newer Older
Mikaël Salson's avatar
Mikaël Salson committed
1
/*
2
  This file is part of Vidjil <http://www.vidjil.org>
Mathieu Giraud's avatar
Mathieu Giraud committed
3
  Copyright (C) 2011-2020 by VidjilNet consortium and Bonsai bioinformatics
4 5 6 7 8
  at CRIStAL (UMR CNRS 9189, Université Lille) and Inria Lille
  Contributors: 
      Mathieu Giraud <mathieu.giraud@vidjil.org>
      Mikaël Salson <mikael.salson@vidjil.org>
      Marc Duez <marc.duez@vidjil.org>
Mikaël Salson's avatar
Mikaël Salson committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

  "Vidjil" is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  "Vidjil" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with "Vidjil". If not, see <http://www.gnu.org/licenses/>
*/


#include <cmath>
#include <list>
#include "kmerstore.h"

// KMer class

Kmer::Kmer():count(0) {}

33 34
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
35
Kmer::Kmer(const string &label, int strand, size_t length) {
Mikaël Salson's avatar
Mikaël Salson committed
36 37
  count = 1;
}
38
#pragma GCC diagnostic pop
Mikaël Salson's avatar
Mikaël Salson committed
39 40 41 42 43 44

Kmer &Kmer::operator+=(const Kmer &kmer) {
  count += kmer.count;
  return *this;
}

Cyprien Borée's avatar
Cyprien Borée committed
45 46 47 48
string Kmer::getLabel() const{
	return "";
}

49 50 51 52
size_t Kmer::getLength() const{
  return 10;
}

Mikaël Salson's avatar
Mikaël Salson committed
53 54 55 56
bool Kmer::hasRevcompSymetry() {
  return true;
}

57
bool Kmer::isNull() const{
58 59 60
  return count == 0;
}

61 62 63
bool Kmer::isUnknown() const{
  return false;
}
64 65 66
bool Kmer::isAmbiguous() const{
  return false;
}
67

Mikaël Salson's avatar
Mikaël Salson committed
68 69 70 71 72
ostream &operator<<(ostream &os, const Kmer &kmer) {
  os << kmer.count << ",";
  return os;
}

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
bool operator==(const Kmer &k1, const Kmer &k2) {
  return k1.count == k2.count;
}

bool operator<(const Kmer &k1, const Kmer &k2) {
  return k1.count < k2.count;
}

bool operator>(const Kmer &k1, const Kmer &k2) {
  return k1.count > k2.count;
}

bool operator<=(const Kmer &k1, const Kmer &k2) {
  return ! (k1 > k2);
}

bool operator>=(const Kmer &k1, const Kmer &k2) {
  return ! (k1 < k2);
}

bool operator!=(const Kmer &k1, const Kmer &k2) {
  return ! (k1 == k2);
}
Mikaël Salson's avatar
Mikaël Salson committed
96