diff --git a/api/tests/integration/ref/layout/arrange_ring_tail_length.py.out b/api/tests/integration/ref/layout/arrange_ring_tail_length.py.out new file mode 100644 index 0000000000..2c8bff0a2c --- /dev/null +++ b/api/tests/integration/ref/layout/arrange_ring_tail_length.py.out @@ -0,0 +1,2 @@ +*** Arrange ring tail length *** +arrange_ring_tail_length:SUCCEED diff --git a/api/tests/integration/tests/layout/arrange_ring_tail_length.py b/api/tests/integration/tests/layout/arrange_ring_tail_length.py new file mode 100644 index 0000000000..0d607f376b --- /dev/null +++ b/api/tests/integration/tests/layout/arrange_ring_tail_length.py @@ -0,0 +1,51 @@ +import math +import os +import sys + +sys.path.append( + os.path.normpath( + os.path.join(os.path.abspath(__file__), "..", "..", "..", "common") + ) +) + +from env_indigo import * # noqa + +indigo = Indigo() + +print("*** Arrange ring tail length ***") + +library = indigo.loadMonomerLibraryFromFile( + dataPath("molecules/basic/monomer_library.ket") +) +helm = ( + "PEPTIDE1{C.C.C.C.C.C.C.C.C.C.C.C.C}$" + + "PEPTIDE1,PEPTIDE1,5:R3-8:R3$$$V2.0" +) +ket_doc = indigo.loadHelm(helm, library) +mol = indigo.loadMolecule(ket_doc.json()) + +for atom in mol.iterateAtoms(): + if atom.index() >= 4: + atom._lib().indigoSelect(atom.id) + +mol.layout() + +expected = 1.5 +tolerance = 0.05 +tail_pairs = [(7, 8), (8, 9), (9, 10), (10, 11), (11, 12)] + +ok = True +for start_idx, end_idx in tail_pairs: + start_atom = mol.getAtom(start_idx) + end_atom = mol.getAtom(end_idx) + sx, sy, _ = start_atom.xyz() + ex, ey, _ = end_atom.xyz() + dist = math.sqrt((sx - ex) ** 2 + (sy - ey) ** 2) + if abs(dist - expected) > tolerance: + ok = False + break + +if ok: + print("arrange_ring_tail_length:SUCCEED") +else: + print("arrange_ring_tail_length:FAILED") diff --git a/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp b/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp index f310271665..78fb29f1cc 100644 --- a/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp +++ b/core/indigo-core/layout/src/molecule_layout_graph_assign.cpp @@ -1252,7 +1252,14 @@ void MoleculeLayoutGraph::_assignFinalCoordinates(float bond_length, const Array } } - _reflectCycleVertices(inner_cycle_vertices, bond_length); + if (!sel_vertices.empty()) + { + for (auto vx_idx : sel_vertices) + _layout_vertices[vx_idx].pos.scale(bond_length); + selected_centroid.scale(bond_length); + } + + _reflectCycleVertices(inner_cycle_vertices, 1.0f); if (!sel_vertices.empty()) {