| |
| |
|
|
| import { compileByMolecule } from "./CompileByMolecule"; |
| import { saveTxtFiles, getConvertedTxtsWithNaming } from "./SaveMolModelsUtils"; |
| import { |
| IMolsToConsider, |
| ICompiledNodes, |
| ICmpdNonCmpdFileInfos, |
| } from "./Types"; |
| import { FileInfo } from "@/FileSystem/FileInfo"; |
| import { TreeNodeType } from "@/UI/Navigation/TreeView/TreeInterfaces"; |
|
|
| |
| |
| |
| |
| |
| |
| |
| export function compileMolModels( |
| molsToConsider: IMolsToConsider, |
| separateComponents: boolean |
| ): ICompiledNodes { |
| return compileByMolecule(molsToConsider, separateComponents); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export function convertCompiledMolModelsToIFileInfos( |
| compiledNodes: ICompiledNodes, |
| formats: { [key in TreeNodeType]?: string }, |
| fallbackFormat: string |
| ): Promise<ICmpdNonCmpdFileInfos> { |
| |
| const allPromises: Promise<FileInfo[]>[] = []; |
|
|
| compiledNodes.byType.forEach((nodeGroups, type) => { |
| const format = formats[type] || fallbackFormat; |
| |
| nodeGroups.forEach(group => { |
| |
| allPromises.push(getConvertedTxtsWithNaming(group, format, true, type)); |
| }); |
| }); |
|
|
| return Promise.all(allPromises).then((results) => { |
| const flat = results.reduce((acc, val) => acc.concat(val), []); |
| |
| const compoundFileInfos = flat.filter(f => f.name.includes("Compound")); |
| const nonCompoundFileInfos = flat.filter(f => !f.name.includes("Compound")); |
|
|
| return { |
| allFileInfos: flat, |
| compoundFileInfos, |
| nonCompoundFileInfos |
| }; |
| }); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| export function saveMolFiles( |
| filename: string, |
| infos: ICmpdNonCmpdFileInfos |
| ): Promise<any> { |
| return saveTxtFiles(infos.allFileInfos, filename); |
| } |
|
|