diff --git a/src/apps/structure-info/model.ts b/src/apps/structure-info/model.ts index d9d42709d84c9a1b4983cb919814da850b8a3206..2cc19a45613210f720cd19807d81924d8ff7cf6c 100644 --- a/src/apps/structure-info/model.ts +++ b/src/apps/structure-info/model.ts @@ -12,7 +12,6 @@ import { CifFrame } from 'mol-io/reader/cif' import { Model, Structure, Element, Unit, Format, StructureProperties } from 'mol-model/structure' // import { Run, Progress } from 'mol-task' import { OrderedSet } from 'mol-data/int'; -import { Table } from 'mol-data/db'; import { openCif, downloadCif } from './helpers'; import { BitFlags } from 'mol-util'; import { SecondaryStructureType } from 'mol-model/structure/model/types'; @@ -192,12 +191,6 @@ export function printSymmetryInfo(model: Model) { console.log(`NCS operators: ${symmetry.ncsOperators && symmetry.ncsOperators.map(a => a.name).join(', ')}`); } -export function printIHMModels(model: Model) { - if (!model.coarseHierarchy.isDefined) return false; - console.log('\nIHM Models\n============='); - console.log(Table.formatToString(model.coarseHierarchy.models)); -} - export function printModelStats(models: ReadonlyArray<Model>) { console.log('\nModels\n============='); @@ -217,7 +210,6 @@ async function run(frame: CifFrame, args: Args) { if (args.models) printModelStats(models); if (args.seq) printSequence(models[0]); - if (args.ihm) printIHMModels(models[0]); if (args.units) printUnits(structure); if (args.sym) printSymmetryInfo(models[0]); if (args.rings) printRings(structure); diff --git a/src/mol-data/db/column.ts b/src/mol-data/db/column.ts index a61efa6771935c8e742d5db03d43883e9b00c67a..d1c183b4c818b6b6de0b9677d2515ea717242a2b 100644 --- a/src/mol-data/db/column.ts +++ b/src/mol-data/db/column.ts @@ -270,6 +270,7 @@ function arrayColumn<T extends Column.Schema>({ array, schema, valueKind }: Colu function windowColumn<T>(column: Column<T>, start: number, end: number) { if (!column.isDefined) return Column.Undefined(end - start, column.schema); + if (start === 0 && end === column.rowCount) return column; if (!!column['@array'] && ColumnHelpers.isTypedArray(column['@array'])) return windowTyped(column, start, end); return windowFull(column, start, end); } diff --git a/src/mol-data/db/table.ts b/src/mol-data/db/table.ts index b68967dfc55f73985b3256beb0f122a733fa4416..1237cba5a7f272778ad5c31fa5c993c8204c1683 100644 --- a/src/mol-data/db/table.ts +++ b/src/mol-data/db/table.ts @@ -102,6 +102,7 @@ namespace Table { } export function window<S extends R, R extends Schema>(table: Table<S>, schema: R, start: number, end: number) { + if (start === 0 && end === table._rowCount) return table; const ret = Object.create(null); const columns = Object.keys(schema); ret._rowCount = view.length; diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts index 4bd2eee7bd7b4ecd40df07003e83c4a2a670c53c..e944d9c8d93060cb76f250996a056c293040050d 100644 --- a/src/mol-model/structure/model/formats/mmcif.ts +++ b/src/mol-model/structure/model/formats/mmcif.ts @@ -135,11 +135,6 @@ function createStandardModel(format: mmCIF_Format, atom_site: AtomSite, entities }; } -// TODO split IHM data into models as well, atomistic ihm models have `atom_site.ihm_model_id`, -// how to handle it in a generic way, i.e. when there is no ihm data, use `atom_site.pdbx_PDB_model_num` -// but if there is use `atom_site.ihm_model_id`, `ihm_sphere_obj_site.model_id` and -// `ihm_gaussian_obj_site.model_id` for splitting -// - PDBDEV_00000002 is an example for an IHM structure with multiple models function createModelIHM(format: mmCIF_Format, data: IHMData): Model { const atomic = getAtomicHierarchyAndConformation(format, data.atom_site, data.entities); const coarse = getIHMCoarse(data); @@ -216,6 +211,7 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format) { const { ihm_model_list } = format.data; const entities: Entities = { data: format.data.entity, getEntityIndex: Column.createIndexer(format.data.entity.id) }; + // TODO: will IHM require sorting or will we trust it? const atom_sites = splitTable(format.data.atom_site, format.data.atom_site.ihm_model_id); 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); @@ -228,7 +224,6 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format) { const data: IHMData = { model_id: id, model_name: model_name.value(i), - ihm_model_list, entities: entities, atom_site: atom_sites.has(id) ? atom_sites.get(id)! : Table.window(format.data.atom_site, format.data.atom_site._schema, 0, 0), ihm_sphere_obj_site: sphere_sites.has(id) ? sphere_sites.get(id)! : Table.window(format.data.ihm_sphere_obj_site, format.data.ihm_sphere_obj_site._schema, 0, 0), @@ -240,34 +235,12 @@ async function readIHM(ctx: RuntimeContext, format: mmCIF_Format) { } return models; - - // const atomCount = format.data.atom_site._rowCount; - // const isIHM = format.data.ihm_model_list._rowCount > 0; - - // if (atomCount === 0) { - // return isIHM - // ? [createModel(format, format.data.atom_site, void 0)] - // : []; - // } - - - // const models: Model[] = []; - // let modelStart = 0; - // while (modelStart < atomCount) { - // const modelEnd = findModelEnd(format, modelStart); - // const atom_site = await sortAtomSite(ctx, format.data.atom_site, modelStart, modelEnd); - // const model = createModel(format, atom_site, models.length > 0 ? models[models.length - 1] : void 0); - // attachProps(model); - // models.push(model); - // modelStart = modelEnd; - // } - // return models; } function buildModels(format: mmCIF_Format): Task<ReadonlyArray<Model>> { return Task.create('Create mmCIF Model', async ctx => { const isIHM = format.data.ihm_model_list._rowCount > 0; - return isIHM ? await readIHM(ctx, format) : await readStandard(ctx, format); + return isIHM ? await readIHM(ctx, format) : await readStandard(ctx, format); }); } diff --git a/src/mol-model/structure/model/formats/mmcif/ihm.ts b/src/mol-model/structure/model/formats/mmcif/ihm.ts index f3bd5ad8113a8cfcf9698e9e45cc38deb65dda9a..db2e86c84014a70e261ec700a16c9c2512cbcfc6 100644 --- a/src/mol-model/structure/model/formats/mmcif/ihm.ts +++ b/src/mol-model/structure/model/formats/mmcif/ihm.ts @@ -14,39 +14,31 @@ import { Segmentation, Interval } from 'mol-data/int'; import { Mat3, Tensor } from 'mol-math/linear-algebra'; import { Element } from '../../../structure' -type AtomSite = mmCIF['atom_site'] -type SphereSite = mmCIF['ihm_sphere_obj_site'] -type GaussSite = mmCIF['ihm_gaussian_obj_site'] -type IHMModels = mmCIF['ihm_model_list'] - export interface IHMData { model_id: number, model_name: string, - ihm_model_list: IHMModels, entities: Entities, - atom_site: AtomSite, - ihm_sphere_obj_site: SphereSite, - ihm_gaussian_obj_site: GaussSite + atom_site: mmCIF['atom_site'], + ihm_sphere_obj_site: mmCIF['ihm_sphere_obj_site'], + ihm_gaussian_obj_site: mmCIF['ihm_gaussian_obj_site'] } export const EmptyIHMCoarse = { hierarchy: CoarseHierarchy.Empty, conformation: void 0 as any } export function getIHMCoarse(data: IHMData): { hierarchy: CoarseHierarchy, conformation: CoarseConformation } { - const { ihm_model_list, ihm_sphere_obj_site, ihm_gaussian_obj_site } = data; - const modelIndex = Column.createIndexer(ihm_model_list.model_id); + const { ihm_sphere_obj_site, ihm_gaussian_obj_site } = data; const sphereData = getData(ihm_sphere_obj_site); const sphereConformation = getSphereConformation(ihm_sphere_obj_site); - const sphereKeys = getCoarseKeys(sphereData, modelIndex, data.entities); + const sphereKeys = getCoarseKeys(sphereData, data.entities); const gaussianData = getData(ihm_gaussian_obj_site); const gaussianConformation = getGaussianConformation(ihm_gaussian_obj_site); - const gaussianKeys = getCoarseKeys(gaussianData, modelIndex, data.entities); + const gaussianKeys = getCoarseKeys(gaussianData, data.entities); return { hierarchy: { isDefined: true, - //models: ihm_model_list, spheres: { ...sphereData, ...sphereKeys }, gaussians: { ...gaussianData, ...gaussianKeys }, }, @@ -96,6 +88,6 @@ function getChainSegments(asym_id: Column<string>) { } function getData(data: mmCIF['ihm_sphere_obj_site'] | mmCIF['ihm_gaussian_obj_site']): CoarseElementData { - const { model_id, entity_id, seq_id_begin, seq_id_end, asym_id } = data; - return { count: model_id.rowCount, entity_id, model_id, asym_id, seq_id_begin, seq_id_end, chainSegments: getChainSegments(asym_id) }; + const { entity_id, seq_id_begin, seq_id_end, asym_id } = data; + return { count: entity_id.rowCount, entity_id, asym_id, seq_id_begin, seq_id_end, chainSegments: getChainSegments(asym_id) }; } \ No newline at end of file diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index c76964e053f6f63e35f8409f59e64b263281173d..e83ed86d3591283395a1efce657fe0d9a57d0acf 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -25,6 +25,7 @@ interface Model extends Readonly<{ id: UUID, label: string, + // for IHM, corresponds to ihm_model_list.model_id modelNum: number, sourceData: Format, diff --git a/src/mol-model/structure/model/properties/coarse/hierarchy.ts b/src/mol-model/structure/model/properties/coarse/hierarchy.ts index 2bcdabbe815d39d0d62a062e9695796294d9688c..86071cbc54be4e9d8b6968e381202e764d87125f 100644 --- a/src/mol-model/structure/model/properties/coarse/hierarchy.ts +++ b/src/mol-model/structure/model/properties/coarse/hierarchy.ts @@ -5,7 +5,6 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { mmCIF_Database as mmCIF } from 'mol-io/reader/cif/schema/mmcif' import { Column } from 'mol-data/db' import { Segmentation } from 'mol-data/int'; import { Element } from '../../../structure' @@ -15,9 +14,6 @@ export interface CoarsedElementKeys { chainKey: ArrayLike<number>, // assign a key to each element, index to the Model.entities.data table entityKey: ArrayLike<number>, - - // // assign a key to each element, index to the CoarseHierarchy.models table - // modelKey: ArrayLike<number>, /** find index of the residue/feature element where seq_id is included */ findSequenceKey(entityId: string, asym_id: string, seq_id: number): number @@ -27,7 +23,6 @@ export interface CoarsedElementKeys { export interface CoarseElementData { count: number, entity_id: Column<string>, - model_id: Column<number>, asym_id: Column<string>, seq_id_begin: Column<number>, seq_id_end: Column<number>, @@ -39,7 +34,6 @@ export type CoarseElements = CoarsedElementKeys & CoarseElementData export interface CoarseHierarchy { isDefined: boolean, - //models: mmCIF['ihm_model_list'], spheres: CoarseElements, gaussians: CoarseElements } diff --git a/src/mol-model/structure/model/properties/utils/coarse-keys.ts b/src/mol-model/structure/model/properties/utils/coarse-keys.ts index c18dc27ec7d72dc43b3dbab51a4f3e30f80a385f..da591779c8d5c17a111c7686686cd78b2156e127 100644 --- a/src/mol-model/structure/model/properties/utils/coarse-keys.ts +++ b/src/mol-model/structure/model/properties/utils/coarse-keys.ts @@ -49,25 +49,18 @@ function missingEntity(k: string) { throw new Error(`Missing entity entry for entity id '${k}'.`); } -function missingModel(k: string) { - throw new Error(`Missing entity entry for model id '${k}'.`); -} - -export function getCoarseKeys(data: CoarseElementData, modelIndex: (id: number) => number, entities: Entities): CoarsedElementKeys { - const { model_id, entity_id, asym_id, seq_id_begin, seq_id_end, count, chainSegments } = data; +export function getCoarseKeys(data: CoarseElementData, entities: Entities): CoarsedElementKeys { + const { entity_id, asym_id, seq_id_begin, seq_id_end, count, chainSegments } = data; const seqMaps = new Map<number, Map<number, number>>(); const chainMaps = new Map<number, Map<string, number>>(), chainCounter = { index: 0 }; const chainKey = new Int32Array(count); const entityKey = new Int32Array(count); - const modelKey = new Int32Array(count); for (let i = 0; i < count; i++) { entityKey[i] = entities.getEntityIndex(entity_id.value(i)); if (entityKey[i] < 0) missingEntity(entity_id.value(i)); - modelKey[i] = modelIndex(model_id.value(i)); - if (modelKey[i] < 0) missingModel('' + model_id.value(i)); } for (let cI = 0; cI < chainSegments.count; cI++) { @@ -92,5 +85,5 @@ export function getCoarseKeys(data: CoarseElementData, modelIndex: (id: number) const { findChainKey, findSequenceKey } = createLookUp(entities, chainMaps, seqMaps); - return { chainKey, entityKey, /*modelKey,*/ findSequenceKey, findChainKey }; + return { chainKey, entityKey, findSequenceKey, findChainKey }; } \ No newline at end of file diff --git a/src/mol-model/structure/structure/properties.ts b/src/mol-model/structure/structure/properties.ts index 943c219c239e6d7a5c04d13fa5cb4f10a2de79da..5a7b9e4d8971e9e1c30781c35d6a72ab87f96667 100644 --- a/src/mol-model/structure/structure/properties.ts +++ b/src/mol-model/structure/structure/properties.ts @@ -72,7 +72,6 @@ const chain = { const coarse = { key: atom.key, - modelKey: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.modelKey[l.element]), entityKey: Element.property(l => !Unit.isCoarse(l.unit) ? notCoarse() : l.unit.coarseElements.entityKey[l.element]), x: atom.x,