From 3f2b0b2442a511d390d2309be8bd0302279e1b2d Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 20 Dec 2024 13:36:46 +0100 Subject: [PATCH] removed explicit query feature bond types for the sake of simplicity. Now regular bond types are used instead also for defining multiple alloweedd bonds as query features. --- .../research/chem/ExtendedMolecule.java | 18 +++++----- ...DCodeParserWithoutCoordinateInvention.java | 14 ++++---- .../research/chem/IsomericSmilesCreator.java | 18 +++++----- .../com/actelion/research/chem/Molecule.java | 33 +++++++----------- .../research/chem/MolfileCreator.java | 8 ++--- .../actelion/research/chem/MolfileParser.java | 6 ++-- .../research/chem/MolfileV3Creator.java | 8 ++--- .../actelion/research/chem/SSSearcher.java | 34 +++++++++---------- .../actelion/research/chem/SmilesParser.java | 24 ++++++------- .../research/chem/TautomerHelper.java | 2 +- .../research/chem/reaction/Reactor.java | 12 +++---- .../chem/reaction/TransformerRule.java | 28 +++++++-------- .../research/gui/JBondQueryFeatureDialog.java | 20 +++++------ .../editor/BondQueryFeatureDialogBuilder.java | 28 +++++++-------- .../com/actelion/research/util/Sketch.java | 6 ++-- 15 files changed, 126 insertions(+), 133 deletions(-) diff --git a/src/main/java/com/actelion/research/chem/ExtendedMolecule.java b/src/main/java/com/actelion/research/chem/ExtendedMolecule.java index 51358ae2..e809058c 100644 --- a/src/main/java/com/actelion/research/chem/ExtendedMolecule.java +++ b/src/main/java/com/actelion/research/chem/ExtendedMolecule.java @@ -4151,8 +4151,8 @@ public void validateBondQueryFeatures() { for (int bond=0; bond"); diff --git a/src/main/java/com/actelion/research/chem/Molecule.java b/src/main/java/com/actelion/research/chem/Molecule.java index a2d937ac..7e8dbb5c 100644 --- a/src/main/java/com/actelion/research/chem/Molecule.java +++ b/src/main/java/com/actelion/research/chem/Molecule.java @@ -207,13 +207,13 @@ public class Molecule implements Serializable { public static final long cAtomQFIsNotStereo = 0x0000200000000000L; public static final long cAtomQFHeteroAromatic = 0x0000400000000000L; - public static final int cBondTypeSingle = 0x00000001; - public static final int cBondTypeDouble = 0x00000002; - public static final int cBondTypeTriple = 0x00000004; - public static final int cBondTypeQuadruple = 0x00000008; - public static final int cBondTypeQuintuple = 0x00000010; - public static final int cBondTypeMetalLigand = 0x00000020; - public static final int cBondTypeDelocalized = 0x00000040; + public static final int cBondTypeSingle = 0x00000001; // first 5 bond types must not be changed, + public static final int cBondTypeDouble = 0x00000002; // because they are part of the idcode + public static final int cBondTypeTriple = 0x00000004; // within the bond query features + public static final int cBondTypeDelocalized = 0x00000008; + public static final int cBondTypeMetalLigand = 0x00000010; + public static final int cBondTypeQuadruple = 0x00000020; + public static final int cBondTypeQuintuple = 0x00000040; public static final int cBondTypeDown = 0x00000081; public static final int cBondTypeUp = 0x00000101; public static final int cBondTypeCross = 0x00000182; @@ -279,13 +279,6 @@ public class Molecule implements Serializable { public static final int cBondQFNarrowing = 0x00600180; public static final int cBondQFBondTypes = 0x0000001F; // original 5 bond types for idcode public static final int cBondQFRareBondTypes = 0x00000060; // using OR logic for all 7 bond types - public static final int cBondQFSingle = 0x00000001; - public static final int cBondQFDouble = 0x00000002; - public static final int cBondQFTriple = 0x00000004; - public static final int cBondQFDelocalized = 0x00000008; - public static final int cBondQFMetalLigand = 0x00000010; - public static final int cBondQFQuadruple = 0x00000020; - public static final int cBondQFQuintuple = 0x00000040; public static final int cBondQFRingState = 0x00000180; public static final int cBondQFNotRing = 0x00000080; public static final int cBondQFRing = 0x00000100; @@ -2664,17 +2657,17 @@ public double getBondLength(int bond) { */ public int getBondOrder(int bond) { if (mIsFragment && (mBondQueryFeatures[bond] & cBondQFBondTypes) != 0) { - if ((mBondQueryFeatures[bond] & (cBondQFSingle | cBondQFDelocalized)) != 0) + if ((mBondQueryFeatures[bond] & (cBondTypeSingle | cBondTypeDelocalized)) != 0) return 1; - if ((mBondQueryFeatures[bond] & cBondQFDouble) != 0) + if ((mBondQueryFeatures[bond] & cBondTypeDouble) != 0) return 2; - if ((mBondQueryFeatures[bond] & cBondQFTriple) != 0) + if ((mBondQueryFeatures[bond] & cBondTypeTriple) != 0) return 3; - if ((mBondQueryFeatures[bond] & cBondQFQuadruple) != 0) + if ((mBondQueryFeatures[bond] & cBondTypeQuadruple) != 0) return 4; - if ((mBondQueryFeatures[bond] & cBondQFQuintuple) != 0) + if ((mBondQueryFeatures[bond] & cBondTypeQuintuple) != 0) return 5; - if ((mBondQueryFeatures[bond] & cBondQFMetalLigand) != 0) + if ((mBondQueryFeatures[bond] & cBondTypeMetalLigand) != 0) return 0; } switch (mBondType[bond] & cBondTypeMaskSimple) { diff --git a/src/main/java/com/actelion/research/chem/MolfileCreator.java b/src/main/java/com/actelion/research/chem/MolfileCreator.java index 795f934e..d0aedc08 100644 --- a/src/main/java/com/actelion/research/chem/MolfileCreator.java +++ b/src/main/java/com/actelion/research/chem/MolfileCreator.java @@ -253,13 +253,13 @@ else if (mol.getAtomESRType(atom) == Molecule.cESRTypeAnd // if query features cannot be expressed exactly stay on the loosely defined side int bondType = mol.getBondQueryFeatures(bond) & Molecule.cBondQFBondTypes; if (bondType != 0) { - if (bondType == Molecule.cBondQFDelocalized) + if (bondType == Molecule.cBondTypeDelocalized) order = 4; // aromatic - else if (bondType == (Molecule.cBondQFSingle | Molecule.cBondQFDouble)) + else if (bondType == (Molecule.cBondTypeSingle | Molecule.cBondTypeDouble)) order = 5; // single or double - else if (bondType == (Molecule.cBondQFSingle | Molecule.cBondQFDelocalized)) + else if (bondType == (Molecule.cBondTypeSingle | Molecule.cBondTypeDelocalized)) order = 6; // single or aromatic - else if (bondType == (Molecule.cBondQFDouble | Molecule.cBondQFDelocalized)) + else if (bondType == (Molecule.cBondTypeDouble | Molecule.cBondTypeDelocalized)) order = 7; // single or double else order = 8; // any diff --git a/src/main/java/com/actelion/research/chem/MolfileParser.java b/src/main/java/com/actelion/research/chem/MolfileParser.java index 433ba6a4..253ddf9f 100644 --- a/src/main/java/com/actelion/research/chem/MolfileParser.java +++ b/src/main/java/com/actelion/research/chem/MolfileParser.java @@ -1075,13 +1075,13 @@ private int buildBond(int atom1,int atom2,int bondType, if(bondType > 4){ switch(bondType){ case 5: - queryFeatures |= Molecule.cBondQFSingle | Molecule.cBondQFDouble; + queryFeatures |= Molecule.cBondTypeSingle | Molecule.cBondTypeDouble; break; case 6: - queryFeatures |= Molecule.cBondQFSingle | Molecule.cBondQFDelocalized; + queryFeatures |= Molecule.cBondTypeSingle | Molecule.cBondTypeDelocalized; break; case 7: - queryFeatures |= Molecule.cBondQFDouble | Molecule.cBondQFDelocalized; + queryFeatures |= Molecule.cBondTypeDouble | Molecule.cBondTypeDelocalized; break; case 8: if (realBondType != Molecule.cBondTypeMetalLigand) diff --git a/src/main/java/com/actelion/research/chem/MolfileV3Creator.java b/src/main/java/com/actelion/research/chem/MolfileV3Creator.java index b8b6b063..f2b14faa 100644 --- a/src/main/java/com/actelion/research/chem/MolfileV3Creator.java +++ b/src/main/java/com/actelion/research/chem/MolfileV3Creator.java @@ -394,16 +394,16 @@ else if (ringFeatures == (Molecule.cAtomQFNotChain | Molecule.cAtomQFNot2RingBon // if query features cannot be expressed exactly stay on the loosely defined side int bondType = mol.getBondQueryFeatures(bond) & Molecule.cBondQFBondTypes; if (bondType != 0) { - if (bondType == Molecule.cBondQFDelocalized) { + if (bondType == Molecule.cBondTypeDelocalized) { order = 4; // aromatic } - else if (bondType == (Molecule.cBondQFSingle | Molecule.cBondQFDouble)) { + else if (bondType == (Molecule.cBondTypeSingle | Molecule.cBondTypeDouble)) { order = 5; // single or double } - else if (bondType == (Molecule.cBondQFSingle | Molecule.cBondQFDelocalized)) { + else if (bondType == (Molecule.cBondTypeSingle | Molecule.cBondTypeDelocalized)) { order = 6; // single or aromatic } - else if (bondType == (Molecule.cBondQFDouble | Molecule.cBondQFDelocalized)) { + else if (bondType == (Molecule.cBondTypeDouble | Molecule.cBondTypeDelocalized)) { order = 7; // single or double } else { diff --git a/src/main/java/com/actelion/research/chem/SSSearcher.java b/src/main/java/com/actelion/research/chem/SSSearcher.java index c7fcc73a..ea926ebf 100644 --- a/src/main/java/com/actelion/research/chem/SSSearcher.java +++ b/src/main/java/com/actelion/research/chem/SSSearcher.java @@ -1300,13 +1300,13 @@ public boolean areBondsSimilar(int moleculeBond, int fragmentBond) { int frgBondType = mFragment.getBondTypeSimple(fragmentBond); int frgBondTypes = mFragment.getBondQueryFeatures(fragmentBond) & Molecule.cBondQFBondTypes; if (molBondType != frgBondType - && !(molBondType == Molecule.cBondTypeSingle && (frgBondTypes & Molecule.cBondQFSingle) != 0) - && !(molBondType == Molecule.cBondTypeDouble && (frgBondTypes & Molecule.cBondQFDouble) != 0) - && !(molBondType == Molecule.cBondTypeTriple && (frgBondTypes & Molecule.cBondQFTriple) != 0) - && !(molBondType == Molecule.cBondTypeQuadruple && (frgBondTypes & Molecule.cBondQFQuadruple) != 0) - && !(molBondType == Molecule.cBondTypeQuintuple && (frgBondTypes & Molecule.cBondQFQuintuple) != 0) - && !(molBondType == Molecule.cBondTypeMetalLigand && (frgBondTypes & Molecule.cBondQFMetalLigand) != 0) - && !(molBondType == Molecule.cBondTypeDelocalized && (frgBondTypes & Molecule.cBondQFDelocalized) != 0)) + && !(molBondType == Molecule.cBondTypeSingle && (frgBondTypes & Molecule.cBondTypeSingle) != 0) + && !(molBondType == Molecule.cBondTypeDouble && (frgBondTypes & Molecule.cBondTypeDouble) != 0) + && !(molBondType == Molecule.cBondTypeTriple && (frgBondTypes & Molecule.cBondTypeTriple) != 0) + && !(molBondType == Molecule.cBondTypeQuadruple && (frgBondTypes & Molecule.cBondTypeQuadruple) != 0) + && !(molBondType == Molecule.cBondTypeQuintuple && (frgBondTypes & Molecule.cBondTypeQuintuple) != 0) + && !(molBondType == Molecule.cBondTypeMetalLigand && (frgBondTypes & Molecule.cBondTypeMetalLigand) != 0) + && !(molBondType == Molecule.cBondTypeDelocalized && (frgBondTypes & Molecule.cBondTypeDelocalized) != 0)) return false; molDefaults &= ~Molecule.cBondQFBondTypes; @@ -1588,13 +1588,13 @@ else if (ringSize == 7) // match fragment's single/double bonds to delocalized molecule bonds also if ((matchMode & cMatchDBondToDelocalized) != 0) { - if ((mFragmentBondFeatures[bond] & Molecule.cBondQFDouble) != 0) - mFragmentBondFeatures[bond] |= Molecule.cBondQFDelocalized; + if ((mFragmentBondFeatures[bond] & Molecule.cBondTypeDouble) != 0) + mFragmentBondFeatures[bond] |= Molecule.cBondTypeDelocalized; } else if ((matchMode & cMatchAromDBondToDelocalized) != 0) { - if ((mFragmentBondFeatures[bond] & Molecule.cBondQFDouble) != 0 + if ((mFragmentBondFeatures[bond] & Molecule.cBondTypeDouble) != 0 && fragment.isAromaticBond(bond)) - mFragmentBondFeatures[bond] |= Molecule.cBondQFDelocalized; + mFragmentBondFeatures[bond] |= Molecule.cBondTypeDelocalized; } } } @@ -1801,25 +1801,25 @@ private int getBondQueryDefaults(StereoMolecule mol, int bond) { if (mol.isDelocalizedBond(bond) || mol.getBondType(bond) == Molecule.cBondTypeDelocalized) - queryDefaults |= Molecule.cBondQFDelocalized; + queryDefaults |= Molecule.cBondTypeDelocalized; else switch (mol.getBondOrder(bond)) { case 0: queryDefaults |= Molecule.cBondTypeMetalLigand; break; case 1: - queryDefaults |= Molecule.cBondQFSingle; + queryDefaults |= Molecule.cBondTypeSingle; break; case 2: - queryDefaults |= Molecule.cBondQFDouble; + queryDefaults |= Molecule.cBondTypeDouble; break; case 3: - queryDefaults |= Molecule.cBondQFTriple; + queryDefaults |= Molecule.cBondTypeTriple; break; case 4: - queryDefaults |= Molecule.cBondQFQuadruple; + queryDefaults |= Molecule.cBondTypeQuadruple; break; case 5: - queryDefaults |= Molecule.cBondQFQuintuple; + queryDefaults |= Molecule.cBondTypeQuintuple; break; } diff --git a/src/main/java/com/actelion/research/chem/SmilesParser.java b/src/main/java/com/actelion/research/chem/SmilesParser.java index e62f1890..b8db111c 100644 --- a/src/main/java/com/actelion/research/chem/SmilesParser.java +++ b/src/main/java/com/actelion/research/chem/SmilesParser.java @@ -490,15 +490,15 @@ else if ((theChar == '-' && smiles[position] == '>') position++; } else if (theChar == '-') - excludedBonds |= Molecule.cBondQFSingle; + excludedBonds |= Molecule.cBondTypeSingle; else if (theChar == '=') - excludedBonds |= Molecule.cBondQFDouble; + excludedBonds |= Molecule.cBondTypeDouble; else if (theChar == '#') - excludedBonds |= Molecule.cBondQFTriple; + excludedBonds |= Molecule.cBondTypeTriple; else if (theChar == '$') - excludedBonds |= Molecule.cBondQFQuadruple; + excludedBonds |= Molecule.cBondTypeQuadruple; else if (theChar == ':') - excludedBonds |= Molecule.cBondQFDelocalized; + excludedBonds |= Molecule.cBondTypeDelocalized; else throw new Exception("SmilesParser: bond symbol '"+theChar+"' not allowed after '!'. Position:"+(position-1)); } @@ -514,7 +514,7 @@ else if (theChar == '$') else if (theChar == ':') bondType = Molecule.cBondTypeDelocalized; else if (theChar == '~') - bondQueryFeatures |= Molecule.cBondQFSingle | Molecule.cBondQFDouble | Molecule.cBondQFTriple | Molecule.cBondQFDelocalized; + bondQueryFeatures |= Molecule.cBondTypeSingle | Molecule.cBondTypeDouble | Molecule.cBondTypeTriple | Molecule.cBondTypeDelocalized; else if (theChar == '/') { if (readStereoFeatures) bondType = Molecule.cBondTypeUp; // encode slash temporarily in bondType @@ -860,12 +860,12 @@ private boolean isBondSymbol(char theChar) { } private int bondSymbolToQueryFeature(char symbol) { - return symbol == '=' ? Molecule.cBondQFDouble - : symbol == '#' ? Molecule.cBondQFTriple - : symbol == '$' ? Molecule.cBondQFQuadruple - : symbol == ':' ? Molecule.cBondQFDelocalized - : symbol == '>' ? Molecule.cBondQFMetalLigand - : symbol == '~' ? Molecule.cBondQFBondTypes : Molecule.cBondQFSingle; + return symbol == '=' ? Molecule.cBondTypeDouble + : symbol == '#' ? Molecule.cBondTypeTriple + : symbol == '$' ? Molecule.cBondTypeQuadruple + : symbol == ':' ? Molecule.cBondTypeDelocalized + : symbol == '>' ? Molecule.cBondTypeMetalLigand + : symbol == '~' ? Molecule.cBondQFBondTypes : Molecule.cBondTypeSingle; } protected void smartsWarning(String feature) { diff --git a/src/main/java/com/actelion/research/chem/TautomerHelper.java b/src/main/java/com/actelion/research/chem/TautomerHelper.java index 695ad29c..2a77294b 100644 --- a/src/main/java/com/actelion/research/chem/TautomerHelper.java +++ b/src/main/java/com/actelion/research/chem/TautomerHelper.java @@ -390,7 +390,7 @@ public StereoMolecule createGenericTautomer() { for (int bond=0; bond 4) { switch (bondType) { case 5: - queryFeatures |= (Molecule.cBondQFSingle | Molecule.cBondQFDouble); + queryFeatures |= (Molecule.cBondTypeSingle | Molecule.cBondTypeDouble); break; case 6: - queryFeatures |= (Molecule.cBondQFSingle | Molecule.cBondQFDelocalized); + queryFeatures |= (Molecule.cBondTypeSingle | Molecule.cBondTypeDelocalized); break; case 7: - queryFeatures |= (Molecule.cBondQFDouble | Molecule.cBondQFDelocalized); + queryFeatures |= (Molecule.cBondTypeDouble | Molecule.cBondTypeDelocalized); break;