From 15aeecde4dc2276f523fa4e126f144b822dbf747 Mon Sep 17 00:00:00 2001 From: Dariusz Murakowski Date: Thu, 23 Apr 2015 23:10:32 -0400 Subject: [PATCH] Start of Potts / amino acid / nucleotide-based virus species. --- pop_ss.cpp | 33 +++++++++++++++++++++++++++++++++ pop_ss.h | 32 ++++++++++++++++++++++++++++++++ ss.cpp | 7 ++++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/pop_ss.cpp b/pop_ss.cpp index 05ff5e7..fb4851b 100644 --- a/pop_ss.cpp +++ b/pop_ss.cpp @@ -36,6 +36,39 @@ bool operator<(const Virus& lhs, const Virus& rhs) { return lhs.mutated_sites < rhs.mutated_sites; } +std::vector translate_nt_seq(const std::string &nt_seq) +{ + std::vector aa_seq; aa_seq.reserve(nt_seq.size() / 3); + for (unsigned i=0; i &aa_seq) +{ + std::string out; out.reserve(aa_seq.size()); + for (std::vector::const_iterator it = aa_seq.begin(), + end = aa_seq.end(); + it != end; ++it) { + out.push_back(aa2str.at(*it)); + } + return out; +} + +NTVirus::NTVirus(const std::string &NT) +: energy(0.0) +, nt_seq(NT) +, aa_seq(translate_nt_seq(NT)) +, L_nt(NT.length()) +, L_aa(this->L_nt/3) +{ +} + +bool operator<(const NTVirus& lhs, const NTVirus& rhs) { + return lhs.nt_seq < rhs.nt_seq; +} + // Did virus escape from immune pressure? bool EpitopeRecognizer::escaped(const Virus &v) const { diff --git a/pop_ss.h b/pop_ss.h index 26cf280..5b02bd9 100644 --- a/pop_ss.h +++ b/pop_ss.h @@ -8,6 +8,7 @@ #include #include "ham_ss.h" +#include "seqTools.h" class Hamiltonian; @@ -40,6 +41,28 @@ typedef std::map virus_map; typedef std::set MutatedSiteSequence; +// helper functions +std::vector translate_nt_seq(const std::string &nt_seq); +std::string aaseq2str(const std::vector &aa_seq); + +class NTVirus { +public: + double energy; + std::string nt_seq; + std::vector aa_seq; + unsigned int L_nt; + unsigned int L_aa; + + NTVirus(const std::string &); +}; + +// needed for STL map +bool operator<(const NTVirus& lhs, const NTVirus& rhs); + +typedef std::map NTVirus_map; + + + class EpitopeRecognizer { public: std::vector epitopeWT; // sites with state=0 are recognized @@ -80,6 +103,15 @@ public: virus_map pop; }; +class NTVirusSpecies : public Species { +public: + NTVirusSpecies() : Species() {} + NTVirusSpecies(long c) : Species(c) {} + NTVirusSpecies(std::string x) : Species(x) {} + NTVirusSpecies(std::string x, long c) : Species(x,c) {} + NTVirus_map pop; +}; + class CTLSpecies : public Species { public: CTLSpecies() : Species(), num_ep(0) {} diff --git a/ss.cpp b/ss.cpp index 94dc750..115ad06 100644 --- a/ss.cpp +++ b/ss.cpp @@ -497,7 +497,12 @@ int main(int argc, char *argv[]) { } std::cout << '\n'; } - std::cout << int2aa.at(codon2aa.at(str2codon.at("TTT"))) << '\n'; + //NTVirus v("TTT"); + NTVirus v(argv[2]); + //std::cout << int2aa.at(codon2aa.at(str2codon.at(v.nt_seq))) << '\n'; + std::cout << aa2str.at(v.aa_seq[0]) << '\n'; + std::cout << aaseq2str(v.aa_seq) << '\n'; + printf("%d %d\n",v.L_nt,v.L_aa); return 0; RunParameters_SS r; -- 2.7.4