in packages/miew/src/io/parsers/PDBParser.js [159:213]
_parseATOM(stream) {
if (this._modelId !== 1) {
return;
}
/* eslint-disable no-magic-numbers */
const het = stream.readCharCode(1) === 0x48;
// field names according to wwPDB Format
// NOTE: Chimera allows (nonstandard) use of columns 6-11 for the integer atom serial number in ATOM records.
const serial = het ? stream.readInt(7, 11) : stream.readInt(6, 11);
let name = stream.readString(13, 16);
const altLoc = stream.readChar(17);
const resName = stream.readString(18, 20).trim();
const chainID = stream.readChar(22);
const resSeq = stream.readInt(23, 26);
const iCode = stream.readChar(27);
const x = stream.readFloat(31, 38);
const y = stream.readFloat(39, 46);
const z = stream.readFloat(47, 54);
const occupancy = stream.readFloat(55, 60);
const tempFactor = stream.readFloat(61, 66);
const element = stream.readString(77, 78).trim() || nameToElement(name);
const charge = stream.readInt(79, 80) || 0;
/* eslint-enable no-magic-numbers */
// skip waters (there may be lots of them)
if (this.settings.now.nowater) {
if (resName === 'HOH' || resName === 'WAT') {
return;
}
}
// PDB uses positional system for atom names. It helps derive element type from the name
// but names may include extra spaces. From this point on we don't need those spaces anymore.
name = name.trim();
const type = Element.getByName(element);
const role = Element.Role[name]; // FIXME: Maybe should use type as additional index (" CA " vs. "CA ")
// NOTE: Residues of a particular chain are not required to be listed next to each other.
// https://github.com/biasmv/pv/commit/7319b898b7473ba380c26699e3b028b2b1a7e1a1
let chain = this._chain;
if (!chain || chain.getName() !== chainID) {
this._chain = chain = this._complex.getChain(chainID) || this._complex.addChain(chainID);
this._residue = null;
}
let residue = this._residue;
if (!residue || residue.getSequence() !== resSeq || residue.getICode() !== iCode) {
this._residue = residue = chain.addResidue(resName, resSeq, iCode);
}
const xyz = new THREE.Vector3(x, y, z);
residue.addAtom(name, type, xyz, role, het, serial, altLoc, occupancy, tempFactor, charge);
}