Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2739 - Wrong stereochemistry when reading cdxml reaction #2740

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/indigo-core/molecule/molecule_cdxml_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ namespace indigo
class BaseCDXProperty
{
public:
virtual ~BaseCDXProperty() = default;
virtual bool hasContent() const = 0;
virtual std::unique_ptr<BaseCDXProperty> copy() = 0;
virtual std::unique_ptr<BaseCDXProperty> next() = 0;
Expand Down Expand Up @@ -375,6 +376,7 @@ namespace indigo
class BaseCDXElement
{
public:
virtual ~BaseCDXElement() = default;
virtual bool hasContent() = 0;
virtual std::unique_ptr<BaseCDXElement> copy() = 0;
virtual std::unique_ptr<BaseCDXProperty> firstProperty() = 0;
Expand Down
1 change: 1 addition & 0 deletions core/indigo-core/molecule/src/molecule_stereocenters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ MoleculeStereocenters::MoleculeStereocenters()
void MoleculeStereocenters::clear()
{
_stereocenters.clear();
_atropocenters.clear();
}

void MoleculeStereocenters::buildFromBonds(BaseMolecule& baseMolecule, const StereocentersOptions& options, int* sensible_bonds_out)
Expand Down
34 changes: 34 additions & 0 deletions core/indigo-core/tests/tests/formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <molecule/sdf_loader.h>
#include <molecule/smiles_loader.h>
#include <molecule/smiles_saver.h>
#include <reaction/reaction_cdxml_loader.h>

#include "common.h"

Expand Down Expand Up @@ -559,6 +560,39 @@ TEST_F(IndigoCoreFormatsTest, mol_to_document)
}
}

TEST_F(IndigoCoreFormatsTest, wrong_stereochemistry_2739)
{
FileScanner scanner(dataPath("reactions/basic/wrong_stereochemistry_2739.cdxml").c_str());
Reaction reaction;
ReactionCdxmlLoader loader(scanner);
loader.loadReaction(reaction);

std::vector<std::pair<int, int>> testData = {{1, 1}, {1, 2}, {2, 1}};

std::vector<std::pair<int, int>> bondDirections;
for (int i = reaction.begin(); i != reaction.end(); i = reaction.next(i))
{
const Molecule& mol = reaction.getMolecule(i);
int bondUp = 0;
int bondDown = 0;
for (int j = mol.edgeBegin(); j != mol.edgeEnd(); j = mol.edgeNext(j))
{
int direction = mol.getBondDirection(j);
if (direction == BOND_UP)
{
++bondUp;
}
else if (direction == BOND_DOWN)
{
++bondDown;
}
}
bondDirections.push_back({bondUp, bondDown});
}

ASSERT_EQ(testData, bondDirections);
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif
Loading
Loading