Commit 24aa7a70 by Maarten L. Hekkelman

Fix writing pdbx_ens_id

parent 5ade3d6c
...@@ -672,6 +672,7 @@ class Fi : public FBase ...@@ -672,6 +672,7 @@ class Fi : public FBase
virtual void out(std::ostream &os) virtual void out(std::ostream &os)
{ {
std::string s{ text() }; std::string s{ text() };
if (s.empty()) if (s.empty())
{ {
os << "NULL"; os << "NULL";
...@@ -679,7 +680,18 @@ class Fi : public FBase ...@@ -679,7 +680,18 @@ class Fi : public FBase
os << std::string(os.width() - 4, ' '); os << std::string(os.width() - 4, ' ');
} }
else else
os << std::stol(s); {
long l = 0;
auto r = std::from_chars(s.data(), s.data() + s.length(), l);
if (r.ec != std::errc())
{
if (VERBOSE > 0)
std::cerr << "Failed to write '" << s << "' as a long from field " << mField << ", this indicates an error in the code for writing PDB files" << std::endl;
os << s;
}
else
os << l;
}
} }
}; };
...@@ -712,7 +724,7 @@ class Ff : public FBase ...@@ -712,7 +724,7 @@ class Ff : public FBase
if (r.ec != std::errc()) if (r.ec != std::errc())
{ {
if (VERBOSE > 0) if (VERBOSE > 0)
std::cerr << "Failed to write '" << s << "' as a double, this indicates an error in the code for writing PDB files" << std::endl; std::cerr << "Failed to write '" << s << "' as a double from field " << mField << ", this indicates an error in the code for writing PDB files" << std::endl;
os << s; os << s;
} }
else else
...@@ -1384,7 +1396,7 @@ void WriteRemark3Refmac(std::ostream &pdbFile, const datablock &db) ...@@ -1384,7 +1396,7 @@ void WriteRemark3Refmac(std::ostream &pdbFile, const datablock &db)
unit = " : "; unit = " : ";
pdbFile << RM3(" ", 18) << type pdbFile << RM3(" ", 18) << type
<< SEP("", -2) << Fi(l, "pdbx_ens_id") << SEP("", -2) << Fs(l, "pdbx_ens_id")
<< SEP(" ", 1) << Fs(l, "pdbx_auth_asym_id") << SEP(" ", 1) << Fs(l, "pdbx_auth_asym_id")
<< SEP(unit.c_str(), -6) << Fi(l, "pdbx_number") << SEP(unit.c_str(), -6) << Fi(l, "pdbx_number")
<< SEP(" ;", -6, 3) << Ff(l, "rms_dev_position") << SEP(" ;", -6, 3) << Ff(l, "rms_dev_position")
...@@ -3365,10 +3377,21 @@ std::tuple<int, int> WriteCoordinatesForModel(std::ostream &pdbFile, const datab ...@@ -3365,10 +3377,21 @@ std::tuple<int, int> WriteCoordinatesForModel(std::ostream &pdbFile, const datab
cif::tie(nextResName, nextChainID, nextICode, nextResSeq, modelNum) = cif::tie(nextResName, nextChainID, nextICode, nextResSeq, modelNum) =
(*ri).get("label_comp_id", "auth_asym_id", "pdbx_PDB_ins_code", "auth_seq_id", "pdbx_PDB_model_num"); (*ri).get("label_comp_id", "auth_asym_id", "pdbx_PDB_ins_code", "auth_seq_id", "pdbx_PDB_model_num");
if (modelNum.empty() == false and stol(modelNum) != model_nr) if (modelNum.empty() == false)
{ {
++ri; int nr = 0;
continue; auto r = std::from_chars(modelNum.data(), modelNum.data() + modelNum.length(), nr);
if (r.ec != std::errc())
{
if (VERBOSE > 0)
std::cerr << "Model number '" << modelNum << "' is not a valid integer" << std::endl;
}
if (nr != model_nr)
{
++ri;
continue;
}
} }
if (chainID.empty() == false and terminatedChains.count(chainID) == 0) if (chainID.empty() == false and terminatedChains.count(chainID) == 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