Commit 64e40e7b by Maarten L. Hekkelman

Fix writing PDB CISPEP records

Better checking for open files
More verbose parser
parent 06d254e0
...@@ -212,12 +212,16 @@ class sac_parser ...@@ -212,12 +212,16 @@ class sac_parser
void error(const std::string &msg) void error(const std::string &msg)
{ {
if (cif::VERBOSE > 0)
std::cerr << "Error parsing mmCIF: " << msg << std::endl;
throw parse_error(m_line_nr, msg); throw parse_error(m_line_nr, msg);
} }
void warning(const std::string &msg) void warning(const std::string &msg)
{ {
std::cerr << "parser warning at line" << m_line_nr << ": " << msg << std::endl; if (cif::VERBOSE > 0)
std::cerr << "parser warning at line" << m_line_nr << ": " << msg << std::endl;
} }
// production methods, these are pure virtual here // production methods, these are pure virtual here
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -184,6 +184,8 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name) ...@@ -184,6 +184,8 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
void file::load(const std::filesystem::path &p) void file::load(const std::filesystem::path &p)
{ {
gxrio::ifstream in(p); gxrio::ifstream in(p);
if (not in.is_open())
throw std::runtime_error("Could not open file " + p.string());
load(in); load(in);
} }
......
...@@ -49,6 +49,9 @@ namespace cif ...@@ -49,6 +49,9 @@ namespace cif
sac_parser::sac_parser(std::istream &is, bool init) sac_parser::sac_parser(std::istream &is, bool init)
: m_source(*is.rdbuf()) : m_source(*is.rdbuf())
{ {
if (is.rdbuf() == nullptr)
throw std::runtime_error("Attempt to read from uninitialised stream");
m_validate = true; m_validate = true;
m_line_nr = 1; m_line_nr = 1;
m_bol = true; m_bol = true;
......
...@@ -3226,7 +3226,8 @@ void WriteConnectivity(std::ostream &pdbFile, const datablock &db) ...@@ -3226,7 +3226,8 @@ void WriteConnectivity(std::ostream &pdbFile, const datablock &db)
"pdbx_label_comp_id_2", "pdbx_auth_asym_id_2", "pdbx_auth_seq_id_2", "pdbx_PDB_ins_code_2", "pdbx_label_comp_id_2", "pdbx_auth_asym_id_2", "pdbx_auth_seq_id_2", "pdbx_PDB_ins_code_2",
"pdbx_PDB_model_num", "pdbx_omega_angle"); "pdbx_PDB_model_num", "pdbx_omega_angle");
pdbFile << format("CISPEP %3d %3.3s %1.1s %4d%1.1s %3.3s %1.1s %4d%1.1s %3d %6.2f", serNum, pep1, chainID1, seqNum1, icode1, pep2, chainID2, seqNum2, icode2, modNum, measure) << std::endl; pdbFile << format("CISPEP %3.3s %3.3s %1.1s %4d%1.1s %3.3s %1.1s %4d%1.1s %3.3s %6.2f",
serNum, pep1, chainID1, seqNum1, icode1, pep2, chainID2, seqNum2, icode2, modNum, measure) << std::endl;
} }
} }
......
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