Skip to content

Commit

Permalink
Minor tweaks to selecting rotation of structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Jul 3, 2019
1 parent 8758d01 commit 4adf223
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
*/
public class StructureDiagramGenerator {

private static final double DEFAULT_BOND_LENGTH = 1.5;
static final double DEFAULT_BOND_LENGTH = 1.5;
private static final Vector2d DEFAULT_BOND_VECTOR = new Vector2d(0, 1);
private static final IdentityTemplateLibrary DEFAULT_TEMPLATE_LIBRARY = IdentityTemplateLibrary.loadFromResource("custom-templates.smi")
.add(IdentityTemplateLibrary.loadFromResource("chebi-ring-templates.smi"));
Expand Down Expand Up @@ -893,9 +893,9 @@ private void refinePlacement(IAtomContainer molecule) {
}
}

// no attachment point, rorate to maximise horizontal spread etc.
// no attachment point, rotate to maximise horizontal spread etc.
if (begAttach == null) {
selectOrientation(molecule, 2 * DEFAULT_BOND_LENGTH, 1);
selectOrientation(molecule, DEFAULT_BOND_LENGTH, 1);
}
// use attachment point bond to rotate
else {
Expand Down Expand Up @@ -964,6 +964,7 @@ private static void selectOrientation(IAtomContainer mol, double widthDiff, int


double maxWidth = minmax[2] - minmax[0];
double begWidth = maxWidth;
int maxAligned = countAlignedBonds(mol);

Point2d[] coords = new Point2d[mol.getAtomCount()];
Expand All @@ -978,11 +979,11 @@ private static void selectOrientation(IAtomContainer mol, double widthDiff, int
minmax = GeometryUtil.getMinMax(mol);

double width = minmax[2] - minmax[0];
double delta = Math.abs(width - maxWidth);
double delta = Math.abs(width - begWidth);

// if this orientation is significantly wider than the
// best so far select it
if (delta > widthDiff && width > maxWidth) {
if (delta >= widthDiff && width > maxWidth) {
maxWidth = width;
for (int j = 0; j < mol.getAtomCount(); j++)
coords[j] = new Point2d(mol.getAtom(j).getPoint2d());
Expand Down

0 comments on commit 4adf223

Please sign in to comment.