Skip to content

Commit

Permalink
Merge pull request #957 from papillot/fix-pdbqt
Browse files Browse the repository at this point in the history
Fix PDBQT parser for wrong H elements interpolation
  • Loading branch information
fredludlow committed Jan 24, 2023
2 parents 3f0fd8e + e68185b commit fee15d5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/parser/pdb-parser.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions src/structure/structure-constants.ts
Expand Up @@ -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'
}
15 changes: 15 additions & 0 deletions 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
26 changes: 26 additions & 0 deletions 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')
})
})
})
})

0 comments on commit fee15d5

Please sign in to comment.