Skip to content
Snippets Groups Projects
Commit 6ae53728 authored by Alexander Rose's avatar Alexander Rose
Browse files

ply spec

parent 88cf0cc6
No related branches found
No related tags found
No related merge requests found
...@@ -265,10 +265,10 @@ describe('mol2 reader', () => { ...@@ -265,10 +265,10 @@ describe('mol2 reader', () => {
expect(molecule.num_subst).toBe(0); expect(molecule.num_subst).toBe(0);
expect(molecule.num_feat).toBe(0); expect(molecule.num_feat).toBe(0);
expect(molecule.num_sets).toBe(0); expect(molecule.num_sets).toBe(0);
expect(molecule.mol_type).toBe("SMALL") expect(molecule.mol_type).toBe('SMALL')
expect(molecule.charge_type).toBe("GASTEIGER"); expect(molecule.charge_type).toBe('GASTEIGER');
expect(molecule.status_bits).toBe(""); expect(molecule.status_bits).toBe('');
expect(molecule.mol_comment).toBe(""); expect(molecule.mol_comment).toBe('');
// required atom fields // required atom fields
expect(atoms.count).toBe(26); expect(atoms.count).toBe(26);
...@@ -277,7 +277,7 @@ describe('mol2 reader', () => { ...@@ -277,7 +277,7 @@ describe('mol2 reader', () => {
expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001);
expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001);
expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 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 // optional atom fields
expect(atoms.subst_id.value(0)).toBe(1); expect(atoms.subst_id.value(0)).toBe(1);
...@@ -316,10 +316,10 @@ describe('mol2 reader', () => { ...@@ -316,10 +316,10 @@ describe('mol2 reader', () => {
expect(molecule.num_subst).toBe(0); expect(molecule.num_subst).toBe(0);
expect(molecule.num_feat).toBe(0); expect(molecule.num_feat).toBe(0);
expect(molecule.num_sets).toBe(0); expect(molecule.num_sets).toBe(0);
expect(molecule.mol_type).toBe("SMALL") expect(molecule.mol_type).toBe('SMALL')
expect(molecule.charge_type).toBe("GASTEIGER"); expect(molecule.charge_type).toBe('GASTEIGER');
expect(molecule.status_bits).toBe(""); expect(molecule.status_bits).toBe('');
expect(molecule.mol_comment).toBe(""); expect(molecule.mol_comment).toBe('');
// required atom fields // required atom fields
expect(atoms.count).toBe(26); expect(atoms.count).toBe(26);
...@@ -328,7 +328,7 @@ describe('mol2 reader', () => { ...@@ -328,7 +328,7 @@ describe('mol2 reader', () => {
expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001);
expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001);
expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 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 // optional atom fields
expect(atoms.subst_id.value(0)).toBe(1); expect(atoms.subst_id.value(0)).toBe(1);
...@@ -367,10 +367,10 @@ describe('mol2 reader', () => { ...@@ -367,10 +367,10 @@ describe('mol2 reader', () => {
expect(molecule.num_subst).toBe(0); expect(molecule.num_subst).toBe(0);
expect(molecule.num_feat).toBe(0); expect(molecule.num_feat).toBe(0);
expect(molecule.num_sets).toBe(0); expect(molecule.num_sets).toBe(0);
expect(molecule.mol_type).toBe("SMALL") expect(molecule.mol_type).toBe('SMALL')
expect(molecule.charge_type).toBe("GASTEIGER"); expect(molecule.charge_type).toBe('GASTEIGER');
expect(molecule.status_bits).toBe(""); expect(molecule.status_bits).toBe('');
expect(molecule.mol_comment).toBe(""); expect(molecule.mol_comment).toBe('');
// required atom fields // required atom fields
expect(atoms.count).toBe(26); expect(atoms.count).toBe(26);
...@@ -379,7 +379,7 @@ describe('mol2 reader', () => { ...@@ -379,7 +379,7 @@ describe('mol2 reader', () => {
expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001); expect(atoms.x.value(0)).toBeCloseTo(1.7394, 0.001);
expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001); expect(atoms.y.value(0)).toBeCloseTo(-2.1169, 0.0001);
expect(atoms.z.value(0)).toBeCloseTo(-1.0893, 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 // optional atom fields
expect(atoms.subst_id.value(0)).toBe(0); expect(atoms.subst_id.value(0)).toBe(0);
......
...@@ -56,6 +56,60 @@ end_header ...@@ -56,6 +56,60 @@ end_header
3 3 5 4 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', () => { describe('ply reader', () => {
it('basic', async () => { it('basic', async () => {
const parsed = await Ply(plyString).run(); const parsed = await Ply(plyString).run();
...@@ -66,13 +120,33 @@ describe('ply reader', () => { ...@@ -66,13 +120,33 @@ describe('ply reader', () => {
if (!vertex) return if (!vertex) return
const x = vertex.getProperty('x') const x = vertex.getProperty('x')
if (!x) return 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 const face = plyFile.getElement('face') as PlyList
if (!face) return if (!face) return
const f0 = face.value(0) expect(face.rowCount).toBe(6)
console.log('f0', f0)
const f1 = face.value(1) const material = plyFile.getElement('face') as PlyTable
console.log('f1', f1) if (!material) return
expect(face.rowCount).toBe(6)
expect.assertions(3)
}); });
}); });
\ No newline at end of file
...@@ -220,7 +220,6 @@ export namespace CifField { ...@@ -220,7 +220,6 @@ export namespace CifField {
throw new Error('unsupported') throw new Error('unsupported')
} }
return { return {
__array: void 0, __array: void 0,
binaryEncoding: void 0, binaryEncoding: void 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment