RDKit: MolInterchange.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
MolInterchange.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2022 Greg Landrum
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef RD_MOLINTERCHANGE_H_JAN2018
12#define RD_MOLINTERCHANGE_H_JAN2018
13
14/*! \file MolInterchange.h
15
16\brief Contains the public API for the convertors to/from the commonchem
17interchange format
18
19\b Note that this should be considered beta and that the format and API
20will very likely change in future releases.
21
22More information about CommonChem is available here:
23https://github.com/mcs07/CommonChem
24*/
25
26#include <string>
27#include <vector>
28
29#include <boost/shared_ptr.hpp>
30
31namespace RDKit {
32
33class RWMol;
34
35namespace MolInterchange {
36
37// \brief parameters controlling parsing of MolJSON
38 struct RDKIT_MOLINTERCHANGE_EXPORT JSONParseParameters {
39 bool setAromaticBonds =
40 true; /*!< toggles setting the BondType of aromatic bonds to Aromatic */
41 bool strictValenceCheck =
42 false; /*!< toggles doing reasonable valence checks */
43 bool parseProperties =
44 true; /*!< toggles extracting molecular properties from the JSON block */
45 bool parseConformers =
46 true; /*!< toggles extracting conformers from the JSON block */
47 bool useHCounts =
48 true; /*!< toggles using the implicit H counts for atoms from the JSON
49 block. You may want to set this to false when parsing queries. */
50};
51 static JSONParseParameters defaultJSONParseParameters;
52
53// \brief construct molecules from MolJSON data in a stream
54/*!
55 * \param inStream - stream containing the data
56 * \param params - parsing options
57 */
58 RDKIT_MOLINTERCHANGE_EXPORT std::vector<boost::shared_ptr<ROMol>>
59JSONDataStreamToMols(std::istream *inStream, const JSONParseParameters &params =
60 defaultJSONParseParameters);
61
62// \brief construct molecules from MolJSON data
63/*!
64 * \param jsonBlock - string containing the mol block
65 * \param params - parsing options
66 */
67 RDKIT_MOLINTERCHANGE_EXPORT std::vector<boost::shared_ptr<ROMol>>
68JSONDataToMols(const std::string &jsonBlock,
69 const JSONParseParameters &params = defaultJSONParseParameters);
70
71// \brief parameters controlling generating of MolJSON
72 struct RDKIT_MOLINTERCHANGE_EXPORT JSONWriteParameters {
73 bool useRDKitExtensions =
74 true; /*!< toggles using RDKit extensions to commmonchem */
75};
76 static JSONWriteParameters defaultJSONWriteParameters;
77
78// \brief returns MolJSON for a set of molecules
79/*!
80 * \param mols - the molecules to work with
81 */
82template <typename T>
83 RDKIT_MOLINTERCHANGE_EXPORT std::string MolsToJSONData(
84 const std::vector<T> &mols,
85 const JSONWriteParameters &params = defaultJSONWriteParameters);
86
87// \brief returns MolJSON for a molecule
88/*!
89 * \param mol - the molecule to work with
90 */
91template <typename T>
92std::string MolToJSONData(const T &mol, const JSONWriteParameters &params =
93 defaultJSONWriteParameters) {
94 std::vector<const T *> ms{&mol};
95 return MolsToJSONData(ms, params);
96};
97
98} // end of namespace MolInterchange
99} // end of namespace RDKit
100
101#endif
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_MOLINTERCHANGE_EXPORT
#define RDKIT_MOLINTERCHANGE_EXPORT
Definition export.h:353
RDKit::MolInterchange
Definition MolInterchange/details.h:17
RDKit::MolInterchange::MolsToJSONData
RDKIT_MOLINTERCHANGE_EXPORT std::string MolsToJSONData(const std::vector< T > &mols, const JSONWriteParameters &params=defaultJSONWriteParameters)
RDKit::MolInterchange::JSONDataToMols
RDKIT_MOLINTERCHANGE_EXPORT std::vector< boost::shared_ptr< ROMol > > JSONDataToMols(const std::string &jsonBlock, const JSONParseParameters &params=defaultJSONParseParameters)
RDKit::MolInterchange::MolToJSONData
std::string MolToJSONData(const T &mol, const JSONWriteParameters &params=defaultJSONWriteParameters)
Definition MolInterchange.h:92
RDKit::MolInterchange::defaultJSONWriteParameters
static JSONWriteParameters defaultJSONWriteParameters
Definition MolInterchange.h:76
RDKit::MolInterchange::defaultJSONParseParameters
static JSONParseParameters defaultJSONParseParameters
Definition MolInterchange.h:51
RDKit::MolInterchange::JSONDataStreamToMols
RDKIT_MOLINTERCHANGE_EXPORT std::vector< boost::shared_ptr< ROMol > > JSONDataStreamToMols(std::istream *inStream, const JSONParseParameters &params=defaultJSONParseParameters)
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::MolInterchange::JSONParseParameters
Definition MolInterchange.h:38
RDKit::MolInterchange::JSONParseParameters::parseConformers
bool parseConformers
Definition MolInterchange.h:45
RDKit::MolInterchange::JSONParseParameters::strictValenceCheck
bool strictValenceCheck
Definition MolInterchange.h:41
RDKit::MolInterchange::JSONParseParameters::setAromaticBonds
bool setAromaticBonds
Definition MolInterchange.h:39
RDKit::MolInterchange::JSONParseParameters::useHCounts
bool useHCounts
Definition MolInterchange.h:47
RDKit::MolInterchange::JSONParseParameters::parseProperties
bool parseProperties
Definition MolInterchange.h:43
RDKit::MolInterchange::JSONWriteParameters
Definition MolInterchange.h:72
RDKit::MolInterchange::JSONWriteParameters::useRDKitExtensions
bool useRDKitExtensions
Definition MolInterchange.h:73