| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| import { IAtom } from "@/UI/Navigation/TreeView/TreeInterfaces"; |
| import { EasyParserParent } from "./EasyParserParent"; |
| import { IFileInfo } from "@/FileSystem/Types"; |
| import { twoLetterElems } from "../../NameVars"; |
|
|
| |
| |
| |
| export class EasyParserPDB extends EasyParserParent { |
| |
| |
| |
| |
| |
| _load(src: IFileInfo): void { |
| const atomLines = src.contents.split("\n"); |
|
|
| |
| this._atoms = atomLines.filter((line: string) => { |
| return line.startsWith("ATOM") || line.startsWith("HETATM"); |
| }); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| _parseAtomStr(atomStr: string, atomParserIndex?: number): IAtom { |
| |
| const atomName = atomStr.slice(12, 16).trim(); |
| const serial = parseInt(atomStr.slice(6, 11).trim()); |
| const altLoc = atomStr.slice(16, 17); |
| const resn = atomStr.slice(17, 20).trim(); |
| const chain = atomStr.slice(21, 22); |
| const resi = parseInt(atomStr.slice(22, 26).trim()); |
| const x = parseFloat(atomStr.slice(30, 38).trim()); |
| const y = parseFloat(atomStr.slice(38, 46).trim()); |
| const z = parseFloat(atomStr.slice(46, 54).trim()); |
| const b = parseFloat(atomStr.slice(60, 66).trim()); |
| const hetflag = atomStr.slice(0, 6).trim() === "HETATM"; |
|
|
| let elem = atomStr.slice(76, 78).trim(); |
| if (elem === "") { |
| |
| elem = atomStr.slice(12, 14).trim(); |
| |
| elem = elem.toUpperCase(); |
| |
| if (twoLetterElems.indexOf(elem) === -1) { |
| elem = elem[0]; |
| } |
| } |
| if (elem.length > 1) { |
| |
| elem = elem[0] + elem.slice(1).toLowerCase(); |
| } |
|
|
| return { |
| resn, |
| chain, |
| resi, |
| x, |
| y, |
| z, |
| bondOrder: [], |
| bonds: [], |
| elem, |
| serial, |
| altLoc, |
| b, |
| atom: atomName, |
| hetflag, |
| }; |
| } |
| } |
|
|