OpenStructure
Loading...
Searching...
No Matches
chemdict_parser.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_CONOP_CHEMDICT_PARSER_HH
20#define OST_CONOP_CHEMDICT_PARSER_HH
21
22/*
23 Author: Marco Biasini
24 */
25
26
27#include <ost/mol/chem_class.hh>
28#include <ost/mol/chem_type.hh>
31
32namespace ost { namespace io {
33
40
42public:
43 ChemdictParser(std::istream& stream, conop::Compound::Dialect dialect,
44 bool ignore_reserved=false, bool ignore_obsolete=false):
45 StarParser(stream), compound_(new conop::Compound("UNK")),
46 last_(0), loop_type_(DONT_KNOW), dialect_(dialect),
47 ignore_reserved_(ignore_reserved), ignore_obsolete_(ignore_obsolete),
48 imported_count_(0)
49 {
50 this->InitTypeMap();
51 this->InitPDBXTypeMap();
52 }
53
54 virtual bool OnBeginData(const StringRef& data_name);
55
56 virtual bool OnBeginLoop(const StarLoopDesc& header);
57
58 virtual void OnDataRow(const StarLoopDesc& header,
59 const std::vector<StringRef>& columns);
60
61 virtual void OnDataItem(const StarDataItem& item);
62
63 virtual void OnEndData();
64
66 {
67 lib_=lib;
68 }
69
72 {
73 return imported_count_;
74 }
75private:
76 void InitTypeMap();
77 void InitPDBXTypeMap();
78 bool IsNameReserved(const String& data_name);
80 conop::CompoundPtr compound_;
81 bool valid_compound_;
82 typedef enum {
83 ATOM_NAME=0,
84 ALT_ATOM_NAME=1,
85 IS_AROMATIC=2,
86 ORDINAL=3,
87 IS_LEAVING=4,
88 ELE=5,
89 CHARGE=6,
90 ATOM_ID1=0,
91 ATOM_ID2=1,
92 BOND_ORDER=2,
93 DESC_TYPE=0,
94 DESC=1,
95 PROGRAM=2,
96 } PropIndex;
97 char last_;
98 int indices_[10];
99 static std::map<String, mol::ChemClass> tm_;
100 static std::map<String, mol::ChemType> xtm_;
101 std::map<String, int> atom_map_;
102 LoopType loop_type_;
103 conop::AtomSpec atom_;
104 bool valid_atom_;
106 bool ignore_reserved_;
107 bool ignore_obsolete_;
108 int imported_count_;
109};
110
111
112}}
113
114
115#endif
convenient datatype for referencing character data
Definition string_ref.hh:39
virtual bool OnBeginData(const StringRef &data_name)
invoked when a new data control structure is encountered
int GetImportedCount()
Get the number of compounds that were successfully parsed.
virtual void OnEndData()
called when leaving a datasection. Will only be invoked when OnBeginData() returned true.
virtual void OnDataItem(const StarDataItem &item)
invoked when a data item is encountered
virtual void OnDataRow(const StarLoopDesc &header, const std::vector< StringRef > &columns)
invoked when a data row in a loop is encountered.
ChemdictParser(std::istream &stream, conop::Compound::Dialect dialect, bool ignore_reserved=false, bool ignore_obsolete=false)
virtual bool OnBeginLoop(const StarLoopDesc &header)
called when a loop is encountered
void SetCompoundLib(const conop::CompoundLibPtr &lib)
parser for the STAR file format
#define DLLEXPORT_OST_IO
std::string String
Definition base.hh:54
boost::shared_ptr< Compound > CompoundPtr
Definition compound.hh:145
boost::shared_ptr< CompoundLib > CompoundLibPtr
Definition base.dox:1