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

[BUG] Positive formal_charge isn't converted to SDF charge field correctly #274

Closed
lohedges opened this issue Jan 17, 2025 · 0 comments · Fixed by #273
Closed

[BUG] Positive formal_charge isn't converted to SDF charge field correctly #274

lohedges opened this issue Jan 17, 2025 · 0 comments · Fixed by #273
Assignees
Labels
bug Something isn't working

Comments

@lohedges
Copy link
Contributor

Round-trip read/write of SDF files is failing due to incorrect handling for positive formal charge values on write. According to this resouce we should have:

Formal charge SDF value
-3 7
-2 6
-1 5
0 0
1 3
2 2
3 1

The code is handled here

if (atom.hasProperty(map["formal_charge"]))
{
int charge = int(atom.property<SireUnits::Dimension::Charge>(map["formal_charge"]).value());
if (charge >= 4 or charge < -3)
{
sdfmol.addProperty("CHG", i + 1, QString::number(charge));
charge = 0;
}
else if (charge < 0)
{
switch (charge)
{
case -1:
charge = 5;
break;
case -2:
charge = 6;
break;
case -3:
charge = 7;
break;
}
}

This has no conditional for positive formal charge, so it just takes the formal charge value, i.e. 1 would be written as 1, not 3. I'm also not sure what one does about the additional "doublet radical" option, which should have a value of 4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant