diff --git a/README.md b/README.md index ec482ded23afc735536387d36d48703685b770cf..6b0635984d0ef7b12d9aab00848afeb97b440b7f 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,10 @@ and navigate to `build/viewer` 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 +**Lipid names** + + node .\lib\cli\lipid-params -o src\mol-model\structure\model\types\lipids.ts + **GraphQL schemas** ./node_modules/.bin/graphql-codegen -c ./src/extensions/rcsb/graphql/codegen.yml diff --git a/src/cli/lipid-params/index.ts b/src/cli/lipid-params/index.ts index 1aec421c4ea76e4b26f29974e3e19c80c95aa03a..2b91011085410c0b8bd8ade88005264223945419 100644 --- a/src/cli/lipid-params/index.ts +++ b/src/cli/lipid-params/index.ts @@ -9,9 +9,9 @@ import * as argparse from 'argparse'; import * as fs from 'fs'; import * as path from 'path'; import fetch from 'node-fetch'; +import { UniqueArray } from '../../mol-data/generic'; -const BUILD_DIR = path.resolve(__dirname, '../build/'); -const LIPIDS_DIR = path.resolve(BUILD_DIR, 'lipids/'); +const LIPIDS_DIR = path.resolve(__dirname, '../../../build/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'; @@ -31,29 +31,58 @@ async function ensureAvailable(path: string, url: string) { async function ensureLipidsAvailable() { await ensureAvailable(MARTINI_LIPIDS_PATH, MARTINI_LIPIDS_URL); } -async function run() { +async function run(out: string) { 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 lipids = UniqueArray.create<string>(); + const reLipid = /\[moleculetype\]\n; molname nrexcl\n +([a-zA-Z]{3,5})/g; + let m: RegExpExecArray | null; + + while ((m = reLipid.exec(lipidsItpStr)) !== null) { + const v = m[0].substr(m[0].lastIndexOf(' ') + 1); + UniqueArray.add(lipids, v, v); + } + + + const lipidNames = JSON.stringify(lipids.array); + + if (out) { + const output = `/** +* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. +* +* Code-generated lipid params file. Names extracted from Martini FF lipids itp. +* +* @author molstar/lipid-params cli +*/ + +export const LipidNames = new Set(${lipidNames.replace(/"/g, "'").replace(/,/g, ', ')}); +`; + fs.writeFileSync(out, output); + } else { + console.log(lipidNames); + } } const parser = new argparse.ArgumentParser({ addHelp: true, description: 'Create lipid params (from martini lipids itp)' }); +parser.addArgument([ '--out', '-o' ], { + help: 'Generated lipid params output path, if not given printed to stdout' +}); parser.addArgument([ '--forceDownload', '-f' ], { action: 'storeTrue', help: 'Force download of martini lipids itp' }); interface Args { + out: string forceDownload: boolean } const args: Args = parser.parseArgs(); const FORCE_DOWNLOAD = args.forceDownload; -run().catch(e => { +run(args.out || '').catch(e => { console.error(e); }); \ No newline at end of file diff --git a/src/mol-model/structure/model/types/lipids.ts b/src/mol-model/structure/model/types/lipids.ts new file mode 100644 index 0000000000000000000000000000000000000000..448af9e02792cf099de29ddfd5aa16789ad7f6ea --- /dev/null +++ b/src/mol-model/structure/model/types/lipids.ts @@ -0,0 +1,9 @@ +/** +* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. +* +* Code-generated lipid params file. Names extracted from Martini FF lipids itp. +* +* @author molstar/lipid-params cli +*/ + +export const LipidNames = new Set(['DAPC', 'DBPC', 'DFPC', 'DGPC', 'DIPC', 'DLPC', 'DNPC', 'DOPC', 'DPPC', 'DRPC', 'DTPC', 'DVPC', 'DXPC', 'DYPC', 'LPPC', 'PAPC', 'PEPC', 'PGPC', 'PIPC', 'POPC', 'PRPC', 'PUPC', 'DAPE', 'DBPE', 'DFPE', 'DGPE', 'DIPE', 'DLPE', 'DNPE', 'DOPE', 'DPPE', 'DRPE', 'DTPE', 'DUPE', 'DVPE', 'DXPE', 'DYPE', 'LPPE', 'PAPE', 'PGPE', 'PIPE', 'POPE', 'PQPE', 'PRPE', 'PUPE', 'DAPS', 'DBPS', 'DFPS', 'DGPS', 'DIPS', 'DLPS', 'DNPS', 'DOPS', 'DPPS', 'DRPS', 'DTPS', 'DUPS', 'DVPS', 'DXPS', 'DYPS', 'LPPS', 'PAPS', 'PGPS', 'PIPS', 'POPS', 'PQPS', 'PRPS', 'PUPS', 'DAPG', 'DBPG', 'DFPG', 'DGPG', 'DIPG', 'DLPG', 'DNPG', 'DOPG', 'DPPG', 'DRPG', 'DTPG', 'DVPG', 'DXPG', 'DYPG', 'LPPG', 'PAPG', 'PGPG', 'PIPG', 'POPG', 'PRPG', 'DAPA', 'DBPA', 'DFPA', 'DGPA', 'DIPA', 'DLPA', 'DNPA', 'DOPA', 'DPPA', 'DRPA', 'DTPA', 'DVPA', 'DXPA', 'DYPA', 'LPPA', 'PAPA', 'PGPA', 'PIPA', 'POPA', 'PRPA', 'PUPA', 'DPP', 'DPPI', 'PAPI', 'PIPI', 'POP', 'POPI', 'PUPI', 'PVP', 'PVPI', 'PADG', 'PIDG', 'PODG', 'PUDG', 'PVDG', 'APC', 'CPC', 'IPC', 'LPC', 'OPC', 'PPC', 'TPC', 'UPC', 'VPC', 'BNSM', 'DBSM', 'DPSM', 'DXSM', 'PGSM', 'PNSM', 'POSM', 'PVSM', 'XNSM', 'DPCE', 'DXCE', 'PNCE', 'XNCE']);