diff --git a/src/mol-io/reader/_spec/mol2.spec.ts b/src/mol-io/reader/_spec/mol2.spec.ts index dc88b16043caf6777ca6571656f2c3cfab6eb38f..04570831700fc0db83cae496f660bbf50ef654ef 100644 --- a/src/mol-io/reader/_spec/mol2.spec.ts +++ b/src/mol-io/reader/_spec/mol2.spec.ts @@ -265,10 +265,10 @@ describe('mol2 reader', () => { expect(molecule.num_subst).toBe(0); expect(molecule.num_feat).toBe(0); expect(molecule.num_sets).toBe(0); - expect(molecule.mol_type).toBe("SMALL") - expect(molecule.charge_type).toBe("GASTEIGER"); - expect(molecule.status_bits).toBe(""); - expect(molecule.mol_comment).toBe(""); + expect(molecule.mol_type).toBe('SMALL') + expect(molecule.charge_type).toBe('GASTEIGER'); + expect(molecule.status_bits).toBe(''); + expect(molecule.mol_comment).toBe(''); // required atom fields expect(atoms.count).toBe(26); @@ -277,7 +277,7 @@ describe('mol2 reader', () => { expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 0.0001); - expect(atoms.atom_type.value(0)).toBe("O.3"); + expect(atoms.atom_type.value(0)).toBe('O.3'); // optional atom fields expect(atoms.subst_id.value(0)).toBe(1); @@ -316,10 +316,10 @@ describe('mol2 reader', () => { expect(molecule.num_subst).toBe(0); expect(molecule.num_feat).toBe(0); expect(molecule.num_sets).toBe(0); - expect(molecule.mol_type).toBe("SMALL") - expect(molecule.charge_type).toBe("GASTEIGER"); - expect(molecule.status_bits).toBe(""); - expect(molecule.mol_comment).toBe(""); + expect(molecule.mol_type).toBe('SMALL') + expect(molecule.charge_type).toBe('GASTEIGER'); + expect(molecule.status_bits).toBe(''); + expect(molecule.mol_comment).toBe(''); // required atom fields expect(atoms.count).toBe(26); @@ -328,7 +328,7 @@ describe('mol2 reader', () => { expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 0.0001); - expect(atoms.atom_type.value(0)).toBe("O.3"); + expect(atoms.atom_type.value(0)).toBe('O.3'); // optional atom fields expect(atoms.subst_id.value(0)).toBe(1); @@ -367,10 +367,10 @@ describe('mol2 reader', () => { expect(molecule.num_subst).toBe(0); expect(molecule.num_feat).toBe(0); expect(molecule.num_sets).toBe(0); - expect(molecule.mol_type).toBe("SMALL") - expect(molecule.charge_type).toBe("GASTEIGER"); - expect(molecule.status_bits).toBe(""); - expect(molecule.mol_comment).toBe(""); + expect(molecule.mol_type).toBe('SMALL') + expect(molecule.charge_type).toBe('GASTEIGER'); + expect(molecule.status_bits).toBe(''); + expect(molecule.mol_comment).toBe(''); // required atom fields expect(atoms.count).toBe(26); @@ -379,7 +379,7 @@ describe('mol2 reader', () => { expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 0.0001); - expect(atoms.atom_type.value(0)).toBe("O.3"); + expect(atoms.atom_type.value(0)).toBe('O.3'); // optional atom fields expect(atoms.subst_id.value(0)).toBe(0); diff --git a/src/mol-io/reader/_spec/ply.spec.ts b/src/mol-io/reader/_spec/ply.spec.ts index 5427eeb2bc3acd5017618d35c2205a4a52fe5e9f..75325914641932f2495716166566fbdc9d084521 100644 --- a/src/mol-io/reader/_spec/ply.spec.ts +++ b/src/mol-io/reader/_spec/ply.spec.ts @@ -56,6 +56,60 @@ end_header 3 3 5 4 ` +const plyCubeString = `ply +format ascii 1.0 +comment test cube +element vertex 24 +property float32 x +property float32 y +property float32 z +property uint32 material_index +element face 6 +property list uint8 int32 vertex_indices +element material 6 +property uint8 red +property uint8 green +property uint8 blue +end_header +-1 -1 -1 0 +1 -1 -1 0 +1 1 -1 0 +-1 1 -1 0 +1 -1 1 1 +-1 -1 1 1 +-1 1 1 1 +1 1 1 1 +1 1 1 2 +1 1 -1 2 +1 -1 -1 2 +1 -1 1 2 +-1 1 -1 3 +-1 1 1 3 +-1 -1 1 3 +-1 -1 -1 3 +-1 1 1 4 +-1 1 -1 4 +1 1 -1 4 +1 1 1 4 +1 -1 1 5 +1 -1 -1 5 +-1 -1 -1 5 +-1 -1 1 5 +4 0 1 2 3 +4 4 5 6 7 +4 8 9 10 11 +4 12 13 14 15 +4 16 17 18 19 +4 20 21 22 23 +255 0 0 +0 255 0 +0 0 255 +255 255 0 +0 255 255 +255 0 255 +` + + describe('ply reader', () => { it('basic', async () => { const parsed = await Ply(plyString).run(); @@ -66,13 +120,33 @@ describe('ply reader', () => { if (!vertex) return const x = vertex.getProperty('x') if (!x) return - console.log('x', x.toArray()) + expect(x.value(0)).toEqual(130.901) + + const face = plyFile.getElement('face') as PlyList + if (!face) return + expect(face.value(0)).toEqual({ count: 3, entries: [0, 2, 1]}) + expect(face.value(1)).toEqual({ count: 3, entries: [3, 5, 4]}) + + expect.assertions(3) + }); + + it('material', async () => { + const parsed = await Ply(plyCubeString).run(); + if (parsed.isError) return; + const plyFile = parsed.result; + + const vertex = plyFile.getElement('vertex') as PlyTable + if (!vertex) return + expect(vertex.rowCount).toBe(24) const face = plyFile.getElement('face') as PlyList if (!face) return - const f0 = face.value(0) - console.log('f0', f0) - const f1 = face.value(1) - console.log('f1', f1) + expect(face.rowCount).toBe(6) + + const material = plyFile.getElement('face') as PlyTable + if (!material) return + expect(face.rowCount).toBe(6) + + expect.assertions(3) }); }); \ No newline at end of file diff --git a/src/mol-io/reader/cif/data-model.ts b/src/mol-io/reader/cif/data-model.ts index 2800437dc930bd57af8dafe14913f9d5e15fc105..c5778c7b55a847616c5c36ff57dcf300f9af1926 100644 --- a/src/mol-io/reader/cif/data-model.ts +++ b/src/mol-io/reader/cif/data-model.ts @@ -199,7 +199,7 @@ export namespace CifField { export function ofColumn(column: Column<any>): CifField { const { rowCount, valueKind, areValuesEqual } = column; - + let str: CifField['str'] let int: CifField['int'] let float: CifField['float'] @@ -219,7 +219,6 @@ export namespace CifField { default: throw new Error('unsupported') } - return { __array: void 0,