Skip to content
Snippets Groups Projects
Commit 010128ec authored by marco's avatar marco
Browse files

moved chemdict parser from conop to io to avoid circular dependency

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2724 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 63d1de4e
No related branches found
No related tags found
No related merge requests found
...@@ -8,11 +8,9 @@ compound_lib.hh ...@@ -8,11 +8,9 @@ compound_lib.hh
module_config.hh module_config.hh
rule_based_builder.hh rule_based_builder.hh
ring_finder.hh ring_finder.hh
chemdict_parser.hh
) )
set(OST_CONOP_SOURCES set(OST_CONOP_SOURCES
chemdict_parser.cc
builder.cc builder.cc
conop.cc conop.cc
heuristic_builder.cc heuristic_builder.cc
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <ost/conop/chemdict_parser.hh> #include <ost/io/mol/chemdict_parser.hh>
using namespace ost; using namespace ost;
...@@ -70,7 +70,7 @@ int main(int argc, char const *argv[]) ...@@ -70,7 +70,7 @@ int main(int argc, char const *argv[])
filtered_istream.push(boost::iostreams::gzip_decompressor()); filtered_istream.push(boost::iostreams::gzip_decompressor());
} }
filtered_istream.push(istream); filtered_istream.push(istream);
conop::ChemdictParser cdp(filtered_istream, dialect); io::ChemdictParser cdp(filtered_istream, dialect);
conop::CompoundLibPtr compound_lib; conop::CompoundLibPtr compound_lib;
if (!strcmp(argv[1], "create")) { if (!strcmp(argv[1], "create")) {
compound_lib=conop::CompoundLib::Create(argv[3]); compound_lib=conop::CompoundLib::Create(argv[3]);
......
...@@ -12,12 +12,14 @@ save_entity.cc ...@@ -12,12 +12,14 @@ save_entity.cc
load_entity.cc load_entity.cc
surface_io_msms_handler.cc surface_io_msms_handler.cc
load_surface.cc load_surface.cc
chemdict_parser.cc
dcd_io.cc dcd_io.cc
star_parser.cc star_parser.cc
PARENT_SCOPE PARENT_SCOPE
) )
set(OST_IO_MOL_HEADERS set(OST_IO_MOL_HEADERS
chemdict_parser.hh
star_parser.hh star_parser.hh
dcd_io.hh dcd_io.hh
entity_io_crd_handler.hh entity_io_crd_handler.hh
......
#include <ost/conop/chemdict_parser.hh> #include <ost/io/mol/chemdict_parser.hh>
namespace ost { namespace conop { namespace ost { namespace io {
using namespace ost::conop;
bool ChemdictParser::OnBeginData(const StringRef& data_name) bool ChemdictParser::OnBeginData(const StringRef& data_name)
{ {
compound_.reset(new Compound(data_name.str())); compound_.reset(new Compound(data_name.str()));
...@@ -15,7 +17,7 @@ bool ChemdictParser::OnBeginData(const StringRef& data_name) ...@@ -15,7 +17,7 @@ bool ChemdictParser::OnBeginData(const StringRef& data_name)
return true; return true;
} }
bool ChemdictParser::OnBeginLoop(const io::StarLoopDesc& header) bool ChemdictParser::OnBeginLoop(const StarLoopDesc& header)
{ {
if (header.GetCategory()=="chem_comp_atom") { if (header.GetCategory()=="chem_comp_atom") {
loop_type_=ATOM_SPEC; loop_type_=ATOM_SPEC;
...@@ -37,7 +39,7 @@ bool ChemdictParser::OnBeginLoop(const io::StarLoopDesc& header) ...@@ -37,7 +39,7 @@ bool ChemdictParser::OnBeginLoop(const io::StarLoopDesc& header)
return false; return false;
} }
void ChemdictParser::OnDataRow(const io::StarLoopDesc& header, void ChemdictParser::OnDataRow(const StarLoopDesc& header,
const std::vector<StringRef>& columns) const std::vector<StringRef>& columns)
{ {
if (loop_type_==ATOM_SPEC) { if (loop_type_==ATOM_SPEC) {
...@@ -65,7 +67,7 @@ void ChemdictParser::OnDataRow(const io::StarLoopDesc& header, ...@@ -65,7 +67,7 @@ void ChemdictParser::OnDataRow(const io::StarLoopDesc& header,
} }
} }
void ChemdictParser::OnDataItem(const io::StarDataItem& item) void ChemdictParser::OnDataItem(const StarDataItem& item)
{ {
if (item.GetCategory()==StringRef("chem_comp", 9)) { if (item.GetCategory()==StringRef("chem_comp", 9)) {
if (item.GetName()==StringRef("type", 4)) { if (item.GetName()==StringRef("type", 4)) {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <ost/io/mol/star_parser.hh> #include <ost/io/mol/star_parser.hh>
#include <ost/conop/compound_lib.hh> #include <ost/conop/compound_lib.hh>
namespace ost { namespace conop { namespace ost { namespace io {
typedef enum { typedef enum {
ATOM_SPEC, ATOM_SPEC,
...@@ -36,10 +36,10 @@ typedef enum { ...@@ -36,10 +36,10 @@ typedef enum {
DONT_KNOW DONT_KNOW
} LoopType; } LoopType;
class DLLEXPORT_OST_CONOP ChemdictParser : public io::StarParser { class DLLEXPORT_OST_CONOP ChemdictParser : public StarParser {
public: public:
ChemdictParser(std::istream& stream, Compound::Dialect dialect): ChemdictParser(std::istream& stream, conop::Compound::Dialect dialect):
io::StarParser(stream), compound_(new Compound("UNK")), StarParser(stream), compound_(new conop::Compound("UNK")),
last_(0), loop_type_(DONT_KNOW), dialect_(dialect) last_(0), loop_type_(DONT_KNOW), dialect_(dialect)
{ {
this->InitTypeMap(); this->InitTypeMap();
...@@ -47,23 +47,23 @@ public: ...@@ -47,23 +47,23 @@ public:
virtual bool OnBeginData(const StringRef& data_name); virtual bool OnBeginData(const StringRef& data_name);
virtual bool OnBeginLoop(const io::StarLoopDesc& header); virtual bool OnBeginLoop(const StarLoopDesc& header);
virtual void OnDataRow(const io::StarLoopDesc& header, virtual void OnDataRow(const StarLoopDesc& header,
const std::vector<StringRef>& columns); const std::vector<StringRef>& columns);
virtual void OnDataItem(const io::StarDataItem& item); virtual void OnDataItem(const StarDataItem& item);
virtual void OnEndData(); virtual void OnEndData();
void SetCompoundLib(const CompoundLibPtr& lib) void SetCompoundLib(const conop::CompoundLibPtr& lib)
{ {
lib_=lib; lib_=lib;
} }
private: private:
void InitTypeMap(); void InitTypeMap();
CompoundLibPtr lib_; conop::CompoundLibPtr lib_;
CompoundPtr compound_; conop::CompoundPtr compound_;
typedef enum { typedef enum {
ATOM_NAME=0, ATOM_NAME=0,
ALT_ATOM_NAME=1, ALT_ATOM_NAME=1,
...@@ -82,8 +82,8 @@ private: ...@@ -82,8 +82,8 @@ private:
static std::map<String, mol::ChemClass> tm_; static std::map<String, mol::ChemClass> tm_;
std::map<String, int> atom_map_; std::map<String, int> atom_map_;
LoopType loop_type_; LoopType loop_type_;
AtomSpec atom_; conop::AtomSpec atom_;
Compound::Dialect dialect_; conop::Compound::Dialect dialect_;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment