src/biu/LatticeProtein_I.cc
Go to the documentation of this file.00001
00002 #include "LatticeProtein_I.hh"
00003 #include "assertbiu.hh"
00004
00005 namespace biu {
00006
00007 LatticeProtein_I::LatticeProtein_I(const LatticeModel* lattice_,
00008 const ContactEnergyFunction* energyFunc_,
00009 const Sequence* seq_,
00010 const bool seqShared_)
00011 : lattice(lattice_), energyFunc(energyFunc_), sequence(NULL),
00012 seqShared(seqShared_)
00013 {
00014 assertbiu (lattice != NULL && energyFunc != NULL,
00015 "no lattice model or energy function available");
00016 assertbiu (seq_ != NULL,
00017 "no sequence available");
00018 assertbiu(energyFunc->getAlphabet()->isAlphabetSequence(*seq_),
00019 "sequence is not valid for the given alphabet");
00020
00021 if (seqShared) {
00022 sequence = &(*seq_);
00023 } else {
00024 sequence = new Sequence(*seq_);
00025 }
00026 }
00027
00028 LatticeProtein_I::LatticeProtein_I(const LatticeProtein_I& l2)
00029 : lattice(l2.lattice), energyFunc(l2.energyFunc), sequence(NULL),
00030 seqShared(l2.seqShared)
00031 {
00032 if (seqShared)
00033 sequence = l2.sequence;
00034 else
00035 sequence = new Sequence(*(l2.sequence));
00036 }
00037
00038 LatticeProtein_I::~LatticeProtein_I()
00039 {
00040
00041 if (!seqShared && sequence != NULL) {
00042 delete sequence;
00043 sequence = NULL;
00044 }
00045 }
00046
00047
00048
00050 const biu::LatticeModel*
00051 LatticeProtein_I::getLatticeModel() const {
00052 return lattice;
00053 }
00054
00056 const biu::ContactEnergyFunction*
00057 LatticeProtein_I::getContactEnergyFunction() const {
00058 return energyFunc;
00059 }
00060
00063 bool
00064 LatticeProtein_I::isSequenceShared() const {
00065 return seqShared;
00066 }
00067
00069 const Sequence*
00070 LatticeProtein_I::getSequenceRef() const {
00071 return sequence;
00072 }
00073
00074
00075
00076
00077 biu::Sequence
00078 LatticeProtein_I::getSequence() const
00079 {
00080 assertbiu( sequence != NULL, "no sequence available");
00081 return *sequence;
00082 }
00083
00086 size_t
00087 LatticeProtein_I::getLength() const {
00088 assertbiu( sequence != NULL, "no sequence available");
00089 return sequence->size();
00090 }
00091
00092 LatticeProtein_I&
00093 LatticeProtein_I::operator =(const LatticeProtein_I& latProt2) {
00094 if (this != &latProt2 && *this != latProt2) {
00095 assertbiu(sequence != NULL,
00096 "sequence not initialized");
00097
00098
00099 lattice = latProt2.getLatticeModel();
00100 energyFunc = latProt2.getContactEnergyFunction();
00101 if (!seqShared) {
00102 delete sequence;
00103 }
00104 seqShared = latProt2.isSequenceShared();
00105
00106 if (seqShared) {
00107 sequence = latProt2.getSequenceRef();
00108 } else {
00109 sequence = new Sequence(*(latProt2.getSequenceRef()));
00110 }
00111 }
00112 return *this;
00113 }
00114
00115
00116 }