|
| 1 | +const producePdb = require('.'); |
| 2 | + |
| 3 | +test('atom serial rollover preserves fixed columns and coordinate indexing', () => { |
| 4 | + const nAtoms = 200001; |
| 5 | + const topology = { |
| 6 | + atom_names: Array(nAtoms).fill('CA'), |
| 7 | + atom_elements: Array(nAtoms).fill('C'), |
| 8 | + atom_residue_indices: Array(nAtoms).fill(0), |
| 9 | + residue_names: ['ALA'], |
| 10 | + residue_numbers: [1], |
| 11 | + residue_chain_indices: [0], |
| 12 | + chain_names: ['A'], |
| 13 | + }; |
| 14 | + const coordinates = Array(nAtoms).fill([1.25, -2.5, 3.75]); |
| 15 | + coordinates[99999] = [4.5, 5.25, -6.75]; |
| 16 | + const lines = producePdb(topology, coordinates).trimEnd().split('\n').slice(1); |
| 17 | + |
| 18 | + expect(lines).toHaveLength(nAtoms); |
| 19 | + for (const [index, serial] of [[0, ' 1'], [99998, '99999'], |
| 20 | + [99999, ' 1'], [100000, ' 2'], [199997, '99999'], |
| 21 | + [199998, ' 1'], [199999, ' 2'], [200000, ' 3']]) { |
| 22 | + const line = lines[index]; |
| 23 | + expect(line).toHaveLength(78); |
| 24 | + expect(line.slice(6, 11)).toBe(serial); |
| 25 | + expect(line.slice(12, 16)).toBe(' CA '); |
| 26 | + expect(line.slice(17, 20)).toBe('ALA'); |
| 27 | + expect(line[21]).toBe('A'); |
| 28 | + expect(line.slice(22, 26)).toBe(' 1'); |
| 29 | + expect([line.slice(30, 38), line.slice(38, 46), line.slice(46, 54)].map(Number)) |
| 30 | + .toEqual(coordinates[index]); |
| 31 | + expect(line.slice(76, 78)).toBe(' C'); |
| 32 | + } |
| 33 | +}); |
0 commit comments