Add formal charge label to representation
See original GitHub issueGreetings!
Is there a quick and painless way to add a label displaying the formal charge (M CHG 1 8 -1
) to the nitrogen at position 8
( 0.2451 -0.3881 -0.5673 N 5 5 0 0 0 2 0 0 0 0 0 0
)
SMILES-CFFFSOON-SOOCFFF
RDKit 3D
15 14 0 0 0 0 0 0 0 0999 V2000
2.4644 -0.6833 0.6783 C 0 0 0 0 0 0 0 0 0 0 0 0
3.1589 -0.1223 -0.3545 F 0 0 0 0 0 0 0 0 0 0 0 0
2.4354 -2.0263 0.4264 F 0 0 0 0 0 0 0 0 0 0 0 0
3.2334 -0.5214 1.7934 F 0 0 0 0 0 0 0 0 0 0 0 0
0.7862 0.0206 0.8608 S 0 0 0 0 0 6 0 0 0 0 0 0
0.9929 1.4434 1.1263 O 0 0 0 0 0 0 0 0 0 0 0 0
0.1705 -0.7131 1.9690 O 0 0 0 0 0 0 0 0 0 0 0 0
0.2451 -0.3881 -0.5673 N 5 5 0 0 0 2 0 0 0 0 0 0 <--------
-1.0100 0.4366 -1.0736 S 0 0 0 0 0 6 0 0 0 0 0 0
-1.6478 -0.2086 -2.2311 O 0 0 0 0 0 0 0 0 0 0 0 0
-0.7964 1.8705 -1.2847 O 0 0 0 0 0 0 0 0 0 0 0 0
-2.2304 0.2627 0.2953 C 0 0 0 0 0 0 0 0 0 0 0 0
-2.3428 -1.0280 0.7238 F 0 0 0 0 0 0 0 0 0 0 0 0
-1.9714 1.0394 1.3799 F 0 0 0 0 0 0 0 0 0 0 0 0
-3.4880 0.6179 -0.1175 F 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0
1 3 1 0
1 4 1 0
1 5 1 0
5 6 2 0
5 7 2 0
5 8 1 0
8 9 1 0
9 10 2 0
9 11 2 0
9 12 1 0
12 13 1 0
12 14 1 0
12 15 1 0
M CHG 1 8 -1
M END
$$$$
From what I understand, I could parse the file to get the charges and the atom ID’s and then add the labels manually with something similar to this:
styleProps = styleProps || { borderWidth: 0.1, borderColor: molstar.COLOR_NAMES.white };
const atomExpression = this.expressions.atom;
const structure = _structures[structureKey].data;
const context = _plugin.managers.task.currentContext;
Object.keys(atomLabels).forEach((atomId) => {
const _atomId = parseInt(atomId)
const query = molstar.StructureSelectionQuery('Query', atomExpression(_atomId));
query.getSelection(_plugin, context, structure)
.then((selection) => {
const loci = molstar.StructureSelection.toLociWithSourceUnits(selection);
molstar.createTextRepresentation({ text: atomLabels[atomId], loci, size }, styleProps)
.then((label) => {
label.setState({ pickable: false });
_plugin.canvas3d.add(label);
if (!_representations[structureKey][representationKey]) {
_representations[structureKey][representationKey] = [];
}
_representations[structureKey][representationKey].push(label);
});
});
});
But I also saw this, https://github.com/molstar/molstar/blob/7a25699c2353c4142286c3403d3ab2416f48043c/src/mol-model/structure/model/properties/atomic/hierarchy.ts#L51 which made think that mol* is already aware of formal charges in some way.
Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Formal Charges in Lewis Structures - Chemistry LibreTexts
To find formal charges in a Lewis structure, for each atom, you should count how many electrons it "owns". Count all of its...
Read more >Formal Charges and Resonance | Chemistry for Majors
Another way of saying this is that formal charge results when we take the number of valence electrons of a neutral atom, subtract...
Read more >How To Calculate Formal Charge - Master Organic Chemistry
To obtain the formal charge of an atom, we start by counting the number of valence electrons [Note 1] for the neutral atom,...
Read more >9. Labeling Charged Atoms in Molecules: Formal Charge 9/13
If an atom in a molecule has the same number of valence electrons as the free, neutral atom, it has no formal charge....
Read more >How to Calculate Formal Charge - Video & Lesson Transcript
The sum of the formal charges in a molecule must equal the charge of the molecule. Formal charge does not necessarily reflect the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am willing to work on this as well once I get the formal charge labels working. 👍
This clarifies my use case. Since the relevant PR is also merged, I am closing the issue. Thanks!