Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Feb 6, 2025
2 parents c5fed7c + 28aeb70 commit cc4ecf7
Show file tree
Hide file tree
Showing 66 changed files with 175 additions and 121 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Please follow the naming scheme YEAR.MONTH.RELEASE_NO_OF_MONTH
(eg. 2016.4.1 for second release in Apr 2016)
-->
<version>2025.2.0</version>
<version>2025.2.1-SNAPSHOT</version>

<name>OpenChemLib</name>
<description>Open Source Chemistry Library</description>
Expand Down Expand Up @@ -207,7 +207,7 @@
<connection>scm:git:[email protected]:Actelion/openchemlib.git</connection>
<developerConnection>scm:git:[email protected]:Actelion/openchemlib.git</developerConnection>
<url>https://github.com/Actelion/openchemlib</url>
<tag>openchemlib-2025.2.0</tag>
<tag>HEAD</tag>
</scm>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ private void promoteDelocalizedChains() {
int terminalBond = bond;
int bridgeAtom = mMol.getBondAtom(1-i, bond);
while (terminalBond != -1) {
mIsDelocalizedAtom[terminalAtom] = false;
mIsDelocalizedBond[terminalBond] = false;
mDelocalizedBonds--;
mMol.setBondType(terminalBond, Molecule.cBondTypeDelocalized);
Expand All @@ -462,13 +463,15 @@ private void promoteDelocalizedChains() {
bridgeAtom = mMol.getConnAtom(terminalAtom, j);
}
else {
terminalAtom = -1;
terminalAtom = -1; // Stop here! We have hit an aromatic branch.
terminalBond = -1;
break;
}
}
}
}
if (terminalAtom != -1) // Regular end of aromatic chain (no branch).
mIsDelocalizedAtom[bridgeAtom] = false;
break;
}
}
Expand Down
39 changes: 36 additions & 3 deletions src/main/java/com/actelion/research/chem/ExtendedMolecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,9 @@ public boolean isPseudoRotatableBond(int bond) {
return false;
}

/**
* @return number of distinct aromatic rings in the molecule
*/
public int getAromaticRingCount() {
ensureHelperArrays(cHelperRings);
int count = 0;
Expand Down Expand Up @@ -1775,6 +1778,7 @@ public boolean isHeteroAromaticAtom(int atom) {


/**
* Requires helper arrays state cHelperRings.
* @param atom
* @return whether the atom is a member of a delocalized ring (subset of aromatic rings)
*/
Expand All @@ -1783,11 +1787,21 @@ public boolean isDelocalizedAtom(int atom) {
}


/**
* Requires helper arrays state cHelperRings.
* @param bond
* @return whether the bond is a member of an aromatic ring
*/
public boolean isAromaticBond(int bond) {
return bond<mBonds && mRingSet.isAromaticBond(bond);
}


/**
* Requires helper arrays state cHelperRings.
* @param bond
* @return whether the bond is a member of an aromatic ring that contains at least one hetero atom
*/
public boolean isHeteroAromaticBond(int bond) {
return bond<mBonds && mRingSet.isHeteroAromaticBond(bond);
}
Expand All @@ -1800,26 +1814,38 @@ public boolean isHeteroAromaticBond(int bond) {
* Indole has 6 delocalized bonds.
* This method also returns true, if the molecule is a fragment and if the bond is explicitly
* defined to be delocalized.
* Requires helper arrays state cHelperRings.
* @param bond
* @return
*/
@Override
public boolean isDelocalizedBond(int bond) {
return (bond < mBonds) ? mRingSet.isDelocalizedBond(bond) || mBondType[bond] == cBondTypeDelocalized : false;
return bond<mBonds && (mRingSet.isDelocalizedBond(bond) || mBondType[bond] == cBondTypeDelocalized);
}


/**
* Requires helper arrays state cHelperRings.
* @param atom
* @return whether the atom is a member of ring of any size
*/
public boolean isRingAtom(int atom) {
return (mAtomFlags[atom] & cAtomFlagsRingBonds) != 0;
}


public boolean isRingBond(int bnd) {
return (mBondFlags[bnd] & cBondFlagRing) != 0;
/**
* Requires helper arrays state cHelperRings.
* @param bond
* @return whether the bond is a member of ring of any size
*/
public boolean isRingBond(int bond) {
return (mBondFlags[bond] & cBondFlagRing) != 0;
}


/**
* Requires helper arrays state cHelperRings.
* @param atom
* @return whether atom is a member of a ring not larger than 7 atoms
*/
Expand All @@ -1829,6 +1855,7 @@ public boolean isSmallRingAtom(int atom) {


/**
* Requires helper arrays state cHelperRings.
* @param bond
* @return whether bond is a member of a ring not larger than 7 atoms
*/
Expand All @@ -1838,6 +1865,7 @@ public boolean isSmallRingBond(int bond) {


/**
* Requires helper arrays state cHelperNeighbours.
* @param atom
* @return whether atom has a neighbor that is connected through a double/triple bond to a hetero atom
*/
Expand All @@ -1846,6 +1874,11 @@ public boolean isStabilizedAtom(int atom) {
}


/**
* Requires helper arrays state cHelperRings.
* @param atom
* @return number of connected bonds, which are member of a ring
*/
public int getAtomRingBondCount(int atom) {
int flags = (mAtomFlags[atom] & cAtomFlagsRingBonds);
return (flags == 0) ? 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,12 +1096,36 @@ public static boolean containsFiveBindingCarbon(StereoMolecule mol) {
int bo = mol.getConnBondOrder(i,j);
sumBO+=bo;
}
five=(sumBO>4)?true:false;
if(sumBO>4){
five=true;
break;
}
}
}

return five;
}
public static boolean containsFiveBindingNitrogenWithoutCharge(StereoMolecule mol) {

boolean fiveBindingNNoPositiveCharge=false;
for (int i = 0; i < mol.getAtoms(); i++) {
if(mol.getAtomicNo(i)==5){
int sumBO=0;
for (int j = 0; j < mol.getConnAtoms(i); j++) {
int bo = mol.getConnBondOrder(i,j);
sumBO+=bo;
}
if(sumBO==5){
if(mol.getAtomCharge(i)!=1) {
fiveBindingNNoPositiveCharge = true;
break;
}
}
}
}

return fiveBindingNNoPositiveCharge;
}

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
* Date: 11/24/2014
* Time: 6:24 PM
*/
@Deprecated
public class GraphicsContextImpl implements IDrawContext<GraphicsContext>
{
GraphicsContext ctx;
Expand All @@ -69,10 +70,10 @@ public GraphicsContext getContext()
}
public static Color createColor(long color)
{
double r = (double) ((color & 0xFF000000l) >> 24) / 255.0;
double g = (double) ((color & 0x00FF0000l) >> 16) / 255.0;
double b = (double) ((color & 0x0000FF00l) >> 8) / 255.0;
double a = (double) (color & 0x000000FFl ) / 255.0;
double r = (double) ((color & 0xFF000000L) >> 24) / 255.0;
double g = (double) ((color & 0x00FF0000L) >> 16) / 255.0;
double b = (double) ((color & 0x0000FF00L) >> 8) / 255.0;
double a = (double) (color & 0x000000FFL ) / 255.0;
return new Color(r, g, b, a);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/** Copyright (c) 1997 - 2016* Actelion Pharmaceuticals Ltd.* Gewerbestrasse 16* CH-4123 Allschwil, Switzerland** All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions are met:** 1. Redistributions of source code must retain the above copyright notice, this* list of conditions and the following disclaimer.* 2. Redistributions in binary form must reproduce the above copyright notice,* this list of conditions and the following disclaimer in the documentation* and/or other materials provided with the distribution.* 3. Neither the name of the the copyright holder nor the* names of its contributors may be used to endorse or promote products* derived from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**/package com.actelion.research.jfx.gui.chem;import com.actelion.research.chem.AbstractDepictor;import com.actelion.research.chem.StereoMolecule;import com.actelion.research.gui.generic.GenericPolygon;import com.actelion.research.jfx.gui.GraphicsContextImpl;import javafx.geometry.Bounds;import javafx.geometry.VPos;import javafx.scene.canvas.GraphicsContext;import javafx.scene.paint.Color;import javafx.scene.shape.ArcType;import javafx.scene.shape.StrokeLineCap;import javafx.scene.shape.StrokeLineJoin;import javafx.scene.text.Font;import javafx.scene.text.Text;import javafx.scene.text.TextAlignment;/** * Project: * User: rufenec * Date: 10/12/11 * Time: 6:00 PM */public class JFXCanvasDepictor extends AbstractDepictor{ private GraphicsContext ctx = null; private Font currentFont = Font.font("Helvetica", 8); ; private double lineWidth = 1.0f; public JFXCanvasDepictor(StereoMolecule mol, int mode) { super(mol != null ? mol : new StereoMolecule()); super.setDisplayMode(mode); } public JFXCanvasDepictor(StereoMolecule mol) { this(mol, 0); } protected void init() { super.init(); } @Override public void paint(Object g) { if (g instanceof GraphicsContext) { ctx = (GraphicsContext) g; } else if (g instanceof GraphicsContextImpl) { ctx = ((GraphicsContextImpl) g).getContext(); } else { throw new IllegalArgumentException("Need to pass a Canvas object " + g); } super.paint(g); } @Override protected void drawBlackLine(DepictorLine theLine) { ctx.save(); ctx.setLineWidth(lineWidth); ctx.setLineCap(StrokeLineCap.ROUND); ctx.setLineJoin(StrokeLineJoin.MITER);// ctx.setStroke(colormap.color); ctx.beginPath(); ctx.moveTo(theLine.x1, theLine.y1); ctx.lineTo(theLine.x2,theLine.y2); ctx.stroke();// ctx.strokeLine(theLine.x1, theLine.y1, theLine.x2, theLine.y2); ctx.restore(); } @Override protected void drawDottedLine(DepictorLine theLine) { ctx.save();// ctx.setStroke(colormap.color); ctx.setLineCap(StrokeLineCap.ROUND); ctx.beginPath(); ctx.moveTo(theLine.x1,theLine.y1); ctx.lineTo(theLine.x2,theLine.y2); ctx.stroke();// ctx.strokeLine(theLine.x1, theLine.y1, theLine.x2, theLine.y2); ctx.restore(); } @Override protected void drawPolygon(GenericPolygon p) { ctx.save();// ctx.setStroke(colormap.color);// ctx.setFill(colormap.color); double[] x = new double[p.getSize()]; double[] y = new double[p.getSize()]; for (int i = 0; i < p.getSize(); i++) { x[i] = p.getX(i); y[i] = p.getY(i); } ctx.fillPolygon(x, y, p.getSize());// ctx.strokePolygon(x, y, count); ctx.restore(); } @Override protected void drawString(String theString, double x, double y) { ctx.save(); ctx.setFont(currentFont); ctx.setTextAlign(TextAlignment.CENTER); ctx.setTextBaseline(VPos.CENTER);// ctx.setFill(colormap.color); ctx.fillText(theString, x, y); ctx.restore(); } private Bounds getBounds(String s) { Text t = new Text(s); t.setFont(currentFont); return t.getLayoutBounds(); } @Override protected void fillCircle(double x, double y, double r) { ctx.save();// if (colormap != null) {// ctx.setFill(colormap.color);// } ctx.fillArc( (double) x, (double) y, (double) r, (double) r, (double) 0, (double) 360, ArcType.ROUND); ctx.restore(); } @Override protected double getStringWidth(String theString) {// Trace.trace(theString); return (double) getBounds(theString).getWidth(); } @Override protected int getTextSize() { return (int) currentFont.getSize(); } @Override protected void setTextSize(int theSize) { currentFont = Font.font("Helvetica", theSize); } @Override protected void setLineWidth(double lineWidth) { this.lineWidth = lineWidth; } @Override protected double getLineWidth() { return lineWidth; } @Override protected void setRGB(int rgb) { if (ctx != null) { Color color = new Color(((rgb & 0x00FF0000) >> 16) / 255.0, ((rgb & 0x0000FF00) >> 8) / 255.0, (rgb & 0x000000FF) / 255.0, 1.0); ctx.setStroke(color); ctx.setFill(color); } //colormap = getColor(theColor); }}
/** Copyright (c) 1997 - 2016* Actelion Pharmaceuticals Ltd.* Gewerbestrasse 16* CH-4123 Allschwil, Switzerland** All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions are met:** 1. Redistributions of source code must retain the above copyright notice, this* list of conditions and the following disclaimer.* 2. Redistributions in binary form must reproduce the above copyright notice,* this list of conditions and the following disclaimer in the documentation* and/or other materials provided with the distribution.* 3. Neither the name of the the copyright holder nor the* names of its contributors may be used to endorse or promote products* derived from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.**/package com.actelion.research.jfx.gui.chem;import com.actelion.research.chem.AbstractDepictor;import com.actelion.research.chem.StereoMolecule;import com.actelion.research.gui.generic.GenericPolygon;import com.actelion.research.gui.fx.FXDrawContext;import com.actelion.research.jfx.gui.GraphicsContextImpl;import javafx.geometry.Bounds;import javafx.geometry.VPos;import javafx.scene.canvas.GraphicsContext;import javafx.scene.paint.Color;import javafx.scene.shape.ArcType;import javafx.scene.shape.StrokeLineCap;import javafx.scene.shape.StrokeLineJoin;import javafx.scene.text.Font;import javafx.scene.text.Text;import javafx.scene.text.TextAlignment;/** * Project: * User: rufenec * Date: 10/12/11 * Time: 6:00 PM */@Deprecated // use a GenericDepictor instaedpublic class JFXCanvasDepictor extends AbstractDepictor{ private GraphicsContext ctx = null; private Font currentFont = Font.font("Helvetica", 8); ; private double lineWidth = 1.0f; public JFXCanvasDepictor(StereoMolecule mol, int mode) { super(mol != null ? mol : new StereoMolecule()); super.setDisplayMode(mode); } public JFXCanvasDepictor(StereoMolecule mol) { this(mol, 0); } protected void init() { super.init(); } @Override public void paint(Object g) { if (g instanceof GraphicsContext) { ctx = (GraphicsContext) g; } else if (g instanceof GraphicsContextImpl) { ctx = ((GraphicsContextImpl) g).getContext(); } else { throw new IllegalArgumentException("Need to pass a Canvas object " + g); } super.paint(g); } @Override protected void drawBlackLine(DepictorLine theLine) { ctx.save(); ctx.setLineWidth(lineWidth); ctx.setLineCap(StrokeLineCap.ROUND); ctx.setLineJoin(StrokeLineJoin.MITER);// ctx.setStroke(colormap.color); ctx.beginPath(); ctx.moveTo(theLine.x1, theLine.y1); ctx.lineTo(theLine.x2,theLine.y2); ctx.stroke();// ctx.strokeLine(theLine.x1, theLine.y1, theLine.x2, theLine.y2); ctx.restore(); } @Override protected void drawDottedLine(DepictorLine theLine) { ctx.save();// ctx.setStroke(colormap.color); ctx.setLineCap(StrokeLineCap.ROUND); ctx.beginPath(); ctx.moveTo(theLine.x1,theLine.y1); ctx.lineTo(theLine.x2,theLine.y2); ctx.stroke();// ctx.strokeLine(theLine.x1, theLine.y1, theLine.x2, theLine.y2); ctx.restore(); } @Override protected void drawPolygon(GenericPolygon p) { ctx.save();// ctx.setStroke(colormap.color);// ctx.setFill(colormap.color); double[] x = new double[p.getSize()]; double[] y = new double[p.getSize()]; for (int i = 0; i < p.getSize(); i++) { x[i] = p.getX(i); y[i] = p.getY(i); } ctx.fillPolygon(x, y, p.getSize());// ctx.strokePolygon(x, y, count); ctx.restore(); } @Override protected void drawString(String theString, double x, double y) { ctx.save(); ctx.setFont(currentFont); ctx.setTextAlign(TextAlignment.CENTER); ctx.setTextBaseline(VPos.CENTER);// ctx.setFill(colormap.color); ctx.fillText(theString, x, y); ctx.restore(); } private Bounds getBounds(String s) { Text t = new Text(s); t.setFont(currentFont); return t.getLayoutBounds(); } @Override protected void fillCircle(double x, double y, double r) { ctx.save();// if (colormap != null) {// ctx.setFill(colormap.color);// } ctx.fillArc( (double) x, (double) y, (double) r, (double) r, (double) 0, (double) 360, ArcType.ROUND); ctx.restore(); } @Override protected double getStringWidth(String theString) {// Trace.trace(theString); return (double) getBounds(theString).getWidth(); } @Override protected int getTextSize() { return (int) currentFont.getSize(); } @Override protected void setTextSize(int theSize) { currentFont = Font.font("Helvetica", theSize); } @Override protected void setLineWidth(double lineWidth) { this.lineWidth = lineWidth; } @Override protected double getLineWidth() { return lineWidth; } @Override protected void setRGB(int rgb) { if (ctx != null) { Color color = new Color(((rgb & 0x00FF0000) >> 16) / 255.0, ((rgb & 0x0000FF00) >> 8) / 255.0, (rgb & 0x000000FF) / 255.0, 1.0); ctx.setStroke(color); ctx.setFill(color); } //colormap = getColor(theColor); }}
Expand Down
Loading

0 comments on commit cc4ecf7

Please sign in to comment.