Skip to content
Snippets Groups Projects
Commit 2086293d authored by Marco Biasini's avatar Marco Biasini
Browse files

added entity io handler for mmcif format

parent f49a7f51
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ io_utils.hh ...@@ -13,6 +13,7 @@ io_utils.hh
io_exception.hh io_exception.hh
convert.hh convert.hh
converting_streams.hh converting_streams.hh
formatted_line.hh formatted_line.hh
) )
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <ost/io/mol/entity_io_crd_handler.hh> #include <ost/io/mol/entity_io_crd_handler.hh>
#include <ost/io/mol/entity_io_sdf_handler.hh> #include <ost/io/mol/entity_io_sdf_handler.hh>
#include <ost/io/mol/entity_io_mae_handler.hh> #include <ost/io/mol/entity_io_mae_handler.hh>
#include <ost/io/mol/entity_io_mmcif_handler.hh>
#include <ost/io/seq/fasta_io_handler.hh> #include <ost/io/seq/fasta_io_handler.hh>
#include <ost/io/seq/pir_io_handler.hh> #include <ost/io/seq/pir_io_handler.hh>
#include <ost/io/seq/promod_io_handler.hh> #include <ost/io/seq/promod_io_handler.hh>
...@@ -44,6 +45,7 @@ namespace ost { namespace io { ...@@ -44,6 +45,7 @@ namespace ost { namespace io {
IOManager::IOManager() IOManager::IOManager()
{ {
RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOMMCIFHandlerFactory));
RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOPDBHandlerFactory)); RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOPDBHandlerFactory));
RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOCRDHandlerFactory)); RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOCRDHandlerFactory));
RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOSDFHandlerFactory)); RegisterFactory(EntityIOHandlerFactoryBaseP(new EntityIOSDFHandlerFactory));
......
...@@ -5,6 +5,7 @@ pdb_reader.cc ...@@ -5,6 +5,7 @@ pdb_reader.cc
entity_io_pdb_handler.cc entity_io_pdb_handler.cc
pdb_writer.cc pdb_writer.cc
entity_io_sdf_handler.cc entity_io_sdf_handler.cc
entity_io_mmcif_handler.cc
sdf_reader.cc sdf_reader.cc
sdf_writer.cc sdf_writer.cc
save_entity.cc save_entity.cc
...@@ -29,6 +30,7 @@ io_profile.hh ...@@ -29,6 +30,7 @@ io_profile.hh
dcd_io.hh dcd_io.hh
entity_io_crd_handler.hh entity_io_crd_handler.hh
entity_io_mae_handler.hh entity_io_mae_handler.hh
entity_io_mmcif_handler.hh
entity_io_handler.hh entity_io_handler.hh
pdb_reader.hh pdb_reader.hh
entity_io_pdb_handler.hh entity_io_pdb_handler.hh
......
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2011 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
//------------------------------------------------------------------------------
/*
Author: Marco Biasini, Ansgar Philippsen
*/
#include <iostream>
#include <sstream>
#include <iomanip>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <ost/log.hh>
#include <ost/io/io_exception.hh>
#include "entity_io_mmcif_handler.hh"
#include <ost/profile.hh>
#include <ost/io/mol/mmcif_reader.hh>
namespace ost { namespace io {
using boost::format;
bool EntityIOMMCIFHandler::RequiresBuilder() const
{
return true;
}
void EntityIOMMCIFHandler::Export(const mol::EntityView& ent,
const boost::filesystem::path& loc) const
{
}
void EntityIOMMCIFHandler::Import(mol::EntityHandle& ent,
std::istream& stream)
{
MMCifParser reader(stream,ent,
IOProfileRegistry::Instance().GetDefault());
reader.Parse();
}
void EntityIOMMCIFHandler::Export(const mol::EntityView& ent,
std::ostream& stream) const
{
}
void EntityIOMMCIFHandler::Import(mol::EntityHandle& ent,
const boost::filesystem::path& loc)
{
std::string filename=loc.string();
MMCifParser reader(filename, ent,
IOProfileRegistry::Instance().GetDefault());
reader.Parse();
}
bool EntityIOMMCIFHandler::ProvidesImport(const boost::filesystem::path& loc,
const String& type)
{
if (type=="auto") {
String match_suf_string=loc.string();
std::transform(match_suf_string.begin(),match_suf_string.end(),
match_suf_string.begin(),tolower);
if(detail::FilenameEndsWith(match_suf_string,".cif") ||
detail::FilenameEndsWith(match_suf_string,".cif.gz")){
return true;
}
}
return type=="cif";
}
bool EntityIOMMCIFHandler::ProvidesExport(const boost::filesystem::path& loc,
const String& type)
{
return false;
}
}} // ns
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2011 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_ENTITY_IO_PLUGIN_MMCIF_HH
#define OST_IO_ENTITY_IO_PLUGIN_MMCIF_HH
#include <vector>
#include <ost/io/mol/entity_io_handler.hh>
namespace ost { namespace io {
class DLLEXPORT_OST_IO EntityIOMMCIFHandler: public EntityIOHandler {
public:
virtual void Import(mol::EntityHandle& ent,
const boost::filesystem::path& loc);
virtual void Export(const mol::EntityView& ent,
const boost::filesystem::path& loc) const;
virtual void Import(mol::EntityHandle& ent, std::istream& stream);
virtual void Export(const mol::EntityView& ent, std::ostream& stream) const;
static bool ProvidesImport(const boost::filesystem::path& loc,
const String& format="auto");
static bool ProvidesExport(const boost::filesystem::path& loc,
const String& format="auto");
virtual bool RequiresBuilder() const;
static String GetFormatName() { return String("mmCIF"); }
static String GetFormatDescription() {
return String("macromolecular Crystallographic Information File ");
}
};
typedef EntityIOHandlerFactory<EntityIOMMCIFHandler> EntityIOMMCIFHandlerFactory;
}} // ns
#endif
...@@ -51,6 +51,7 @@ StarParser::StarParser(const String& filename, bool items_as_row): ...@@ -51,6 +51,7 @@ StarParser::StarParser(const String& filename, bool items_as_row):
items_row_header_(), file_open_(true), items_row_columns_(), items_row_header_(), file_open_(true), items_row_columns_(),
items_row_values_() items_row_values_()
{ {
items_as_row_=items_as_row;
if (filename.length() >= 3 && if (filename.length() >= 3 &&
filename.substr(filename.length() - 3) == ".gz") { filename.substr(filename.length() - 3) == ".gz") {
stream_.push(boost::iostreams::gzip_decompressor()); stream_.push(boost::iostreams::gzip_decompressor());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment