#include #include "Sequence.h" #include "ElementSet.h" using namespace std; Sequence::Sequence() { myMutationCount = 0; } Sequence::Sequence(int size) { myMutationCount = 0; myElements = vector(size); } Sequence::Sequence(const char * initializer) { myMutationCount = 0; int len = strlen(initializer); myElements = vector(len); for (int i = 0; i < len; i++) { myElements[i] = ElementSet(initializer[i]); } } Sequence Sequence::parent(const Sequence & other) { int size = myElements.size(); Sequence s(size); for (int i = 0; i < size; i++) { ElementSet intersection = myElements[i].Intersection(other.myElements[i]); if (intersection.size() == 0) { s.myElements[i] = myElements[i].Union(other.myElements[i]); s.myMutationCount++; } else { s.myElements[i] = intersection; } } return s; } ostream & operator<<(ostream & out, const Sequence & s) { int sz = s.myElements.size(); for (int i = 0; i < sz; i++) out << s.myElements[i]; return out; } void Sequence::label() { for (int i = 0, sz = myElements.size(); i < sz; i++) myElements[i].label(); }