diff --git a/src/parser/pdb-parser.ts b/src/parser/pdb-parser.ts index ed9da88d..7a46ffb4 100755 --- a/src/parser/pdb-parser.ts +++ b/src/parser/pdb-parser.ts @@ -12,7 +12,7 @@ import StructureParser from './structure-parser' import Entity, { EntityTypeString } from '../structure/entity' import Unitcell, { UnitcellParams } from '../symmetry/unitcell' import Assembly, { AssemblyPart } from '../symmetry/assembly' -import { WaterNames } from '../structure/structure-constants' +import { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants' import { assignSecondaryStructure, buildUnitcellAssembly, calculateBonds, calculateChainnames, calculateSecondaryStructure @@ -301,7 +301,9 @@ class PdbParser extends StructureParser { if (!isLegacy) { if (isPdbqt) { - element = line.substr(12, 2).trim() + element = line.substr(76, 3).trim() + // @ts-expect-error TS limitation on narrowing indexes types with `in` + if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element] } else { element = line.substr(76, 2).trim() if (!chainname) { diff --git a/src/structure/structure-constants.ts b/src/structure/structure-constants.ts index 9431b20e..0175cb9d 100644 --- a/src/structure/structure-constants.ts +++ b/src/structure/structure-constants.ts @@ -1105,3 +1105,24 @@ ResidueTypeAtoms[ CgDnaBackboneType ] = { } ResidueTypeAtoms[ UnknownBackboneType ] = {} + +// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py +export const PDBQTSpecialElements = { + 'HD': 'H', + 'HS': 'H', + 'A': 'C', + 'NA': 'N', + 'NS': 'N', + 'OA': 'O', + 'OS': 'O', + 'SA': 'S', + 'G0': 'C', + 'G1': 'C', + 'G2': 'C', + 'G3': 'C', + 'CG0': 'C', + 'CG1': 'C', + 'CG2': 'C', + 'CG3': 'C', + 'W': 'O' +} \ No newline at end of file diff --git a/test/data/1xdn_gln.pdbqt b/test/data/1xdn_gln.pdbqt new file mode 100644 index 00000000..23c08439 --- /dev/null +++ b/test/data/1xdn_gln.pdbqt @@ -0,0 +1,15 @@ +ATOM 1 N GLN 52 42.237 16.800 35.823 1.00 0.00 -0.066 N +ATOM 2 CA GLN 52 41.667 17.015 34.477 1.00 0.00 0.275 C +ATOM 3 C GLN 52 40.148 17.010 34.446 1.00 0.00 0.249 C +ATOM 4 O GLN 52 39.564 17.006 33.382 1.00 0.00 -0.271 OA +ATOM 5 CB GLN 52 42.228 15.967 33.522 1.00 0.00 0.052 C +ATOM 6 CG GLN 52 43.746 16.016 33.446 1.00 0.00 0.105 C +ATOM 7 CD GLN 52 44.292 17.263 32.785 1.00 0.00 0.215 C +ATOM 8 OE1 GLN 52 43.587 17.906 32.000 1.00 0.00 -0.274 OA +ATOM 9 NE2 GLN 52 45.513 17.598 33.072 1.00 0.00 -0.370 N +ATOM 10 H2 GLN 52 41.772 15.848 36.146 1.00 0.00 0.275 HD +ATOM 11 H3 GLN 52 43.141 16.691 35.848 1.00 0.00 0.275 HD +ATOM 12 H GLN 52 41.923 17.526 36.434 1.00 0.00 0.275 HD +ATOM 13 2HE2 GLN 52 46.044 17.022 33.735 1.00 0.00 0.159 HD +ATOM 14 1HE2 GLN 52 45.958 18.423 32.653 1.00 0.00 0.159 HD +TER 15 GLN 52 diff --git a/test/parser/tests-pdbqt-parser.spec.ts b/test/parser/tests-pdbqt-parser.spec.ts new file mode 100644 index 00000000..fa3c7325 --- /dev/null +++ b/test/parser/tests-pdbqt-parser.spec.ts @@ -0,0 +1,26 @@ +import StringStreamer from '../../src/streamer/string-streamer' +import PdbqtParser from '../../src/parser/pdbqt-parser' +import { Structure } from '../../src/ngl' + + +import { join } from 'path' +import * as fs from 'fs' + + +describe('parser/pdb-parser', function () { + describe('parsing', function () { + it('translates PDBQT special atom types to elements', function() { + const file = join(__dirname, '/../data/1xdn_gln.pdbqt') + const str = fs.readFileSync(file, 'utf-8') + const streamer = new StringStreamer(str) + const pdbqtParser = new PdbqtParser(streamer) + return pdbqtParser.parse().then(function (structure: Structure) { + const ap = structure.getAtomProxy() + ap.index = 3 + expect(ap.element).toBe('O') + ap.index = 12 + expect(ap.element).toBe('H') + }) + }) + }) +})