1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/KERNEL/protein.h>
using namespace::std;
namespace BALL
{
Protein::Protein()
: Molecule(),
id_(BALL_PROTEIN_DEFAULT_ID)
{
}
Protein::Protein(const Protein& protein, bool deep)
: Molecule(protein, deep),
id_(protein.id_)
{
}
Protein::Protein(const String& name,const String& id)
: Molecule(name),
id_(id)
{
}
Protein::~Protein()
{
destroy();
}
void Protein::clear()
{
Molecule::clear();
id_ = BALL_PROTEIN_DEFAULT_ID;
}
void Protein::destroy()
{
Molecule::destroy();
id_ = BALL_PROTEIN_DEFAULT_ID;
}
void Protein::persistentWrite(PersistenceManager& pm, const char* name) const
{
pm.writeObjectHeader(this, name);
Molecule::persistentWrite(pm);
pm.writePrimitive(id_, "id_");
pm.writeObjectTrailer(name);
}
void Protein::persistentRead(PersistenceManager& pm)
{
pm.checkObjectHeader(RTTI::getStreamName<Molecule>());
Molecule::persistentRead(pm);
pm.checkObjectTrailer(0);
pm.readPrimitive(id_, "id_");
}
void Protein::set(const Protein& protein, bool deep)
{
Molecule::set(protein, deep);
id_ = protein.id_;
}
Protein& Protein::operator =(const Protein &protein)
{
set(protein);
return *this;
}
void Protein::get(Protein &protein, bool deep) const
{
protein.set(*this, deep);
}
void Protein::swap(Protein& protein)
{
Molecule::swap(protein);
id_.swap(protein.id_);
}
Chain* Protein::getChain(Position position)
{
for (ChainIterator chain_it = beginChain(); !chain_it.isEnd(); ++chain_it)
{
if (position-- == 0)
{
return &(*chain_it);
}
}
return 0;
}
const Chain* Protein::getChain(Position position) const
{
return ((Protein *)this)->getChain(position);
}
SecondaryStructure* Protein::getSecondaryStructure(Position position)
{
for (SecondaryStructureIterator secondary_structure_it = beginSecondaryStructure();
!secondary_structure_it.isEnd(); ++secondary_structure_it)
{
if (position-- == 0)
{
return &(*secondary_structure_it);
}
}
return 0;
}
const SecondaryStructure* Protein::getSecondaryStructure(Position position) const
{
return ((Protein *)this)->getSecondaryStructure(position);
}
Residue* Protein::getResidue(Position position)
{
for (ResidueIterator res_it = beginResidue(); !res_it.isEnd(); ++res_it)
{
if (position-- == 0)
{
return &(*res_it);
}
}
return 0;
}
const Residue* Protein::getResidue(Position position) const
{
return ((Protein *)this)->getResidue(position);
}
Residue* Protein::getResidueByID(String residue_ID)
{
for (ResidueIterator res_it = beginResidue(); !res_it.isEnd(); ++res_it)
{
if(res_it->getID()==residue_ID) return &*res_it;
}
return 0;
}
const Residue* Protein::getResidueByID(String residue_ID) const
{
return ((Protein*)this)->getResidueByID(residue_ID);
}
Residue* Protein::getNTerminal()
{
return (Residue *)::BALL::getNTerminal(*this);
}
const Residue* Protein::getNTerminal() const
{
return ::BALL::getNTerminal(*this);
}
Residue* Protein::getCTerminal()
{
return (Residue *)::BALL::getCTerminal(*this);
}
const Residue* Protein::getCTerminal() const
{
return ::BALL::getCTerminal(*this);
}
PDBAtom* Protein::getPDBAtom(Position position)
{
for (PDBAtomIterator protein_atom_it = beginPDBAtom();
!protein_atom_it.isEnd(); ++protein_atom_it)
{
if (position-- == 0)
{
return &(*protein_atom_it);
}
}
return 0;
}
const PDBAtom* Protein::getPDBAtom(Position position) const
{
return ((Protein *)this)->getPDBAtom(position);
}
void Protein::setID(const String& id)
{
id_ = id;
}
const String& Protein::getID() const
{
return id_;
}
Size Protein::countChains() const
{
Size size = 0;
for (ChainConstIterator chain_it = beginChain(); !chain_it.isEnd(); ++chain_it)
{
++size;
}
return size;
}
Size Protein::countSecondaryStructures() const
{
Size size = 0;
for (SecondaryStructureConstIterator secondary_structure_it = beginSecondaryStructure();
!secondary_structure_it.isEnd(); ++secondary_structure_it)
{
++size;
}
return size;
}
Size Protein::countResidues() const
{
Size size = 0;
for (ResidueConstIterator res_it = beginResidue(); !res_it.isEnd(); ++res_it)
{
++size;
}
return size;
}
Size Protein::countPDBAtoms() const
{
Size size = 0;
for (PDBAtomConstIterator protein_atom_it = beginPDBAtom(); !protein_atom_it.isEnd(); ++protein_atom_it)
{
++size;
}
return size;
}
bool Protein::isValid() const
{
return(Molecule::isValid() && id_.isValid());
}
void Protein::dump(ostream& s, Size depth) const
{
BALL_DUMP_STREAM_PREFIX(s);
Molecule::dump(s, depth);
BALL_DUMP_DEPTH(s, depth);
s << " id: " << id_ << endl;
BALL_DUMP_STREAM_SUFFIX(s);
}
bool Protein::operator == (const Protein& protein) const
{
return(Object::operator == (protein));
}
bool Protein::operator != (const Protein& protein) const
{
return ! (*this == protein);
}
} // namespace BALL
|