File size: 1,023 Bytes
71174bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { TreeNode } from "@/TreeNodes/TreeNode/TreeNode";
import { IAtom, SelectedType } from "@/UI/Navigation/TreeView/TreeInterfaces";
import { _convertTreeNodeListToPDB } from "./_ConvertTreeNodeListToPDB";
import { TreeNodeList } from "@/TreeNodes/TreeNodeList/TreeNodeList";
import type { IFileInfo } from "@/FileSystem/Types";

/**
 * Convert IAtoms to IFileInfo PDB.
 * 
 * @param {IAtom[]} atoms The atoms to convert.
 * @returns {IFileInfo} The converted atoms.
 */
export function convertIAtomsToIFileInfoPDB(atoms: IAtom[]): IFileInfo {
    // I found myself often needing this conversion.

    const node = new TreeNode({
        title: "tmp",
        model: atoms,
        visible: false,
        focused: false,
        viewerDirty: false,
        treeExpanded: false,
        selected: SelectedType.False,
    });

    const pdbTxt = _convertTreeNodeListToPDB(
        new TreeNodeList([node]),
        false
    )[0];

    return {
        name: "tmpmol.pdb",
        contents: pdbTxt,
    } as IFileInfo;
}