Fix writing PDB CISPEP records

Better checking for open files
More verbose parser
This commit is contained in:
Maarten L. Hekkelman
2022-11-07 11:06:06 +01:00
parent 06d254e0de
commit 64e40e7b31
5 changed files with 107275 additions and 89105 deletions

View File

@@ -212,12 +212,16 @@ class sac_parser
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);
}
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

File diff suppressed because it is too large Load Diff

View File

@@ -184,6 +184,8 @@ std::tuple<file::iterator, bool> file::emplace(std::string_view name)
void file::load(const std::filesystem::path &p)
{
gxrio::ifstream in(p);
if (not in.is_open())
throw std::runtime_error("Could not open file " + p.string());
load(in);
}

View File

@@ -49,6 +49,9 @@ namespace cif
sac_parser::sac_parser(std::istream &is, bool init)
: m_source(*is.rdbuf())
{
if (is.rdbuf() == nullptr)
throw std::runtime_error("Attempt to read from uninitialised stream");
m_validate = true;
m_line_nr = 1;
m_bol = true;

View File

@@ -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_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;
}
}