Browse Source

add ion & lipid as chem_comp type, charmm ion names

Alexander Rose 4 years ago
parent
commit
272e208fd4

+ 9 - 2
src/mol-io/reader/cif/schema/mmcif-extras.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -23,4 +23,11 @@ export const mmCIF_chemCompBond_schema = {
     ...mmCIF_Schema.chem_comp_bond,
     /** Indicates if the bond entry was taken from the protonation variant dictionary */
     molstar_protonation_variant: Column.Schema.Str()
-};
+};
+
+/** Has `type` extended with 'Ion' and 'Lipid' */
+export const mmCIF_chemComp_schema = {
+    ...mmCIF_Schema.chem_comp,
+    type: Column.Schema.Aliased<mmCIF_Schema['chem_comp']['type']['T'] | 'Ion' | 'Lipid'>(Column.Schema.str)
+};
+export type mmCIF_chemComp_schema = typeof mmCIF_chemComp_schema;

+ 3 - 2
src/mol-model-formats/structure/basic/schema.ts

@@ -6,6 +6,7 @@
 
 import { mmCIF_Schema } from '../../../mol-io/reader/cif/schema/mmcif';
 import { Table } from '../../../mol-data/db';
+import { mmCIF_chemComp_schema } from '../../../mol-io/reader/cif/schema/mmcif-extras';
 
 // TODO split into conformation and hierarchy parts
 
@@ -19,7 +20,7 @@ export type Entity = Table<mmCIF_Schema['entity']>
 export type EntityPoly = Table<mmCIF_Schema['entity_poly']>
 export type EntityPolySeq = Table<mmCIF_Schema['entity_poly_seq']>
 export type EntityBranch = Table<mmCIF_Schema['pdbx_entity_branch']>
-export type ChemComp = Table<mmCIF_Schema['chem_comp']>
+export type ChemComp = Table<mmCIF_chemComp_schema>
 export type ChemCompIdentifier = Table<mmCIF_Schema['pdbx_chem_comp_identifier']>
 export type AtomSite = Table<mmCIF_Schema['atom_site']>
 export type IhmSphereObjSite = Table<mmCIF_Schema['ihm_sphere_obj_site']>
@@ -38,7 +39,7 @@ export const BasicSchema = {
     entity_poly: mmCIF_Schema.entity_poly,
     entity_poly_seq: mmCIF_Schema.entity_poly_seq,
     pdbx_entity_branch: mmCIF_Schema.pdbx_entity_branch,
-    chem_comp: mmCIF_Schema.chem_comp,
+    chem_comp: mmCIF_chemComp_schema,
     pdbx_chem_comp_identifier: mmCIF_Schema.pdbx_chem_comp_identifier,
     atom_site: mmCIF_Schema.atom_site,
     ihm_sphere_obj_site: mmCIF_Schema.ihm_sphere_obj_site,

+ 25 - 6
src/mol-model-formats/structure/common/component.ts

@@ -5,12 +5,12 @@
  */
 
 import { Table, Column } from '../../../mol-data/db';
-import { mmCIF_Schema } from '../../../mol-io/reader/cif/schema/mmcif';
 import { WaterNames, PolymerNames } from '../../../mol-model/structure/model/types';
 import { SetUtils } from '../../../mol-util/set';
 import { BasicSchema } from '../basic/schema';
+import { mmCIF_chemComp_schema } from '../../../mol-io/reader/cif/schema/mmcif-extras';
 
-type Component = Table.Row<Pick<mmCIF_Schema['chem_comp'], 'id' | 'name' | 'type'>>
+type Component = Table.Row<Pick<mmCIF_chemComp_schema, 'id' | 'name' | 'type'>>
 
 const ProteinAtomIdsList = [
     new Set([ 'CA' ]),
@@ -71,13 +71,27 @@ const StandardComponents = (function() {
     return map;
 })();
 
+const CharmmIonComponents = (function() {
+    const map = new Map<string, Component>();
+    const components: Component[] = [
+        { id: 'ZN2', name: 'ZINC ION', type: 'Ion' },
+        { id: 'SOD', name: 'SODIUM ION', type: 'Ion' },
+        { id: 'CES', name: 'CESIUM ION', type: 'Ion' },
+        { id: 'CLA', name: 'CHLORIDE ION', type: 'Ion' },
+        { id: 'CAL', name: 'CALCIUM ION', type: 'Ion' },
+        { id: 'POT', name: 'POTASSIUM ION', type: 'Ion' },
+    ];
+    components.forEach(c => map.set(c.id, c));
+    return map;
+})();
+
 export class ComponentBuilder {
     private namesMap = new Map<string, string>()
     private comps = new Map<string, Component>()
     private ids: string[] = []
     private names: string[] = []
-    private types: mmCIF_Schema['chem_comp']['type']['T'][] = []
-    private mon_nstd_flags: mmCIF_Schema['chem_comp']['mon_nstd_flag']['T'][] = []
+    private types: mmCIF_chemComp_schema['type']['T'][] = []
+    private mon_nstd_flags: mmCIF_chemComp_schema['mon_nstd_flag']['T'][] = []
 
     private set(c: Component) {
         this.comps.set(c.id, c);
@@ -131,8 +145,13 @@ export class ComponentBuilder {
             } else if (WaterNames.has(compId)) {
                 this.set({ id: compId, name: 'WATER', type: 'non-polymer' });
             } else {
-                const type = this.getType(this.getAtomIds(index));
-                this.set({ id: compId, name: this.namesMap.get(compId) || compId, type });
+                const atomIds = this.getAtomIds(index);
+                if (CharmmIonComponents.has(compId) && atomIds.size === 1) {
+                    this.set(CharmmIonComponents.get(compId)!);
+                } else {
+                    const type = this.getType(atomIds);
+                    this.set({ id: compId, name: this.namesMap.get(compId) || compId, type });
+                }
             }
         }
         return this.get(compId)!;

+ 2 - 1
src/mol-model/structure/model/properties/common.ts

@@ -8,6 +8,7 @@
 import { mmCIF_Database, mmCIF_Schema } from '../../../../mol-io/reader/cif/schema/mmcif';
 import { Table, Column } from '../../../../mol-data/db';
 import { EntityIndex } from '../indexing';
+import { mmCIF_chemComp_schema } from '../../../../mol-io/reader/cif/schema/mmcif-extras';
 
 export type EntitySubtype = (
     mmCIF_Schema['entity_poly']['type']['T'] |
@@ -24,7 +25,7 @@ export interface Entities {
     getEntityIndex(id: string): EntityIndex
 }
 
-export type ChemicalComponent = Table.Row<mmCIF_Schema['chem_comp']>
+export type ChemicalComponent = Table.Row<mmCIF_chemComp_schema>
 export type ChemicalComponentMap = ReadonlyMap<string, ChemicalComponent>
 
 export type MissingResidue = Table.Row<Pick<mmCIF_Schema['pdbx_unobs_or_zero_occ_residues'], 'polymer_flag' | 'occupancy_flag'>>

+ 14 - 3
src/mol-model/structure/model/types.ts

@@ -11,6 +11,7 @@ import { mmCIF_Schema } from '../../../mol-io/reader/cif/schema/mmcif';
 import { SetUtils } from '../../../mol-util/set';
 import { EntitySubtype, ChemicalComponent } from './properties/common';
 import { LipidNames } from './types/lipids';
+import { mmCIF_chemComp_schema } from '../../../mol-io/reader/cif/schema/mmcif-extras';
 
 const _esCache = (function () {
     const cache = Object.create(null);
@@ -225,6 +226,16 @@ export const OtherComponentTypeNames = new Set([
     'NON-POLYMER', 'OTHER'
 ]);
 
+/** Chemical component type names for ion (extension to mmcif) */
+export const IonComponentTypeNames = new Set([
+    'ION'
+]);
+
+/** Chemical component type names for lipid (extension to mmcif) */
+export const LipidComponentTypeNames = new Set([
+    'LIPID'
+]);
+
 /** Common names for water molecules */
 export const WaterNames = new Set([
     'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP', 'TIP3', 'TIP4', 'SPC'
@@ -333,7 +344,7 @@ export function getPolymerType(compType: string, molType: MoleculeType): Polymer
     }
 }
 
-export function getComponentType(compId: string): mmCIF_Schema['chem_comp']['type']['T'] {
+export function getComponentType(compId: string): mmCIF_chemComp_schema['type']['T'] {
     compId = compId.toUpperCase();
     if (AminoAcidNames.has(compId)) {
         return 'peptide linking';
@@ -400,9 +411,9 @@ export function getEntitySubtype(compId: string, compType: string): EntitySubtyp
         return 'polyribonucleotide';
     } else if (DnaBaseNames.has(compId)) {
         return 'polydeoxyribonucleotide';
-    } else if (IonNames.has(compId)) {
+    } else if (IonComponentTypeNames.has(compType) || IonNames.has(compId)) {
         return 'ion';
-    } else if (LipidNames.has(compId)) {
+    } else if (LipidComponentTypeNames.has(compType) || LipidNames.has(compId)) {
         return 'lipid';
     } else {
         return 'other';