RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
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
namespace
RDKit
{
14
class
ROMol
;
15
class
RWMol
;
16
}
// namespace RDKit
17
18
/*! \file MolInterchange.h
19
20
\brief Contains the public API for the convertors to/from the commonchem
21
interchange format
22
23
\b Note that this should be considered beta and that the format and API
24
will very likely change in future releases.
25
26
More information about CommonChem is available here:
27
https://github.com/mcs07/CommonChem
28
*/
29
30
#include <string>
31
#include <vector>
32
33
#include <boost/shared_ptr.hpp>
34
35
namespace
RDKit
{
36
37
class
RWMol
;
38
39
namespace
MolInterchange
{
40
41
// \brief parameters controlling parsing of MolJSON
42
struct
RDKIT_MOLINTERCHANGE_EXPORT
JSONParseParameters
{
43
bool
setAromaticBonds
=
44
true
;
/*!< toggles setting the BondType of aromatic bonds to Aromatic */
45
bool
strictValenceCheck
=
46
false
;
/*!< toggles doing reasonable valence checks */
47
bool
parseProperties
=
48
true
;
/*!< toggles extracting molecular properties from the JSON block */
49
bool
parseConformers
=
50
true
;
/*!< toggles extracting conformers from the JSON block */
51
bool
useHCounts
=
52
true
;
/*!< toggles using the implicit H counts for atoms from the JSON
53
block. You may want to set this to false when parsing queries. */
54
};
55
static
JSONParseParameters
defaultJSONParseParameters
;
56
57
// \brief construct molecules from MolJSON data in a stream
58
/*!
59
* \param inStream - stream containing the data
60
* \param params - parsing options
61
*/
62
RDKIT_MOLINTERCHANGE_EXPORT
std::vector<boost::shared_ptr<ROMol>>
63
JSONDataStreamToMols
(std::istream *inStream,
const
JSONParseParameters
¶ms =
64
defaultJSONParseParameters
);
65
66
// \brief construct molecules from MolJSON data
67
/*!
68
* \param jsonBlock - string containing the mol block
69
* \param params - parsing options
70
*/
71
RDKIT_MOLINTERCHANGE_EXPORT
std::vector<boost::shared_ptr<ROMol>>
72
JSONDataToMols
(
const
std::string &jsonBlock,
73
const
JSONParseParameters
¶ms =
defaultJSONParseParameters
);
74
75
// \brief parameters controlling generating of MolJSON
76
struct
RDKIT_MOLINTERCHANGE_EXPORT
JSONWriteParameters
{
77
bool
useRDKitExtensions
=
78
true
;
/*!< toggles using RDKit extensions to commmonchem */
79
};
80
static
JSONWriteParameters
defaultJSONWriteParameters
;
81
82
// \brief returns MolJSON for a set of molecules
83
/*!
84
* \param mols - the molecules to work with
85
*/
86
template
<
typename
T>
87
RDKIT_MOLINTERCHANGE_EXPORT
std::string
MolsToJSONData
(
88
const
std::vector<T> &mols,
89
const
JSONWriteParameters
¶ms =
defaultJSONWriteParameters
);
90
91
// \brief returns MolJSON for a molecule
92
/*!
93
* \param mol - the molecule to work with
94
*/
95
template
<
typename
T>
96
std::string
MolToJSONData
(
const
T &mol,
const
JSONWriteParameters
¶ms =
97
defaultJSONWriteParameters
) {
98
std::vector<const T *> ms{&mol};
99
return
MolsToJSONData
(ms, params);
100
};
101
102
}
// end of namespace MolInterchange
103
}
// end of namespace RDKit
104
105
#endif
RDKit::ROMol
Definition
ROMol.h:344
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:451
RDKit::MolInterchange
Definition
MolInterchange/details.h:17
RDKit::MolInterchange::MolsToJSONData
RDKIT_MOLINTERCHANGE_EXPORT std::string MolsToJSONData(const std::vector< T > &mols, const JSONWriteParameters ¶ms=defaultJSONWriteParameters)
RDKit::MolInterchange::JSONDataToMols
RDKIT_MOLINTERCHANGE_EXPORT std::vector< boost::shared_ptr< ROMol > > JSONDataToMols(const std::string &jsonBlock, const JSONParseParameters ¶ms=defaultJSONParseParameters)
RDKit::MolInterchange::MolToJSONData
std::string MolToJSONData(const T &mol, const JSONWriteParameters ¶ms=defaultJSONWriteParameters)
Definition
MolInterchange.h:96
RDKit::MolInterchange::defaultJSONWriteParameters
static JSONWriteParameters defaultJSONWriteParameters
Definition
MolInterchange.h:80
RDKit::MolInterchange::defaultJSONParseParameters
static JSONParseParameters defaultJSONParseParameters
Definition
MolInterchange.h:55
RDKit::MolInterchange::JSONDataStreamToMols
RDKIT_MOLINTERCHANGE_EXPORT std::vector< boost::shared_ptr< ROMol > > JSONDataStreamToMols(std::istream *inStream, const JSONParseParameters ¶ms=defaultJSONParseParameters)
RDKit
Std stuff.
Definition
Abbreviations.h:19
RDKit::MolInterchange::JSONParseParameters
Definition
MolInterchange.h:42
RDKit::MolInterchange::JSONParseParameters::parseConformers
bool parseConformers
Definition
MolInterchange.h:49
RDKit::MolInterchange::JSONParseParameters::strictValenceCheck
bool strictValenceCheck
Definition
MolInterchange.h:45
RDKit::MolInterchange::JSONParseParameters::setAromaticBonds
bool setAromaticBonds
Definition
MolInterchange.h:43
RDKit::MolInterchange::JSONParseParameters::useHCounts
bool useHCounts
Definition
MolInterchange.h:51
RDKit::MolInterchange::JSONParseParameters::parseProperties
bool parseProperties
Definition
MolInterchange.h:47
RDKit::MolInterchange::JSONWriteParameters
Definition
MolInterchange.h:76
RDKit::MolInterchange::JSONWriteParameters::useRDKitExtensions
bool useRDKitExtensions
Definition
MolInterchange.h:77
GraphMol
MolInterchange
MolInterchange.h
Generated on
for RDKit by
1.17.0