From 50c372584ea18d777432e816d96726b34ab9931f Mon Sep 17 00:00:00 2001 From: yarong-lifemap <64833447+yarong-lifemap@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:25:53 +0800 Subject: [PATCH] Support comma-separated list of files as input --- src/index.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9401ba7..c56858f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -84,11 +84,6 @@ addBasicArgs(allParser); const args = parser.parse_args(); -if (!fs.existsSync(args.in)) { - console.error(`Input path "${args.in}" does not exist`); - process.exit(1); -} - if (!fs.existsSync(args.out)) { fs.mkdirSync(args.out, { recursive: true }); } @@ -103,10 +98,28 @@ export function getFileName(inPath: string) { } async function main() { - const renderer = new ImageRenderer(args.width, args.height, args.format, args.plddt, new FocusFirstResidue()); + // Support multiple, comma-separated files + var files:string[] = args.in.split(','); + + // Confirm all files exist + files.forEach(file => { + if (!fs.existsSync(file)) { + console.error(`Input path "${file}" does not exist`); + process.exit(1); + } + }); - const fileName = getFileName(args.in); - const cif = await readCifFile(args.in); + // Run the rendering process + files.forEach(async file => { + await renderFile(file); + }); +} + +async function renderFile(filePath: string) { + var fileName = getFileName(filePath); + + const renderer = new ImageRenderer(args.width, args.height, args.format, args.plddt, new FocusFirstResidue()); + const cif = await readCifFile(filePath); const trajectory = await getTrajectory(cif as CifFrame); switch (args.render) {