Commit cf465134 by Maarten L. Hekkelman

fixing linux again

parent 873ac70d
......@@ -1474,7 +1474,7 @@ class conditional_iterator_proxy
conditional_iterator_proxy(Category& cat, row_iterator pos, Condition&& cond);
template<typename = std::enable_if_t<sizeof...(Ts) != 0>>
template<std::size_t TN = N, std::enable_if_t<TN != 0, bool> = true>
conditional_iterator_proxy(Category& cat, row_iterator pos, Condition&& cond, char const* const columns[N]);
conditional_iterator_proxy(conditional_iterator_proxy&& p);
......@@ -2053,7 +2053,7 @@ conditional_iterator_proxy<RowType, Ts...>::conditional_iterator_proxy(Category&
}
template<typename RowType, typename... Ts>
template<typename T>
template<std::size_t TN, std::enable_if_t<TN != 0, bool>>
conditional_iterator_proxy<RowType, Ts...>::conditional_iterator_proxy(Category& cat, row_iterator pos, Condition&& cond, const char* const columns[N])
: mCat(&cat)
, mCondition(std::move(cond))
......
......@@ -40,6 +40,8 @@
#if _MSC_VER
constexpr inline bool isatty(int) { return false; }
#else
#include <unistd.h>
#endif
namespace cif
......
......@@ -130,7 +130,7 @@ class DSSP
DSSP_Statistics GetStatistics() const;
class iterator;
using res_iter = typename std::vector<Res>::iterator;
using res_iterator = typename std::vector<Res>::iterator;
class ResidueInfo
{
......@@ -169,7 +169,7 @@ class DSSP
std::tuple<ResidueInfo,double> donor(int i) const;
private:
ResidueInfo(Res* res);
ResidueInfo(Res* res) : mImpl(res) {}
Res* mImpl;
};
......@@ -184,7 +184,7 @@ class DSSP
using reference = value_type&;
iterator(const iterator& i);
iterator(res_iter cur);
iterator(Res* res);
iterator& operator=(const iterator& i);
reference operator*() { return mCurrent; }
......
......@@ -1353,11 +1353,6 @@ void DSSPImpl::calculateSurface()
// --------------------------------------------------------------------
DSSP::ResidueInfo::ResidueInfo(Res* res)
: mImpl(res)
{
}
const Monomer& DSSP::ResidueInfo::residue() const
{
return mImpl->mM;
......@@ -1431,8 +1426,8 @@ std::tuple<DSSP::ResidueInfo,double> DSSP::ResidueInfo::donor(int i) const
// --------------------------------------------------------------------
DSSP::iterator::iterator(res_iter cur)
: mCurrent(&*cur)
DSSP::iterator::iterator(Res* res)
: mCurrent(res)
{
}
......@@ -1475,12 +1470,20 @@ DSSP::~DSSP()
DSSP::iterator DSSP::begin() const
{
return iterator(mImpl->mResidues.begin());
return iterator(mImpl->mResidues.empty() ? nullptr : mImpl->mResidues.data());
}
DSSP::iterator DSSP::end() const
{
return iterator(mImpl->mResidues.end());
// careful now, MSVC is picky when it comes to dereferencing iterators that are at the end.
Res* res = nullptr;
if (not mImpl->mResidues.empty())
{
res = mImpl->mResidues.data();
res += mImpl->mResidues.size();
}
return iterator(res);
}
SecondaryStructureType DSSP::operator()(const std::string& inAsymID, int inSeqID) const
......
......@@ -4,7 +4,10 @@
#include "cif++/Symmetry.hpp"
const mmcif::Spacegroup kSpaceGroups[] =
namespace mmcif
{
const Spacegroup kSpaceGroups[] =
{
{ "" , "P 2 1 1" , " P 2y (y,z,x)" , 10005 },
{ "" , "P 21 1 1" , " P 2yb (y,z,x)" , 10008 },
......@@ -629,9 +632,9 @@ const mmcif::Spacegroup kSpaceGroups[] =
};
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(mmcif::Spacegroup);
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(Spacegroup);
const mmcif::SymopDataBlock kSymopNrTable[] = {
const SymopDataBlock kSymopNrTable[] = {
// P 1
{ 1, 1, { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, } },
......@@ -8651,6 +8654,7 @@ const mmcif::SymopDataBlock kSymopNrTable[] = {
{ 10528, 192, { 0, 0, 1, 0,-1, 0,-1, 0, 0, 1, 2, 2, 6, 3, 4, } },
};
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(mmcif::SymopDataBlock);
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(SymopDataBlock);
} // namespace mmcif
......@@ -34,6 +34,8 @@
#include "cif++/Symmetry.hpp"
#include "cif++/CifUtils.hpp"
#include "SymOpTable_data.cpp"
namespace mmcif
{
......@@ -42,8 +44,6 @@ namespace mmcif
// for rotation numbers. So we created a table to map those.
// Perhaps a bit over the top, but hey....
#include "SymOpTable_data.cpp"
// --------------------------------------------------------------------
int GetSpacegroupNumber(std::string spacegroup)
......
......@@ -31,10 +31,11 @@
#include <fstream>
#include <regex>
#include <map>
#include <filesystem>
#include <cstdlib>
using namespace std;
namespace fs = std::filesystem;
std::regex kNameRx(R"(^(\d+) +(\d+) +(\d+) +(\S+) +(\S+) +(\S+) +'([^']+)'( +'([^']+)')?(?: +!.+)?$)");
......@@ -43,7 +44,7 @@ class SymopParser
public:
SymopParser() {}
array<int,15> parse(const string& s)
std::array<int,15> parse(const std::string& s)
{
m_p = s.begin();
m_e = s.end();
......@@ -56,7 +57,7 @@ class SymopParser
parsepart(2);
if (m_lookahead != 0 or m_p != m_e)
throw runtime_error("symmetry expression contains more data than expected");
throw std::runtime_error("symmetry expression contains more data than expected");
return {
m_rot[0][0], m_rot[0][1], m_rot[0][2],
......@@ -72,7 +73,7 @@ class SymopParser
enum Token : int { Eof = 0, Number = 256, XYZ };
string to_string(Token t)
std::string to_string(Token t)
{
switch (t)
{
......@@ -81,7 +82,7 @@ class SymopParser
case XYZ: return "'x', 'y' or 'z'";
default:
if (isprint(t))
return string({'\'', static_cast<char>(t), '\''});
return std::string({'\'', static_cast<char>(t), '\''});
return "invalid character " + std::to_string(static_cast<int>(t));
}
}
......@@ -134,7 +135,7 @@ class SymopParser
void match(Token token)
{
if (m_lookahead != token)
throw runtime_error("Unexpected character " + to_string(m_lookahead) + " expected " + to_string(token));
throw std::runtime_error("Unexpected character " + to_string(m_lookahead) + " expected " + to_string(token));
m_lookahead = next_token();
}
......@@ -169,8 +170,8 @@ class SymopParser
Token m_lookahead;
int m_nr;
string m_s;
string::const_iterator m_p, m_e;
std::string m_s;
std::string::const_iterator m_p, m_e;
int m_rot[3][3] = {};
int m_trn[3][2] = {};
......@@ -178,54 +179,59 @@ class SymopParser
int main(int argc, char* const argv[])
{
using namespace std::literals;
fs::path tmpFile;
try
{
if (argc != 2)
throw std::runtime_error("Usage: symom-map-generator <outputfile>");
std::ofstream out(argv[1]);
tmpFile = argv[1] + ".tmp"s;
std::ofstream out(tmpFile);
if (not out.is_open())
throw std::runtime_error("Failed to open output file");
const char* CLIBD = getenv("CLIBD");
if (CLIBD == nullptr)
throw runtime_error("CCP4 not sourced");
throw std::runtime_error("CCP4 not sourced");
// --------------------------------------------------------------------
// store symop data here
vector<tuple<int,int,array<int,15>>> data;
std::vector<std::tuple<int,int,std::array<int,15>>> data;
// -----------------------------------------------------------------------
struct SymInfoBlock
{
int nr;
string xHM;
string Hall;
string old[2];
std::string xHM;
std::string Hall;
std::string old[2];
};
map<int,SymInfoBlock> symInfo;
std::map<int,SymInfoBlock> symInfo;
int symopnr, mysymnr = 10000;
ifstream file(CLIBD + "/syminfo.lib"s);
std::ifstream file(CLIBD + "/syminfo.lib"s);
if (not file.is_open())
throw runtime_error("Could not open syminfo.lib file");
throw std::runtime_error("Could not open syminfo.lib file");
enum class State { skip, spacegroup } state = State::skip;
string line;
string Hall;
vector<string> old;
std::string line;
std::string Hall;
std::vector<std::string> old;
const regex rx(R"(^symbol +(Hall|xHM|old) +'(.+?)'(?: +'(.+?)')?$)"),
const std::regex rx(R"(^symbol +(Hall|xHM|old) +'(.+?)'(?: +'(.+?)')?$)"),
rx2(R"(symbol ccp4 (\d+))");;
SymInfoBlock cur = {};
std::vector<array<int,15>> symops, cenops;
std::vector<std::array<int,15>> symops, cenops;
while (getline(file, line))
{
......@@ -243,8 +249,8 @@ int main(int argc, char* const argv[])
case State::spacegroup:
{
smatch m;
if (regex_match(line, m, rx))
std::smatch m;
if (std::regex_match(line, m, rx))
{
if (m[1] == "old")
{
......@@ -310,11 +316,14 @@ int main(int argc, char* const argv[])
#include "cif++/Symmetry.hpp"
namespace mmcif
{
const Spacegroup kSpaceGroups[] =
{
)";
vector<tuple<string,int,string,string>> spacegroups;
std::vector<std::tuple<std::string,int,std::string,std::string>> spacegroups;
for (auto& [nr, info]: symInfo)
{
......@@ -327,18 +336,18 @@ const Spacegroup kSpaceGroups[] =
for (auto [old, nr, xHM, Hall]: spacegroups)
{
old = '"' + old + '"' + string(20 - old.length(), ' ');
xHM = '"' + xHM + '"' + string(30 - xHM.length(), ' ');
old = '"' + old + '"' + std::string(20 - old.length(), ' ');
xHM = '"' + xHM + '"' + std::string(30 - xHM.length(), ' ');
for (string::size_type p = Hall.length(); p > 0; --p)
for (std::string::size_type p = Hall.length(); p > 0; --p)
{
if (Hall[p - 1] == '"')
Hall.insert(p - 1, "\\", 1);
}
Hall = '"' + Hall + '"' + string(40 - Hall.length(), ' ');
Hall = '"' + Hall + '"' + std::string(40 - Hall.length(), ' ');
out << "\t{ " << old << ", " << xHM << ", " << Hall << ", " << nr << " }," << endl;
out << "\t{ " << old << ", " << xHM << ", " << Hall << ", " << nr << " }," << std::endl;
}
out << R"(
......@@ -347,36 +356,40 @@ out << R"(
const size_t kNrOfSpaceGroups = sizeof(kSpaceGroups) / sizeof(Spacegroup);
const SymopDataBlock kSymopNrTable[] = {
)" << endl;
)" << std::endl;
int spacegroupNr = 0;
for (auto& sd: data)
{
int sp, o;
tie(sp, o, ignore) = sd;
std::tie(sp, o, std::ignore) = sd;
if (sp > spacegroupNr)
out << " // " << symInfo[sp].xHM << endl;
out << " // " << symInfo[sp].xHM << std::endl;
spacegroupNr = sp;
out << " { " << setw(3) << sp
<< ", " << setw(3) << o << ", { ";
out << " { " << std::setw(3) << sp
<< ", " << std::setw(3) << o << ", { ";
for (auto& i: std::get<2>(sd))
out << setw(2) << i << ',';
out << " } }," << endl;
out << std::setw(2) << i << ',';
out << " } }," << std::endl;
}
out << R"(};
const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(SymopDataBlock);
)" << endl;
} // namespace mmcif
)" << std::endl;
out.close();
fs::rename(tmpFile, argv[1]);
}
catch (const exception& ex)
catch (const std::exception& ex)
{
cerr << endl
<< "Program terminated due to error:" << endl
<< ex.what() << endl;
std::cerr << std::endl
<< "Program terminated due to error:" << std::endl
<< ex.what() << std::endl;
}
return 0;
......
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