|
| 1 | +# API Reference (High-Level) |
| 2 | + |
| 3 | +This document summarizes the primary public API surface of `CDKSwiftNativePort`. |
| 4 | + |
| 5 | +## 1) Core Model |
| 6 | + |
| 7 | +Defined in `Sources/CDKSwiftNativePort/Molecule.swift`. |
| 8 | + |
| 9 | +- `Molecule` |
| 10 | +- `Atom` |
| 11 | +- `Bond` |
| 12 | +- `BondOrder` |
| 13 | +- `BondStereo` |
| 14 | +- `AtomChirality` |
| 15 | +- `ChemFormat` |
| 16 | +- `ChemError` |
| 17 | + |
| 18 | +Useful methods on `Molecule` include: |
| 19 | +- graph neighborhood/bond lookup helpers |
| 20 | +- ring/cycle helpers |
| 21 | +- implicit hydrogen helpers |
| 22 | +- geometry helpers (`boundingBox`, normalization-friendly traversal utilities) |
| 23 | + |
| 24 | +## 2) Layout and Depiction |
| 25 | + |
| 26 | +- `Depiction2DGenerator.generate(for:)` |
| 27 | + - applies CDK-style 2D coordinate generation. |
| 28 | +- `CDKDepictionGenerator.toSVG(...)` |
| 29 | + - produces SVG depictions. |
| 30 | +- `CDKMetalDepictionSceneBuilder.build(...)` |
| 31 | + - builds a render-agnostic scene representation suitable for Metal-style renderers. |
| 32 | +- `CDKStandardGenerator.draw(...)` |
| 33 | + - SwiftUI `GraphicsContext` drawing path. |
| 34 | + |
| 35 | +Style controls: |
| 36 | +- `RenderStyle` |
| 37 | +- `CDKAtomColoringMode` |
| 38 | +- `CDKAromaticDisplayMode` |
| 39 | + |
| 40 | +## 3) Import APIs |
| 41 | + |
| 42 | +Generic dispatch: |
| 43 | +- `CDKFileImporter.readMolecules(from:)` |
| 44 | +- `CDKFileImporter.readMolecules(text:fileExtension:)` |
| 45 | +- `CDKFileImporter.preferredInputFormat(...)` |
| 46 | + |
| 47 | +Format-specific readers: |
| 48 | +- MDL: `CDKMDLReader`, `CDKMDLV2000Reader`, `CDKMDLV3000Reader`, `CDKIteratingSDFReader` |
| 49 | +- SMILES: `CDKSMILESReader` |
| 50 | +- InChI: `CDKInChIReader` |
| 51 | +- MOL2: `CDKMol2Reader` |
| 52 | +- PDB: `CDKPDBReader` |
| 53 | +- XYZ: `CDKXYZReader` |
| 54 | +- CML: `CDKCMLReader` |
| 55 | +- RXN/RDF: `CDKRXNReader`, `CDKRDFReader` |
| 56 | + |
| 57 | +## 4) Export APIs |
| 58 | + |
| 59 | +Generic dispatch: |
| 60 | +- `CDKFileExporter.write(...)` |
| 61 | +- `CDKFileExporter.write(..., to:as:options:)` |
| 62 | +- `CDKFileExportFormat` |
| 63 | +- `CDKFileExportOptions` |
| 64 | + |
| 65 | +Format-specific writers: |
| 66 | +- MDL/SDF: `CDKMDLV2000Writer`, `CDKSDFWriter` |
| 67 | +- SMILES: `CDKSMILESWriter` |
| 68 | +- InChI: `CDKInChIWriter` |
| 69 | +- MOL2: `CDKMol2Writer` |
| 70 | +- PDB: `CDKPDBWriter` |
| 71 | +- XYZ: `CDKXYZWriter` |
| 72 | +- CML: `CDKCMLWriter` |
| 73 | +- RXN/RDF: `CDKRXNWriter`, `CDKRDFWriter` |
| 74 | + |
| 75 | +## 5) SMILES APIs |
| 76 | + |
| 77 | +- Parsing: |
| 78 | + - `CDKSmilesParser` |
| 79 | + - `CDKSmilesParserFactory` |
| 80 | + - `CDKCxSmilesParser` |
| 81 | + - `CDKSmilesReactionParser` |
| 82 | +- Generation: |
| 83 | + - `CDKSmilesGenerator` |
| 84 | + - `CDKSmilesGeneratorFactory` |
| 85 | + - `CDKSmiFlavor` |
| 86 | + |
| 87 | +## 6) InChI APIs |
| 88 | + |
| 89 | +- `CDKInChIToStructure` |
| 90 | +- `CDKInChIGenerator` |
| 91 | +- `CDKInChIGeneratorFactory` |
| 92 | +- `CDKInChIStatus` |
| 93 | + |
| 94 | +Facade: |
| 95 | +- `CDKMoleculeIdentifierService.compute(for:)` |
| 96 | + - returns `CDKMoleculeIdentifiers` (SMILES, ISO SMILES, InChI, InChIKey). |
| 97 | + |
| 98 | +## 7) Descriptors and Property Services |
| 99 | + |
| 100 | +Facade: |
| 101 | +- `CDKMoleculePropertyService.compute(for:)` |
| 102 | + - returns `CDKMolecularProperties`. |
| 103 | + |
| 104 | +Rule-of-Five helpers: |
| 105 | +- `CDKRuleOfFiveDescriptor` |
| 106 | +- `CDKRuleOfFiveResult` |
| 107 | + |
| 108 | +Descriptors: |
| 109 | +- `CDKMolecularFormulaDescriptor` |
| 110 | +- `CDKMolecularWeightDescriptor` |
| 111 | +- `CDKExactMassDescriptor` |
| 112 | +- `CDKHeavyAtomCountDescriptor` |
| 113 | +- `CDKHBondDonorCountDescriptor` |
| 114 | +- `CDKHBondAcceptorCountDescriptor` |
| 115 | +- `CDKRotatableBondsCountDescriptor` |
| 116 | +- `CDKRingCountDescriptor` |
| 117 | +- `CDKXLogPDescriptor` |
| 118 | +- `CDKMannholdLogPDescriptor` |
| 119 | + |
| 120 | +## 8) Error Handling |
| 121 | + |
| 122 | +Most parsing and writing APIs throw `ChemError`: |
| 123 | +- `.emptyInput` |
| 124 | +- `.unsupported(String)` |
| 125 | +- `.parseFailed(String)` |
| 126 | + |
| 127 | +Call sites should use `do / try / catch` and surface `LocalizedError.errorDescription` where appropriate. |
| 128 | + |
| 129 | +## 9) Stability Notes |
| 130 | + |
| 131 | +- Public symbols listed above are intended as the stable integration surface for application use. |
| 132 | +- Internals under the `CDK/...` tree may evolve as parity with upstream CDK improves. |
| 133 | +- For release history and compatibility notes, see `CHANGELOG.md`. |
0 commit comments