From 4e6a08c93e28949eb830af813fe3a15c54d70db6 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Wed, 24 Oct 2018 14:50:42 -0700 Subject: [PATCH] added support for extra enum values to cif schema generator --- src/apps/schema-generator/util/cif-dic.ts | 21 +++++++++++++++++++++ src/mol-io/reader/cif/schema/mmcif.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/apps/schema-generator/util/cif-dic.ts b/src/apps/schema-generator/util/cif-dic.ts index 9b16bc602..8376fcb3d 100644 --- a/src/apps/schema-generator/util/cif-dic.ts +++ b/src/apps/schema-generator/util/cif-dic.ts @@ -189,6 +189,20 @@ const SEMICOLON_SEPARATED_LIST_FIELDS = [ '_chem_comp.pdbx_synonyms' // GLYCERIN; PROPANE-1,2,3-TRIOL ] +/** + * Useful when a dictionary extension will add enum values to an existing dictionary. + * By adding them here, the dictionary extension can be tested before the added enum + * values are available in the existing dictionary. + */ +const EXTRA_ENUM_VALUES: { [k: string]: string[] } = { + // TODO for carbohydrate extension draft, remove when added to chem_comp dic + '_pdbx_chem_comp_identifier.type': [ + 'CONDENSED IUPAC CARB SYMBOL', + 'IUPAC CARB SYMBOL', + 'SNFG CARB SYMBOL' + ] +} + export function generateSchema (frames: CifFrame[]) { const schema: Database = {} @@ -310,6 +324,13 @@ export function generateSchema (frames: CifFrame[]) { console.log(`forcing space separated: ${d.header}`) } } + if (d.header in EXTRA_ENUM_VALUES) { + if (fieldType.type === 'enum') { + fieldType.values.push(...EXTRA_ENUM_VALUES[d.header]) + } else { + console.warn(`expected enum: ${d.header}`) + } + } fields[itemName] = fieldType } else { console.log(`could not determine code for '${d.header}'`) diff --git a/src/mol-io/reader/cif/schema/mmcif.ts b/src/mol-io/reader/cif/schema/mmcif.ts index 8cb54134c..6f18cc2aa 100644 --- a/src/mol-io/reader/cif/schema/mmcif.ts +++ b/src/mol-io/reader/cif/schema/mmcif.ts @@ -1536,7 +1536,7 @@ export const mmCIF_Schema = { /** * This data item contains the identifier type. */ - type: Aliased<'COMMON NAME' | 'SYSTEMATIC NAME' | 'CAS REGISTRY NUMBER' | 'PUBCHEM Identifier' | 'MDL Identifier' | 'SYNONYM'>(str), + type: Aliased<'COMMON NAME' | 'SYSTEMATIC NAME' | 'CAS REGISTRY NUMBER' | 'PUBCHEM Identifier' | 'MDL Identifier' | 'SYNONYM' | 'CONDENSED IUPAC CARB SYMBOL' | 'IUPAC CARB SYMBOL' | 'SNFG CARB SYMBOL'>(str), /** * This data item contains the name of the program * or library used to compute the identifier. -- GitLab