}
- // Check for mismatch between targeted epitope and current sequence
-
return ((efield * bh) + (ecoupling * bJ));
}
// Return the energy for a given set of mutated sites
+// default: do include contribution from epitopes
+
+double EpitopeHamiltonian::get_energy(const std::set<unsigned int> &mutated_sites) const
+{
+ return get_energy<true>(mutated_sites);
+}
+
+// tried to have a forward declaration of explicit specializations,
+// which "must occur before instantiation",
+// but then linker complained about undefined reference
+double ensure_get_energy_false_instantiated(const std::set<unsigned int> &x) { EpitopeHamiltonian A((std::string&)""); return A.get_energy<false>(x); }
+
+// Return the energy for a given set of mutated sites
-double EpitopeHamiltonian::get_energy(const std::set<unsigned int> &mutated_sites) const {
+template <bool include_epitope>
+double EpitopeHamiltonian::get_energy(const std::set<unsigned int> &mutated_sites) const
+{
double efield = 0.0;
double ecoupling = 0.0;
}
- // Check for mismatch between targeted epitope and current sequence
-
double energy = (efield * bh) + (ecoupling * bJ);
- for (unsigned ep=0; ep<penalty.size(); ++ep) {
- if (!escaped(mutated_sites, epitopeWT[ep], epitopeMut[ep])) {
- energy += penalty[ep] * bh;
+ if (include_epitope) {
+
+ // Check for mismatch between targeted epitope and current sequence
+
+ for (unsigned ep=0; ep<penalty.size(); ++ep) {
+ if (!escaped(mutated_sites, epitopeWT[ep], epitopeMut[ep])) {
+ energy += penalty[ep] * bh;
+ }
+ // alternatively, if(escaped): energy -= penalty
}
- // alternatively, if(escaped): energy -= penalty
+
}
return energy;
}
+
/***********************************************
* my simple 2-site 2-allele system
***********************************************/
bool escaped(const Virus &v, const std::vector<unsigned int> &eWT, const std::vector<unsigned int> &eMut);
bool escaped(const std::set<unsigned int> &mutated_sites, const std::vector<unsigned int> &eWT, const std::vector<unsigned int> &eMut) const;
double get_energy(const std::set<unsigned int> &mutated_sites) const;
+ template<bool include_epitope> double get_energy(const std::set<unsigned int> &mutated_sites) const;
};