From 0f59fc78999993964635392394a941425930edd1 Mon Sep 17 00:00:00 2001 From: Dariusz Murakowski Date: Wed, 16 Apr 2014 20:53:21 -0400 Subject: [PATCH] Allow calculating energy without including epitope bonus. --- hamiltonian.cpp | 36 +++++++++++++++++++++++++++--------- hamiltonian.h | 1 + 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/hamiltonian.cpp b/hamiltonian.cpp index af10101..bcedac6 100644 --- a/hamiltonian.cpp +++ b/hamiltonian.cpp @@ -212,8 +212,6 @@ double Hamiltonian::get_energy(const std::set &mutated_sites) cons } - // Check for mismatch between targeted epitope and current sequence - return ((efield * bh) + (ecoupling * bJ)); } @@ -283,8 +281,23 @@ bool EpitopeHamiltonian::escaped(const std::set &mutated_sites, co // Return the energy for a given set of mutated sites +// default: do include contribution from epitopes + +double EpitopeHamiltonian::get_energy(const std::set &mutated_sites) const +{ + return get_energy(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 &x) { EpitopeHamiltonian A((std::string&)""); return A.get_energy(x); } + +// Return the energy for a given set of mutated sites -double EpitopeHamiltonian::get_energy(const std::set &mutated_sites) const { +template +double EpitopeHamiltonian::get_energy(const std::set &mutated_sites) const +{ double efield = 0.0; double ecoupling = 0.0; @@ -302,15 +315,19 @@ double EpitopeHamiltonian::get_energy(const std::set &mutated_site } - // Check for mismatch between targeted epitope and current sequence - double energy = (efield * bh) + (ecoupling * bJ); - for (unsigned ep=0; ep &mutated_site } + /*********************************************** * my simple 2-site 2-allele system ***********************************************/ diff --git a/hamiltonian.h b/hamiltonian.h index 32ca26c..3d2faf4 100644 --- a/hamiltonian.h +++ b/hamiltonian.h @@ -56,6 +56,7 @@ public: bool escaped(const Virus &v, const std::vector &eWT, const std::vector &eMut); bool escaped(const std::set &mutated_sites, const std::vector &eWT, const std::vector &eMut) const; double get_energy(const std::set &mutated_sites) const; + template double get_energy(const std::set &mutated_sites) const; }; -- 2.7.4