From 8891fa328bc519fefb66ff77d7cb4eccfe8387bb Mon Sep 17 00:00:00 2001 From: dsehnal <david.sehnal@gmail.com> Date: Fri, 25 Mar 2022 13:45:00 +0100 Subject: [PATCH] cif2bcif BCIF => CIF conversion support --- CHANGELOG.md | 4 ++++ README.md | 7 ++++++- src/cli/cif2bcif/converter.ts | 2 +- src/cli/cif2bcif/index.ts | 8 ++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d991f9b8..0a33a8c1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ Note that since we don't clearly distinguish between a public and private interf ## [Unreleased] + +## [v3.5.0] - 2022-03-25 + - Fix issues with bounding-sphere & color-smoothing (mostly for small geometries) +- Support BCIF => CIF conversion in ``cif2bcif`` CLI tool ## [v3.4.0] - 2022-03-13 diff --git a/README.md b/README.md index 8a5f27cc8..10e926c50 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ and navigate to `build/viewer` export NODE_PATH="lib"; node build/state-docs -**Convert any CIF to BinaryCIF** +**Convert any CIF to BinaryCIF (or vice versa)** node lib/commonjs/servers/model/preprocess -i file.cif -ob file.bcif @@ -151,6 +151,11 @@ Or node lib/commonjs/cli/cif2bcif +E.g. + + node lib/commonjs/cli/cif2bcif src.cif out.bcif.gz + node lib/commonjs/cli/cif2bcif src.bcif.gz out.cif + ## Development ### Installation diff --git a/src/cli/cif2bcif/converter.ts b/src/cli/cif2bcif/converter.ts index bb931ea6d..e740bb4aa 100644 --- a/src/cli/cif2bcif/converter.ts +++ b/src/cli/cif2bcif/converter.ts @@ -71,7 +71,7 @@ function classify(name: string, field: CifField): CifWriter.Field { } export function convert(path: string, asText = false, hints?: EncodingStrategyHint[], filter?: string) { - return Task.create<Uint8Array>('BinaryCIF', async ctx => { + return Task.create<Uint8Array>('Convert CIF', async ctx => { const encodingProvider: BinaryEncodingProvider = hints ? CifWriter.createEncodingProviderFromJsonConfig(hints) : { get: (c, f) => void 0 }; diff --git a/src/cli/cif2bcif/index.ts b/src/cli/cif2bcif/index.ts index 5dcd39af5..0c3507260 100644 --- a/src/cli/cif2bcif/index.ts +++ b/src/cli/cif2bcif/index.ts @@ -18,7 +18,7 @@ async function process(srcPath: string, outPath: string, configPath?: string, fi const config = configPath ? JSON.parse(fs.readFileSync(configPath, 'utf8')) : void 0; const filter = filterPath ? fs.readFileSync(filterPath, 'utf8') : void 0; - const res = await convert(srcPath, false, config, filter); + const res = await convert(srcPath, srcPath.toLowerCase().indexOf('.bcif') > 0, config, filter); await write(outPath, res); } @@ -38,13 +38,13 @@ function run(args: Args) { const parser = new argparse.ArgumentParser({ add_help: true, - description: 'Convert any CIF file to a BCIF file' + description: 'Convert any BCIF file to a CIF file or vice versa' }); parser.add_argument('src', { - help: 'Source CIF path' + help: 'Source file path' }); parser.add_argument('out', { - help: 'Output BCIF path' + help: 'Output file path' }); parser.add_argument('-c', '--config', { help: 'Optional encoding strategy/precision config path', -- GitLab