OpenStructure
Loading...
Searching...
No Matches
entity_io_pqr_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-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/*
20 Author: Ansgar Philippsen
21*/
22
23#ifndef OST_IO_ENTITY_IO_PLUGIN_PQR_H
24#define OST_IO_ENTITY_IO_PLUGIN_PQR_H
25
31
32#include <boost/iostreams/filtering_stream.hpp>
33#include <boost/filesystem/fstream.hpp>
34
35namespace ost { namespace io {
36
39public:
40 PQRReader(const boost::filesystem::path& loc);
41
43
44 std::vector<mol::AtomHandle> GetSequentialAtoms() const;
45
46private:
47
48 void ParseAndAddAtom(const String& line, mol::EntityHandle& h);
49 void ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& h);
50
51 std::vector<mol::AtomHandle> sequential_atom_list_;
52 mol::ChainHandle curr_chain_;
53 mol::ResidueHandle curr_residue_;
54 int chain_count_;
55 int residue_count_;
56 int atom_count_;
57 boost::filesystem::ifstream infile_;
58 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
59};
60
63public:
64 PQRWriter(const String& filename, bool ext=false);
65 PQRWriter(const boost::filesystem::path& filename, bool ext=false);
66 PQRWriter(std::ostream& outstream, bool ext=false);
67
68 void Write(const mol::EntityView& ent);
69 void Write(const mol::EntityHandle& ent);
70
71 virtual bool VisitAtom(const mol::AtomHandle& atom);
72 virtual bool VisitResidue(const mol::ResidueHandle& r);
73
74 void WriteHeader(const mol::EntityView& ent);
75
76private:
77 void Init();
78
79 std::ofstream outfile_;
80 std::ostream& outstream_;
81 bool ext_;
82 int atom_count_;
83 int atom_total_;
84 int res_count_;
85};
86
88public:
89 virtual void Import(mol::EntityHandle& ent, const boost::filesystem::path& loc);
90
91 virtual void Export(const mol::EntityView& ent,
92 const boost::filesystem::path& loc) const;
93
94 virtual void Import(mol::EntityHandle& ent, std::istream& stream);
95
96 virtual void Export(const mol::EntityView& ent, std::ostream& stream) const;
97
98 static bool ProvidesImport(const boost::filesystem::path& loc,
99 const String& format="auto");
100 static bool ProvidesExport(const boost::filesystem::path& loc,
101 const String& format="auto");
102 virtual bool RequiresBuilder() const;
103
104 static String GetFormatName() { return String("Crd"); }
105 static String GetFormatDescription() { return String("CARD format file used by the Charmm software package"); }
106};
107
108
110
112
113}} // ns
114
115#endif
pure abstract base class for entity io handlers
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 void Export(const mol::EntityView &ent, const boost::filesystem::path &loc) const
virtual void Import(mol::EntityHandle &ent, const boost::filesystem::path &loc)
virtual bool RequiresBuilder() const
virtual void Export(const mol::EntityView &ent, std::ostream &stream) const
virtual void Import(mol::EntityHandle &ent, std::istream &stream)
CHARMM coordinate file import.
void Import(mol::EntityHandle &ent)
std::vector< mol::AtomHandle > GetSequentialAtoms() const
PQRReader(const boost::filesystem::path &loc)
CHARMM coordinate file export.
PQRWriter(const String &filename, bool ext=false)
PQRWriter(std::ostream &outstream, bool ext=false)
virtual bool VisitResidue(const mol::ResidueHandle &r)
Residue callback.
void Write(const mol::EntityHandle &ent)
void WriteHeader(const mol::EntityView &ent)
void Write(const mol::EntityView &ent)
virtual bool VisitAtom(const mol::AtomHandle &atom)
Atom callback.
PQRWriter(const boost::filesystem::path &filename, bool ext=false)
Handle to atom datatype.
linear chain of residues
Protein or molecule.
definition of EntityView
EntityVisitor interface.
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
EntityIOHandlerFactory< EntityIOPQRHandler > EntityIOPQRHandlerFactory
mol::EntityHandle DLLEXPORT_OST_IO LoadPQR(const String &file_name)
Definition base.dox:1