mirror of
https://github.com/PDB-REDO/libcifpp.git
synced 2026-06-04 13:54:25 +08:00
Fix writing PDB CISPEP records
Better checking for open files More verbose parser
This commit is contained in:
@@ -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
|
||||
|
||||
196366
rsrc/mmcif_pdbx.dic
196366
rsrc/mmcif_pdbx.dic
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user