Skip to content
Snippets Groups Projects
Commit 0e5ed275 authored by David Sehnal's avatar David Sehnal
Browse files

Renamed mol-view mol-canvas3d, moved parameters.ts to mol-util, added mol-plugin

parent cb689707
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ import { PickingId } from '../../geometry/picking';
import { MarkerAction } from '../../geometry/marker-data';
import { Loci, EmptyLoci } from 'mol-model/loci';
import { createRenderableState, updateRenderableState, Geometry } from '../../geometry/geometry';
import { paramDefaultValues } from 'mol-view/parameter';
import { paramDefaultValues } from 'mol-util/parameter';
import { DirectVolume } from '../../geometry/direct-volume/direct-volume';
import { Vec3, Mat4 } from 'mol-math/linear-algebra';
import { Box3D } from 'mol-math/geometry';
......
......@@ -11,7 +11,7 @@ import { PickingId } from '../../geometry/picking';
import { Loci, EmptyLoci } from 'mol-model/loci';
import { MarkerAction } from '../../geometry/marker-data';
import { Geometry } from '../../geometry/geometry';
import { paramDefaultValues } from 'mol-view/parameter';
import { paramDefaultValues } from 'mol-util/parameter';
export interface VolumeVisual<P extends RepresentationProps = {}> extends Visual<VolumeData, P> { }
......
......@@ -18,7 +18,7 @@ import { LocationIterator } from '../../util/location-iterator';
import { NullLocation } from 'mol-model/location';
import { createIdentityTransform } from '../../geometry/transform-data';
import { createRenderableState, updateRenderableState } from '../../geometry/geometry';
import { paramDefaultValues, RangeParam } from 'mol-view/parameter';
import { paramDefaultValues, RangeParam } from 'mol-util/parameter';
import { ValueCell } from 'mol-util';
export async function createVolumeSurface(ctx: RuntimeContext, volume: VolumeData, isoValueAbsolute: number, mesh?: Mesh) {
......
......@@ -6,7 +6,7 @@
import { createGl } from './gl.shim';
import { PerspectiveCamera } from 'mol-view/camera/perspective';
import { PerspectiveCamera } from 'mol-canvas3d/camera/perspective';
import { Vec3, Mat4 } from 'mol-math/linear-algebra';
import { ValueCell } from 'mol-util';
......
......@@ -5,8 +5,8 @@
*/
// import { Vec3, Mat4 } from 'mol-math/linear-algebra'
import { Viewport } from 'mol-view/camera/util';
import { Camera } from 'mol-view/camera/base';
import { Viewport } from 'mol-canvas3d/camera/util';
import { Camera } from 'mol-canvas3d/camera/base';
import Scene from './scene';
import { Context, createImageData } from './webgl/context';
......
......@@ -5,11 +5,11 @@
*/
import { Unit, StructureElement, ElementIndex } from 'mol-model/structure';
import { SizeTheme } from 'mol-view/theme/size';
import { SizeTheme } from 'mol-canvas3d/theme/size';
import { GaussianDensity } from 'mol-math/geometry/gaussian-density';
import { Task, RuntimeContext } from 'mol-task';
import { DensityData } from 'mol-math/geometry';
import { NumberParam, paramDefaultValues, BooleanParam, ValueParam } from 'mol-view/parameter';
import { NumberParam, paramDefaultValues, BooleanParam, ValueParam } from 'mol-util/parameter';
import { Context } from 'mol-gl/webgl/context';
import { GaussianDensityTexture } from 'mol-math/geometry/gaussian-density/gpu';
import { Texture } from 'mol-gl/webgl/texture';
......
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
// TODO
\ No newline at end of file
......@@ -6,7 +6,7 @@
import { Color } from './color'
import { ColorBrewer } from './tables'
import { ScaleLegend } from 'mol-view/theme/color';
import { ScaleLegend } from 'mol-canvas3d/theme/color';
import { defaults } from 'mol-util';
export interface ColorScale {
......
File moved
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { BehaviorSubject } from 'rxjs';
import { UUID } from 'mol-util'
import { AnyEntity } from './entity';
import Viewer from '../viewer';
import { Progress } from 'mol-task';
// TODO
export type StateTree = {}
export class StateContext {
id = UUID.create()
change = new BehaviorSubject(0)
tree: StateTree = {}
entities: Set<AnyEntity> = new Set()
viewer: Viewer
constructor(readonly log: (p: Progress) => void) {
}
}
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { readFile, readUrl } from 'mol-util/read'
import { idFactory } from 'mol-util/id-factory'
import { StateContext } from './context';
import { getFileInfo } from 'mol-util/file-info';
import { CifFile, CifFrame } from 'mol-io/reader/cif';
import { mmCIF_Database } from 'mol-io/reader/cif/schema/mmcif';
import { Model, Structure } from 'mol-model/structure';
import { StructureRepresentation } from 'mol-geo/representation/structure';
import { SpacefillProps } from 'mol-geo/representation/structure/representation/spacefill';
import { BallAndStickProps } from 'mol-geo/representation/structure/representation/ball-and-stick';
import { DistanceRestraintProps } from 'mol-geo/representation/structure/representation/distance-restraint';
import { CartoonProps } from 'mol-geo/representation/structure/representation/cartoon';
import { BackboneProps } from 'mol-geo/representation/structure/representation/backbone';
import { CarbohydrateProps } from 'mol-geo/representation/structure/representation/carbohydrate';
const getNextId = idFactory(1)
export interface StateEntity<T, K extends string> {
id: number
kind: K
value: T
}
export namespace StateEntity {
export function create<T, K extends string>(ctx: StateContext, kind: K, value: T): StateEntity<T, K> {
const entity = { id: getNextId(), kind, value }
ctx.entities.add(entity)
ctx.change.next(ctx.change.getValue() + 1)
return entity
}
}
export type AnyEntity = StateEntity<any, any>
export type NullEntity = StateEntity<null, 'null'>
export const NullEntity: NullEntity = { id: -1, kind: 'null', value: null }
export const RootEntity: StateEntity<null, 'root'> = { id: 0, kind: 'root', value: null }
export interface UrlProps {
url: string
name: string
type: string
getData: () => Promise<string | Uint8Array>
}
export type UrlEntity = StateEntity<UrlProps, 'url'>
export namespace UrlEntity {
export function ofUrl(ctx: StateContext, url: string, isBinary?: boolean): UrlEntity {
const { name, ext: type, compressed, binary } = getFileInfo(url)
return StateEntity.create(ctx, 'url', {
url, name, type,
getData: () => readUrl(url, isBinary || !!compressed || binary)
})
}
}
export interface FileProps {
name: string
type: string
getData: () => Promise<string | Uint8Array>
}
export type FileEntity = StateEntity<FileProps, 'file'>
export namespace FileEntity {
export function ofFile(ctx: StateContext, file: File, isBinary?: boolean): FileEntity {
const { name, ext: type, compressed, binary } = getFileInfo(file)
return StateEntity.create(ctx, 'file', {
name, type,
getData: () => readFile(file, isBinary || !!compressed || binary)
})
}
}
export interface DataProps {
type: string
data: string | Uint8Array
}
export type DataEntity = StateEntity<DataProps, 'data'>
export namespace DataEntity {
export function ofData<T>(ctx: StateContext, data: string | Uint8Array, type: string): DataEntity {
return StateEntity.create(ctx, 'data', {
type,
data
})
}
}
export type CifEntity = StateEntity<CifFile, 'cif'>
export namespace CifEntity {
export function ofCifFile(ctx: StateContext, file: CifFile): CifEntity {
return StateEntity.create(ctx, 'cif', file)
}
}
export type MmcifEntity = StateEntity<{ db: mmCIF_Database, frame: CifFrame }, 'mmcif'>
export namespace MmcifEntity {
export function ofMmcifDb(ctx: StateContext, mmCif: { db: mmCIF_Database, frame: CifFrame }): MmcifEntity {
return StateEntity.create(ctx, 'mmcif', mmCif)
}
}
export type ModelEntity = StateEntity<ReadonlyArray<Model>, 'model'>
export namespace ModelEntity {
export function ofModels(ctx: StateContext, models: ReadonlyArray<Model>): ModelEntity {
return StateEntity.create(ctx, 'model', models)
}
}
export type StructureEntity = StateEntity<Structure, 'structure'>
export namespace StructureEntity {
export function ofStructure(ctx: StateContext, structure: Structure): StructureEntity {
return StateEntity.create(ctx, 'structure', structure)
}
}
export type SpacefillEntity = StateEntity<StructureRepresentation<SpacefillProps>, 'spacefill'>
export namespace SpacefillEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<SpacefillProps>): SpacefillEntity {
return StateEntity.create(ctx, 'spacefill', repr)
}
}
export type BallAndStickEntity = StateEntity<StructureRepresentation<BallAndStickProps>, 'ballandstick'>
export namespace BallAndStickEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<BallAndStickProps>): BallAndStickEntity {
return StateEntity.create(ctx, 'ballandstick', repr)
}
}
export type DistanceRestraintEntity = StateEntity<StructureRepresentation<DistanceRestraintProps>, 'distancerestraint'>
export namespace DistanceRestraintEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<DistanceRestraintProps>): DistanceRestraintEntity {
return StateEntity.create(ctx, 'distancerestraint', repr)
}
}
export type BackboneEntity = StateEntity<StructureRepresentation<BackboneProps>, 'backbone'>
export namespace BackboneEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<BackboneProps>): BackboneEntity {
return StateEntity.create(ctx, 'backbone', repr)
}
}
export type CartoonEntity = StateEntity<StructureRepresentation<CartoonProps>, 'cartoon'>
export namespace CartoonEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<CartoonProps>): CartoonEntity {
return StateEntity.create(ctx, 'cartoon', repr)
}
}
export type CarbohydrateEntity = StateEntity<StructureRepresentation<CarbohydrateProps>, 'carbohydrate'>
export namespace CarbohydrateEntity {
export function ofRepr(ctx: StateContext, repr: StructureRepresentation<CarbohydrateProps>): CarbohydrateEntity {
return StateEntity.create(ctx, 'carbohydrate', repr)
}
}
\ No newline at end of file
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import CIF from 'mol-io/reader/cif'
import { FileEntity, DataEntity, UrlEntity, CifEntity, MmcifEntity, ModelEntity, StructureEntity, SpacefillEntity, AnyEntity, NullEntity, BallAndStickEntity, DistanceRestraintEntity, CartoonEntity, BackboneEntity, CarbohydrateEntity } from './entity';
import { Model, Structure, Format } from 'mol-model/structure';
import { StateContext } from './context';
import StructureSymmetry from 'mol-model/structure/structure/symmetry';
import { SpacefillProps, SpacefillRepresentation } from 'mol-geo/representation/structure/representation/spacefill';
import { BallAndStickProps, BallAndStickRepresentation } from 'mol-geo/representation/structure/representation/ball-and-stick';
import { DistanceRestraintRepresentation, DistanceRestraintProps } from 'mol-geo/representation/structure/representation/distance-restraint';
import { CartoonRepresentation, CartoonProps } from 'mol-geo/representation/structure/representation/cartoon';
import { BackboneProps, BackboneRepresentation } from 'mol-geo/representation/structure/representation/backbone';
import { CarbohydrateProps, CarbohydrateRepresentation } from 'mol-geo/representation/structure/representation/carbohydrate';
type transformer<I extends AnyEntity, O extends AnyEntity, P extends {}> = (ctx: StateContext, inputEntity: I, props?: P) => Promise<O>
export interface StateTransform<I extends AnyEntity, O extends AnyEntity, P extends {}> {
inputKind: I['kind']
outputKind: O['kind']
kind: string
apply: transformer<I, O, P>
}
export namespace StateTransform {
export function create<I extends AnyEntity, O extends AnyEntity, P extends {}>(inputKind: I['kind'], outputKind: O['kind'], kind: string, transformer: transformer<I, O, P>) {
return { inputKind, outputKind, kind, apply: transformer }
}
}
export type AnyTransform = StateTransform<AnyEntity, AnyEntity, {}>
export type UrlToData = StateTransform<UrlEntity, DataEntity, {}>
export const UrlToData: UrlToData = StateTransform.create('url', 'data', 'url-to-data',
async function (ctx: StateContext, urlEntity: UrlEntity) {
return DataEntity.ofData(ctx, await urlEntity.value.getData(), urlEntity.value.type)
})
export type FileToData = StateTransform<FileEntity, DataEntity, {}>
export const FileToData: FileToData = StateTransform.create('file', 'data', 'file-to-data',
async function (ctx: StateContext, fileEntity: FileEntity) {
return DataEntity.ofData(ctx, await fileEntity.value.getData(), fileEntity.value.type)
})
export type DataToCif = StateTransform<DataEntity, CifEntity, {}>
export const DataToCif: DataToCif = StateTransform.create('data', 'cif', 'data-to-cif',
async function (ctx: StateContext, dataEntity: DataEntity) {
const comp = CIF.parse(dataEntity.value.data)
const parsed = await comp.run(ctx.log)
if (parsed.isError) throw parsed
return CifEntity.ofCifFile(ctx, parsed.result)
})
export type CifToMmcif = StateTransform<CifEntity, MmcifEntity, {}>
export const CifToMmcif: CifToMmcif = StateTransform.create('cif', 'mmcif', 'cif-to-mmcif',
async function (ctx: StateContext, cifEntity: CifEntity) {
const frame = cifEntity.value.blocks[0];
return MmcifEntity.ofMmcifDb(ctx, { frame, db: CIF.schema.mmCIF(frame) })
})
export type MmcifToModel = StateTransform<MmcifEntity, ModelEntity, {}>
export const MmcifToModel: MmcifToModel = StateTransform.create('mmcif', 'model', 'mmcif-to-model',
async function (ctx: StateContext, mmcifEntity: MmcifEntity) {
const models = await Model.create(Format.mmCIF(mmcifEntity.value.frame, mmcifEntity.value.db)).run(ctx.log)
return ModelEntity.ofModels(ctx, models)
})
export interface StructureProps {
assembly?: string
}
export type ModelToStructure = StateTransform<ModelEntity, StructureEntity, StructureProps>
export const ModelToStructure: ModelToStructure = StateTransform.create('model', 'structure', 'model-to-structure',
async function (ctx: StateContext, modelEntity: ModelEntity, props: StructureProps = {}) {
const model = modelEntity.value[0]
const assembly = props.assembly
let structure: Structure
const assemblies = model.symmetry.assemblies
if (assemblies.length) {
structure = await StructureSymmetry.buildAssembly(Structure.ofModel(model), assembly || '1').run(ctx.log)
} else {
structure = Structure.ofModel(model)
}
return StructureEntity.ofStructure(ctx, structure)
})
export type StructureCenter = StateTransform<StructureEntity, NullEntity, {}>
export const StructureCenter: StructureCenter = StateTransform.create('structure', 'null', 'structure-center',
async function (ctx: StateContext, structureEntity: StructureEntity) {
ctx.viewer.center(structureEntity.value.boundary.sphere.center)
return NullEntity
})
export type StructureToSpacefill = StateTransform<StructureEntity, SpacefillEntity, Partial<SpacefillProps>>
export const StructureToSpacefill: StructureToSpacefill = StateTransform.create('structure', 'spacefill', 'structure-to-spacefill',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<SpacefillProps> = {}) {
const spacefillRepr = SpacefillRepresentation()
await spacefillRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(spacefillRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return SpacefillEntity.ofRepr(ctx, spacefillRepr)
})
export type StructureToBallAndStick = StateTransform<StructureEntity, BallAndStickEntity, Partial<BallAndStickProps>>
export const StructureToBallAndStick: StructureToBallAndStick = StateTransform.create('structure', 'ballandstick', 'structure-to-ballandstick',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<BallAndStickProps> = {}) {
const ballAndStickRepr = BallAndStickRepresentation()
await ballAndStickRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(ballAndStickRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return BallAndStickEntity.ofRepr(ctx, ballAndStickRepr)
})
export type StructureToDistanceRestraint = StateTransform<StructureEntity, DistanceRestraintEntity, Partial<DistanceRestraintProps>>
export const StructureToDistanceRestraint: StructureToDistanceRestraint = StateTransform.create('structure', 'distancerestraint', 'structure-to-distancerestraint',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<DistanceRestraintProps> = {}) {
const distanceRestraintRepr = DistanceRestraintRepresentation()
await distanceRestraintRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(distanceRestraintRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return DistanceRestraintEntity.ofRepr(ctx, distanceRestraintRepr)
})
export type StructureToBackbone = StateTransform<StructureEntity, BackboneEntity, Partial<BackboneProps>>
export const StructureToBackbone: StructureToBackbone = StateTransform.create('structure', 'backbone', 'structure-to-backbone',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<BackboneProps> = {}) {
const backboneRepr = BackboneRepresentation()
await backboneRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(backboneRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return BackboneEntity.ofRepr(ctx, backboneRepr)
})
export type StructureToCartoon = StateTransform<StructureEntity, CartoonEntity, Partial<CartoonProps>>
export const StructureToCartoon: StructureToCartoon = StateTransform.create('structure', 'cartoon', 'structure-to-cartoon',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<CartoonProps> = {}) {
const cartoonRepr = CartoonRepresentation()
await cartoonRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(cartoonRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return CartoonEntity.ofRepr(ctx, cartoonRepr)
})
export type StructureToCarbohydrate = StateTransform<StructureEntity, CarbohydrateEntity, Partial<CarbohydrateProps>>
export const StructureToCarbohydrate: StructureToCarbohydrate = StateTransform.create('structure', 'carbohydrate', 'structure-to-cartoon',
async function (ctx: StateContext, structureEntity: StructureEntity, props: Partial<CarbohydrateProps> = {}) {
const carbohydrateRepr = CarbohydrateRepresentation()
await carbohydrateRepr.createOrUpdate(props, structureEntity.value).run(ctx.log)
ctx.viewer.add(carbohydrateRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return CarbohydrateEntity.ofRepr(ctx, carbohydrateRepr)
})
export type SpacefillUpdate = StateTransform<SpacefillEntity, NullEntity, Partial<SpacefillProps>>
export const SpacefillUpdate: SpacefillUpdate = StateTransform.create('spacefill', 'null', 'spacefill-update',
async function (ctx: StateContext, spacefillEntity: SpacefillEntity, props: Partial<SpacefillProps> = {}) {
const spacefillRepr = spacefillEntity.value
await spacefillRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(spacefillRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
export type BallAndStickUpdate = StateTransform<BallAndStickEntity, NullEntity, Partial<BallAndStickProps>>
export const BallAndStickUpdate: BallAndStickUpdate = StateTransform.create('ballandstick', 'null', 'ballandstick-update',
async function (ctx: StateContext, ballAndStickEntity: BallAndStickEntity, props: Partial<BallAndStickProps> = {}) {
const ballAndStickRepr = ballAndStickEntity.value
await ballAndStickRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(ballAndStickRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
export type DistanceRestraintUpdate = StateTransform<DistanceRestraintEntity, NullEntity, Partial<DistanceRestraintProps>>
export const DistanceRestraintUpdate: DistanceRestraintUpdate = StateTransform.create('distancerestraint', 'null', 'distancerestraint-update',
async function (ctx: StateContext, distanceRestraintEntity: DistanceRestraintEntity, props: Partial<DistanceRestraintProps> = {}) {
const distanceRestraintRepr = distanceRestraintEntity.value
await distanceRestraintRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(distanceRestraintRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
export type BackboneUpdate = StateTransform<BackboneEntity, NullEntity, Partial<BackboneProps>>
export const BackboneUpdate: BackboneUpdate = StateTransform.create('backbone', 'null', 'backbone-update',
async function (ctx: StateContext, backboneEntity: BackboneEntity, props: Partial<BackboneProps> = {}) {
const backboneRepr = backboneEntity.value
await backboneRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(backboneRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
export type CartoonUpdate = StateTransform<CartoonEntity, NullEntity, Partial<CartoonProps>>
export const CartoonUpdate: CartoonUpdate = StateTransform.create('cartoon', 'null', 'cartoon-update',
async function (ctx: StateContext, cartoonEntity: CartoonEntity, props: Partial<CartoonProps> = {}) {
const cartoonRepr = cartoonEntity.value
await cartoonRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(cartoonRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
export type CarbohydrateUpdate = StateTransform<CarbohydrateEntity, NullEntity, Partial<CarbohydrateProps>>
export const CarbohydrateUpdate: CarbohydrateUpdate = StateTransform.create('carbohydrate', 'null', 'carbohydrate-update',
async function (ctx: StateContext, carbohydrateEntity: CarbohydrateEntity, props: Partial<CarbohydrateProps> = {}) {
const carbohydrateRepr = carbohydrateEntity.value
await carbohydrateRepr.createOrUpdate(props).run(ctx.log)
ctx.viewer.add(carbohydrateRepr)
ctx.viewer.requestDraw()
console.log('stats', ctx.viewer.stats)
return NullEntity
})
// composed
export type MmcifUrlToModel = StateTransform<UrlEntity, ModelEntity, {}>
export const MmcifUrlToModel: MmcifUrlToModel = StateTransform.create('url', 'model', 'url-to-model',
async function (ctx: StateContext, urlEntity: UrlEntity) {
const dataEntity = await UrlToData.apply(ctx, urlEntity)
return DataToModel.apply(ctx, dataEntity)
})
export type MmcifFileToModel = StateTransform<FileEntity, ModelEntity, {}>
export const MmcifFileToModel: MmcifFileToModel = StateTransform.create('file', 'model', 'file-to-model',
async function (ctx: StateContext, fileEntity: FileEntity) {
const dataEntity = await FileToData.apply(ctx, fileEntity)
return DataToModel.apply(ctx, dataEntity)
})
export type DataToModel = StateTransform<DataEntity, ModelEntity, {}>
export const DataToModel: DataToModel = StateTransform.create('data', 'model', 'data-to-model',
async function getModelFromData(ctx: StateContext, dataEntity: DataEntity) {
const cifEntity = await DataToCif.apply(ctx, dataEntity)
const mmcifEntity = await CifToMmcif.apply(ctx, cifEntity)
return MmcifToModel.apply(ctx, mmcifEntity)
})
export type ModelToSpacefill = StateTransform<ModelEntity, SpacefillEntity, Partial<SpacefillProps>>
export const ModelToSpacefill: ModelToSpacefill = StateTransform.create('model', 'spacefill', 'model-to-spacefill',
async function (ctx: StateContext, modelEntity: ModelEntity, props: Partial<SpacefillProps> = {}) {
const structureEntity = await ModelToStructure.apply(ctx, modelEntity)
// StructureToBond.apply(ctx, structureEntity, props)
return StructureToSpacefill.apply(ctx, structureEntity, props)
})
export type MmcifUrlToSpacefill = StateTransform<UrlEntity, SpacefillEntity, Partial<SpacefillProps>>
export const MmcifUrlToSpacefill: MmcifUrlToSpacefill = StateTransform.create('url', 'spacefill', 'url-to-spacefill',
async function (ctx: StateContext, urlEntity: UrlEntity, props: Partial<SpacefillProps> = {}) {
const modelEntity = await MmcifUrlToModel.apply(ctx, urlEntity)
return ModelToSpacefill.apply(ctx, modelEntity, props)
})
export type MmcifFileToSpacefill = StateTransform<FileEntity, SpacefillEntity, Partial<SpacefillProps>>
export const MmcifFileToSpacefill: MmcifFileToSpacefill = StateTransform.create('file', 'spacefill', 'file-to-spacefill',
async function (ctx: StateContext, fileEntity: FileEntity, props: Partial<SpacefillProps> = {}) {
const modelEntity = await MmcifFileToModel.apply(ctx, fileEntity)
return ModelToSpacefill.apply(ctx, modelEntity, props)
})
\ No newline at end of file
......@@ -25,9 +25,10 @@
"mol-ql": ["./mol-ql"],
"mol-script": ["./mol-script"],
"mol-state": ["./mol-state", "./mol-state/index.ts"],
"mol-plugin": ["./mol-plugin", "./mol-plugin/index.ts"],
"mol-task": ["./mol-task", "./mol-task/index.ts"],
"mol-util": ["./mol-util", "./mol-util/index.ts"],
"mol-view": ["./mol-view"]
"mol-canvas3d": ["./mol-view"]
}
},
"include": [ "**/*" ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment