OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 /*
20  Author: Tobias Schmidt
21  */
22 #ifndef OST_IO_SDF_READER_HH
23 #define OST_IO_SDF_READER_HH
24 
25 #include <boost/filesystem/fstream.hpp>
26 #include <ost/mol/chain_handle.hh>
28 #include <ost/io/module_config.hh>
29 
30 namespace ost { namespace io {
31 
32 class DLLEXPORT_OST_IO SDFReader {
33 public:
34  SDFReader(const String& filename);
35  SDFReader(const boost::filesystem::path& loc);
36  SDFReader(std::istream& instream);
37 
38  bool HasNext();
39 
40  void Import(mol::EntityHandle& ent);
41 
42 private:
43  void ClearState(const boost::filesystem::path& loc);
44  void NextMolecule();
45 
46  void ParseAndAddHeader(const String& line, int line_num, mol::EntityHandle& ent,
47  mol::XCSEditor& editor);
48 
49  void ParseAndAddAtom(const String& line, int line_num, mol::EntityHandle& ent,
50  bool hetatm, mol::XCSEditor& editor);
51 
52  void ParseAndAddBond(const String& line, int line_num, mol::EntityHandle& ent,
53  mol::XCSEditor& editor);
54 
55  mol::ChainHandle curr_chain_;
56  mol::ResidueHandle curr_residue_;
57  int chain_count_;
58  int residue_count_;
59  int atom_count_;
60  int bond_count_;
61  int line_num;
62  boost::filesystem::ifstream infile_;
63  std::istream& instream_;
64 };
65 
66 }}
67 
68 #endif