From 5ccb329af1d833c27b5ef1b73da99f44f36ad84a Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Wed, 26 Feb 2020 17:13:34 -0800 Subject: [PATCH] added SetUtils.toArray --- src/mol-plugin/util/structure-selection-helper.ts | 7 ++++--- src/mol-util/set.ts | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mol-plugin/util/structure-selection-helper.ts b/src/mol-plugin/util/structure-selection-helper.ts index 71a9fe1b2..b4c0954ff 100644 --- a/src/mol-plugin/util/structure-selection-helper.ts +++ b/src/mol-plugin/util/structure-selection-helper.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author David Sehnal <david.sehnal@gmail.com> @@ -15,6 +15,7 @@ import { PluginContext } from '../context'; import Expression from '../../mol-script/language/expression'; import { BondType, ProteinBackboneAtoms, NucleicBackboneAtoms, SecondaryStructureType } from '../../mol-model/structure/model/types'; import { StateTransforms } from '../state/transforms'; +import { SetUtils } from '../../mol-util/set'; export interface StructureSelectionQuery { label: string @@ -68,7 +69,7 @@ const backbone = StructureSelectionQuery('Backbone', MS.struct.modifier.union([ ]) ]), 'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']), - 'atom-test': MS.core.set.has([MS.set(...Array.from(ProteinBackboneAtoms.values())), MS.ammp('label_atom_id')]) + 'atom-test': MS.core.set.has([MS.set(...SetUtils.toArray(ProteinBackboneAtoms)), MS.ammp('label_atom_id')]) }) ]), MS.struct.modifier.union([ @@ -81,7 +82,7 @@ const backbone = StructureSelectionQuery('Backbone', MS.struct.modifier.union([ ]) ]), 'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']), - 'atom-test': MS.core.set.has([MS.set(...Array.from(NucleicBackboneAtoms.values())), MS.ammp('label_atom_id')]) + 'atom-test': MS.core.set.has([MS.set(...SetUtils.toArray(NucleicBackboneAtoms)), MS.ammp('label_atom_id')]) }) ]) ]) diff --git a/src/mol-util/set.ts b/src/mol-util/set.ts index af02d56a3..9e1f71738 100644 --- a/src/mol-util/set.ts +++ b/src/mol-util/set.ts @@ -4,9 +4,15 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ +import { iterableToArray } from '../mol-data/util/array'; + // TODO use set@@iterator when targeting es6 export namespace SetUtils { + export function toArray<T>(set: ReadonlySet<T>) { + return iterableToArray(set.values()) + } + /** Test if set a contains all elements of set b. */ export function isSuperset<T>(setA: ReadonlySet<T>, setB: ReadonlySet<T>) { let flag = true -- GitLab