import { parseSdf } from '../sdf/parser'; const SdfString = ` Mrv1718007121815122D 5 4 0 0 0 0 999 V2000 0.0000 0.8250 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0 -0.8250 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 0.0000 -0.8250 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0 0.0000 0.0000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 0.8250 0.0000 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0 4 1 1 0 0 0 0 4 2 2 0 0 0 0 4 3 1 0 0 0 0 4 5 1 0 0 0 0 M CHG 3 1 -1 3 -1 5 -1 M END > DB14523 > drugbank > [O-]P([O-])([O-])=O > InChI=1S/H3O4P/c1-5(2,3)4/h(H3,1,2,3,4)/p-3 > NBIIXXVUZAFLBC-UHFFFAOYSA-K > O4P > 94.9714 > 94.95342 > 4 > 5 > 4.932162910070488 > 1 > 0 > -3 > 0 > phosphate > -1.0201038226666665 > 0 > 0 > -2 > 6.951626889535468 > 1.7961261340181292 > 86.25 > 11.2868 > 0 > 1 > phosphate > 0 > DB14523 > experimental > Phosphate ion > Orthophosphate; Phosphate $$$$`; describe('sdf reader', () => { it('basic', async () => { const parsed = await parseSdf(SdfString).run(); if (parsed.isError) { throw new Error(parsed.message); } const compound = parsed.result.compounds[0]; const { molFile, dataItems } = compound; const { atoms, bonds } = molFile; // number of structures expect(atoms.count).toBe(5); expect(bonds.count).toBe(4); expect(atoms.x.value(0)).toBeCloseTo(0, 0.001); expect(atoms.y.value(0)).toBeCloseTo(0.8250, 0.0001); expect(atoms.z.value(0)).toBeCloseTo(0, 0.0001); expect(atoms.type_symbol.value(0)).toBe('O'); expect(bonds.atomIdxA.value(3)).toBe(4); expect(bonds.atomIdxB.value(3)).toBe(5); expect(bonds.order.value(3)).toBe(1); expect(dataItems.dataHeader.value(0)).toBe('DATABASE_ID'); expect(dataItems.data.value(0)).toBe('DB14523'); expect(dataItems.dataHeader.value(1)).toBe('DATABASE_NAME'); expect(dataItems.data.value(1)).toBe('drugbank'); expect(dataItems.dataHeader.value(31)).toBe('SYNONYMS'); expect(dataItems.data.value(31)).toBe('Orthophosphate; Phosphate'); }); });