OpenStructure
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-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_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/mol/mol.hh>
32 
33 #include <ost/io/module_config.hh>
34 #include <ost/io/formatted_line.hh>
35 #include <ost/io/mol/io_profile.hh>
36 
37 namespace ost { namespace io {
38 
39 class DLLEXPORT_OST_IO PDBWriter {
40 public:
41  PDBWriter(const String& filename,
42  const IOProfile& profile);
43  PDBWriter(const boost::filesystem::path& filename,
44  const IOProfile& profile);
45  PDBWriter(std::ostream& outstream, const IOProfile& profile);
46  void SetWriteMultiModel(bool flag) { multi_model_=flag; }
47  bool GetWriteMultiModel() const { return multi_model_; }
48  void SetIsPQR(bool flag) { is_pqr_=flag; }
49  bool IsPQR() const { return is_pqr_; }
50  void Write(const mol::EntityView& ent);
51  void Write(const mol::EntityHandle& ent);
52 
53  void Write(const mol::AtomHandleList& atoms);
54 
55  ~PDBWriter();
56 private:
57  template <typename H>
58  void WriteModel(H ent);
59 
60  void WriteModelLeader();
61  void WriteModelTrailer();
62  std::ofstream outfile_;
63  std::ostream& outstream_;
64  int mol_count_;
65  std::map<long, int> atom_indices_;
66  FormattedLine line_;
67  bool multi_model_;
68  bool charmm_style_;
69  bool is_pqr_;
70  IOProfile profile_;
71 };
72 
73 }}
74 
75 #endif