CIP labels are always rendered from cdxml
Summary CIP labels are always rendered from cdxml, even when they are set not to display
Steps to Reproduce
- indigo-depict.exe cip_labels.cdx cip_labels.svg
Actual behavior
All CIP labels are displayed, when only the labels on the first molecule have been explicitly set to be displayed.
Expected behavior
The CIP labels on the first molecule should be displayed, while the labels of the second molecule should be hidden.
Environment details:
- windows 11
- indigo 098fd1d
Attachments cip_labels.cdx.txt
Additional context We need to parse the ShowAtomStereo="yes" from the cdxml file. The default for this option should be "no".
1. Problem Description:
The CIP (Cahn-Ingold-Prelog) labels are always rendered from a CDXML file, even when the CDXML explicitly specifies that these labels should not be displayed. This happens because the ShowAtomStereo="no" attribute in the CDXML file is ignored during rendering. As a result, all CIP labels (e.g., (R), (S)) are displayed, regardless of whether they are set to be shown or hidden.
Hypothesis:
The rendering logic does not correctly parse the ShowAtomStereo attribute within the CDXML file. Instead, it defaults to displaying all CIP labels unless specifically overridden. This likely occurs due to the absence of logic to process and enforce ShowAtomStereo="no" during parsing.
2. Steps to Reproduce:
-
Use the
indigo-depict.execommand-line tool to generate an SVG file from a CDXML file:indigo-depict.exe cip_labels.cdx cip_labels.svg -
Open the generated
cip_labels.svgfile in any SVG viewer or browser. -
Observe the CIP labels rendered on both molecules.
- The first molecule contains CIP labels explicitly set to display (
ShowAtomStereo="yes"). - The second molecule has CIP labels explicitly hidden (
ShowAtomStereo="no").
- The first molecule contains CIP labels explicitly set to display (
3. Expected Behavior:
- The CIP labels on the first molecule should render correctly, as they are explicitly set to be displayed via the attribute
ShowAtomStereo="yes". - The CIP labels on the second molecule should not render because they are explicitly set to be hidden via the attribute
ShowAtomStereo="no".
4. Actual Behavior:
- CIP labels are rendered for both molecules, ignoring the
ShowAtomStereo="no"attribute present in the CDXML file. - The labels
(R)and(S)appear on the second molecule even though they should be hidden.
5. Analysis of the Problem:
-
Affected Modules:
-
CDXML Parser: The module responsible for parsing the CDXML file, specifically the
ShowAtomStereoattribute. - SVG Renderer: The rendering logic that determines whether to display CIP labels based on parsed attributes.
-
CDXML Parser: The module responsible for parsing the CDXML file, specifically the
-
Potential Root Cause:
- The parser does not process or respect the
ShowAtomStereoattribute when reading CDXML files. - The rendering layer assumes a default behavior of
ShowAtomStereo="yes", failing to check for explicit instructions in the input file.
- The parser does not process or respect the
6. Suggested Solutions:
High-Level Solution:
-
Modify the CDXML parser: Ensure that it correctly parses the
ShowAtomStereoattribute. -
Update the rendering logic: The renderer should enforce the parsed visibility rules (
ShowAtomStereo="yes"or"no") when generating the SVG output.
Technical Solution:
-
Enhance the CDXML Parser:
- Update the parser to correctly interpret the
ShowAtomStereoattribute. - Ensure that the default behavior is set to
ShowAtomStereo="no", unless explicitly overridden in the CDXML file.
Example Code Logic (Pseudocode):
def process_atom_stereo(atom): show_stereo = atom.get('ShowAtomStereo', 'no') # Default to "no" if show_stereo.lower() == 'yes': render_cip_label(atom) else: skip_cip_label(atom) - Update the parser to correctly interpret the
-
Modify the Rendering Logic:
- Add a conditional check during rendering to skip labels with
ShowAtomStereo="no".
Example Code:
function renderCIPLabel(atom, showAtomStereo) { if (showAtomStereo === 'yes') { drawLabel(atom.position, atom.stereoLabel); } } - Add a conditional check during rendering to skip labels with
-
Testing:
- Test the updated parser and rendering logic with multiple CDXML files, ensuring that:
- CIP labels appear only when
ShowAtomStereo="yes". - CIP labels are hidden when
ShowAtomStereo="no".
- CIP labels appear only when
- Test the updated parser and rendering logic with multiple CDXML files, ensuring that: