smiles-js 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ring.js +6 -4
- package/test/ring-composition.test.js +13 -0
- package/test/ring.test.js +1 -1
package/package.json
CHANGED
package/src/ring.js
CHANGED
|
@@ -60,9 +60,7 @@ export function Ring(atom, size, options = {}) {
|
|
|
60
60
|
for (let i = 0; i < size; i++) {
|
|
61
61
|
const currentAtom = replace[i] !== undefined ? replace[i] : atom;
|
|
62
62
|
|
|
63
|
-
if (i
|
|
64
|
-
parts.push(currentAtom + '1');
|
|
65
|
-
} else if (newSubstituents[i]) {
|
|
63
|
+
if (newSubstituents[i]) {
|
|
66
64
|
// Remap ring numbers in substituent to avoid conflicts
|
|
67
65
|
const currentSmiles = parts.join('');
|
|
68
66
|
const usedInCurrent = findUsedRingNumbers(currentSmiles);
|
|
@@ -83,11 +81,15 @@ export function Ring(atom, size, options = {}) {
|
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
// Add substituent at this position
|
|
86
|
-
if (i ===
|
|
84
|
+
if (i === 0) {
|
|
85
|
+
parts.push(currentAtom + '1(' + remappedSubstituent + ')');
|
|
86
|
+
} else if (i === size - 1) {
|
|
87
87
|
parts.push(currentAtom + '(' + remappedSubstituent + ')1');
|
|
88
88
|
} else {
|
|
89
89
|
parts.push(currentAtom + '(' + remappedSubstituent + ')');
|
|
90
90
|
}
|
|
91
|
+
} else if (i === 0) {
|
|
92
|
+
parts.push(currentAtom + '1');
|
|
91
93
|
} else if (i === size - 1) {
|
|
92
94
|
parts.push(currentAtom + '1');
|
|
93
95
|
} else {
|
|
@@ -59,3 +59,16 @@ test('Ring composition counts rings correctly', async () => {
|
|
|
59
59
|
assert.ok(await isValidSMILES(triphenyl.smiles));
|
|
60
60
|
assert.strictEqual(triphenyl.rings, 3);
|
|
61
61
|
});
|
|
62
|
+
|
|
63
|
+
test('Phenol composition works correctly', async () => {
|
|
64
|
+
const benzene = Ring('c', 6);
|
|
65
|
+
const phenol = benzene.attachAt(1, 'O');
|
|
66
|
+
assert.ok(await isValidSMILES(phenol.smiles));
|
|
67
|
+
assert.strictEqual(phenol.smiles, 'c1(O)ccccc1');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('Para-quinone (2,5-cyclohexadiene-1,4-dione) composition works correctly', async () => {
|
|
71
|
+
const result = Ring('c', 6).attachAt(1, '=O').attachAt(4, '=O');
|
|
72
|
+
assert.ok(await isValidSMILES(result.smiles));
|
|
73
|
+
assert.strictEqual(result.smiles, 'c1(=O)ccc(=O)cc1');
|
|
74
|
+
});
|
package/test/ring.test.js
CHANGED
|
@@ -59,7 +59,7 @@ test('Ring counts rings correctly', () => {
|
|
|
59
59
|
test('Ring.attachAt creates toluene at position 1', async () => {
|
|
60
60
|
const benzene = Ring('c', 6);
|
|
61
61
|
const toluene = benzene.attachAt(1, 'C');
|
|
62
|
-
assert.strictEqual(toluene.smiles, '
|
|
62
|
+
assert.strictEqual(toluene.smiles, 'c1(C)ccccc1');
|
|
63
63
|
assert.ok(await isValidSMILES(toluene.smiles));
|
|
64
64
|
});
|
|
65
65
|
|