22 #ifndef OST_IO_SDF_READER_HH
23 #define OST_IO_SDF_READER_HH
26 #include <boost/iostreams/filtering_stream.hpp>
27 #include <boost/filesystem/fstream.hpp>
32 namespace ost {
namespace io {
39 SDFReader(
const String& filename);
40 SDFReader(
const boost::filesystem::path& loc);
41 SDFReader(std::istream& instream);
45 void Import(mol::EntityHandle& ent);
48 typedef std::tuple<int, String, String, String, String, String> atom_data;
49 typedef std::tuple<String, String, String> bond_data;
50 typedef std::tuple<String, String> charge_data;
51 typedef std::tuple<std::vector<String>, std::map<String, String>> v3000_line_tokens;
53 boost::iostreams::filtering_stream<boost::iostreams::input>& GetLine(
54 boost::iostreams::filtering_stream<boost::iostreams::input>& in,
57 void ClearState(
const boost::filesystem::path& loc);
60 void ParseHeader(
const String& line,
int line_num, mol::EntityHandle& ent,
61 mol::XCSEditor& editor);
62 void SetCounts(
const String& anum,
const String bnum,
int line_num);
64 atom_data ParseAtom(
const String& line,
int line_num);
65 void AddAtom(
const atom_data& atom_tuple,
int line_num, mol::EntityHandle& ent,
66 bool hetatm, mol::XCSEditor& editor);
68 bond_data ParseBond(
const String& line,
int line_num);
69 void AddBond(
const bond_data& bond_tuple,
int line_num, mol::EntityHandle& ent,
70 mol::XCSEditor& editor);
72 std::vector<charge_data> ParseMCharge(
const String& line,
int line_num);
73 void AddCharge(
const charge_data& charge_tuple,
int line_num, mol::EntityHandle& ent,
74 mol::XCSEditor& editor);
78 v3000_line_tokens TokenizeV3000Line(
const String& line,
int line_num,
81 void ProcessV3000Line(
const String& line, mol::EntityHandle& ent,
82 mol::XCSEditor& editor);
83 atom_data ParseV3000Atom(
const String& line,
int line_num);
84 bond_data ParseV3000Bond(
const String& line,
int line_num);
85 std::tuple<String, String> ParseV3000Counts(
const String& line,
int line_num);
86 void VerifyV3000Counts();
90 mol::ChainHandle curr_chain_;
91 mol::ResidueHandle curr_residue_;
97 boost::filesystem::ifstream infile_;
98 std::istream& instream_;
99 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
101 bool v3000_atom_block_;
102 bool v3000_bond_block_;