Indigo icon indicating copy to clipboard operation
Indigo copied to clipboard

CIP labels are always rendered from cdxml

Open jblack-mestre opened this issue 11 months ago • 1 comments

Summary CIP labels are always rendered from cdxml, even when they are set not to display

Steps to Reproduce

  1. 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. Image

Expected behavior The CIP labels on the first molecule should be displayed, while the labels of the second molecule should be hidden. Image

Environment details:

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".

jblack-mestre avatar May 12 '25 09:05 jblack-mestre

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:

  1. Use the indigo-depict.exe command-line tool to generate an SVG file from a CDXML file:

    indigo-depict.exe cip_labels.cdx cip_labels.svg
    
  2. Open the generated cip_labels.svg file in any SVG viewer or browser.

  3. 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").

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:

  1. Affected Modules:

    • CDXML Parser: The module responsible for parsing the CDXML file, specifically the ShowAtomStereo attribute.
    • SVG Renderer: The rendering logic that determines whether to display CIP labels based on parsed attributes.
  2. Potential Root Cause:

    • The parser does not process or respect the ShowAtomStereo attribute when reading CDXML files.
    • The rendering layer assumes a default behavior of ShowAtomStereo="yes", failing to check for explicit instructions in the input file.

6. Suggested Solutions:

High-Level Solution:

  • Modify the CDXML parser: Ensure that it correctly parses the ShowAtomStereo attribute.
  • Update the rendering logic: The renderer should enforce the parsed visibility rules (ShowAtomStereo="yes" or "no") when generating the SVG output.

Technical Solution:

  1. Enhance the CDXML Parser:

    • Update the parser to correctly interpret the ShowAtomStereo attribute.
    • 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)
    
  2. 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);
        }
    }
    
  3. 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".

mobilisf avatar Jun 11 '25 09:06 mobilisf