return escape;
}
+
// returns the affinity to which a virus is recognized
// or 0 if it is not recognized (i.e. has escaped from all epitopes)
// If multiple epitopes are present and recognized, returns the total affinity
return bind;
}
+
+// Did virus escape from immune pressure by mutating *any* of the sites away from ref?
+bool AARecognizer::escaped(const NTVirus &v) const {
+ return AARecognizer::escaped(v.aa_seq);
+}
+bool AARecognizer::escaped(const std::vector<aa> &aa_seq) const {
+ bool escape = false;
+ for (unsigned i=0; i<len; i++) {
+ if (aa_seq[site[i]] != ref[i]) { escape=true; break; }
+ }
+ return escape;
+}
+
+// returns the affinity to which a virus is recognized
+// or 0 if it is not recognized (i.e. has escaped from all epitopes)
+// If multiple epitopes are present and recognized, returns the total affinity
+double CTLaaSpecies::recognized(const NTVirus &v) const {
+ return CTLaaSpecies::recognized(v.aa_seq);
+}
+double CTLaaSpecies::recognized(const std::vector<aa> &aa_seq) const {
+ double bind = 0.0;
+ for (size_t i = 0; i < num_ep; ++i) {
+ if (!epitopes[i].escaped(aa_seq)) {
+ bind += affinity[i];
+ }
+ }
+ return bind;
+}
+
};
+class AARecognizer {
+public:
+ std::vector<unsigned> site;
+ std::vector<aa> ref;
+ size_t len;
+ bool escaped(const NTVirus &v) const;
+ bool escaped(const std::vector<aa> &aa_seq) const;
+};
+
+
class Species {
public:
long count;
};
+class CTLaaSpecies : public Species {
+public:
+ CTLaaSpecies() : Species(), num_ep(0) {}
+ CTLaaSpecies(long c) : Species(c), num_ep(0) {}
+ CTLaaSpecies(std::string x) : Species(x), num_ep(0) {}
+ CTLaaSpecies(std::string x, long c) : Species(x,c), num_ep(0) {}
+
+ std::vector<AARecognizer> epitopes;
+ std::vector<double> affinity;
+ size_t num_ep;
+
+ double recognized(const NTVirus &v) const;
+ double recognized(const std::vector<aa> &aa_seq) const;
+};
+
+
#endif // POP_SS_H