Explorar el Código

added sourceIndex property to mol-script

David Sehnal hace 6 años
padre
commit
a5286338bf

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

@@ -292,6 +292,7 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format, formatData: Fo
     const atom_sites = splitTable(format.data.atom_site, format.data.atom_site.ihm_model_id);
     // TODO: will coarse IHM records require sorting or will we trust it?
     // ==> Probably implement a sort as as well and store the sourceIndex same as with atomSite
+    // If the sorting is implemented, updated mol-model/structure/properties: atom.sourceIndex
     const sphere_sites = splitTable(format.data.ihm_sphere_obj_site, format.data.ihm_sphere_obj_site.model_id);
     const gauss_sites = splitTable(format.data.ihm_gaussian_obj_site, format.data.ihm_gaussian_obj_site.model_id);
 

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

@@ -35,6 +35,10 @@ const atom = {
     id: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicConformation.atomId.value(l.element)),
     occupancy: StructureElement.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.occupancy.value(l.element)),
     B_iso_or_equiv: StructureElement.property(l => !Unit.isAtomic(l.unit) ?  notAtomic() : l.unit.model.atomicConformation.B_iso_or_equiv.value(l.element)),
+    sourceIndex: StructureElement.property(l => Unit.isAtomic(l.unit)
+        ? l.unit.model.atomicHierarchy.atoms.sourceIndex.value(l.element)
+        // TODO: when implemented, this should map to the source index.
+        : l.element),
 
     // Hierarchy
     type_symbol: StructureElement.property(l => !Unit.isAtomic(l.unit) ? notAtomic() : l.unit.model.atomicHierarchy.atoms.type_symbol.value(l.element)),

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

@@ -242,7 +242,9 @@ const atomProperty = {
         bondCount: symbol(Arguments.Dictionary({
             0: Argument(Types.ElementReference, { isOptional: true, defaultValue: 'slot.current-atom' }),
             flags: Argument(Types.BondFlags, { isOptional: true, defaultValue: 'covalent' as any }),
-        }), Type.Num, 'Number of bonds (by default only covalent bonds are counted).')
+        }), Type.Num, 'Number of bonds (by default only covalent bonds are counted).'),
+
+        sourceIndex: atomProp(Type.Num, 'Index of the atom/element in the input file.'),
     },
 
     topology: {

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

@@ -205,6 +205,7 @@ const symbols = [
     D(MolScript.structureQuery.atomProperty.core.x, atomProp(StructureProperties.atom.x)),
     D(MolScript.structureQuery.atomProperty.core.y, atomProp(StructureProperties.atom.y)),
     D(MolScript.structureQuery.atomProperty.core.z, atomProp(StructureProperties.atom.z)),
+    D(MolScript.structureQuery.atomProperty.core.sourceIndex, atomProp(StructureProperties.atom.sourceIndex)),
     D(MolScript.structureQuery.atomProperty.core.atomKey, (ctx, _) => cantorPairing(ctx.element.unit.id, ctx.element.element)),
 
     // TODO:

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

@@ -196,6 +196,7 @@ export const SymbolTable = [
             Alias(MolScript.structureQuery.atomProperty.core.x, 'atom.x'),
             Alias(MolScript.structureQuery.atomProperty.core.y, 'atom.y'),
             Alias(MolScript.structureQuery.atomProperty.core.z, 'atom.z'),
+            Alias(MolScript.structureQuery.atomProperty.core.sourceIndex, 'atom.src-index'),
             Alias(MolScript.structureQuery.atomProperty.core.atomKey, 'atom.key'),
             Alias(MolScript.structureQuery.atomProperty.core.bondCount, 'atom.bond-count'),