ソースを参照

add prd_id as entity property, treat prd as ligand

Alexander Rose 4 年 前
コミット
2142290300

+ 24 - 3
src/mol-model-formats/structure/basic/entities.ts

@@ -8,10 +8,10 @@
 import { Column, Table } from '../../../mol-data/db';
 import { Entities, EntitySubtype } from '../../../mol-model/structure/model/properties/common';
 import { getEntityType, getEntitySubtype } from '../../../mol-model/structure/model/types';
-import { ElementIndex, EntityIndex } from '../../../mol-model/structure/model';
+import { ElementIndex, EntityIndex, Model } from '../../../mol-model/structure/model';
 import { BasicData, BasicSchema, Entity } from './schema';
 
-export function getEntities(data: BasicData): Entities {
+export function getEntities(data: BasicData, properties: Model['properties']): Entities {
     let entityData: Entity;
 
     if (!data.entity.id.isDefined) {
@@ -118,5 +118,26 @@ export function getEntities(data: BasicData): Entities {
 
     //
 
-    return { data: entityData, subtype: subtypeColumn, getEntityIndex };
+    const prdIds: string[] = new Array(entityData._rowCount);
+    prdIds.fill('');
+
+    if (data.pdbx_molecule && data.pdbx_molecule.prd_id.isDefined) {
+        const { asym_id, prd_id, _rowCount } = data.pdbx_molecule;
+        for (let i = 0; i < _rowCount; ++i) {
+            const asymId = asym_id.value(i);
+            const entityId = properties.structAsymMap.get(asymId)?.entity_id;
+            if (entityId !== undefined) {
+                prdIds[getEntityIndex(entityId)] = prd_id.value(i);
+            }
+        }
+    }
+
+    const prdIdColumn = Column.ofArray({ array: prdIds, schema: Column.Schema.str });
+
+    return {
+        data: entityData,
+        subtype: subtypeColumn,
+        prd_id: prdIdColumn,
+        getEntityIndex
+    };
 }

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

@@ -134,7 +134,7 @@ async function readStandard(ctx: RuntimeContext, data: BasicData, properties: Mo
 
     if (data.atom_site) {
         const atomCount = data.atom_site.id.rowCount;
-        const entities = getEntities(data);
+        const entities = getEntities(data, properties);
 
         let modelStart = 0;
         while (modelStart < atomCount) {
@@ -168,7 +168,7 @@ function splitTable<T extends Table<any>>(table: T, col: Column<number>) {
 
 
 async function readIntegrative(ctx: RuntimeContext, data: BasicData, properties: Model['properties'], format: ModelFormat) {
-    const entities = getEntities(data);
+    const entities = getEntities(data, properties);
     // when `atom_site.ihm_model_id` is undefined fall back to `atom_site.pdbx_PDB_model_num`
     const atom_sites_modelColumn = data.atom_site.ihm_model_id.isDefined
         ? data.atom_site.ihm_model_id : data.atom_site.pdbx_PDB_model_num;

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

@@ -25,6 +25,7 @@ export type AtomSite = Table<mmCIF_Schema['atom_site']>
 export type IhmSphereObjSite = Table<mmCIF_Schema['ihm_sphere_obj_site']>
 export type IhmGaussianObjSite =Table<mmCIF_Schema['ihm_gaussian_obj_site']>
 export type UnobsOrZeroOccResidues =Table<mmCIF_Schema['pdbx_unobs_or_zero_occ_residues']>
+export type Molecule =Table<mmCIF_Schema['pdbx_molecule']>
 
 export const BasicSchema = {
     entry: mmCIF_Schema.entry,
@@ -43,6 +44,7 @@ export const BasicSchema = {
     ihm_sphere_obj_site: mmCIF_Schema.ihm_sphere_obj_site,
     ihm_gaussian_obj_site: mmCIF_Schema.ihm_gaussian_obj_site,
     pdbx_unobs_or_zero_occ_residues: mmCIF_Schema.pdbx_unobs_or_zero_occ_residues,
+    pdbx_molecule: mmCIF_Schema.pdbx_molecule,
 };
 
 export interface BasicData {
@@ -62,6 +64,7 @@ export interface BasicData {
     ihm_sphere_obj_site: IhmSphereObjSite
     ihm_gaussian_obj_site: IhmGaussianObjSite
     pdbx_unobs_or_zero_occ_residues: UnobsOrZeroOccResidues
+    pdbx_molecule: Molecule
 }
 
 export function createBasic(data: Partial<BasicData>): BasicData {

+ 0 - 9
src/mol-model-formats/structure/mmcif.ts

@@ -84,15 +84,6 @@ namespace MmcifFormat {
         if (!db) db = CIF.schema.mmCIF(frame);
         return { kind: 'mmCIF', name: db._name, data: { db, frame } };
     }
-
-    export function isBirdMolecule(model: Model, asymId: string) {
-        if (!MmcifFormat.is(model.sourceData)) return false;
-        const { _rowCount, asym_id } = model.sourceData.data.db.pdbx_molecule;
-        for (let i = 0, il = _rowCount; i < il; ++i) {
-            if (asym_id.value(i) === asymId) return true;
-        }
-        return false;
-    }
 }
 
 export function trajectoryFromMmCIF(frame: CifFrame): Task<Model.Trajectory> {

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

@@ -18,6 +18,7 @@ export const EntitySubtype = Column.Schema.Aliased<EntitySubtype>(Column.Schema.
 export interface Entities {
     data: mmCIF_Database['entity'],
     subtype: Column<EntitySubtype>,
+    prd_id: Column<string>,
     getEntityIndex(id: string): EntityIndex
 }
 

+ 4 - 2
src/mol-model/structure/structure/properties.ts

@@ -157,7 +157,6 @@ const entity = {
 
     id: p(l => l.unit.model.entities.data.id.value(eK(l))),
     type: p(l => l.unit.model.entities.data.type.value(eK(l))),
-    subtype: p(l => l.unit.model.entities.subtype.value(eK(l))),
     src_method: p(l => l.unit.model.entities.data.src_method.value(eK(l))),
     pdbx_description: p(l => l.unit.model.entities.data.pdbx_description.value(eK(l))),
     formula_weight: p(l => l.unit.model.entities.data.formula_weight.value(eK(l))),
@@ -165,7 +164,10 @@ const entity = {
     details: p(l => l.unit.model.entities.data.details.value(eK(l))),
     pdbx_mutation: p(l => l.unit.model.entities.data.pdbx_mutation.value(eK(l))),
     pdbx_fragment: p(l => l.unit.model.entities.data.pdbx_fragment.value(eK(l))),
-    pdbx_ec: p(l => l.unit.model.entities.data.pdbx_ec.value(eK(l)))
+    pdbx_ec: p(l => l.unit.model.entities.data.pdbx_ec.value(eK(l))),
+
+    subtype: p(l => l.unit.model.entities.subtype.value(eK(l))),
+    prd_id: p(l => l.unit.model.entities.prd_id.value(eK(l))),
 };
 
 const _emptyList: any[] = [];

+ 4 - 1
src/mol-plugin-state/helpers/structure-selection-query.ts

@@ -301,7 +301,10 @@ const ligand = StructureSelectionQuery('Ligand', MS.struct.modifier.union([
         MS.struct.modifier.union([
             MS.struct.generator.atomGroups({
                 'entity-test': MS.core.logic.and([
-                    MS.core.rel.eq([MS.ammp('entityType'), 'non-polymer']),
+                    MS.core.logic.or([
+                        MS.core.rel.eq([MS.ammp('entityType'), 'non-polymer']),
+                        MS.core.rel.neq([MS.ammp('entityPrdId'), ''])
+                    ]),
                     MS.core.logic.not([MS.core.str.match([
                         MS.re('oligosaccharide', 'i'),
                         MS.ammp('entitySubtype')

+ 1 - 3
src/mol-plugin-ui/structure/focus.tsx

@@ -6,7 +6,6 @@
 
 import * as React from 'react';
 import { OrderedSet, SortedArray } from '../../mol-data/int';
-import { MmcifFormat } from '../../mol-model-formats/structure/mmcif';
 import { Structure, StructureElement, StructureProperties, Unit } from '../../mol-model/structure';
 import { UnitIndex } from '../../mol-model/structure/structure/element/element';
 import { FocusEntry } from '../../mol-plugin-state/manager/structure/focus';
@@ -66,8 +65,7 @@ function getFocusEntries(structure: Structure) {
         const entityType = StructureProperties.entity.type(l);
         const isPolymer = entityType === 'non-polymer';
         const isBranched = entityType === 'branched';
-        const asymId = StructureProperties.chain.label_asym_id(l);
-        const isBirdMolecule = MmcifFormat.isBirdMolecule(l.unit.model, asymId);
+        const isBirdMolecule = !!StructureProperties.entity.prd_id(l);
 
         if (isBirdMolecule) {
             addSymmetryGroupEntries(entityEntries, l, ug, 'chain');

+ 1 - 0
src/mol-script/language/symbol-table/structure-query.ts

@@ -308,6 +308,7 @@ const atomProperty = {
 
         entityType: atomProp(Types.EntityType, 'Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)'),
         entitySubtype: atomProp(Types.EntitySubtype, 'Subtype of the entity as defined in mmCIF _entity_poly.type and _pdbx_entity_branch.type (other, polypeptide(D), polypeptide(L), polydeoxyribonucleotide, polyribonucleotide, polydeoxyribonucleotide/polyribonucleotide hybrid, cyclic-pseudo-peptide, peptide nucleic acid, oligosaccharide)'),
+        entityPrdId: atomProp(Type.Str, `The PRD ID of the entity.`),
         entityDescription: atomProp(Core.Types.List(Type.Str)),
         objectPrimitive: atomProp(Types.ObjectPrimitive, 'Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)'),
 

+ 1 - 0
src/mol-script/runtime/query/table.ts

@@ -336,6 +336,7 @@ const symbols = [
 
     D(MolScript.structureQuery.atomProperty.macromolecular.entityType, atomProp(StructureProperties.entity.type)),
     D(MolScript.structureQuery.atomProperty.macromolecular.entitySubtype, atomProp(StructureProperties.entity.subtype)),
+    D(MolScript.structureQuery.atomProperty.macromolecular.entityPrdId, atomProp(StructureProperties.entity.prd_id)),
     D(MolScript.structureQuery.atomProperty.macromolecular.entityDescription, atomProp(StructureProperties.entity.pdbx_description)),
     D(MolScript.structureQuery.atomProperty.macromolecular.objectPrimitive, atomProp(StructureProperties.unit.object_primitive)),
 

+ 1 - 0
src/mol-script/script/mol-script/symbols.ts

@@ -234,6 +234,7 @@ export const SymbolTable = [
             Alias(MolScript.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, 'atom.B_iso_or_equiv', 'atom.bfactor'),
             Alias(MolScript.structureQuery.atomProperty.macromolecular.entityType, 'atom.entity-type'),
             Alias(MolScript.structureQuery.atomProperty.macromolecular.entitySubtype, 'atom.entity-subtype'),
+            Alias(MolScript.structureQuery.atomProperty.macromolecular.entityPrdId, 'atom.entity-prd-id'),
             Alias(MolScript.structureQuery.atomProperty.macromolecular.entityDescription, 'atom.entity-description'),
             Alias(MolScript.structureQuery.atomProperty.macromolecular.objectPrimitive, 'atom.object-primitive'),
             Alias(MolScript.structureQuery.atomProperty.macromolecular.chemCompType, 'atom.chem-comp-type'),