Loading...
Searching...
No Matches
CDXMLParser.h
Go to the documentation of this file.
//
// Copyright (c) 2022 Brian P Kelley
// All rights reserved.
//
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/export.h>
#ifndef RD_CDXML_FILEPARSERS_H
#define RD_CDXML_FILEPARSERS_H
#include <RDGeneral/types.h>
#include <string>
#include <iostream>
#include <vector>
namespace RDKit {
class RWMol;
namespace v2 {
namespace CDXMLParser {
enum class CDXMLFormat {
CDXML = 0,
CDX = 1,
Auto = 2
};
//! \brief Returns true if the RDKit was build with ChemDraw CDX support
RDKIT_FILEPARSERS_EXPORT bool hasChemDrawCDXSupport();
struct RDKIT_FILEPARSERS_EXPORT CDXMLParserParams {
bool sanitize = true;
bool removeHs = true;
CDXMLFormat format = CDXMLFormat::Auto;
CDXMLParserParams() = default;
CDXMLParserParams(bool sanitize, bool removeHs, CDXMLFormat format) :
sanitize(sanitize), removeHs(removeHs), format(format) {}
};
//! \brief construct molecules from a CDXML file
//! The RDKit is optionally built with the Revvity ChemDraw parser
//! If this is available, CDX and CDXML can be read, see CDXMLParserParams
//! Note that the CDXML format is large and complex, the RDKit doesn't
//! support full functionality, just the base ones required for molecule and
//! reaction parsing.
//! Note: If the ChemDraw extensions are available, this auto detects between
//! CDXML and CDX
/*!
* \param inStream - string containing the mol block
* \param params - parameters controlling the parsing and post-processing
*/
RDKIT_FILEPARSERS_EXPORT std::vector<std::unique_ptr<RWMol>>
MolsFromCDXMLDataStream(std::istream &inStream,
const CDXMLParserParams &params = CDXMLParserParams());
//! \brief construct molecules from a CDXML file
//! The RDKit is optionally built with the Revvity ChemDraw parser
//! If this is available, CDX and CDXML can be read, see CDXMLParserParams
//! Note that the CDXML format is large and complex, the RDKit doesn't
//! support full functionality, just the base ones required for molecule and
//! reaction parsing.
/*!
* \param fileName - cdxml fileName
* \param params - parameters controlling the parsing and post-processing
*/
RDKIT_FILEPARSERS_EXPORT std::vector<std::unique_ptr<RWMol>> MolsFromCDXMLFile(
const std::string &filename,
const CDXMLParserParams &params = CDXMLParserParams(true, true, CDXMLFormat::Auto));
//! \brief construct molecules from a CDXML block
//! The RDKit is optionally built with the Revvity ChemDraw parser
//! If this is available, CDX and CDXML can be read, see CDXMLParserParams
//! Note that the CDXML format is large and complex, the RDKit doesn't
//! support full functionality, just the base ones required for molecule and
//! reaction parsing.
//! Note: If the ChemDraw extensions are available,
//! CDXMLFormat::Auto attempts to see if the input string is CDXML or CDX
/*!
* \param cdxml - string containing the mol block
* \param params - parameters controlling the parsing and post-processing
*/
RDKIT_FILEPARSERS_EXPORT std::vector<std::unique_ptr<RWMol>> MolsFromCDXML(
const std::string &cdxml,
const CDXMLParserParams &params = CDXMLParserParams(true, true, v2::CDXMLParser::CDXMLFormat::Auto));
} // namespace CDXMLParser
} // namespace v2
inline namespace v1 {
//! \brief construct molecules from a CDXML file
//! Note that the CDXML format is large and complex, the RDKit doesn't support
//! full functionality, just the base ones required for molecule and
//! reaction parsing.
//! Note: If the ChemDraw extensions are available, this auto detects between
//! CDXML and CDX
/*!
* \param inStream - string containing the mol block
* \param sanitize - toggles sanitization and stereochemistry
* perception of the molecule
* \param removeHs - toggles removal of Hs from the molecule. H removal
* is only done if the molecule is sanitized
* correctness of the contents.
*/
inline std::vector<std::unique_ptr<RWMol>> CDXMLDataStreamToMols(
std::istream &inStream, bool sanitize = true, bool removeHs = true) {
v2::CDXMLParser::CDXMLParserParams params(
sanitize, removeHs, v2::CDXMLParser::CDXMLFormat::Auto);
return v2::CDXMLParser::MolsFromCDXMLDataStream(inStream, params);
}
//! \brief construct molecules from a CDXML file
//! Note that the CDXML format is large and complex, the RDKit doesn't support
//! full functionality, just the base ones required for molecule and
//! reaction parsing.
//! Note: If the ChemDraw extensions are available,
//! This function uses the file extension to determine the file type, .cdx or .cdxml
//! If not, it defaults to CDXML
/*!
* \param fileName - cdxml fileName
* \param sanitize - toggles sanitization and stereochemistry
* perception of the molecule
* \param removeHs - toggles removal of Hs from the molecule. H removal
* is only done if the molecule is sanitized
* correctness of the contents.
*/
inline std::vector<std::unique_ptr<RWMol>> CDXMLFileToMols(
const std::string &filename, bool sanitize = true, bool removeHs = true) {
v2::CDXMLParser::CDXMLParserParams params;
params.sanitize = sanitize;
params.removeHs = removeHs;
params.format = v2::CDXMLParser::CDXMLFormat::Auto;
return v2::CDXMLParser::MolsFromCDXMLFile(filename, params);
}
//! \brief construct molecules from a CDXML block
//! Note that the CDXML format is large and complex, the RDKit doesn't support
//! full functionality, just the base ones required for molecule and
//! reaction parsing.
//! Note: to parse CDX files see the CDXParserParams variant of this function
/*!
* \param cdxml - string containing the mol block
* \param sanitize - toggles sanitization and stereochemistry
* perception of the molecule
* \param removeHs - toggles removal of Hs from the molecule. H removal
* is only done if the molecule is sanitized
* correctness of the contents.
*/
inline std::vector<std::unique_ptr<RWMol>> CDXMLToMols(const std::string &cdxml,
bool sanitize = true,
bool removeHs = true) {
v2::CDXMLParser::CDXMLParserParams params;
params.sanitize = sanitize;
params.removeHs = removeHs;
params.format = v2::CDXMLParser::CDXMLFormat::Auto;
return v2::CDXMLParser::MolsFromCDXML(cdxml, params);
}
} // namespace v1
} // namespace RDKit
#endif // RD_CDXML_FILEPARSERS_H
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_FILEPARSERS_EXPORT
#define RDKIT_FILEPARSERS_EXPORT
Definition export.h:177
RDKit::v1
Definition ReactionParser.h:92
RDKit::v1::CDXMLToMols
std::vector< std::unique_ptr< RWMol > > CDXMLToMols(const std::string &cdxml, bool sanitize=true, bool removeHs=true)
construct molecules from a CDXML block Note that the CDXML format is large and complex,...
Definition CDXMLParser.h:151
RDKit::v1::CDXMLFileToMols
std::vector< std::unique_ptr< RWMol > > CDXMLFileToMols(const std::string &filename, bool sanitize=true, bool removeHs=true)
construct molecules from a CDXML file Note that the CDXML format is large and complex,...
Definition CDXMLParser.h:129
RDKit::v1::CDXMLDataStreamToMols
std::vector< std::unique_ptr< RWMol > > CDXMLDataStreamToMols(std::istream &inStream, bool sanitize=true, bool removeHs=true)
construct molecules from a CDXML file Note that the CDXML format is large and complex,...
Definition CDXMLParser.h:107
RDKit::v2::CDXMLParser
Definition CDXMLParser.h:23
RDKit::v2::CDXMLParser::CDXMLFormat
CDXMLFormat
Definition CDXMLParser.h:25
RDKit::v2::CDXMLParser::CDXMLFormat::Auto
@ Auto
Definition CDXMLParser.h:28
RDKit::v2::CDXMLParser::CDXMLFormat::CDXML
@ CDXML
Definition CDXMLParser.h:26
RDKit::v2::CDXMLParser::CDXMLFormat::CDX
@ CDX
Definition CDXMLParser.h:27
RDKit::v2::CDXMLParser::MolsFromCDXMLFile
RDKIT_FILEPARSERS_EXPORT std::vector< std::unique_ptr< RWMol > > MolsFromCDXMLFile(const std::string &filename, const CDXMLParserParams &params=CDXMLParserParams(true, true, CDXMLFormat::Auto))
construct molecules from a CDXML file The RDKit is optionally built with the Revvity ChemDraw parser ...
RDKit::v2::CDXMLParser::MolsFromCDXMLDataStream
RDKIT_FILEPARSERS_EXPORT std::vector< std::unique_ptr< RWMol > > MolsFromCDXMLDataStream(std::istream &inStream, const CDXMLParserParams &params=CDXMLParserParams())
construct molecules from a CDXML file The RDKit is optionally built with the Revvity ChemDraw parser ...
RDKit::v2::CDXMLParser::MolsFromCDXML
RDKIT_FILEPARSERS_EXPORT std::vector< std::unique_ptr< RWMol > > MolsFromCDXML(const std::string &cdxml, const CDXMLParserParams &params=CDXMLParserParams(true, true, v2::CDXMLParser::CDXMLFormat::Auto))
construct molecules from a CDXML block The RDKit is optionally built with the Revvity ChemDraw parser...
RDKit::v2::CDXMLParser::hasChemDrawCDXSupport
RDKIT_FILEPARSERS_EXPORT bool hasChemDrawCDXSupport()
Returns true if the RDKit was build with ChemDraw CDX support.
RDKit::v2
Definition ReactionParser.h:72
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::v2::CDXMLParser::CDXMLParserParams
Definition CDXMLParser.h:34
RDKit::v2::CDXMLParser::CDXMLParserParams::format
CDXMLFormat format
Definition CDXMLParser.h:37
RDKit::v2::CDXMLParser::CDXMLParserParams::removeHs
bool removeHs
Definition CDXMLParser.h:36
RDKit::v2::CDXMLParser::CDXMLParserParams::CDXMLParserParams
CDXMLParserParams()=default
RDKit::v2::CDXMLParser::CDXMLParserParams::sanitize
bool sanitize
Definition CDXMLParser.h:35
RDKit::v2::CDXMLParser::CDXMLParserParams::CDXMLParserParams
CDXMLParserParams(bool sanitize, bool removeHs, CDXMLFormat format)
Definition CDXMLParser.h:40
types.h