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

added chemCompType and other mol-script improvements

parent c28feb2d
No related branches found
No related tags found
No related merge requests found
...@@ -53,19 +53,30 @@ const atom = { ...@@ -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))), 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 = { const residue = {
key: p(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.residueIndex[l.element]), 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])), 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])), 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])), 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])), 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])), 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 // 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_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]]), 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 = { const chain = {
...@@ -107,7 +118,7 @@ function eK(l: StructureElement) { ...@@ -107,7 +118,7 @@ function eK(l: StructureElement) {
} }
const entity = { const entity = {
key: eK, key: p(eK),
id: p(l => l.unit.model.entities.data.id.value(eK(l))), id: p(l => l.unit.model.entities.data.id.value(eK(l))),
type: p(l => l.unit.model.entities.data.type.value(eK(l))), type: p(l => l.unit.model.entities.data.type.value(eK(l))),
......
...@@ -12,27 +12,36 @@ export namespace MolScriptBuilder { ...@@ -12,27 +12,36 @@ export namespace MolScriptBuilder {
export const core = SymbolTable.core; export const core = SymbolTable.core;
export const struct = SymbolTable.structureQuery; export const struct = SymbolTable.structureQuery;
/** Atom-name constructor */
export function atomName(s: string) { return struct.type.atomName([s]); } export function atomName(s: string) { return struct.type.atomName([s]); }
/** Element-symbol constructor */
export function es(s: string) { return struct.type.elementSymbol([s]); } export function es(s: string) { return struct.type.elementSymbol([s]); }
/** List constructor */
export function list(...xs: Expression[]) { return core.type.list(xs); } export function list(...xs: Expression[]) { return core.type.list(xs); }
/** Set constructor */
export function set(...xs: Expression[]) { return core.type.set(xs); } 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 fn(x: Expression) { return core.ctrl.fn([x]); }
export function evaluate(x: Expression) { return core.ctrl.eval([x]); } export function evaluate(x: Expression) { return core.ctrl.eval([x]); }
const _acp = struct.atomProperty.core, _ammp = struct.atomProperty.macromolecular, _atp = struct.atomProperty.topology; 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>)() }; 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>)() }; 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>)() }; export function ammp(p: keyof typeof _ammp) { return (_ammp[p] as MSymbol<any>)() };
// atom property sets
const _aps = struct.atomSet.propertySet const _aps = struct.atomSet.propertySet
/** atom core property set */
export function acpSet(p: keyof typeof _acp) { return _aps([ acp(p) ]) }; 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) ]) }; 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) ]) }; export function ammpSet(p: keyof typeof _ammp) { return _aps([ ammp(p) ]) };
} }
\ No newline at end of file
...@@ -300,9 +300,9 @@ const atomProperty = { ...@@ -300,9 +300,9 @@ const atomProperty = {
secondaryStructureKey: atomProp(Type.AnyValue, 'Unique value for each secondary structure element.'), secondaryStructureKey: atomProp(Type.AnyValue, 'Unique value for each secondary structure element.'),
secondaryStructureFlags: atomProp(Types.SecondaryStructureFlags), secondaryStructureFlags: atomProp(Types.SecondaryStructureFlags),
isModified: atomProp(Type.Bool, 'True if the atom bolongs to modification of a standard residue.'), 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.`), 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.`),
} }
} }
......
...@@ -301,15 +301,11 @@ const symbols = [ ...@@ -301,15 +301,11 @@ const symbols = [
D(MolScript.structureQuery.atomProperty.macromolecular.entityType, atomProp(StructureProperties.entity.type)), 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.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.isModified, atomProp(StructureProperties.residue.isModified)),
D(MolScript.structureQuery.atomProperty.macromolecular.modifiedParentName, (ctx, _) => { D(MolScript.structureQuery.atomProperty.macromolecular.modifiedParentName, atomProp(StructureProperties.residue.modifiedParentName)),
const id = StructureProperties.residue.label_comp_id(ctx.element); D(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey, atomProp(StructureProperties.residue.secondary_structure_key)),
return ctx.element.unit.model.properties.modifiedResidues.parentId.get(id) || id D(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, atomProp(StructureProperties.residue.secondary_structure_type)),
}) D(MolScript.structureQuery.atomProperty.macromolecular.chemCompType, atomProp(StructureProperties.residue.chem_comp_type)),
// TODO
// MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey
// MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureFlags
// ============= BOND PROPERTIES ================ // ============= BOND PROPERTIES ================
]; ];
......
...@@ -230,6 +230,7 @@ export const SymbolTable = [ ...@@ -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.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.entityType, 'atom.entity-type'),
Alias(MolScript.structureQuery.atomProperty.macromolecular.objectPrimitive, 'atom.object-primitive'), 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'), Alias(MolScript.structureQuery.atomProperty.macromolecular.secondaryStructureKey, 'atom.key.sec-struct'),
......
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