CTL for recognizing arbitrary amino acid sequence as epitope.
authorDariusz Murakowski <murakdar@mit.edu>
Fri, 24 Apr 2015 06:50:08 +0000 (02:50 -0400)
committerDariusz Murakowski <murakdar@mit.edu>
Fri, 24 Apr 2015 06:50:08 +0000 (02:50 -0400)
pop_ss.cpp
pop_ss.h

index ba8ddad..ff9bbd5 100644 (file)
@@ -110,6 +110,7 @@ bool EpitopeRecognizer::escaped(const MutatedSiteSequence &mutated_sites) const
     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
@@ -126,3 +127,32 @@ double CTLSpecies::recognized(const MutatedSiteSequence &mutated_sites) const {
     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;
+}
+
index ea92489..c8e0629 100644 (file)
--- a/pop_ss.h
+++ b/pop_ss.h
@@ -79,6 +79,16 @@ public:
 };
 
 
+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;
@@ -134,4 +144,20 @@ public:
 };
 
 
+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