RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
ElementFileSource.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 elemental data file (atomic no,element name,vdw radii)
14// Provides the data as a vector of structs
15
16#ifndef _RBTELEMENTFILESOURCE_H_
17#define _RBTELEMENTFILESOURCE_H_
18
19#include "rxdock/BaseFileSource.h"
20
21#include <nlohmann/json.hpp>
22
23using json = nlohmann::json;
24
25namespace rxdock {
26
27// Simple struct for holding the element data
29public:
31 : atomicNo(0), element(""), minVal(0), maxVal(0), commonVal(0), mass(0.0),
32 vdwRadius(0.0) {}
33 ElementData(json j) { j.get_to(*this); }
34
35 friend void to_json(json &j, const ElementData &e) {
36 j = json{{"atomic-number", e.atomicNo}, {"element-name", e.element},
37 {"minimum-value", e.minVal}, {"maximum-value", e.maxVal},
38 {"common-value", e.commonVal}, {"atomic-mass", e.mass},
39 {"vdw-radius", e.vdwRadius}};
40 }
41
42 friend void from_json(const json &j, ElementData &e) {
43 j.at("atomic-number").get_to(e.atomicNo);
44 j.at("element-name").get_to(e.element);
45 j.at("minimum-value").get_to(e.minVal);
46 j.at("maximum-value").get_to(e.maxVal);
47 j.at("common-value").get_to(e.commonVal);
48 j.at("atomic-mass").get_to(e.mass);
49 j.at("vdw-radius").get_to(e.vdwRadius);
50 }
51
52 int atomicNo;
53 std::string element;
54 int minVal;
55 int maxVal;
56 int commonVal;
57 double mass;
58 double vdwRadius; // Regular vdW radius
59};
60
61// Map with element data indexed by element name
62typedef std::map<std::string, ElementData> StringElementDataMap;
63typedef StringElementDataMap::iterator StringElementDataMapIter;
64typedef StringElementDataMap::const_iterator StringElementDataMapConstIter;
65// Map with element data indexed by atomic number
66typedef std::map<int, ElementData> IntElementDataMap;
67typedef IntElementDataMap::iterator IntElementDataMapIter;
68typedef IntElementDataMap::const_iterator IntElementDataMapConstIter;
69
71public:
72 // Constructors
73 // ElementFileSource(const char* fileName);
74 ElementFileSource(const std::string &fileName);
75
76 // Destructor
77 virtual ~ElementFileSource();
78
80 // Public methods
81 RBTDLL_EXPORT std::string GetTitle();
82 std::string GetVersion();
83 unsigned int GetNumElements();
84 std::vector<std::string> GetElementNameList(); // List of element names
85 std::vector<int> GetAtomicNumberList(); // List of atomic numbers
86 // Get element data for a given element name, throws error if not found
87 ElementData GetElementData(const std::string &strElementName);
88 // Get element data for a given atomic number, throws error if not found
89 ElementData GetElementData(int nAtomicNumber);
90 // Check if given element name is present
91 bool isElementNamePresent(const std::string &strElementName);
92 // Check if given atomic number is present
93 bool isAtomicNumberPresent(int nAtomicNumber);
94
95 // Get vdw radius increment for hydrogen-bonding donors
96 double GetHBondRadiusIncr();
97 // Get vdw radius increment for atoms with implicit hydrogens
98 double GetImplicitRadiusIncr();
99
100protected:
101 // Protected methods
102
103private:
104 // Private methods
105 ElementFileSource(); // Disable default constructor
107 const ElementFileSource &); // Copy constructor disabled by default
109 operator=(const ElementFileSource &); // Copy assignment disabled by default
110
111 // Pure virtual in BaseFileSource - needs to be defined here
112 virtual void Parse();
113 void ClearElementDataCache();
114
115protected:
116 // Protected data
117
118private:
119 // Private data
120 std::string m_inputFileName;
121 std::string m_strTitle;
122 std::string m_strVersion;
123 double m_dHBondRadiusIncr; // Increment to add to vdW radius for H-bonding
124 // hydrogens
125 double m_dImplicitRadiusIncr; // Increment to add to vdW radius for atoms
126 // with implicit hydrogens
127 StringElementDataMap m_elementNameMap;
128 IntElementDataMap m_atomicNumberMap;
129};
130
131// useful typedefs
133
134} // namespace rxdock
135
136#endif //_RBTELEMENTFILESOURCE_H_
Definition BaseFileSource.h:36
Definition ElementFileSource.h:28
Definition ElementFileSource.h:70
Definition SmartPointer.h:48