| |
| |
| |
| |
| |
| |
|
|
| import { IFileInfo } from "@/FileSystem/Types"; |
| import { EasyParserParent } from "./EasyParserParent"; |
| import { IAtom } from "@/UI/Navigation/TreeView/TreeInterfaces"; |
|
|
| |
| |
| |
| export class EasyParserMol2 extends EasyParserParent { |
| |
| |
| |
| |
| |
| _load(src: IFileInfo): void { |
| if (src.contents.indexOf("@<TRIPOS>ATOM") === -1) { |
| throw new Error("MOL2 file does not contain @<TRIPOS>ATOM section. Incorrect format?"); |
| } |
| const prts = src.contents.split("@<TRIPOS>ATOM"); |
| let atoms = prts[1].split("@<TRIPOS>")[0]; |
|
|
| |
| while (atoms[0] === "\n") { |
| atoms = atoms.slice(1); |
| } |
|
|
| |
| atoms = atoms.trimRight(); |
|
|
| this._atoms = atoms.split("\n").map((atom: string) => atom.trim()); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| _parseAtomStr(atomStr: string, atomParserIndex?: number): IAtom { |
| |
| |
|
|
| |
| const [serialOrig, atomName, xOrig, yOrig, zOrig, elemOrig, resiOrig, resn, bOrig] = atomStr.split(/\s+/); |
| const serial = parseInt(serialOrig); |
| const x = parseFloat(xOrig); |
| const y = parseFloat(yOrig); |
| const z = parseFloat(zOrig); |
| const elem = elemOrig.split(".")[0] |
| const resi = parseInt(resiOrig); |
| const b = parseFloat(bOrig); |
| |
| |
|
|
| |
| const chain = "A"; |
| const altLoc = " "; |
|
|
| return { |
| resn, |
| chain, |
| resi, |
| x, |
| y, |
| z, |
| bondOrder: [], |
| bonds: [], |
| elem, |
| serial, |
| altLoc, |
| b, |
| atom: atomName, |
| }; |
| } |
| } |