RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
ParameterFileSource.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// File reader for rxdock parameter files
14
15#ifndef _RBTPARAMETERFILESOURCE_H_
16#define _RBTPARAMETERFILESOURCE_H_
17
18#include "rxdock/BaseFileSource.h"
19#include "rxdock/Variant.h"
20
21#include <nlohmann/json.hpp>
22
23using json = nlohmann::json;
24
25namespace rxdock {
26
28public:
29 // Constructors
30 ParameterFileSource(const char *fileName);
31 RBTDLL_EXPORT ParameterFileSource(const std::string &fileName);
32
33 // Destructor
34 virtual ~ParameterFileSource();
35
36 friend void to_json(json &j, const ParameterFileSource &parameterFileSrc);
37 friend void from_json(const json &j, ParameterFileSource &parameterFileSrc);
38
40 // Public methods
41 RBTDLL_EXPORT std::string GetTitle();
42 std::string GetVersion();
43 // DM 06 June 2000 - limit #parameters to those in current section
44 unsigned int GetNumParameters();
45 // DM 4 Feb 1999 Renamed from GetParameters()
46 // std::map<std::string, double> GetParameterMap();
47 // DM 12 Feb 1999 - only return the list of parameter names, not their values
48 // DM 06 Jun 2000 - limits params to those in named section
49 RBTDLL_EXPORT std::vector<std::string> GetParameterList();
50 // DM 4 Feb 1999 Get a particular named parameter value as a double
51 double GetParameterValue(const std::string &strParamName);
52 // DM 12 Feb 1999 Get a particular named parameter value as a string
53 RBTDLL_EXPORT std::string
54 GetParameterValueAsString(const std::string &strParamName);
55 // DM 11 Feb 1999 Check if parameter is present
56 bool isParameterPresent(const std::string &strParamName);
57
58 // DM 11 Feb 1999 - section handling
59 // Parameters can be grouped into named sections
60 // such that the same parameter name can appear in multiple sections
61 // Default namespace is the unnamed section.
62 // Main use is for simulation protocols which may need to define a variable
63 // number of phases - e.g. high temperature sampling, cooling phase,
64 // minimisation phase and need the same parameters to appear in each
65 int GetNumSections(); // Number of named sections
66 std::vector<std::string> GetSectionList(); // List of section names
67 std::string GetSection() const; // Get current section name
68 RBTDLL_EXPORT void
69 SetSection(const std::string &strSection = ""); // Set current section name
70
71protected:
72 // Protected methods
73
74private:
75 // Private methods
76 ParameterFileSource(); // Disable default constructor
78 const ParameterFileSource &); // Copy constructor disabled by default
80 operator=(const ParameterFileSource &); // Copy assignment disabled by default
81
82 // Pure virtual in BaseFileSource - needs to be defined here
83 virtual void Parse();
84 void ClearParamsCache();
85 // Add a new section name
86 // Throws an error if section name is empty, or is a duplicate
87 void AddSection(const std::string &strSection);
88 // Returns the fully qualified parameter name (<section>::<parameter name>)
89 // Checks if name already contains a section name, if so just returns the name
90 // unchanged If not, prefixes the name with the current section name
91 std::string GetFullParameterName(const std::string &strParamName);
92
93protected:
94 // Protected data
95
96private:
97 // Private data
98 std::string m_inputFileName;
99 std::string m_strTitle;
100 std::string m_strVersion;
101 StringVariantMap m_paramsMap;
102 std::vector<std::string> m_sectionNames; // List(vector) of section names
103 std::string m_strSection; // Current section
104 bool m_json;
105};
106
107void to_json(json &j, const ParameterFileSource &parameterFileSrc);
108void from_json(const json &j, ParameterFileSource &parameterFileSrc);
109
110// useful typedefs
112
113} // namespace rxdock
114
115#endif //_RBTPARAMETERFILESOURCE_H_
Definition BaseFileSource.h:36
Definition ParameterFileSource.h:27
Definition SmartPointer.h:48