diff --git a/src/mol-data/db/column.ts b/src/mol-data/db/column.ts index d1c183b4c818b6b6de0b9677d2515ea717242a2b..55243135fd47da9c203215d019a012ab1c84dfe5 100644 --- a/src/mol-data/db/column.ts +++ b/src/mol-data/db/column.ts @@ -141,8 +141,8 @@ namespace Column { return createFirstIndexMapOfColumn(column); } - export function createIndexer<T>(column: Column<T>) { - return createIndexerOfColumn(column); + export function createIndexer<T, R extends number = number>(column: Column<T>) { + return createIndexerOfColumn(column) as ((e: T) => R); } export function mapToArray<T, S>(column: Column<T>, f: (v: T) => S, ctor?: ArrayCtor<S>): ArrayLike<S> { diff --git a/src/mol-model/structure/model.ts b/src/mol-model/structure/model.ts index 0551a4c2098ebf6cb5ec74367fb37905d55b0500..af5b8c7bb5d6eb1acdbdce5db003abc366d202ee 100644 --- a/src/mol-model/structure/model.ts +++ b/src/mol-model/structure/model.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import Model from './model/model' +import { Model } from './model/model' import * as Types from './model/types' import Format from './model/format' import { ModelSymmetry } from './model/properties/symmetry' diff --git a/src/mol-model/structure/model/formats/mmcif.ts b/src/mol-model/structure/model/formats/mmcif.ts index 17b7ee9cf9f4df0ad0ab90bc398af82163679569..46fd62b3ec67f34bb46e2df353eae2f71afccdd1 100644 --- a/src/mol-model/structure/model/formats/mmcif.ts +++ b/src/mol-model/structure/model/formats/mmcif.ts @@ -11,7 +11,7 @@ import { Tensor, Vec3 } from 'mol-math/linear-algebra'; import { Task, RuntimeContext } from 'mol-task'; import UUID from 'mol-util/uuid'; import Format from '../format'; -import Model from '../model'; +import { Model } from '../model'; import { Entities } from '../properties/common'; import { CustomProperties } from '../properties/custom'; import { ModelSymmetry } from '../properties/symmetry'; diff --git a/src/mol-model/structure/model/formats/mmcif/atomic.ts b/src/mol-model/structure/model/formats/mmcif/atomic.ts index 5ab6ded5d7192a896499d3ce4853fc2578d62618..d9ddcd2b07c529eb5cf1cdb17665f578cfab769b 100644 --- a/src/mol-model/structure/model/formats/mmcif/atomic.ts +++ b/src/mol-model/structure/model/formats/mmcif/atomic.ts @@ -10,7 +10,7 @@ import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif'; import UUID from 'mol-util/uuid'; import { Element } from '../../../../structure'; import Format from '../../format'; -import Model from '../../model'; +import { Model } from '../../model'; import { AtomicConformation, AtomicData, AtomicHierarchy, AtomicSegments, AtomsSchema, ChainsSchema, ResiduesSchema } from '../../properties/atomic'; import { getAtomicKeys } from '../../properties/utils/atomic-keys'; import { ElementSymbol } from '../../types'; diff --git a/src/mol-model/structure/model/formats/mmcif/bonds/comp.ts b/src/mol-model/structure/model/formats/mmcif/bonds/comp.ts index 6a3f12ffe0b76444f4d8d14ee9ba6506acd80a36..77ab1f08485da42b5550feee60073d1cafa7f487 100644 --- a/src/mol-model/structure/model/formats/mmcif/bonds/comp.ts +++ b/src/mol-model/structure/model/formats/mmcif/bonds/comp.ts @@ -5,7 +5,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Model from '../../../model' +import { Model } from '../../../model' import { LinkType } from '../../../types' import { ModelPropertyDescriptor } from '../../../properties/custom'; import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif'; diff --git a/src/mol-model/structure/model/formats/mmcif/bonds/struct_conn.ts b/src/mol-model/structure/model/formats/mmcif/bonds/struct_conn.ts index f2ea4703a18f1ef90982750a70c37a1036e963ab..2d79a18b9a7c5cbeb01388be27913613d356a49f 100644 --- a/src/mol-model/structure/model/formats/mmcif/bonds/struct_conn.ts +++ b/src/mol-model/structure/model/formats/mmcif/bonds/struct_conn.ts @@ -5,7 +5,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Model from '../../../model' +import { Model } from '../../../model' import { Element, Structure } from '../../../../structure' import { LinkType } from '../../../types' import { findEntityIdByAsymId, findAtomIndexByLabelName } from '../util' diff --git a/src/mol-model/structure/model/formats/mmcif/pair-restraints/cross-links.ts b/src/mol-model/structure/model/formats/mmcif/pair-restraints/cross-links.ts index 584a429ccb559cef0e7480f0db2b20734aaa13e0..835b4c440a566eec10eb662de8df9a0b729fc1b6 100644 --- a/src/mol-model/structure/model/formats/mmcif/pair-restraints/cross-links.ts +++ b/src/mol-model/structure/model/formats/mmcif/pair-restraints/cross-links.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Model from '../../../model' +import { Model } from '../../../model' import { Table } from 'mol-data/db' import { mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif'; import { findAtomIndexByLabelName } from '../util'; diff --git a/src/mol-model/structure/model/formats/mmcif/util.ts b/src/mol-model/structure/model/formats/mmcif/util.ts index 7c4806cc1988dd921eedaba84536b02578a585c5..5747eb1664efbcfa782082f825939f98215aa52b 100644 --- a/src/mol-model/structure/model/formats/mmcif/util.ts +++ b/src/mol-model/structure/model/formats/mmcif/util.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import Model from '../../model' +import { Model } from '../../model' import { Element } from '../../../structure' export function findEntityIdByAsymId(model: Model, asymId: string) { diff --git a/src/mol-model/structure/model/model.ts b/src/mol-model/structure/model/model.ts index 24e5a5875ecb7006e999f998339933509fc97101..412531f73311585995d658e4312f6f820892156a 100644 --- a/src/mol-model/structure/model/model.ts +++ b/src/mol-model/structure/model/model.ts @@ -22,7 +22,7 @@ import { ChemicalComponent } from './properties/chemical-component'; * * "Atoms" are integers in the range [0, atomCount). */ -interface Model extends Readonly<{ +export interface Model extends Readonly<{ id: UUID, label: string, @@ -64,25 +64,17 @@ interface Model extends Readonly<{ } { } -namespace Model { +export namespace Model { export function create(format: Format) { switch (format.kind) { // case 'gro': return from_gro(format); case 'mmCIF': return from_mmCIF(format); } } - - // TODO: figure the place to include this? - // export interface Property<T, K> { (model: Model, index: number): T, _kind: K } - // export interface AtomicProperty<T> extends Property<T, 'atomic'> { } - // export interface CoarseProperty<T> extends Property<T, 'coarse'> { } - // export interface SphereProperty<T> extends Property<T, 'sphere'> { } - // export interface GaussianProperty<T> extends Property<T, 'gaussian'> { } - - // export function atomProp<T>(p: (model: Model, i: number) => T): AtomicProperty<T> { return p as any; } - // export function residueProp<T>(p: (model: Model, residueIndex: number) => T): AtomicProperty<T> { - // return p as any; - // } } -export default Model \ No newline at end of file + +export type ElementIndex = { readonly '@type': 'element-index' } & number +export type ResidueIndex = { readonly '@type': 'residue-index' } & number +export type ChainIndex = { readonly '@type': 'chain-index' } & number +export type EntityIndex = { readonly '@type': 'entity-index' } & number \ No newline at end of file diff --git a/src/mol-model/structure/model/properties/atomic/hierarchy.ts b/src/mol-model/structure/model/properties/atomic/hierarchy.ts index 2d2612a759769bc91317157fa71c3b08f8048ba5..a4aeaacad61ebb52999a8a2fd578d91cf9d0b5d5 100644 --- a/src/mol-model/structure/model/properties/atomic/hierarchy.ts +++ b/src/mol-model/structure/model/properties/atomic/hierarchy.ts @@ -80,9 +80,15 @@ export interface AtomicKeys { // also index to the Entities table. entityKey: ArrayLike<number>, + /** + * @returns index or -1 if not present. + */ findChainKey(entityId: string, label_asym_id: string): number, - /** Unique number for each of the residue. Also the index of the 1st occurence of this residue. */ + /** + * Unique number for each of the residue. Also the index of the 1st occurence of this residue. + * @returns index or -1 if not present. + */ findResidueKey(entityId: string, label_asym_id: string, label_comp_id: string, auth_seq_id: number, pdbx_PDB_ins_code: string): number } diff --git a/src/mol-model/structure/model/properties/common.ts b/src/mol-model/structure/model/properties/common.ts index 9dadbc95ac9d951e4d175949655012b0222a52a5..35d9143ae8873630f628a9d99ef6f8afd99d6715 100644 --- a/src/mol-model/structure/model/properties/common.ts +++ b/src/mol-model/structure/model/properties/common.ts @@ -8,5 +8,5 @@ import { mmCIF_Database as mmCIF } from 'mol-io/reader/cif/schema/mmcif' export interface Entities { data: mmCIF['entity'], - getEntityIndex(id: string): number + getEntityIndex(id: string): import('../model').EntityIndex } \ No newline at end of file