Commit cf465134 by Maarten L. Hekkelman

fixing linux again

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