Sails::JSONLoader
class Sails::JSONLoader
The JSONLoader class is responsible for loading and parsing JSON files.
This class provides methods for loading a JSON data file and extracting data from it. It requires a path to the file and ResidueDatabase object to fill.
Summary
Members | Descriptions |
---|---|
| |
| |
| |
| Loads the residue database from a JSON file. |
| Loads the linkage database from a JSON file. |
| |
| |
| Extracts a vector of AtomSet objects from a JSON value using the specified key. |
| Extracts angles from a JSON object. |
| Extracts the torsion angles from a JSON value. |
Members
public
JSONLoader
() = default
public
JSONLoader
(const std::string & path)
public void
init
(const std::string & path)
public ResidueDatabase
load_residue_database
()
Loads the residue database from a JSON file.
This method loads a JSON file containing residue data and parses it to create a ResidueDatabase object. It uses the simdjson library for efficient parsing. The path to the JSON file must be specified in the 'm_path' member variable.
Returns
The ResidueDatabase object containing the loaded residue data.
public LinkageDatabase
load_linkage_database
()
Loads the linkage database from a JSON file.
This method loads a JSON file containing linkage data and parses it to create a LinkageDatabase object. It uses the simdjson library for efficient parsing. The path to the JSON file must be specified in the 'm_path' member variable.
Returns
The LinkageDatabase object containing the loaded residue data.
private std::string
m_path
private simdjson::ondemand::document
m_doc
private static std::vector<
AtomSet
>
extract_atom_set
(simdjson::simdjson_result< simdjson::ondemand::value > & value, const char * key)
Extracts a vector of AtomSet objects from a JSON value using the specified key.
This function takes a simdjson value and extracts an array of objects from it using the specified key. Each object in the array represents an AtomSet, which contains information about three atoms and an identifier. The extracted AtomSets are returned as a vector.
Parameters
value
The simjson value to extract data from.key
The key to extract the array of AtomSet objects.
Returns
std::vectorSails::AtomSet The vector of extracted AtomSet objects.
private static
AngleSet
extract_angles
(simdjson::simdjson_result< simdjson::ondemand::value > & value)
Extracts angles from a JSON object.
This method extracts angles from a JSON object using keys "alpha", "beta", and "gamma".
Parameters
value
A simdjson_resultsimdjson::ondemand::value reference to extract angles from.
Returns
An AngleSet object containing the extracted angles.
private static
TorsionSet
extract_torsions
(simdjson::simdjson_result< simdjson::ondemand::value > & value)
Extracts the torsion angles from a JSON value.
This method extracts angles from a JSON object using the keys "phiMean", "phiStdDev", "psiMean", "psiStdDev", "omegaMean", and "omegaStdDev", each associated with a numerical value.
Parameters
value
A simdjson_resultsimdjson::ondemand::value reference to extract torsions from..
Returns
A TorsionSet object containing the extracted torsion angles.