Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect phosphorus valence #2746

Open
jblack-mestre opened this issue Jan 30, 2025 · 4 comments · May be fixed by #2754
Open

Incorrect phosphorus valence #2746

jblack-mestre opened this issue Jan 30, 2025 · 4 comments · May be fixed by #2754
Labels
Export to SVG/PNG Bucket: Bugs related to SVG/PNG export Micromolecules canvas Bucket: Micromolecules canvas related issues User`s Feedback

Comments

@jblack-mestre
Copy link
Contributor

jblack-mestre commented Jan 30, 2025

Summary
When generating an .svg image with indigo-depict phosphorus_valence.cml, the phosphorus is incorrectly depicted as having a wrong valence of 5. It should have a valence of 3, with no added hydrogens.

Steps to Reproduce

  1. indigo-depict.exe phosphorus_valence.cml phosphorus_valence.svg

Actual behavior
The phosphorus is depicted as having a valence of 5 with two added hydrogens.
Image

Expected behavior
The phosphorus should be depicted as having a valence of 3 with no added hydrogens.
Image

Environment details:

Attachments
phosphorus_valence.cml.txt

Additional context
When adding sgroup bonds, indigo recalculates the valence and implicit hydrogens before it has removed the bond to the atom connecting to the sgroup. So P initially has a valence of 3, then this is raised to 4 when adding the bond to the new sgroup. Once the valence is recalculated, this is increased to 5.

jblack-mestre added a commit to mestrelab-chemoinformatics/Indigo that referenced this issue Feb 5, 2025
@AlexeyGirin AlexeyGirin added User`s Feedback Micromolecules canvas Bucket: Micromolecules canvas related issues Export to SVG/PNG Bucket: Bugs related to SVG/PNG export labels Feb 5, 2025
@AliaksandrDziarkach
Copy link
Collaborator

Looks like issue reproduced when abbreviation contracted and all valence connection used:

Image

Image

@jblack-mestre
Copy link
Contributor Author

Could you send me the file for this picture so I can reproduce the issue? The problem is that the molecules at the top should have the same oxidation state as the ones at the bottom?

@AliaksandrDziarkach
Copy link
Collaborator

Just add correspondig count of C, then make one of them Superatom S-Group and contract it.

{
    "root": {
        "nodes": [
            {
                "$ref": "mol0"
            },
            {
                "$ref": "mol1"
            }
        ],
        "connections": [],
        "templates": []
    },
    "mol0": {
        "type": "molecule",
        "atoms": [
            {
                "label": "P",
                "location": [
                    9.850000000000001,
                    -4.575,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    10.850000000000001,
                    -4.575,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    9.350000000000001,
                    -3.7089745962155614,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    9.350000000000001,
                    -5.4410254037844386,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    3
                ]
            }
        ],
        "sgroups": [
            {
                "type": "SUP",
                "atoms": [
                    1
                ],
                "name": "Sub",
                "expanded": false,
                "id": 0
            }
        ]
    },
    "mol1": {
        "type": "molecule",
        "atoms": [
            {
                "label": "P",
                "location": [
                    14.25,
                    -4.675,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    15.25,
                    -4.675,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    13.75,
                    -3.808974596215561,
                    0
                ]
            },
            {
                "label": "C",
                "location": [
                    13.75,
                    -5.541025403784438,
                    0
                ]
            }
        ],
        "bonds": [
            {
                "type": 1,
                "atoms": [
                    0,
                    1
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    2
                ]
            },
            {
                "type": 1,
                "atoms": [
                    0,
                    3
                ]
            }
        ],
        "sgroups": [
            {
                "type": "SUP",
                "atoms": [
                    1
                ],
                "name": "Sub",
                "expanded": true,
                "id": 0
            }
        ]
    }
}

@jblack-mestre
Copy link
Contributor Author

I'm having trouble reproducing your test. I have taken your ket file - modified it in ketcher and then put it through indigo-depict. But my svg looks very bad
Image

Instead, if I save to a cdxml file and use with indigo depict, I lose the bracketed [CH3]Sub group, however all the oxidation states are correct
Image

@AlexanderSavelyev AlexanderSavelyev linked a pull request Feb 10, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Export to SVG/PNG Bucket: Bugs related to SVG/PNG export Micromolecules canvas Bucket: Micromolecules canvas related issues User`s Feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants