Commit 6946c406 by Maarten L. Hekkelman

Merge branch 'trunk' of github.com:PDB-REDO/libcifpp into trunk

parents bd3723ee 3c62a386
......@@ -31,14 +31,30 @@
namespace cif::pdb
{
file read(std::istream &is);
/// \brief Read a file in either mmCIF or PDB format, compressed or not,
/// depending on the content.
file read(const std::filesystem::path &file);
/// \brief Read a file in either mmCIF or PDB format, compressed or not,
/// depending on the content.
file read(std::istream &is);
/// \brief Write out a file in PDB format
void write(std::ostream &os, const datablock &db);
/// \brief Write out a file in PDB format
inline void write(std::ostream &os, const file &f)
{
write(os, f.front());
}
/// \brief Write out a file in PDB format or mmCIF format, depending on the filename extension
void write(const std::filesystem::path &file, const datablock &db);
/// \brief Write out a file in PDB format or mmCIF format, depending on the filename extension
inline void write(const std::filesystem::path &p, const file &f)
{
write(p, f.front());
}
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include <regex>
#include <set>
#include <gxrio.hpp>
#include <cif++.hpp>
#include <cif++/pdb/cif2pdb.hpp>
......@@ -3723,4 +3724,21 @@ void write(std::ostream &os, const datablock &db)
<< "END" << std::endl;
}
void write(const std::filesystem::path &p, const datablock &db)
{
gxrio::ofstream out(p);
bool writePDB = false;
if (p.extension() == ".gz")
writePDB = iequals(p.stem().extension().string(), ".pdb");
else
writePDB = iequals(p.extension().string(), ".pdb");
if (writePDB)
write(out, db);
else
db.write(out);
}
} // namespace cif::pdb
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