Closed lifenjoiner closed 1 year ago
Append:
The same issue with setAtomBackgroundColors
.
Try the js from your browser console to an example page:
// one example with issues on 1 atom and 2 bonds
// jsmeApplet.readGenericMolecularInput('C1(CC2=CC=C(C3CCCCC3)C=N2)=CC=CC=C1');
jsmeApplet.readGenericMolecularInput('19 21 C 8.49 4.20 C 7.27 4.90 C 6.06 4.20 C 4.85 4.90 C 3.64 4.20 C 3.64 2.80 C 2.42 2.10 C 1.21 2.80 C 0.00 2.10 C 0.00 0.70 C 1.21 0.00 C 2.42 0.70 C 4.85 2.10 N 6.06 2.80 C 8.49 2.80 C 9.70 2.10 C 10.91 2.80 C 10.91 4.20 C 9.70 4.90 2 1 1 3 2 1 4 3 2 5 4 1 6 5 2 7 6 1 8 7 1 9 8 1 10 9 1 11 10 1 12 11 1 12 7 1 13 6 1 14 13 2 14 3 1 15 1 2 16 15 1 17 16 2 18 17 1 19 18 2 19 1 1');
// highlight all bonds
var BondsCount = jsmeApplet.totalNumberOfBonds();
var BondColors = [];
for (var i = 1; i <= BondsCount; i++) BondColors.push(i);
jsmeApplet.setBondBackgroundColors(1, BondColors.join(',4,'));
// highlight all atoms
var AtomsCount = jsmeApplet.totalNumberOfAtoms();
var AtomColors = [];
for (var i = 1; i <= AtomsCount; i++) AtomColors.push(i);
jsmeApplet.setAtomBackgroundColors(1, AtomColors.join(',1,'));
Version: JSME_2022-02-26
There is indeed a bug in the code for setBondBackgroundColors(). It has been fixed. A new distribution with fixed issues is in preparation.
I did not find a bug in the code for setAtomBackgroundColors(). I believe the code example you provided has a bug. The atom color specification provided in the code is "1,1,2,1,3,1,4". Because of the use of join(), there is no color for the last atom. It should be "1,1,2,1,3,1,4,1".
Thanks!
Correct highlighting all bonds/atoms:
// highlight all bonds
var BondsCount = jsmeApplet.totalNumberOfBonds();
var BondColors = [];
for (var i = 1; i <= BondsCount; i++) BondColors.push(i);
BondColors.push('');
jsmeApplet.setBondBackgroundColors(1, BondColors.join(',4,'));
// highlight all atoms
var AtomsCount = jsmeApplet.totalNumberOfAtoms();
var AtomColors = [];
for (var i = 1; i <= AtomsCount; i++) AtomColors.push(i);
AtomColors.push('');
jsmeApplet.setAtomBackgroundColors(1, AtomColors.join(',1,'));
As the following example shows, I caught 2 cases that
setBondBackgroundColors
doesn't work correctly. For the 1st case, there could be more than one of the last bonds that are not colored. It seems to happen on cyclic compounds. And for the 2nd case, it shows there could be more issues about loading SMILES.