UNPKG

molstar

Version:

A comprehensive macromolecular library.

31 lines (30 loc) 1.35 kB
/** * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> */ import { Column } from '../../../../mol-data/db'; import { CifWriter } from '../../../../mol-io/writer/cif'; import { getModelMmCifCategory, getUniqueEntityIdsFromStructures } from './utils'; var CifCategory = CifWriter.Category; export var _struct_asym = createCategory('struct_asym'); export var _entity_poly = createCategory('entity_poly'); export var _entity_poly_seq = createCategory('entity_poly_seq'); function createCategory(categoryName) { return { name: categoryName, instance: function (_a) { var structures = _a.structures, cache = _a.cache; return getCategoryInstance(structures, categoryName, cache); } }; } function getCategoryInstance(structures, categoryName, cache) { var category = getModelMmCifCategory(structures[0].model, categoryName); if (!category) return CifCategory.Empty; var entity_id = category.entity_id; var names = cache.uniqueEntityIds || (cache.uniqueEntityIds = getUniqueEntityIdsFromStructures(structures)); var indices = Column.indicesOf(entity_id, function (id) { return names.has(id); }); return CifCategory.ofTable(category, indices); }