openchemlib 9.10.0 → 9.11.1

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.
@@ -1285,6 +1285,17 @@ export declare class Molecule {
1285
1285
  */
1286
1286
  getName(): string;
1287
1287
 
1288
+ /**
1289
+ * This method will return the next custom label that can be used for an atom
1290
+ * If the provided label is already used, it will try to increment it
1291
+ * If no label is provided, it will start from '1'
1292
+ * The incrementing works for numbers and letters (lower and uppercase)
1293
+ * If the label contains both letters and numbers, only the number part is incremented
1294
+ * If the label ends with Z or z, it will return '1' as next label
1295
+ * @param label - optional label to start from
1296
+ */
1297
+ getNextCustomAtomLabel(label?: string): string;
1298
+
1288
1299
  /**
1289
1300
  * The stereo problem flag is set by the stereo recognition (available
1290
1301
  * equal/above helper level cHelperParities) if an atom has over- or
@@ -1288,6 +1288,40 @@ function init(OCL) {
1288
1288
  delete OCL.GenericUIHelper;
1289
1289
  }
1290
1290
 
1291
+ // lib/extend/appendGetNextCustomAtomLabel.js
1292
+ function appendGetNextCustomAtomLabel(Molecule2) {
1293
+ Molecule2.prototype.getNextCustomAtomLabel = function getNextCustomAtomLabel(label) {
1294
+ let nextLabel = label || "1";
1295
+ const existingLabels = /* @__PURE__ */ new Set();
1296
+ for (let i = 0; i < this.getAllAtoms(); i++) {
1297
+ const existingLabel = this.getAtomCustomLabel(i);
1298
+ if (existingLabel) {
1299
+ existingLabels.add(existingLabel);
1300
+ }
1301
+ }
1302
+ let counter = 0;
1303
+ while (existingLabels.has(nextLabel) && counter++ < 100) {
1304
+ nextLabel = getNextLabel(nextLabel);
1305
+ }
1306
+ return nextLabel;
1307
+ };
1308
+ }
1309
+ function getNextLabel(label) {
1310
+ const match = label.match(/(\d+)/);
1311
+ if (match) {
1312
+ const number = Number.parseInt(match[1], 10);
1313
+ return label.replace(/(\d+)/, (number + 1).toString());
1314
+ }
1315
+ const match2 = label.match(/([a-yA-Y])([^a-zA-Z]*)$/);
1316
+ if (match2) {
1317
+ const char = match2[1];
1318
+ const nextChar = String.fromCodePoint(char.codePointAt(0) + 1);
1319
+ if (nextChar === "Z" || nextChar === "z") return "1";
1320
+ return label.replace(/([a-yA-Y])([^a-zA-Z]*)$/, `${nextChar}$2`);
1321
+ }
1322
+ return "1";
1323
+ }
1324
+
1291
1325
  // lib/extend/utils/changeMolfileCustomLabelPosition.js
1292
1326
  function changeMolfileCustomLabelPosition(molecule, customLabelPosition) {
1293
1327
  switch (customLabelPosition) {
@@ -1388,7 +1422,7 @@ function extendToMolfile(Molecule2) {
1388
1422
  removeCustomAtomLabels = false
1389
1423
  } = options;
1390
1424
  changeMolfileCustomLabelPosition(molecule, customLabelPosition);
1391
- const molfile = _toMolfile.call(this);
1425
+ const molfile = _toMolfile.call(molecule);
1392
1426
  if (!includeCustomAtomLabelsAsALines && !includeCustomAtomLabelsAsVLines && !removeCustomAtomLabels) {
1393
1427
  return molfile;
1394
1428
  }
@@ -1450,6 +1484,7 @@ function extendOCL(OCL) {
1450
1484
  };
1451
1485
  extendFromMolfile(Molecule2);
1452
1486
  extendToMolfile(Molecule2);
1487
+ appendGetNextCustomAtomLabel(Molecule2);
1453
1488
  function parseMoleculeFromText(text) {
1454
1489
  if (!text) {
1455
1490
  return null;
@@ -71157,7 +71192,7 @@ function getExports($wnd) {
71157
71192
  $sendStats("moduleStartup", "end");
71158
71193
  $gwt && $gwt.permProps && __gwtModuleFunction.__moduleStartupDone($gwt.permProps);
71159
71194
  const toReturn = $wnd["OCL"];
71160
- toReturn.version = "9.10.0";
71195
+ toReturn.version = "9.11.1";
71161
71196
  return toReturn;
71162
71197
  }
71163
71198
  var isBrowserWindow = typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -71301,8 +71336,8 @@ export {
71301
71336
  };
71302
71337
  /**
71303
71338
  * openchemlib - Manipulate molecules
71304
- * @version v9.10.0
71305
- * @date 2025-10-08T14:06:44.519Z
71339
+ * @version v9.11.1
71340
+ * @date 2025-10-14T12:21:23.561Z
71306
71341
  * @link https://github.com/cheminfo/openchemlib-js
71307
71342
  * @license BSD-3-Clause
71308
71343
  */