| import type { TreeNodeList } from "@/TreeNodes/TreeNodeList/TreeNodeList"; |
| import { parseMolecularModelFromTexts } from "./ParseMolModelsUtils"; |
| import { IFormatInfo } from "../Types/MolFormats"; |
| import { FileInfo } from "@/FileSystem/FileInfo"; |
| import { IGen3DOptions, convertFileInfosOpenBabel } from "@/FileSystem/OpenBabel/OpenBabel"; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export function parseUsingOpenBabel( |
| fileInfo: FileInfo, |
| formatInfo: IFormatInfo, |
| desalt = false, |
| gen3D?: IGen3DOptions, |
| surpressMsgs?: boolean |
| ): Promise<TreeNodeList> { |
| const targetFormat = formatInfo.hasBondOrders ? "mol2" : "pdb"; |
|
|
| |
| return convertFileInfosOpenBabel([fileInfo], targetFormat, gen3D, undefined, desalt, surpressMsgs) |
| .then((contents: string[]) => { |
| const hasMultipleFrames = contents.length > 1; |
| const fileInfos = contents.map((c, i) => { |
| |
|
|
| |
| let { name } = fileInfo; |
| if (hasMultipleFrames) { |
| |
| |
| name = `(frame${i + 1}) ${fileInfo.name}`; |
| } |
|
|
| return new FileInfo({ |
| contents: c, |
| name: name, |
| }); |
| }); |
|
|
| return parseMolecularModelFromTexts( |
| fileInfos, |
| targetFormat |
| ); |
| }) |
| .catch((err) => { |
| |
| |
| throw err; |
| }); |
| } |
|
|