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

fix: update OCL to master branch #247

Merged
merged 4 commits into from
Feb 6, 2025
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
26 changes: 0 additions & 26 deletions __tests__/copyMoleculeByAtoms.test.js

This file was deleted.

70 changes: 70 additions & 0 deletions __tests__/copy_molecule_by_atoms.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { expect, test } from 'vitest';

import { Molecule } from '../minimal.js';

// idCode debug view: https://www.cheminfo.org/?viewURL=https%3A%2F%2Fcouch.cheminfo.org%2Fcheminfo-public%2F1cc9e892242664b1d5a37312bda159ef%2Fview.json&loadversion=true&fillsearch=Display+OCLcode+oclID
test('copyMoleculeByAtoms and keep aromaticity. We copy only 3 atoms', () => {
const molecule = Molecule.fromSmiles('c1ccccc1');
const fragment = new Molecule(0, 0);

expect(molecule.getBondOrder(0)).toBe(2);
expect(molecule.isDelocalizedBond(0)).toBe(true);
expect(molecule.getBondOrder(1)).toBe(1);
expect(molecule.isDelocalizedBond(1)).toBe(true);

const atomMask = [true, true, true, false, false, false];
molecule.copyMoleculeByAtoms(fragment, atomMask, true, null);
fragment.ensureHelperArrays(Molecule.cHelperRings); // would crash without Helper

expect(fragment.getAllAtoms()).toBe(3);
expect(fragment.getAllBonds()).toBe(2);

expect(fragment.getBondOrder(0)).toBe(1);
expect(fragment.isDelocalizedBond(0)).toBe(true);
expect(fragment.getBondOrder(1)).toBe(1);
expect(fragment.isDelocalizedBond(1)).toBe(true);
});

test('copyMoleculeByAtoms and keep aromaticity, we copy 5 atoms', () => {
const molecule = Molecule.fromSmiles('c1ccccc1');
const fragment = new Molecule(0, 0);

expect(molecule.getBondOrder(0)).toBe(2);
expect(molecule.isDelocalizedBond(0)).toBe(true);
expect(molecule.getBondOrder(1)).toBe(1);
expect(molecule.isDelocalizedBond(1)).toBe(true);

const atomMask = [true, true, true, true, true, false];
molecule.copyMoleculeByAtoms(fragment, atomMask, true, null);
fragment.ensureHelperArrays(Molecule.cHelperRings); // would crash without Helper

expect(fragment.getAllAtoms()).toBe(5);
expect(fragment.getAllBonds()).toBe(4);

expect(fragment.getBondOrder(0)).toBe(1);
expect(fragment.isDelocalizedBond(0)).toBe(true);
expect(fragment.getBondOrder(1)).toBe(1);
expect(fragment.isDelocalizedBond(1)).toBe(true);
});

test('copyMoleculeByAtoms and keep aromaticity, we copy all atoms', () => {
const molecule = Molecule.fromSmiles('c1ccccc1');
const fragment = new Molecule(0, 0);

expect(molecule.getBondOrder(0)).toBe(2);
expect(molecule.isDelocalizedBond(0)).toBe(true);
expect(molecule.getBondOrder(1)).toBe(1);
expect(molecule.isDelocalizedBond(1)).toBe(true);

const atomMask = [true, true, true, true, true, true];
molecule.copyMoleculeByAtoms(fragment, atomMask, true, null);
fragment.ensureHelperArrays(Molecule.cHelperRings); // would crash without Helper

expect(fragment.getAllAtoms()).toBe(6);
expect(fragment.getAllBonds()).toBe(6);

expect(fragment.getBondOrder(0)).toBe(2);
expect(fragment.isDelocalizedBond(0)).toBe(true);
expect(fragment.getBondOrder(1)).toBe(1);
expect(fragment.isDelocalizedBond(1)).toBe(true);
});
2 changes: 1 addition & 1 deletion openchemlib
Submodule openchemlib updated 56 files
+2 −2 pom.xml
+221 −309 src/main/java/com/actelion/research/chem/AromaticityResolver.java
+1 −1 src/main/java/com/actelion/research/chem/Coordinates.java
+15 −25 src/main/java/com/actelion/research/chem/ExtendedMolecule.java
+2 −0 src/main/java/com/actelion/research/chem/ExtendedMoleculeFunctions.java
+2 −57 src/main/java/com/actelion/research/chem/IDCodeParserWithoutCoordinateInvention.java
+20 −17 src/main/java/com/actelion/research/chem/IsomericSmilesCreator.java
+30 −118 src/main/java/com/actelion/research/chem/Molecule.java
+1 −1 src/main/java/com/actelion/research/chem/Molecule3D.java
+8 −19 src/main/java/com/actelion/research/chem/MoleculeStandardizer.java
+4 −4 src/main/java/com/actelion/research/chem/MolfileCreator.java
+3 −3 src/main/java/com/actelion/research/chem/MolfileParser.java
+4 −4 src/main/java/com/actelion/research/chem/MolfileV3Creator.java
+21 −48 src/main/java/com/actelion/research/chem/RingCollection.java
+26 −25 src/main/java/com/actelion/research/chem/SSSearcher.java
+1 −1 src/main/java/com/actelion/research/chem/SmilesAtomParser.java
+200 −573 src/main/java/com/actelion/research/chem/SmilesParser.java
+1 −1 src/main/java/com/actelion/research/chem/TautomerHelper.java
+0 −1,187 src/main/java/com/actelion/research/chem/io/CDX2CDXML.java
+0 −1,171 src/main/java/com/actelion/research/chem/io/CDXMLParser.java
+0 −204 src/main/java/com/actelion/research/chem/io/CDXParser.java
+2 −2 src/main/java/com/actelion/research/chem/io/CompoundTableConstants.java
+1 −2 src/main/java/com/actelion/research/chem/io/DWARFileParser.java
+0 −93 src/main/java/com/actelion/research/chem/io/ParserUtils.java
+4 −19 src/main/java/com/actelion/research/chem/io/SDFileParser.java
+0 −490 src/main/java/com/actelion/research/chem/io/XmlReader.java
+0 −122 src/main/java/com/actelion/research/chem/io/pdb/converter/AminoAcids.java
+102 −0 src/main/java/com/actelion/research/chem/io/pdb/converter/AminoAcidsLabeledContainer.java
+179 −273 src/main/java/com/actelion/research/chem/io/pdb/converter/BondsCalculator.java
+48 −0 src/main/java/com/actelion/research/chem/io/pdb/converter/ConstantsAminoAcidsLabeled.java
+4 −3 src/main/java/com/actelion/research/chem/io/pdb/converter/MoleculeGrid.java
+3 −11 src/main/java/com/actelion/research/chem/io/pdb/parser/AtomRecord.java
+8 −4 src/main/java/com/actelion/research/chem/io/pdb/parser/ModelParser.java
+3 −24 src/main/java/com/actelion/research/chem/io/pdb/parser/PDBCoordEntryFile.java
+137 −141 src/main/java/com/actelion/research/chem/io/pdb/parser/PDBFileParser.java
+25 −19 src/main/java/com/actelion/research/chem/io/pdb/parser/ProteinSynthesizer.java
+42 −24 src/main/java/com/actelion/research/chem/io/pdb/parser/Residue.java
+48 −66 src/main/java/com/actelion/research/chem/io/pdb/parser/StructureAssembler.java
+1 −1 src/main/java/com/actelion/research/chem/mcs/MCS.java
+5 −5 src/main/java/com/actelion/research/chem/reaction/MCSReactionMapper.java
+6 −6 src/main/java/com/actelion/research/chem/reaction/Reactor.java
+14 −14 src/main/java/com/actelion/research/chem/reaction/TransformerRule.java
+4 −28 src/main/java/com/actelion/research/chem/reaction/mapping/ChemicalRule.java
+56 −62 src/main/java/com/actelion/research/chem/reaction/mapping/ChemicalRuleEnhancedReactionMapper.java
+2 −13 src/main/java/com/actelion/research/chem/reaction/mapping/MappingScorer.java
+14 −18 src/main/java/com/actelion/research/chem/reaction/mapping/SimilarityGraphBasedReactionMapper.java
+10 −10 src/main/java/com/actelion/research/gui/JBondQueryFeatureDialog.java
+52 −22 src/main/java/com/actelion/research/gui/editor/BondQueryFeatureDialogBuilder.java
+0 −54 src/main/java/com/actelion/research/gui/editor/FXEditorTestApp.java
+45 −63 src/main/java/com/actelion/research/gui/editor/GenericEditorArea.java
+43 −23 src/main/java/com/actelion/research/gui/fx/FXUIHelper.java
+1 −3 src/main/java/com/actelion/research/gui/table/JTableWithRowNumbers.java
+0 −7 src/main/java/com/actelion/research/util/CommandLineParser.java
+3 −3 src/main/java/com/actelion/research/util/Sketch.java
+0 −21 src/main/java/com/actelion/research/util/StringFunctions.java
+26 −0 src/main/resources/resources/pdb/aminoAcidsLabeled.txt
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
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 @@ -38,6 +38,7 @@
import com.actelion.research.share.gui.editor.chem.IDrawingObject;
import com.actelion.research.share.gui.editor.geom.IDrawContext;

@Deprecated
public class Arrow implements IDrawingObject
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.awt.*;


@Deprecated
public class ChemistryGeometryHelper
{
public static final int REACTION_TYPE_NOMOLS = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

package com.actelion.research.share.gui;

@Deprecated
public class Delegator<T>
{
T delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/**
* Return values from Dialog calls
*/
@Deprecated
public enum DialogResult
{
IDOK, IDCANCEL, IDYES, IDNO, IDABORT, IDRETRY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* User: rufenec
* Creation Date: 8/24/2016
*/
@Deprecated
public abstract class DrawConfig
{
public final long createColor(double r, double g, double b, double alpha)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.List;


@Deprecated
public class Polygon implements IPolygon
{
List<GenericPoint> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/**
* Created by rufenec on 08/05/15.
*/
@Deprecated
public abstract class ImageProvider<T>
{
public abstract T getESRImage(boolean up);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@
* Date: 1/24/13
* Time: 5:02 PM
*/
@Deprecated
public abstract class Model
{
public interface AtomHighlightCallback
@Deprecated
public interface AtomHighlightCallback
{
void onHighlight(int atom, boolean selected);
}

public interface BondHighlightCallback
@Deprecated
public interface BondHighlightCallback
{
void onHighlight(int atom, boolean selected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/**
* Basic Interface for all editor actions
*/
@Deprecated
public interface Action
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* Date: 2/1/13
* Time: 4:03 PM
*/
@Deprecated
public class AddRingAction extends BondHighlightAction
{
Model model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* Date: 5/16/13
* Time: 3:46 PM
*/
@Deprecated
public class ArrowAction extends DrawAction
{
GenericPoint origin,last;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* Date: 2/1/13
* Time: 4:13 PM
*/
@Deprecated
public abstract class AtomHighlightAction extends DrawAction
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* Date: 5/22/13
* Time: 4:00 PM
*/
@Deprecated
public class AtomMapAction extends AtomHighlightAction
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* Date: 1/28/13
* Time: 1:07 PM
*/
@Deprecated
public abstract class BondBaseAction extends BondHighlightAction
{

Expand Down
Loading
Loading