diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index 11223672cc0e6fb8121cdc44a2ad58ede5c0211c..954240725a665b5cce55ab3951b3375047bda253 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -26,6 +26,7 @@ using namespace boost::python; #include <ost/io/mol/io_profile.hh> #include <ost/io/mol/mmcif_reader.hh> #include <ost/io/mol/mmcif_info.hh> +#include <ost/io/mmcif_str.hh> using namespace ost; using namespace ost::io; using namespace ost::mol; @@ -44,6 +45,16 @@ boost::python::list WrapGetNames(MMCifInfo *p){ return VecToList<String>(names); } +boost::python::tuple WrapMMCifStringToEntity(const String& mmcif, + const IOProfile& profile=IOProfile(), + bool process=false) { + std::tuple<mol::EntityHandle, MMCifInfo, ost::seq::SequenceList> res = + MMCifStringToEntity(mmcif, profile, process); + return boost::python::make_tuple(std::get<0>(res), + std::get<1>(res), + std::get<2>(res)); +} + void export_mmcif_io() { class_<MMCifReader, boost::noncopyable>("MMCifReader", init<const String&, EntityHandle&, const IOProfile&>()) @@ -436,4 +447,8 @@ void export_mmcif_io() &MMCifInfo::SetObsoleteInfo) .add_property("revisions", &MMCifInfo::GetRevisions) ; + + def("MMCifStrToEntity", &WrapMMCifStringToEntity, (arg("pdb_string"), + arg("profile")=IOProfile(), + arg("process")=false)); } diff --git a/modules/io/src/mol/CMakeLists.txt b/modules/io/src/mol/CMakeLists.txt index 1581c9519b10e9b790f63cbbb20c51ce2abbd527..92d769f38df294adefa3d740840201416986ae0f 100644 --- a/modules/io/src/mol/CMakeLists.txt +++ b/modules/io/src/mol/CMakeLists.txt @@ -20,6 +20,7 @@ star_parser.cc mmcif_reader.cc mmcif_info.cc pdb_str.cc +mmcif_str.cc stereochemical_params_reader.cc omf.cc PARENT_SCOPE @@ -49,6 +50,7 @@ surface_io_handler.hh load_surface.hh surface_io_msms_handler.hh pdb_str.hh +mmcif_str.hh stereochemical_params_reader.hh omf.hh PARENT_SCOPE diff --git a/modules/io/src/mol/mmcif_str.cc b/modules/io/src/mol/mmcif_str.cc new file mode 100644 index 0000000000000000000000000000000000000000..e24f9d79113f3e85513d3a9f08d35cd088162d2b --- /dev/null +++ b/modules/io/src/mol/mmcif_str.cc @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2020 by the OpenStructure authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ +#include <sstream> +#include <ost/io/mol/mmcif_str.hh> +#include <ost/io/mol/mmcif_reader.hh> + +namespace ost { namespace io { + +std::tuple<mol::EntityHandle, MMCifInfo, ost::seq::SequenceList> +MMCifStringToEntity(const String& mmcif, const IOProfile& profile, bool process) { + std::stringstream stream(mmcif); + mol::EntityHandle ent = mol::CreateEntity(); + MMCifReader reader(stream, ent, profile); + reader.SetReadSeqRes(true); + reader.Parse(); + if(profile.processor && process) { + profile.processor->Process(ent); + } + return std::make_tuple(ent, reader.GetInfo(), reader.GetSeqRes()); +} + +}} diff --git a/modules/io/src/mol/mmcif_str.hh b/modules/io/src/mol/mmcif_str.hh new file mode 100644 index 0000000000000000000000000000000000000000..7e0ec2a113f77d92d0f8e94dbecab32c2a62d080 --- /dev/null +++ b/modules/io/src/mol/mmcif_str.hh @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2020 by the OpenStructure authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ +#ifndef OST_IO_MMCIF_STR_HH +#define OST_IO_MMCIF_STR_HH + +#include <ost/io/module_config.hh> +#include <ost/io/io_exception.hh> +#include <ost/mol/entity_handle.hh> +#include <ost/io/mmcif_reader.hh> +#include <ost/io/mol/io_profile.hh> + +namespace ost { namespace io { + +std::tuple<mol::EntityHandle, MMCifInfo, ost::seq::SequenceList> DLLEXPORT_OST_IO +MMCifStringToEntity(const String& mmcif, const IOProfile& profile, bool process); + +}} + +#endif