24 #ifndef _REPERTOIRE_H_ 25 #define _REPERTOIRE_H_ 31 #include "clonotype.h" 38 #define DEFAULT_REPERTOIRE_RESERVE_SIZE 300000 41 typedef std::vector<MAAG> MAAGRepertoire;
45 typedef std::vector<Clonotype> ClonotypeVector;
48 typedef std::shared_ptr<ClonotypeVector> SharedClonotypeVectorPtr;
56 : _source(
new ClonotypeVector())
62 const std::vector<size_t>& shifts)
63 : _source(pvec), _shifts(shifts)
69 const Clonotype& operator[] (
size_t index)
const {
70 return _source->at(_shifts[index]);
73 ClonesetView subvec(
const std::vector<size_t> &indices)
const {
74 std::vector<size_t> shifts;
75 shifts.reserve(indices.size());
76 for (
size_t i = 0; i < indices.size(); ++i) {
77 shifts.push_back(_shifts[indices[i]]);
84 size_t size()
const {
return _shifts.size(); }
88 std::vector<size_t> inds;
89 inds.reserve(this->size() / 3);
90 for (
size_t i = 0; i < this->size(); ++i) {
91 if ((*
this)[i].isCoding()) {
95 return this->subvec(inds);
99 ClonesetView noncoding(
bool out_of_frames_only =
false)
const {
100 std::vector<size_t> inds;
101 inds.reserve(this->size() / 3);
102 if (out_of_frames_only) {
103 for (
size_t i = 0; i < this->size(); ++i) {
104 if ((*
this)[i].isOutOfFrame()) {
109 for (
size_t i = 0; i < this->size(); ++i) {
110 if ((*
this)[i].isNoncoding()) {
116 return this->subvec(inds);
121 std::vector<size_t> shifts;
122 shifts.reserve(size);
123 for (
size_t i = 0; i < size; ++i) {
126 return this->subvec(shifts);
132 std::vector<size_t> shifts;
133 shifts.reserve(end - start + 1);
134 for (
size_t i = start; i < end; ++i) {
137 return this->subvec(shifts);
139 cerr <<
"Error in ClonesetView: the end index is lower than the start index." << endl;
146 std::default_random_engine generator;
147 std::uniform_int_distribution<size_t> distribution(0, this->size());
149 std::vector<size_t> indices(this->size());
150 for (
size_t i = 0; i < this->size(); ++i) {
151 indices[i] = distribution(generator);
154 return this->subvec(indices);
159 return this->shuffle().head(n);
165 SharedClonotypeVectorPtr _source;
166 std::vector<size_t> _shifts;
187 void swap(ClonotypeVector& vec) {
188 this->_source->swap(vec);
189 this->_shifts.resize(this->_source->size());
190 for (
size_t i = 0; i < this->_source->size(); ++i) {
191 this->_shifts[i] = i;
197 return _source->at(_shifts[index]);
Definition: clonotype.h:46
Definition: repertoire.h:171
Definition: repertoire.h:51