forked from rdkit/rdkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose molzip functionality to MinimalLib (rdkit#7959)
* Expose molzip functionality to MinimalLib * changes from code review --------- Co-authored-by: ptosco <[email protected]> Co-authored-by: Greg Landrum <[email protected]>
- Loading branch information
1 parent
9db22a9
commit 9c63cf6
Showing
12 changed files
with
304 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// Copyright (C) 2024 Novartis Biomedical Research and other RDKit contributors | ||
// | ||
// @@ 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. | ||
// | ||
|
||
#define USE_BETTER_ENUMS | ||
#include "MolFragmenterJSONParser.h" | ||
#include <RDGeneral/BoostStartInclude.h> | ||
#include <boost/property_tree/ptree.hpp> | ||
#include <boost/property_tree/json_parser.hpp> | ||
#include <RDGeneral/BoostEndInclude.h> | ||
|
||
namespace RDKit { | ||
|
||
void parseMolzipParametersJSON(MolzipParams ¶ms, const char *details_json) { | ||
if (!details_json || !strlen(details_json)) { | ||
return; | ||
} | ||
boost::property_tree::ptree pt; | ||
std::istringstream ss; | ||
ss.str(details_json); | ||
boost::property_tree::read_json(ss, pt); | ||
std::string label; | ||
label = pt.get<std::string>("Label", label); | ||
if (MolzipLabel::_is_valid(label.c_str())) { | ||
params.label = MolzipLabel::_from_string(label.c_str()); | ||
} | ||
auto atomSymbolsIt = pt.find("AtomSymbols"); | ||
if (atomSymbolsIt != pt.not_found()) { | ||
const auto &jsonVect = atomSymbolsIt->second; | ||
params.atomSymbols.resize(jsonVect.size()); | ||
std::transform( | ||
jsonVect.begin(), jsonVect.end(), params.atomSymbols.begin(), | ||
[](const auto &atomSymbolNode) { | ||
return atomSymbolNode.second.template get_value<std::string>(); | ||
}); | ||
} | ||
|
||
params.atomProperty = | ||
pt.get<std::string>("AtomProperty", params.atomProperty); | ||
params.enforceValenceRules = | ||
pt.get<bool>("EnforceValenceRules", params.enforceValenceRules); | ||
params.generateCoordinates = | ||
pt.get<bool>("GenerateCoordinates", params.generateCoordinates); | ||
} | ||
|
||
} // end namespace RDKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Copyright (C) 2024 Novartis Biomedical Research and other RDKit contributors | ||
// | ||
// @@ 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. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "MolFragmenter.h" | ||
|
||
namespace RDKit { | ||
|
||
//! \brief Parse MolzipParams from JSON. | ||
/*! The passed MolzipParams instance is updated from | ||
* the JSON-parsed content. | ||
* | ||
* @param params - molzip parameters | ||
* @param details_json - JSON string | ||
*/ | ||
RDKIT_CHEMTRANSFORMS_EXPORT void parseMolzipParametersJSON( | ||
MolzipParams ¶ms, const char *details_json); | ||
|
||
} // end namespace RDKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.