Skip to content
Snippets Groups Projects
Commit faa63233 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

Load mmcif from strings

parent 65ba012f
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ using namespace boost::python; ...@@ -26,6 +26,7 @@ using namespace boost::python;
#include <ost/io/mol/io_profile.hh> #include <ost/io/mol/io_profile.hh>
#include <ost/io/mol/mmcif_reader.hh> #include <ost/io/mol/mmcif_reader.hh>
#include <ost/io/mol/mmcif_info.hh> #include <ost/io/mol/mmcif_info.hh>
#include <ost/io/mmcif_str.hh>
using namespace ost; using namespace ost;
using namespace ost::io; using namespace ost::io;
using namespace ost::mol; using namespace ost::mol;
...@@ -44,6 +45,16 @@ boost::python::list WrapGetNames(MMCifInfo *p){ ...@@ -44,6 +45,16 @@ boost::python::list WrapGetNames(MMCifInfo *p){
return VecToList<String>(names); 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() void export_mmcif_io()
{ {
class_<MMCifReader, boost::noncopyable>("MMCifReader", init<const String&, EntityHandle&, const IOProfile&>()) class_<MMCifReader, boost::noncopyable>("MMCifReader", init<const String&, EntityHandle&, const IOProfile&>())
...@@ -436,4 +447,8 @@ void export_mmcif_io() ...@@ -436,4 +447,8 @@ void export_mmcif_io()
&MMCifInfo::SetObsoleteInfo) &MMCifInfo::SetObsoleteInfo)
.add_property("revisions", &MMCifInfo::GetRevisions) .add_property("revisions", &MMCifInfo::GetRevisions)
; ;
def("MMCifStrToEntity", &WrapMMCifStringToEntity, (arg("pdb_string"),
arg("profile")=IOProfile(),
arg("process")=false));
} }
...@@ -20,6 +20,7 @@ star_parser.cc ...@@ -20,6 +20,7 @@ star_parser.cc
mmcif_reader.cc mmcif_reader.cc
mmcif_info.cc mmcif_info.cc
pdb_str.cc pdb_str.cc
mmcif_str.cc
stereochemical_params_reader.cc stereochemical_params_reader.cc
omf.cc omf.cc
PARENT_SCOPE PARENT_SCOPE
...@@ -49,6 +50,7 @@ surface_io_handler.hh ...@@ -49,6 +50,7 @@ surface_io_handler.hh
load_surface.hh load_surface.hh
surface_io_msms_handler.hh surface_io_msms_handler.hh
pdb_str.hh pdb_str.hh
mmcif_str.hh
stereochemical_params_reader.hh stereochemical_params_reader.hh
omf.hh omf.hh
PARENT_SCOPE PARENT_SCOPE
......
//------------------------------------------------------------------------------
// 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());
}
}}
//------------------------------------------------------------------------------
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment