openchemlib 9.12.1 → 9.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2995,6 +2995,7 @@ export interface DepictorOptions {
2995
2995
  suppressChiralText?: boolean;
2996
2996
  suppressCIPParity?: boolean;
2997
2997
  suppressESR?: boolean;
2998
+ noCarbonLabelWithCustomLabel?: boolean;
2998
2999
 
2999
3000
  showSymmetryAny?: boolean;
3000
3001
  showSymmetrySimple?: boolean;
@@ -1397,6 +1397,13 @@ function extendFromMolfile(Molecule2) {
1397
1397
  }
1398
1398
  }
1399
1399
  }
1400
+ if (line.startsWith("M ZZC")) {
1401
+ const atom = Number(line.slice(7, 10).trim());
1402
+ const label = line.slice(10).trim();
1403
+ if (atom && label) {
1404
+ molecule.setAtomCustomLabel(atom - 1, label);
1405
+ }
1406
+ }
1400
1407
  }
1401
1408
  changeMolfileCustomLabelPosition(molecule, customLabelPosition);
1402
1409
  return molecule;
@@ -6797,7 +6804,7 @@ function getExports($wnd) {
6797
6804
  this.setColorCode(this.mStandardForegroundColor);
6798
6805
  };
6799
6806
  _.mpDrawAtom = function mpDrawAtom(atom, esrGroupMemberCount) {
6800
- var angle, atmStart, atomStr, bestSide, bnd, charge, chax, chay, cipStr, counterHindrance, counterSide, eNegNeighbours, esrInfo, esrStr, hHeight, hNoStr, hNoWidth, hindrance, hydrogenWidth, hydrogens, hydrogensToAdd, i, i0, isoStr, j, labelWidth, largeIsoString, mapStr, minHindrance, neighbours, piElectrons, propStr, queryFeatures, ringBonds, theAngle, theColor, unpairedElectrons, valStr, x_0, xdiff, y_0, ydiff;
6807
+ var angle, atmStart, atomStr, bestSide, bnd, charge, chax, chay, cipStr, counterHindrance, counterSide, eNegNeighbours, esrInfo, esrStr, hHeight, hNoStr, hNoWidth, hindrance, hydrogenWidth, hydrogens, hydrogensToAdd, i, i0, isSmallCustomLabel, isSmallCustomLabelOnly, isoStr, j, labelWidth, mapStr, minHindrance, neighbours, piElectrons, propStr, queryFeatures, ringBonds, theAngle, theColor, unpairedElectrons, valStr, x_0, xdiff, y_0, ydiff;
6801
6808
  if (!this.mIsValidatingView)
6802
6809
  this.onDrawAtom(atom, this.mMol.getAtomLabel_0(atom), this.getAtomX_0(atom), this.getAtomY_0(atom));
6803
6810
  propStr = null;
@@ -7016,12 +7023,14 @@ function getExports($wnd) {
7016
7023
  hydrogensToAdd = this.mMol.getImplicitHydrogens_1(atom);
7017
7024
  }
7018
7025
  }
7019
- largeIsoString = false;
7026
+ isSmallCustomLabelOnly = false;
7027
+ isSmallCustomLabel = false;
7020
7028
  atomStr = this.mMol.getAtomCustomLabel_0(atom);
7021
7029
  if (jsNotEquals(atomStr, null) && jl.startsWith_Ljava_lang_String__Z__devirtual$(atomStr, "]")) {
7030
+ isSmallCustomLabelOnly = jsEquals(isoStr, null);
7031
+ isSmallCustomLabel = true;
7022
7032
  isoStr = this.append(jl.substring_I_Ljava_lang_String___devirtual$(atomStr, 1), isoStr);
7023
7033
  atomStr = null;
7024
- largeIsoString = true;
7025
7034
  }
7026
7035
  if (jsNotEquals(atomStr, null)) {
7027
7036
  hydrogensToAdd = 0;
@@ -7036,7 +7045,7 @@ function getExports($wnd) {
7036
7045
  atomStr = "?";
7037
7046
  if (neq(and_0(this.mMol.getAtomQueryFeatures(atom), 2048), 0))
7038
7047
  hydrogensToAdd = -1;
7039
- } else if (this.mMol.getAtomicNo_0(atom) != 6 || jsNotEquals(propStr, null) || jsNotEquals(isoStr, null) || hydrogensToAdd > 0 || !this.mAtomIsConnected[atom])
7048
+ } else if (this.mMol.getAtomicNo_0(atom) != 6 || jsNotEquals(propStr, null) || jsNotEquals(isoStr, null) && (!isSmallCustomLabelOnly || (this.mDisplayMode & 256) == 0) || hydrogensToAdd > 0 || !this.mAtomIsConnected[atom])
7040
7049
  atomStr = this.mMol.getAtomLabel_0(atom);
7041
7050
  labelWidth = 0;
7042
7051
  if (!this.mMol.isSelectedAtom_0(atom) & this.mMol.isExcludeGroupAtom(atom))
@@ -7057,7 +7066,7 @@ function getExports($wnd) {
7057
7066
  if ((this.mDisplayMode & 2) != 0)
7058
7067
  isoStr = jl.valueOf_18(atom);
7059
7068
  if (jsNotEquals(isoStr, null)) {
7060
- if (largeIsoString)
7069
+ if (isSmallCustomLabel)
7061
7070
  this.mpSetReducedLabelSize();
7062
7071
  else
7063
7072
  this.mpSetSmallLabelSize();
@@ -8059,6 +8068,7 @@ function getExports($wnd) {
8059
8068
  carc2.cDModeBondNo = 4;
8060
8069
  carc2.cDModeDrawBondsInGray = 16384;
8061
8070
  carc2.cDModeHiliteAllQueryFeatures = 8;
8071
+ carc2.cDModeNoCarbonLabelWithCustomLabel = 256;
8062
8072
  carc2.cDModeNoColorOnESRAndCIP = 4096;
8063
8073
  carc2.cDModeNoImplicitAtomLabelColors = 1024;
8064
8074
  carc2.cDModeNoImplicitHydrogen = 8192;
@@ -27683,7 +27693,7 @@ function getExports($wnd) {
27683
27693
  this.parse_8(mol, smiles, position, endIndex, true, true);
27684
27694
  };
27685
27695
  _.parse_8 = function parse_9(mol, smiles, position, endIndex, createCoordinates, readStereoFeatures) {
27686
- var a1, a2, allowSmarts, atom, atom0, atomMass, atomParser, baseAtom, bond, bondQueryFeatures, bondType, bondTypePosition, bracketLevel, compatibleValenceFound, ep, excludedBonds, explicitHydrogen, fromAtom, handleHydrogenAtomMap, hasBondType, hasLeadingBracket, hydrogenCount, i, i0, inventor, isDoubleDigit, newSize, number, oldSize, parity, parity$iterator, parityMap, rca, rca$array, rca$index, rca$max, ringClosureAtom, ringClosureBondQueryFeatures, ringClosureBondType, ringClosurePosition, squareBracketOpen, theChar, usedValence, valence, valence$array, valence$index, valence$max, valences;
27696
+ var a1, a2, allowSmarts, atom, atom0, atomMass, atomParser, baseAtom, bond, bondQueryFeatures, bondType, bondTypePosition, bracketLevel, compatibleValenceFound, ep, excludedBonds, explicitHydrogen, fromAtom, handleHydrogenAtomMap, hasBondType, hasLeadingBracket, hydrogenCount, i, i0, i1, i2, inventor, isDoubleDigit, newSize, number, oldSize, parity, parity$iterator, parityMap, ringClosureAtom, ringClosureBondQueryFeatures, ringClosureBondType, ringClosurePosition, squareBracketOpen, theChar, usedValence, valence, valence$array, valence$index, valence$max, valences;
27687
27697
  this.smiles = smiles;
27688
27698
  this.mMol = mol;
27689
27699
  this.mMol.clear_0();
@@ -27892,8 +27902,8 @@ function getExports($wnd) {
27892
27902
  ringClosurePosition = ju.copyOf_9(ringClosurePosition, newSize);
27893
27903
  ringClosureBondType = ju.copyOf_9(ringClosureBondType, newSize);
27894
27904
  ringClosureBondQueryFeatures = ju.copyOf_9(ringClosureBondQueryFeatures, newSize);
27895
- for (i = oldSize; i < newSize; i++)
27896
- ringClosureAtom[i] = -1;
27905
+ for (i1 = oldSize; i1 < newSize; i1++)
27906
+ ringClosureAtom[i1] = -1;
27897
27907
  }
27898
27908
  if (ringClosureAtom[number] == -1) {
27899
27909
  ringClosureAtom[number] = baseAtom[bracketLevel];
@@ -27973,12 +27983,10 @@ function getExports($wnd) {
27973
27983
  throw toJs(new jl.Exception_1("SmilesParser: unexpected character outside brackets: '" + charToString(theChar) + "' position:" + (position - 1)));
27974
27984
  }
27975
27985
  if (bondType != 1)
27976
- throw toJs(new jl.Exception_1("SmilesParser: dangling open bond"));
27977
- for (rca$array = ringClosureAtom, rca$index = 0, rca$max = rca$array.length; rca$index < rca$max; ++rca$index) {
27978
- rca = rca$array[rca$index];
27979
- if (rca != -1)
27980
- throw toJs(new jl.Exception_1("SmilesParser: dangling ring closure."));
27981
- }
27986
+ throw toJs(new jl.Exception_1("SmilesParser: dangling open bond; position:" + position));
27987
+ for (i2 = 0; i2 < ringClosureAtom.length; i2++)
27988
+ if (ringClosureAtom[i2] != -1)
27989
+ throw toJs(new jl.Exception_1("SmilesParser: dangling ring closure: " + i2 + "; position:" + position));
27982
27990
  handleHydrogenAtomMap = this.mMol.getHandleHydrogenMap_0();
27983
27991
  this.mMol.setHydrogenProtection_0(true);
27984
27992
  this.mMol.ensureHelperArrays_0(1);
@@ -28083,7 +28091,7 @@ function getExports($wnd) {
28083
28091
  return jsEquals(smiles, null) ? null : this.parseReaction_1(jl.getBytes_Ljava_nio_charset_Charset___B__devirtual$(smiles, (jnc.$clinit_StandardCharsets(), jnc.UTF_8)));
28084
28092
  };
28085
28093
  _.parseReaction_1 = function parseReaction_0(smiles) {
28086
- var closingGroupBracketIndex, end, i, index_0, index1, index2, level, mol, molend, part, rxn;
28094
+ var i, index_0, index1, index2, level, mol, molEnd, molStart, part, rxn;
28087
28095
  index1 = caru.indexOf_2(smiles, narrow_byte(62));
28088
28096
  while (index1 > 0 && smiles[index1 - 1] == narrow_byte(45))
28089
28097
  index1 = caru.indexOf_3(smiles, narrow_byte(62), index1 + 1);
@@ -28097,37 +28105,36 @@ function getExports($wnd) {
28097
28105
  rxn = new carcr.Reaction();
28098
28106
  part = 0;
28099
28107
  index_0 = 0;
28100
- closingGroupBracketIndex = -1;
28101
28108
  while (index_0 < smiles.length) {
28102
28109
  while (index_0 < smiles.length && smiles[index_0] == 46)
28103
28110
  index_0++;
28104
- if (smiles[index_0] == 40) {
28105
- if (closingGroupBracketIndex != -1)
28106
- throw toJs(new jl.Exception_1("Second open group bracket found before closing first one."));
28107
- index_0++;
28108
- level = 0;
28109
- for (i = index_0; i < smiles.length; i++) {
28110
- if (smiles[i] == 40) {
28111
- level++;
28112
- } else if (smiles[i] == 41) {
28113
- if (level-- == 0) {
28114
- closingGroupBracketIndex = i;
28115
- break;
28116
- }
28111
+ if (index_0 == smiles.length)
28112
+ break;
28113
+ molStart = index_0;
28114
+ molEnd = -1;
28115
+ level = 0;
28116
+ for (i = index_0; i < smiles.length; i++) {
28117
+ if (smiles[i] == 40) {
28118
+ level++;
28119
+ continue;
28120
+ }
28121
+ if (smiles[i] == 41) {
28122
+ if (--level < 0)
28123
+ throw toJs(new jl.Exception_1("Found closing bracket without matching opening one."));
28124
+ continue;
28125
+ }
28126
+ if (level == 0) {
28127
+ if (smiles[i] == 46 && (this.mSingleDotSeparator || i + 1 < smiles.length && smiles[i + 1] == 46) || smiles[i] == 62 && (i == 0 || smiles[i - 1] != 45)) {
28128
+ molEnd = i;
28129
+ break;
28117
28130
  }
28118
28131
  }
28119
28132
  }
28120
- end = index_0;
28121
- while (end < smiles.length && smiles[end] != 62 && !(smiles[end] == 46 && (this.mSingleDotSeparator && closingGroupBracketIndex == -1 || closingGroupBracketIndex == end - 1 || end + 1 == smiles.length || smiles[end + 1] == 46)))
28122
- end++;
28123
- molend = end;
28124
- if (closingGroupBracketIndex == end - 1) {
28125
- molend--;
28126
- closingGroupBracketIndex = -1;
28127
- }
28128
- if (index_0 != molend) {
28133
+ if (molEnd == -1)
28134
+ molEnd = smiles.length;
28135
+ if (molStart < molEnd) {
28129
28136
  mol = new carc2.StereoMolecule();
28130
- this.parse_7(mol, smiles, index_0, molend);
28137
+ this.parse_7(mol, smiles, molStart, molEnd);
28131
28138
  if (this.mSmartsMode == 1 && this.mSmartsFeatureFound)
28132
28139
  return new carc2.SmilesParser_0(this.mMode | 2).parseReaction_1(smiles);
28133
28140
  if (part == 0)
@@ -28137,7 +28144,7 @@ function getExports($wnd) {
28137
28144
  else
28138
28145
  rxn.addProduct_0(mol);
28139
28146
  }
28140
- index_0 = end;
28147
+ index_0 = molEnd;
28141
28148
  while (index_0 < smiles.length && smiles[index_0] == 62) {
28142
28149
  index_0++;
28143
28150
  part++;
@@ -30294,6 +30301,7 @@ function getExports($wnd) {
30294
30301
  var atom;
30295
30302
  if (isNull(mol))
30296
30303
  mol = this.mMol.getCompactCopy_0();
30304
+ mol.invalidateHelperArrays_0(248);
30297
30305
  for (atom = 0; atom < mol.getAllAtoms_0(); atom++)
30298
30306
  mol.getAtomCoordinates_0(atom).set_1(this.mCoordinates[atom]);
30299
30307
  if (jsNotEquals(this.mName, null))
@@ -39721,7 +39729,7 @@ function getExports($wnd) {
39721
39729
  mapNo0 = reactant.getAtomMapNo_0(j);
39722
39730
  if (mapNo0 != 0) {
39723
39731
  if (mapNoInReactant[mapNo0])
39724
- throw toJs(new jl.Exception_1("Duplicate mapping no in reactants"));
39732
+ throw toJs(new jl.Exception_1("Duplicate mapping no in reactants: " + mapNo0));
39725
39733
  mapNoInReactant[mapNo0] = true;
39726
39734
  }
39727
39735
  }
@@ -39733,7 +39741,7 @@ function getExports($wnd) {
39733
39741
  mapNo0 = product.getAtomMapNo_0(j);
39734
39742
  if (mapNo0 != 0) {
39735
39743
  if (mapNoInProduct[mapNo0])
39736
- throw toJs(new jl.Exception_1("Duplicate mapping no in products"));
39744
+ throw toJs(new jl.Exception_1("Duplicate mapping no in products: " + mapNo0));
39737
39745
  mapNoInProduct[mapNo0] = true;
39738
39746
  }
39739
39747
  }
@@ -51328,6 +51336,8 @@ function getExports($wnd) {
51328
51336
  displayMode |= 64;
51329
51337
  if (options.suppressESR)
51330
51338
  displayMode |= 128;
51339
+ if (options.noCarbonLabelWithCustomLabel)
51340
+ displayMode |= 256;
51331
51341
  if (options.showSymmetryAny)
51332
51342
  displayMode |= 768;
51333
51343
  if (options.showSymmetrySimple)
@@ -71252,7 +71262,7 @@ function getExports($wnd) {
71252
71262
  $sendStats("moduleStartup", "end");
71253
71263
  $gwt && $gwt.permProps && __gwtModuleFunction.__moduleStartupDone($gwt.permProps);
71254
71264
  const toReturn = $wnd["OCL"];
71255
- toReturn.version = "9.12.1";
71265
+ toReturn.version = "9.14.0";
71256
71266
  return toReturn;
71257
71267
  }
71258
71268
  var isBrowserWindow = typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -71396,8 +71406,8 @@ export {
71396
71406
  };
71397
71407
  /**
71398
71408
  * openchemlib - Manipulate molecules
71399
- * @version v9.12.1
71400
- * @date 2025-10-22T07:23:31.337Z
71409
+ * @version v9.14.0
71410
+ * @date 2025-10-29T09:34:22.062Z
71401
71411
  * @link https://github.com/cheminfo/openchemlib-js
71402
71412
  * @license BSD-3-Clause
71403
71413
  */