Commit dbd82686 by maarten

backup

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@493 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent fe519e71
......@@ -12,6 +12,7 @@ namespace mmcif
clipper::Coord_orth CalculateOffsetForCell(const Structure& p, const clipper::Spacegroup& spacegroup, const clipper::Cell& cell);
std::vector<clipper::RTop_orth> AlternativeSites(const clipper::Spacegroup& spacegroup, const clipper::Cell& cell);
int GetSpacegroupNumber(const std::string& spacegroup); // alternative for clipper's parsing code
// --------------------------------------------------------------------
// To iterate over all near symmetry copies of an atom
......
......@@ -160,7 +160,7 @@ int32_t GetRotationalIndexNumber(int spacegroup, const clipper::RTop_frac& rt)
for (int i = 0; i < 3; ++i)
{
int n = (lrint(trn[i] * 24) + 24) % 24;
int n = lrint(trn[i] * 24);
int d = 24;
if (n == 0 or abs(n) == 24)
......@@ -172,6 +172,8 @@ int32_t GetRotationalIndexNumber(int spacegroup, const clipper::RTop_frac& rt)
n /= i;
d /= i;
}
n = (n + d) % d;
switch (i)
{
......@@ -201,6 +203,38 @@ int32_t GetRotationalIndexNumber(int spacegroup, const clipper::RTop_frac& rt)
throw runtime_error("Symmetry operation was not found in table, cannot find rotational number");
}
// --------------------------------------------------------------------
// And unfortunately, clipper does not know all the spacegroup names mentioned in symop.lib
int GetSpacegroupNumber(const std::string& spacegroup)
{
int result = 0;
const size_t N = sizeof(kSpaceGroups) / sizeof(Spacegroup);
int32_t L = 0, R = static_cast<int32_t>(N - 1);
while (L <= R)
{
int32_t i = (L + R) / 2;
int d = spacegroup.compare(kSpaceGroups[i].name);
if (d > 0)
L = i + 1;
else if (d < 0)
R = i - 1;
else
{
result = kSpaceGroups[i].nr;
break;
}
}
if (result == 0)
throw runtime_error("Spacegroup name " + spacegroup + " was not found in table");
return result;
}
// -----------------------------------------------------------------------
string SymmetryAtomIteratorFactory::symop_mmcif(const Atom& a) const
......
......@@ -121,8 +121,6 @@ class SymopParser
void parsepart(int row)
{
bool first = false;
do
{
int sign = m_lookahead == '-' ? -1 : 1;
......@@ -149,7 +147,7 @@ class SymopParser
}
Token m_lookahead;
char m_nr;
int m_nr;
string m_s;
string::const_iterator m_p, m_e;
......@@ -177,6 +175,8 @@ int main()
vector<tuple<int,int,string,array<int,15>>> data;
vector<tuple<string,int>> spacegroups;
// --------------------------------------------------------------------
string line;
......@@ -228,6 +228,8 @@ int main()
spacegroupName = m[7];
symopnr = 1;
spacegroups.emplace_back(spacegroupName, spacegroupNr);
state = State::InSpacegroup;
break;
}
......@@ -237,11 +239,26 @@ int main()
// --------------------------------------------------------------------
sort(data.begin(), data.end());
sort(spacegroups.begin(), spacegroups.end());
// --------------------------------------------------------------------
cout << R"(// This file was generated from $CLIBD/symop.lib
struct Spacegroup
{
const char* name;
int nr;
} kSpaceGroups[] =
{
)";
for (auto& [name, nr]: spacegroups)
cout << "\t{ \"" << name << "\", " << nr << " }," << endl;
cout << R"(
};
union SymopData
{
struct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment