OpenStructure
entity_io_mae_handler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_IO_ENTITY_IO_PLUGIN_MAE_H
20 #define OST_IO_ENTITY_IO_PLUGIN_MAE_H
21 
23 
24 #include <boost/iostreams/filtering_stream.hpp>
25 #include <boost/filesystem/fstream.hpp>
26 
27 namespace ost { namespace io {
28 
30 public:
31  MAEReader(const boost::filesystem::path& loc);
32 
33  void Import(mol::EntityHandle& ent);
34 
35 private:
36 
37  void add_atom(mol::EntityHandle ent,
38  mol::XCSEditor& editor,const std::string& s_aname,
39  const std::string& s_axpos,
40  const std::string& s_aypos,
41  const std::string& s_azpos,
42  const std::string& s_rname,
43  const std::string& s_rnum,
44  const std::string& s_cname);
45 
46  mol::ChainHandle curr_chain_;
47  mol::ResidueHandle curr_residue_;
48  int chain_count_;
49  int residue_count_;
50  int atom_count_;
51  boost::filesystem::ifstream infile_;
52  boost::iostreams::filtering_stream<boost::iostreams::input> in_;
53 };
54 
56 public:
57  virtual void Import(mol::EntityHandle& ent, const boost::filesystem::path& loc);
58 
59  virtual void Export(const mol::EntityView& ent,
60  const boost::filesystem::path& loc) const;
61 
62  virtual void Import(mol::EntityHandle& ent, std::istream& stream);
63 
64  virtual void Export(const mol::EntityView& ent, std::ostream& stream) const;
65 
66  static bool ProvidesImport(const boost::filesystem::path& loc,
67  const String& format="auto");
68  static bool ProvidesExport(const boost::filesystem::path& loc,
69  const String& format="auto");
70  virtual bool RequiresBuilder() const;
71 
72  static String GetFormatName() { return String("Mae"); }
73  static String GetFormatDescription() { return String("MAEstro coordinate file format"); }
74 };
75 
76 
78 
80 
81 }} // ns
82 
83 #endif
84 //------------------------------------------------------------------------------
85 // This file is part of the OpenStructure project <www.openstructure.org>
86 //
87 // Copyright (C) 2008-2011 by the OpenStructure authors
88 //
89 // This library is free software; you can redistribute it and/or modify it under
90 // the terms of the GNU Lesser General Public License as published by the Free
91 // Software Foundation; either version 3.0 of the License, or (at your option)
92 // any later version.
93 // This library is distributed in the hope that it will be useful, but WITHOUT
94 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
95 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
96 // details.
97 //
98 // You should have received a copy of the GNU Lesser General Public License
99 // along with this library; if not, write to the Free Software Foundation, Inc.,
100 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
101 //------------------------------------------------------------------------------
102 #ifndef OST_IO_ENTITY_IO_PLUGIN_MAE_H
103 #define OST_IO_ENTITY_IO_PLUGIN_MAE_H
104 
106 
107 #include <boost/iostreams/filtering_stream.hpp>
108 #include <boost/filesystem/fstream.hpp>
109 
110 namespace ost { namespace io {
111 
112 class DLLEXPORT_OST_IO MAEReader {
113 public:
114  MAEReader(const boost::filesystem::path& loc);
115 
116  void Import(mol::EntityHandle& ent);
117 
118 private:
119 
120  void add_atom(mol::EntityHandle ent,
121  mol::XCSEditor& editor,const std::string& s_aname,
122  const std::string& s_axpos,
123  const std::string& s_aypos,
124  const std::string& s_azpos,
125  const std::string& s_rname,
126  const std::string& s_rnum,
127  const std::string& s_cname);
128 
129  mol::ChainHandle curr_chain_;
130  mol::ResidueHandle curr_residue_;
131  int chain_count_;
132  int residue_count_;
133  int atom_count_;
134  boost::filesystem::ifstream infile_;
135  boost::iostreams::filtering_stream<boost::iostreams::input> in_;
136 };
137 
138 class DLLEXPORT_OST_IO EntityIOMAEHandler: public EntityIOHandler {
139 public:
140  virtual void Import(mol::EntityHandle& ent, const boost::filesystem::path& loc);
141 
142  virtual void Export(const mol::EntityView& ent,
143  const boost::filesystem::path& loc) const;
144 
145  virtual void Import(mol::EntityHandle& ent, std::istream& stream);
146 
147  virtual void Export(const mol::EntityView& ent, std::ostream& stream) const;
148 
149  static bool ProvidesImport(const boost::filesystem::path& loc,
150  const String& format="auto");
151  static bool ProvidesExport(const boost::filesystem::path& loc,
152  const String& format="auto");
153  virtual bool RequiresBuilder() const;
154 
155  static String GetFormatName() { return String("Mae"); }
156  static String GetFormatDescription() { return String("MAEstro coordinate file format"); }
157 };
158 
159 
160 typedef EntityIOHandlerFactory<EntityIOMAEHandler> EntityIOMAEHandlerFactory;
161 
162 mol::EntityHandle DLLEXPORT_OST_IO LoadMAE(const String& file_name);
163 
164 }} // ns
165 
166 #endif