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
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/MOLMEC/PARAMETER/residueTorsions.h>
#include <BALL/MOLMEC/PARAMETER/forceFieldParameters.h>
using namespace std;
namespace BALL
{
bool ResidueTorsions::Data::operator == (const Data& data) const
{
return residue_name == data.residue_name &&
atom_name_A == data.atom_name_A&&
atom_name_B == data.atom_name_B&&
atom_name_C == data.atom_name_C&&
atom_name_D == data.atom_name_D;
}
bool ResidueTorsions::Data::operator != (const Data& data) const
{
return !(*this == data);
}
ResidueTorsions::ResidueTorsions()
: ParameterSection()
{
}
ResidueTorsions::~ResidueTorsions()
{
clear();
}
void ResidueTorsions::clear()
{
ParameterSection::clear();
}
bool ResidueTorsions::extractSection
(Parameters& parameters, const String& section_name)
{
return ParameterSection::extractSection(parameters, section_name);
}
bool ResidueTorsions::extractSection
(ForceFieldParameters& parameters, const String& section_name)
{
// check whether the parameters are valid
if (!parameters.isValid())
{
return false;
}
// extract the basis information
ParameterSection::extractSection(parameters, section_name);
// iterate over all keys and construct the hash map of vectors
for (Size i = 0; i < getNumberOfKeys(); i++)
{
String key = getKey(i);
String residue = key.getField(0);
// do we have an vector for this residue?
if (!torsions_.has(residue))
{
// create the vector
torsions_.insert(pair<String, vector<Data> >(residue, vector<Data>()));
}
// insert the torsions
torsions_[residue].push_back(Data(residue, key.getField(1), key.getField(2), key.getField(3), key.getField(4)));
all_torsions_.insert(key);
}
return true;
}
Size ResidueTorsions::getNumberOfResidueTorsions(const String& residue_name) const
{
// if we know this residue...
if (torsions_.has(residue_name))
{
// return the size of the corresponding array
return (Size)torsions_[residue_name].size();
}
return 0;
}
bool ResidueTorsions::assignTorsion
(const String& name, Position i, Data& torsion) const
{
// if we know this residue...
if (torsions_.has(name))
{
// ...verify the index...
Size max_index = (Size)torsions_[name].size();
if (i < (Position)max_index)
{
// ...and assign the torsion structure
torsion = torsions_[name][i];
return true;
}
}
return false;
}
bool ResidueTorsions::hasTorsion
(const String& residue, const String& atom_A, const String& atom_B,
const String& atom_C, const String& atom_D) const
{
String query = residue + " " + atom_A + " "
+ atom_B + " " + atom_C + " " + atom_D;
// is this a known torsion?
if (all_torsions_.has(query))
{
return true;
}
// reverse the order of the atoms and try again
query = residue + " " + atom_D + " "
+ atom_C + " " + atom_B + " " + atom_A;
return all_torsions_.has(query);
}
} // namespace BALL
|