diff --git a/src/mol-model/structure/structure/properties.ts b/src/mol-model/structure/structure/properties.ts index 29c21954a09905c5bd67e6757e1d084b79b18887..8826d101929d44f7c0e7fe20cc171c38f7450796 100644 --- a/src/mol-model/structure/structure/properties.ts +++ b/src/mol-model/structure/structure/properties.ts @@ -53,19 +53,30 @@ const atom = { vdw_radius: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : VdwRadius(l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element))), } +function compId(l: StructureElement) { + return !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_comp_id.value(l.unit.residueIndex[l.element]) +} + const residue = { key: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.residueIndex[l.element]), group_PDB: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.group_PDB.value(l.unit.residueIndex[l.element])), - label_comp_id: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_comp_id.value(l.unit.residueIndex[l.element])), + label_comp_id: p(compId), auth_comp_id: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_comp_id.value(l.unit.residueIndex[l.element])), label_seq_id: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.label_seq_id.value(l.unit.residueIndex[l.element])), auth_seq_id: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.auth_seq_id.value(l.unit.residueIndex[l.element])), pdbx_PDB_ins_code: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(l.unit.residueIndex[l.element])), // Properties + isModified: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.modifiedResidues.parentId.has(compId(l))), + modifiedParentName: p(l => { + if (!Unit.isAtomic(l.unit)) notAtomic() + const id = compId(l) + return l.unit.model.properties.modifiedResidues.parentId.get(id) || id + }), secondary_structure_type: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.type[l.unit.residueIndex[l.element]]), secondary_structure_key: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.secondaryStructure.key[l.unit.residueIndex[l.element]]), + chem_comp_type: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.properties.chemicalComponentMap.get(compId(l))!.type), } const chain = { @@ -107,7 +118,7 @@ function eK(l: StructureElement) { } const entity = { - key: eK, + key: p(eK), id: p(l => l.unit.model.entities.data.id.value(eK(l))), type: p(l => l.unit.model.entities.data.type.value(eK(l))), diff --git a/src/mol-script/language/builder.ts b/src/mol-script/language/builder.ts index 8c7efa07de3d50d5890519d21fe76e2c3a5c668e..c114c0ff6307c5c2ed36ad44a35ff7a01a82c288 100644 --- a/src/mol-script/language/builder.ts +++ b/src/mol-script/language/builder.ts @@ -12,27 +12,36 @@ export namespace MolScriptBuilder { export const core = SymbolTable.core; export const struct = SymbolTable.structureQuery; + /** Atom-name constructor */ export function atomName(s: string) { return struct.type.atomName([s]); } + /** Element-symbol constructor */ export function es(s: string) { return struct.type.elementSymbol([s]); } + /** List constructor */ export function list(...xs: Expression[]) { return core.type.list(xs); } + /** Set constructor */ export function set(...xs: Expression[]) { return core.type.set(xs); } + /** RegEx constructor */ + export function re(pattern: string, flags?: string) { return core.type.regex([pattern, flags]); } + /** Function constructor */ export function fn(x: Expression) { return core.ctrl.fn([x]); } export function evaluate(x: Expression) { return core.ctrl.eval([x]); } const _acp = struct.atomProperty.core, _ammp = struct.atomProperty.macromolecular, _atp = struct.atomProperty.topology; - // atom core property + /** atom core property */ export function acp(p: keyof typeof _acp) { return (_acp[p] as MSymbol<any>)() }; - // atom topology property + /** atom topology property */ export function atp(p: keyof typeof _atp) { return (_atp[p] as MSymbol<any>)() }; - // atom macromolecular property + /** atom macromolecular property */ export function ammp(p: keyof typeof _ammp) { return (_ammp[p] as MSymbol<any>)() }; - // atom property sets const _aps = struct.atomSet.propertySet + /** atom core property set */ export function acpSet(p: keyof typeof _acp) { return _aps([ acp(p) ]) }; + /** atom topology property set */ export function atpSet(p: keyof typeof _atp) { return _aps([ atp(p) ]) }; + /** atom macromolecular property set */ export function ammpSet(p: keyof typeof _ammp) { return _aps([ ammp(p) ]) }; } \ No newline at end of file diff --git a/src/mol-script/language/symbol-table/structure-query.ts b/src/mol-script/language/symbol-table/structure-query.ts index 252c1b8ac59a79fa3641538fa1a9d49826c7e55e..c2b04dedc007cf87cfc8801283c56f94fef8787e 100644 --- a/src/mol-script/language/symbol-table/structure-query.ts +++ b/src/mol-script/language/symbol-table/structure-query.ts @@ -300,9 +300,9 @@ const atomProperty = { secondaryStructureKey: atomProp(Type.AnyValue, 'Unique value for each secondary structure element.'), secondaryStructureFlags: atomProp(Types.SecondaryStructureFlags), - isModified: atomProp(Type.Bool, 'True if the atom bolongs to modification of a standard residue.'), modifiedParentName: atomProp(Type.Str, `'3-letter' code of the modifed parent residue.`), + chemCompType: atomProp(Type.Str, `Type of the chemical component as defined in mmCIF.`), } } diff --git a/src/mol-script/runtime/query/table.ts b/src/mol-script/runtime/query/table.ts index eeb4edc181032ab037f7bb3d34a0af795237c38c..6ca3a8807d58f780018ef39f45c0b5249733a09a 100644 --- a/src/mol-script/runtime/query/table.ts +++ b/src/mol-script/runtime/query/table.ts @@ -301,15 +301,11 @@ const symbols = [ D(MolScript.structureQuery.atomProperty.macromolecular.entityType, atomProp(StructureProperties.entity.type)), D(MolScript.structureQuery.atomProperty.macromolecular.objectPrimitive, atomProp(StructureProperties.unit.object_primitive)), - D(MolScript.structureQuery.atomProperty.macromolecular.isModified, (ctx, _) => ctx.element.unit.model.properties.modifiedResidues.parentId.has(StructureProperties.residue.label_comp_id(ctx.element))), - D(MolScript.structureQuery.atomProperty.macromolecular.modifiedParentName, (ctx, _) => { - const id = StructureProperties.residue.label_comp_id(ctx.element); - return ctx.element.unit.model.properties.modifiedResidues.parentId.get(id) || id - }) - - // TODO - // MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey - // MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureFlags + D(MolScript.structureQuery.atomProperty.macromolecular.isModified, atomProp(StructureProperties.residue.isModified)), + D(MolScript.structureQuery.atomProperty.macromolecular.modifiedParentName, atomProp(StructureProperties.residue.modifiedParentName)), + D(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey, atomProp(StructureProperties.residue.secondary_structure_key)), + D(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, atomProp(StructureProperties.residue.secondary_structure_type)), + D(MolScript.structureQuery.atomProperty.macromolecular.chemCompType, atomProp(StructureProperties.residue.chem_comp_type)), // ============= BOND PROPERTIES ================ ]; diff --git a/src/mol-script/script/mol-script/symbols.ts b/src/mol-script/script/mol-script/symbols.ts index 7c2566ca43965fc9a510f29ecdafefe3daa66f28..2018030dcd72c9f37c3f67184634457e599655bd 100644 --- a/src/mol-script/script/mol-script/symbols.ts +++ b/src/mol-script/script/mol-script/symbols.ts @@ -230,6 +230,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.objectPrimitive, 'atom.object-primitive'), + Alias(MolScript.structureQuery.atomProperty.macromolecular.chemCompType, 'atom.chem-comp-type'), Alias(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey, 'atom.key.sec-struct'),