# Help & User Guide (DCODE & NMR Shift Prediction)

Welcome to **DCODE & NMR Shift Prediction**. This web application allows you to draw chemical structures, compute hierarchical D-Code descriptors, and predict NMR chemical shifts based on a spectral reference database.

---

## 🚀 Quick Start Guide

1. **Draw a structure:**
   - Use the integrated **Ketcher 2D editor** on the left side.
   - Draw your molecular structure or import an existing structure via the Ketcher menu (e.g., as MOL/SDF or SMILES).

2. **Select nucleus & settings:**
   - Choose the desired NMR nucleus in the top toolbar (e.g., `13C`, `31P`, `19F`, `29Si`, `11B`).
   - **Min Hashes (#):** Defines the minimum hierarchy depth of the D-Codes used for database lookup (default: `3`).
   - **Symmetry Average:** When enabled, predicted shifts of chemically/topologically equivalent atoms (automorphism groups) are averaged.

3. **Run prediction:**
   - Click the **“⚡ Predict Chemical Shifts”** button.
   - The 3D conformation and explicit hydrogen atoms are generated automatically via the external **NCI/CADD Chemical Identifier Resolver (CACTUS)** (with an automatic local browser fallback if unavailable).
   - The 3D viewer displays the optimized spatial structure.

4. **Inspect & export results:**
   - **Right panel:** Table showing atom indices, symmetry ranks, predicted chemical shifts (in ppm), hit counts, spans, and standard deviations.
   - **“D-Code Details” tab:** Detailed view of the matched hierarchical D-Codes for each atom.
   - **Export button (💾 Export):** Exports all prediction results in structured JSON format.

---

## 🌐 3D Geometry Optimization (External Service)

To calculate accurate spatial interatomic distances (D-Codes), the application requires a realistic 3D geometry including explicit hydrogen atoms:

1. A **SMILES string** is generated from your 2D structure drawn in Ketcher and sent to the backend (`api_calcshift.php`).
2. The backend requests a 3D-optimized structure file (SDF) from the external **NCI/CADD Chemical Identifier Resolver (CACTUS)** ([https://cactus.nci.nih.gov](https://cactus.nci.nih.gov), National Cancer Institute / NIH, USA).
3. The returned 3D coordinates are mapped back onto the exact Ketcher atom indices via graph isomorphism, used for D-Code computation, and rendered in the 3D viewer.
4. **Automatic fallback:** If the external CACTUS service is temporarily unreachable, times out, or cannot resolve a structure, the application automatically falls back to the geometry generated locally in your browser (`dcode.js`).

> **Privacy note:** Please note that for external 3D geometry optimization, the SMILES string of the drawn structure is transmitted server-side to `cactus.nci.nih.gov` (USA). Do not enter strictly confidential or unpublished structures unless this is acceptable for your use case.

---

## 📊 Prediction Accuracy & ¹³C NMR Benchmark

To provide a transparent assessment of prediction accuracy, DCODE Online was systematically benchmarked against three experimental reference datasets (**DELTA50**, **NP-MRD**, and a representative **NMRShiftDB2 sample**) with strict database-overlap and data-leakage controls (*Leave-Molecule-Out / Leave-Connectivity-Out* and genuinely unseen natural products):

- **DELTA50 (Live Production, 221 ¹³C atoms in CDCl₃):** MAE **0.80 ppm**, Median AE **0.26 ppm**, R² = **0.9988** (Leak-Free LMO: MAE **2.71 ppm**, RMSE **4.83 ppm**)
- **NMRShiftDB2 LCO (1,000 unseen molecules / 9,052 ¹³C atoms):** MAE **2.62 ppm**, Median AE **1.12 ppm**, Bias **−0.04 ppm**, Coverage **99.6%** (for ≥ 15 `#` neighbors: **1.34 ppm MAE**, **0.60 ppm Median AE**)
- **NP-MRD (unseen experimental natural products):** optMAE **3.38 ppm**, Median AE **2.30 ppm** (2023–24 organic natural products: **2.47 ppm**; for ≥ 15 `#` neighbors: **2.03 ppm MAE**)

👉 **[Full ¹³C Benchmark & Validation Report (English)](viewer.html?doc=BENCHMARK_13C_EN.md&lang=en)**  
👉 **[Vollständiger ¹³C-Benchmark & Validierungsbericht (Deutsch)](viewer.html?doc=BENCHMARK_13C_DE.md&lang=de)**

---

## 🧭 3D Viewer Controls

- **Hold Left Mouse Button + Drag:** Rotate the molecule in 3D space
- **Mouse Wheel / Scroll:** Zoom in and out
- **Shift + Hold Left Mouse Button + Drag:** Pan / move the molecule

---

## ❓ Frequently Asked Questions (FAQ)

### What does a value of “–” or “No Hit” mean?
If no hit is displayed for a specific atom, the reference database does not contain a matching D-Code descriptor with sufficient hierarchy depth for that chemical environment.

### Which nuclei are supported?
The prediction engine currently supports:
- **¹³C** (Carbon)
- **³¹P** (Phosphorus)
- **¹⁹F** (Fluorine)
- **²⁹Si** (Silicon)
- **¹¹B** (Boron)

### Can I import my own structures?
Yes. Through the Ketcher editor's file menu, you can open and edit common chemical formats such as `.mol`, `.rxn`, `.smi` (SMILES), or InChI.
