Skip to content
Snippets Groups Projects
Commit 9fe16e32 authored by Alexander Rose's avatar Alexander Rose
Browse files

add script to generate martini lipid names

parent 697e9986
No related branches found
No related tags found
No related merge requests found
...@@ -95,6 +95,10 @@ and navigate to `build/viewer` ...@@ -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/bird.ts -p BIRD
node ./lib/cli/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/cif-core.ts -p CifCore -aa
**Lipid names**
node .\lib\cli\lipid-params -o src\mol-model\structure\model\types\lipids.ts
**GraphQL schemas** **GraphQL schemas**
./node_modules/.bin/graphql-codegen -c ./src/extensions/rcsb/graphql/codegen.yml ./node_modules/.bin/graphql-codegen -c ./src/extensions/rcsb/graphql/codegen.yml
......
...@@ -9,9 +9,9 @@ import * as argparse from 'argparse'; ...@@ -9,9 +9,9 @@ import * as argparse from 'argparse';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import { UniqueArray } from '../../mol-data/generic';
const BUILD_DIR = path.resolve(__dirname, '../build/'); const LIPIDS_DIR = path.resolve(__dirname, '../../../build/lipids/');
const LIPIDS_DIR = path.resolve(BUILD_DIR, 'lipids/');
const MARTINI_LIPIDS_PATH = path.resolve(LIPIDS_DIR, 'martini_lipids.itp'); 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'; 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) { ...@@ -31,29 +31,58 @@ async function ensureAvailable(path: string, url: string) {
async function ensureLipidsAvailable() { await ensureAvailable(MARTINI_LIPIDS_PATH, MARTINI_LIPIDS_URL); } async function ensureLipidsAvailable() { await ensureAvailable(MARTINI_LIPIDS_PATH, MARTINI_LIPIDS_URL); }
async function run() { async function run(out: string) {
await ensureLipidsAvailable(); await ensureLipidsAvailable();
const lipidsItpStr = fs.readFileSync(MARTINI_LIPIDS_PATH, 'utf8'); const lipidsItpStr = fs.readFileSync(MARTINI_LIPIDS_PATH, 'utf8');
const m = lipidsItpStr.match(/\[moleculetype\]\n; molname nrexcl\n(DGPC)/g); const lipids = UniqueArray.create<string>();
console.log(m); 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({ const parser = new argparse.ArgumentParser({
addHelp: true, addHelp: true,
description: 'Create lipid params (from martini lipids itp)' 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' ], { parser.addArgument([ '--forceDownload', '-f' ], {
action: 'storeTrue', action: 'storeTrue',
help: 'Force download of martini lipids itp' help: 'Force download of martini lipids itp'
}); });
interface Args { interface Args {
out: string
forceDownload: boolean forceDownload: boolean
} }
const args: Args = parser.parseArgs(); const args: Args = parser.parseArgs();
const FORCE_DOWNLOAD = args.forceDownload; const FORCE_DOWNLOAD = args.forceDownload;
run().catch(e => { run(args.out || '').catch(e => {
console.error(e); console.error(e);
}); });
\ No newline at end of file
/**
* 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']);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment