diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index 15c0beebe151417910b25d7af94f5ced332819ac..3665c351bb0d22730ad187ffd501c37132e71116 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -57,6 +57,18 @@ boost::python::tuple WrapMMCifStringToEntity(const String& mmcif, std::get<2>(res)); } +String WrapEntityToMMCifStringEnt(const ost::mol::EntityHandle& ent, + const String& data_name, + bool mmcif_conform) { + return EntityToMMCifString(ent, data_name, mmcif_conform); +} + +String WrapEntityToMMCifStringView(const ost::mol::EntityView& ent, + const String& data_name, + bool mmcif_conform) { + return EntityToMMCifString(ent, data_name, mmcif_conform); +} + void WrapStarLoopAddData(StarWriterLoop& sl, const boost::python::list& l) { std::vector<StarWriterValue> v; for (int i = 0; i < boost::python::len(l); ++i){ @@ -516,4 +528,12 @@ void export_mmcif_io() def("MMCifStrToEntity", &WrapMMCifStringToEntity, (arg("pdb_string"), arg("profile")=IOProfile(), arg("process")=false)); + + def("EntityToMMCifString", &WrapEntityToMMCifStringEnt, (arg("ent"), + arg("data_name")="OST_structure", + arg("mmcif_conform")=true)); + + def("EntityToMMCifString", &WrapEntityToMMCifStringView, (arg("ent"), + arg("data_name")="OST_structure", + arg("mmcif_conform")=true)); } diff --git a/modules/io/src/mol/mmcif_str.cc b/modules/io/src/mol/mmcif_str.cc index e24f9d79113f3e85513d3a9f08d35cd088162d2b..a127ab7fabe8f775a3f8658a1887ffa7d1daff0e 100644 --- a/modules/io/src/mol/mmcif_str.cc +++ b/modules/io/src/mol/mmcif_str.cc @@ -19,9 +19,28 @@ #include <sstream> #include <ost/io/mol/mmcif_str.hh> #include <ost/io/mol/mmcif_reader.hh> +#include <ost/io/mmcif_writer.hh> namespace ost { namespace io { +String EntityToMMCifString(const ost::mol::EntityHandle& ent, + const String& data_name, bool mmcif_conform) { + std::stringstream ss; + MMCifWriter writer; + writer.SetStructure(ent, mmcif_conform); + writer.Write(data_name, ss); + return ss.str(); +} + +String EntityToMMCifString(const ost::mol::EntityView& ent, + const String& data_name, bool mmcif_conform) { + std::stringstream ss; + MMCifWriter writer; + writer.SetStructure(ent, mmcif_conform); + writer.Write(data_name, ss); + return ss.str(); +} + std::tuple<mol::EntityHandle, MMCifInfo, ost::seq::SequenceList> MMCifStringToEntity(const String& mmcif, const IOProfile& profile, bool process) { std::stringstream stream(mmcif); diff --git a/modules/io/src/mol/mmcif_str.hh b/modules/io/src/mol/mmcif_str.hh index 7e0ec2a113f77d92d0f8e94dbecab32c2a62d080..ec0c92df40d53c6deb55ab6cf53b557862e3b0d4 100644 --- a/modules/io/src/mol/mmcif_str.hh +++ b/modules/io/src/mol/mmcif_str.hh @@ -27,6 +27,14 @@ namespace ost { namespace io { +String DLLEXPORT_OST_IO +EntityToMMCifString(const ost::mol::EntityHandle& ent, const String& data_name, + bool mmcif_conform); + +String DLLEXPORT_OST_IO +EntityToMMCifString(const ost::mol::EntityView& ent, const String& data_name, + bool mmcif_conform); + std::tuple<mol::EntityHandle, MMCifInfo, ost::seq::SequenceList> DLLEXPORT_OST_IO MMCifStringToEntity(const String& mmcif, const IOProfile& profile, bool process);