Skip to content

Commit

Permalink
atrop layout
Browse files Browse the repository at this point in the history
  • Loading branch information
even1024 committed Sep 14, 2023
1 parent 0bb224e commit e97f85e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
7 changes: 5 additions & 2 deletions api/c/indigo/src/indigo_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ CEXPORT int indigoLayout(int object)
ml.max_iterations = self.layout_max_iterations;
ml.bond_length = 1.6f;
ml.layout_orientation = (layout_orientation_value)self.layout_orientation;
bool has_atropisomery = mol->hasAtropisomericCenter();
if (has_atropisomery)
ml.respect_existing_layout = true;

TimeoutCancellationHandler cancellation(self.cancellation_timeout);
ml.setCancellationHandler(&cancellation);
Expand All @@ -66,8 +69,8 @@ CEXPORT int indigoLayout(int object)

if (obj.type != IndigoObject::SUBMOLECULE)
{
// Not for submolecule yet
mol->clearBondDirections();
if (!has_atropisomery)
mol->clearBondDirections();
try
{
mol->markBondsStereocenters();
Expand Down
3 changes: 1 addition & 2 deletions core/indigo-core/layout/src/molecule_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace indigo;

IMPL_ERROR(MoleculeLayout, "molecule_layout");

MoleculeLayout::MoleculeLayout(BaseMolecule& molecule, bool smart_layout) : _molecule(molecule), _smart_layout(smart_layout)
MoleculeLayout::MoleculeLayout(BaseMolecule& molecule, bool smart_layout) : _molecule(molecule), _smart_layout(smart_layout), respect_existing_layout(false)
{
_hasMulGroups = _molecule.sgroups.getSGroupCount(SGroup::SG_TYPE_MUL) > 0;
_init(smart_layout);
Expand All @@ -36,7 +36,6 @@ MoleculeLayout::MoleculeLayout(BaseMolecule& molecule, bool smart_layout) : _mol
void MoleculeLayout::_init(bool smart_layout)
{
bond_length = 1.f;
respect_existing_layout = false;
filter = 0;
_smart_layout = smart_layout;
if (_smart_layout)
Expand Down
1 change: 1 addition & 0 deletions core/indigo-core/molecule/base_molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ namespace indigo
const int* getPyramidStereocenters(int idx) const;
void markBondsStereocenters();
void markBondStereocenters(int atom_idx);
bool hasAtropisomericCenter();

void addStereocenters(int atom_idx, int type, int group, const int pyramid[4]);
void addStereocenters(int atom_idx, int type, int group, bool inverse_pyramid);
Expand Down
11 changes: 11 additions & 0 deletions core/indigo-core/molecule/src/base_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4196,6 +4196,17 @@ void BaseMolecule::markBondsStereocenters()
stereocenters.markBonds(*this);
}

bool BaseMolecule::hasAtropisomericCenter()
{
for (int i = stereocenters.begin(); i != stereocenters.end(); i = stereocenters.next(i))
{
auto atom_idx = stereocenters.getAtomIndex(i);
if (stereocenters.isAtropisomeric(atom_idx))
return true;
}
return false;
}

void BaseMolecule::markBondStereocenters(int atom_idx)
{
stereocenters.markBond(*this, atom_idx);
Expand Down
9 changes: 5 additions & 4 deletions core/indigo-core/molecule/src/molecule_stereocenters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,10 +1676,11 @@ void MoleculeStereocenters::markBond(BaseMolecule& baseMolecule, int atom_idx)

void MoleculeStereocenters::markBonds(BaseMolecule& baseMolecule)
{
int i;

for (i = _stereocenters.begin(); i != _stereocenters.end(); i = _stereocenters.next(i))
markBond(baseMolecule, _stereocenters.key(i));
for (int i = _stereocenters.begin(); i != _stereocenters.end(); i = _stereocenters.next(i))
{
if (!_stereocenters.value(i).is_atropisomeric)
markBond(baseMolecule, _stereocenters.key(i));
}
}

bool MoleculeStereocenters::isAutomorphism(BaseMolecule& mol, const Array<int>& mapping, const Filter* filter)
Expand Down

0 comments on commit e97f85e

Please sign in to comment.