diff --git a/.gitignore b/.gitignore index 202483f20b4c9c40df2adaae5ca2e5e127fbd198..d0ab23e573a48452cf041ef47f8ee17a14574a97 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ node_modules/ debug.log npm-debug.log tsconfig.tsbuildinfo +tsconfig.servers.tsbuildinfo *.sublime-workspace .idea diff --git a/README.md b/README.md index d30244e44e42a736fc6927f754fc05308cce5fc9..ec482ded23afc735536387d36d48703685b770cf 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Moreover, the project contains the implementation of `servers`, including - `servers/volume` A tool for accessing volumetric experimental data related to molecular structures. - `servers/plugin-state` A basic server to store Mol* Plugin states. -The project also contains performance tests (`perf-tests`), `examples`, and basic proof of concept `apps` (CIF to BinaryCIF converter and JSON domain annotation to CIF converter). +The project also contains performance tests (`perf-tests`), `examples`, and basic proof of concept `cli` apps (CIF to BinaryCIF converter and JSON domain annotation to CIF converter). ## Previous Work This project builds on experience from previous solutions: @@ -90,10 +90,10 @@ and navigate to `build/viewer` ### Code generation **CIF schemas** - node ./lib/apps/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/mmcif.ts -p mmCIF - node ./lib/apps/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/ccd.ts -p CCD - node ./lib/apps/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/bird.ts -p BIRD - node ./lib/apps/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/cif-core.ts -p CifCore -aa + node ./lib/cli/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/mmcif.ts -p mmCIF + node ./lib/cli/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/ccd.ts -p CCD + node ./lib/cli/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/bird.ts -p BIRD + node ./lib/cli/cifschema -mip ../../../../mol-data -o src/mol-io/reader/cif/schema/cif-core.ts -p CifCore -aa **GraphQL schemas** @@ -102,7 +102,7 @@ and navigate to `build/viewer` ### Other scripts **Create chem comp bond table** - node --max-old-space-size=4096 lib/apps/chem-comp-bond/create-table.js build/data/ccb.bcif -b + node --max-old-space-size=4096 lib/cli/chem-comp-bond/create-table.js build/data/ccb.bcif -b **Test model server** @@ -120,7 +120,7 @@ To see all available commands, use ``node lib/servers/model/preprocess -h``. Or - node ./lib/apps/cif2bcif + node ./lib/cli/cif2bcif ## Development diff --git a/package.json b/package.json index c5aab99a0063b70f2b335a37dc7cc21a2ad1b4a5..72986faaf46071e3088f27ad8e75eed01099c252 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "build/viewer/" ], "bin": { - "cif2bcif": "lib/apps/cif2bcif/index.js", - "cifschema": "lib/apps/cifschema/index.js", + "cif2bcif": "lib/cli/cif2bcif/index.js", + "cifschema": "lib/cli/cifschema/index.js", "model-server": "lib/servers/servers/model/server.js", "model-server-query": "lib/servers/servers/model/query.js", "model-server-preprocess": "lib/servers/servers/model/preprocess.js", diff --git a/src/apps/chem-comp-bond/create-table.ts b/src/cli/chem-comp-bond/create-table.ts similarity index 99% rename from src/apps/chem-comp-bond/create-table.ts rename to src/cli/chem-comp-bond/create-table.ts index ef09d66cc33f6ebcda90bd9ab421a099e388804a..1837028e6133c54ec47fd13567d3c104eb67283d 100644 --- a/src/apps/chem-comp-bond/create-table.ts +++ b/src/cli/chem-comp-bond/create-table.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/apps/cif2bcif/converter.ts b/src/cli/cif2bcif/converter.ts similarity index 100% rename from src/apps/cif2bcif/converter.ts rename to src/cli/cif2bcif/converter.ts diff --git a/src/apps/cif2bcif/index.ts b/src/cli/cif2bcif/index.ts similarity index 98% rename from src/apps/cif2bcif/index.ts rename to src/cli/cif2bcif/index.ts index c3b278d6f7532eec5b8c937aa0e9d479dc9811b2..c862695ec4389df4d8e3991eff6237fe02d8e9ab 100644 --- a/src/apps/cif2bcif/index.ts +++ b/src/cli/cif2bcif/index.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/apps/cifschema/index.ts b/src/cli/cifschema/index.ts similarity index 99% rename from src/apps/cifschema/index.ts rename to src/cli/cifschema/index.ts index b20754ce80ed6fc707a7fcc6891b0b7d8cb4abec..41032a0384b07118c07d28343e6be33d903e2f20 100644 --- a/src/apps/cifschema/index.ts +++ b/src/cli/cifschema/index.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/apps/cifschema/util/cif-dic.ts b/src/cli/cifschema/util/cif-dic.ts similarity index 100% rename from src/apps/cifschema/util/cif-dic.ts rename to src/cli/cifschema/util/cif-dic.ts diff --git a/src/apps/cifschema/util/generate.ts b/src/cli/cifschema/util/generate.ts similarity index 100% rename from src/apps/cifschema/util/generate.ts rename to src/cli/cifschema/util/generate.ts diff --git a/src/apps/cifschema/util/helper.ts b/src/cli/cifschema/util/helper.ts similarity index 100% rename from src/apps/cifschema/util/helper.ts rename to src/cli/cifschema/util/helper.ts diff --git a/src/apps/cifschema/util/schema.ts b/src/cli/cifschema/util/schema.ts similarity index 100% rename from src/apps/cifschema/util/schema.ts rename to src/cli/cifschema/util/schema.ts diff --git a/src/cli/lipid-params/index.ts b/src/cli/lipid-params/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aec421c4ea76e4b26f29974e3e19c80c95aa03a --- /dev/null +++ b/src/cli/lipid-params/index.ts @@ -0,0 +1,59 @@ +#!/usr/bin/env node +/** + * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * + * @author Alexander Rose <alexander.rose@weirdbyte.de> + */ + +import * as argparse from 'argparse'; +import * as fs from 'fs'; +import * as path from 'path'; +import fetch from 'node-fetch'; + +const BUILD_DIR = path.resolve(__dirname, '../build/'); +const LIPIDS_DIR = path.resolve(BUILD_DIR, 'lipids/'); + +const MARTINI_LIPIDS_PATH = path.resolve(LIPIDS_DIR, 'martini_lipids.itp'); +const MARTINI_LIPIDS_URL = 'http://www.cgmartini.nl/images/parameters/lipids/Collections/martini_v2.0_lipids_all_201506.itp'; + +async function ensureAvailable(path: string, url: string) { + if (FORCE_DOWNLOAD || !fs.existsSync(path)) { + const name = url.substr(url.lastIndexOf('/') + 1); + console.log(`downloading ${name}...`); + const data = await fetch(url); + if (!fs.existsSync(LIPIDS_DIR)) { + fs.mkdirSync(LIPIDS_DIR); + } + fs.writeFileSync(path, await data.text()); + console.log(`done downloading ${name}`); + } +} + +async function ensureLipidsAvailable() { await ensureAvailable(MARTINI_LIPIDS_PATH, MARTINI_LIPIDS_URL); } + +async function run() { + await ensureLipidsAvailable(); + const lipidsItpStr = fs.readFileSync(MARTINI_LIPIDS_PATH, 'utf8'); + + const m = lipidsItpStr.match(/\[moleculetype\]\n; molname nrexcl\n(DGPC)/g); + console.log(m); +} + +const parser = new argparse.ArgumentParser({ + addHelp: true, + description: 'Create lipid params (from martini lipids itp)' +}); +parser.addArgument([ '--forceDownload', '-f' ], { + action: 'storeTrue', + help: 'Force download of martini lipids itp' +}); +interface Args { + forceDownload: boolean +} +const args: Args = parser.parseArgs(); + +const FORCE_DOWNLOAD = args.forceDownload; + +run().catch(e => { + console.error(e); +}); \ No newline at end of file diff --git a/src/apps/state-docs/index.ts b/src/cli/state-docs/index.ts similarity index 99% rename from src/apps/state-docs/index.ts rename to src/cli/state-docs/index.ts index bdc50e6540969bcdad9f5dd18379d925ef295968..36ed9a90370785d0c9cfe3a03667fd0c510a6c00 100644 --- a/src/apps/state-docs/index.ts +++ b/src/cli/state-docs/index.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/apps/state-docs/pd-to-md.ts b/src/cli/state-docs/pd-to-md.ts similarity index 100% rename from src/apps/state-docs/pd-to-md.ts rename to src/cli/state-docs/pd-to-md.ts diff --git a/src/apps/structure-info/helpers.ts b/src/cli/structure-info/helpers.ts similarity index 100% rename from src/apps/structure-info/helpers.ts rename to src/cli/structure-info/helpers.ts diff --git a/src/apps/structure-info/model.ts b/src/cli/structure-info/model.ts similarity index 99% rename from src/apps/structure-info/model.ts rename to src/cli/structure-info/model.ts index f50df0dabbba7fca69977bd25b33b63b7d162b90..39c9f73ed0bf2472f13d68326402f047c36d959b 100644 --- a/src/apps/structure-info/model.ts +++ b/src/cli/structure-info/model.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/apps/structure-info/volume.ts b/src/cli/structure-info/volume.ts similarity index 99% rename from src/apps/structure-info/volume.ts rename to src/cli/structure-info/volume.ts index cfedb46e9e4a7d520469ca3b1206d1992a0d5522..27b13ba0ef4d3da9acaa077a5d8e825655f01f9b 100644 --- a/src/apps/structure-info/volume.ts +++ b/src/cli/structure-info/volume.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node /** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * diff --git a/src/perf-tests/mol-script.ts b/src/perf-tests/mol-script.ts index 3b4fc50308bd02c3add42349b52764e91e292dff..8e4481de2e8f825cb92995483c569617ca045e98 100644 --- a/src/perf-tests/mol-script.ts +++ b/src/perf-tests/mol-script.ts @@ -1,7 +1,7 @@ import { MolScriptBuilder } from '../mol-script/language/builder'; import { compile, QuerySymbolRuntime, DefaultQueryRuntimeTable } from '../mol-script/runtime/query/compiler'; import { QueryContext, Structure, StructureQuery } from '../mol-model/structure'; -import { readCifFile, getModelsAndStructure } from '../apps/structure-info/model'; +import { readCifFile, getModelsAndStructure } from '../cli/structure-info/model'; import { CustomPropSymbol } from '../mol-script/language/symbol'; import Type from '../mol-script/language/type'; import { parseMolScript } from '../mol-script/language/parser'; diff --git a/tsconfig.json b/tsconfig.json index df2e30317fdbe4978f627bbcf653542fcf177761..8f10a37beac04837f85deb26722801e27dc9888a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,5 @@ "outDir": "lib" }, "include": [ "src/**/*" ], - "exclude": [ "src/servers/**/*" ] + "exclude": [ "src/servers/**/*", "src/perf-tests/*", "src/cli/**/*" ] } \ No newline at end of file diff --git a/tsconfig.servers.json b/tsconfig.servers.json index 023a1cec328f2f528b4e9a510d4f85f5e7db6a28..0a29bd69b8b6e471f0bc766923224a9a61f396e6 100644 --- a/tsconfig.servers.json +++ b/tsconfig.servers.json @@ -17,7 +17,7 @@ "jsx": "react", "lib": [ "es6", "dom", "esnext.asynciterable", "es2016" ], "rootDir": "src", - "outDir": "lib/servers" + "outDir": "lib" }, - "include": [ "src/servers/**/*", "src/perf-tests/*" ] + "include": [ "src/servers/**/*", "src/perf-tests/*", "src/cli/**/*" ] } \ No newline at end of file