OpenStructure
Loading...
Searching...
No Matches
sdf_reader.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: Tobias Schmidt
21 */
22#ifndef OST_IO_SDF_READER_HH
23#define OST_IO_SDF_READER_HH
24
25#include <tuple>
26#include <boost/iostreams/filtering_stream.hpp>
27#include <boost/filesystem/fstream.hpp>
32
33namespace ost { namespace io {
34
35
36
37
39public:
40 SDFReader(const String& filename, const IOProfile& profile);
41 SDFReader(const boost::filesystem::path& loc, const IOProfile& profile);
42 SDFReader(std::istream& instream, const IOProfile& profile);
43
45
46private:
47 typedef std::tuple<int, String, String, String, String, String> atom_data;
48 typedef std::tuple<String, String, String> bond_data;
49 typedef std::tuple<String, String> charge_data;
50 typedef std::tuple<std::vector<String>, std::map<String, String>> v3000_line_tokens;
51
52 boost::iostreams::filtering_stream<boost::iostreams::input>& GetLine(
53 boost::iostreams::filtering_stream<boost::iostreams::input>& in,
54 String& line);
55
56 void ClearState(const boost::filesystem::path& loc);
57 void NextMolecule();
58
59 void ParseHeader(const String& line, int line_num, mol::EntityHandle& ent,
60 mol::XCSEditor& editor);
61 void SetCounts(const String& anum, const String bnum, int line_num);
62
63 atom_data ParseAtom(const String& line, int line_num);
64 void AddAtom(const atom_data& atom_tuple, int line_num, mol::EntityHandle& ent,
65 bool hetatm, mol::XCSEditor& editor);
66
67 bond_data ParseBond(const String& line, int line_num);
68 void AddBond(const bond_data& bond_tuple, int line_num, mol::EntityHandle& ent,
69 mol::XCSEditor& editor);
70
71 std::vector<charge_data> ParseMCharge(const String& line, int line_num);
72 void AddCharge(const charge_data& charge_tuple, int line_num, mol::EntityHandle& ent,
73 mol::XCSEditor& editor);
74 void ResetCharges();
75
76 // V3000 methods
77 v3000_line_tokens TokenizeV3000Line(const String& line, int line_num,
78 int num_posval);
79 String CleanupV3000Line(const String& line);
80 void ProcessV3000Line(const String& line, mol::EntityHandle& ent,
81 mol::XCSEditor& editor);
82 atom_data ParseV3000Atom(const String& line, int line_num);
83 bond_data ParseV3000Bond(const String& line, int line_num);
84 std::tuple<String, String> ParseV3000Counts(const String& line, int line_num);
85 void VerifyV3000Counts();
86
87 String curr_chain_name_;
88 mol::ResidueKey curr_res_key_;
89 mol::ChainHandle curr_chain_;
90 mol::ResidueHandle curr_residue_;
91 int chain_count_;
92 int residue_count_;
93 int atom_count_;
94 int bond_count_;
95 int line_num;
96 boost::filesystem::ifstream infile_;
97 std::istream& instream_;
98 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
99 IOProfile profile_;
100 String version_;
101 bool v3000_atom_block_;
102 bool v3000_bond_block_;
103 bool charges_reset_;
104};
105
106}}
107
108#endif
void Import(mol::EntityHandle &ent)
SDFReader(const boost::filesystem::path &loc, const IOProfile &profile)
SDFReader(std::istream &instream, const IOProfile &profile)
SDFReader(const String &filename, const IOProfile &profile)
linear chain of residues
Protein or molecule.
external coordinate system editor
Definition xcs_editor.hh:36
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
String ResidueKey
Definition base.dox:1