OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pdb_writer.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-2020 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_PDB_WRITER_HH
20 #define OST_IO_PDB_WRITER_HH
21 
22 
23 /*
24  Author: Marco Biasini
25  */
26 #include <fstream>
27 
28 #include <boost/filesystem/fstream.hpp>
29 #include <boost/iostreams/filtering_stream.hpp>
30 
31 #include <ost/io/module_config.hh>
32 #include <ost/io/formatted_line.hh>
33 #include <ost/io/mol/io_profile.hh>
34 
35 namespace ost {
36 
37 namespace mol {
38 
39 class EntityView;
40 class EntityHandle;
41 
42 }
43 
44 namespace io {
45 
46 
47 class DLLEXPORT_OST_IO PDBWriter {
48  typedef boost::iostreams::filtering_stream<boost::iostreams::output> OutStream;
49 public:
50  PDBWriter(const String& filename,
51  const IOProfile& profile);
52  PDBWriter(const boost::filesystem::path& filename,
53  const IOProfile& profile);
54  PDBWriter(std::ostream& outstream, const IOProfile& profile);
55  void SetWriteMultiModel(bool flag) { multi_model_=flag; }
56  bool GetWriteMultiModel() const { return multi_model_; }
57  void SetIsPQR(bool flag) { is_pqr_=flag; }
58  bool IsPQR() const { return is_pqr_; }
59  void Write(const mol::EntityView& ent);
60  void Write(const mol::EntityHandle& ent);
61 
62  void Write(const mol::AtomHandleList& atoms);
63 
64  ~PDBWriter();
65 private:
66  template <typename H>
67  void WriteModel(H ent);
68 
69  void WriteModelLeader();
70  void WriteModelTrailer();
71  std::ofstream outfile_;
72  std::ostream& outstream_;
73  int mol_count_;
74  std::map<long, int> atom_indices_;
75  FormattedLine line_;
76  bool multi_model_;
77  bool charmm_style_;
78  bool is_pqr_;
79  IOProfile profile_;
80  String filename_;
81  OutStream out_;
82 };
83 
84 }}
85 
86 #endif
bool GetWriteMultiModel() const
Definition: pdb_writer.hh:56
bool IsPQR() const
Definition: pdb_writer.hh:58
std::string String
Definition: base.hh:54
Protein or molecule.
void SetIsPQR(bool flag)
Definition: pdb_writer.hh:57
#define DLLEXPORT_OST_IO
void SetWriteMultiModel(bool flag)
Definition: pdb_writer.hh:55
std::vector< AtomHandle > AtomHandleList
definition of EntityView
Definition: entity_view.hh:86