mirror of
https://github.com/molstar/molstar.git
synced 2026-06-04 13:30:24 +08:00
Removing initial plugin-based Kinemage reader stubs, leaving the extension that handles both File/Open and drag-and-drop
This commit is contained in:
@@ -14,8 +14,8 @@ import { Mat3, Quat, Vec3 } from '../../../../mol-math/linear-algebra';
|
||||
import { GraphicsMode, MesoscaleGroup, MesoscaleState, getGraphicsModeProps, getMesoscaleGroupParams } from '../state';
|
||||
import { ColorNames } from '../../../../mol-util/color/names';
|
||||
import { ShapeRepresentation3D, StructureRepresentation3D } from '../../../../mol-plugin-state/transforms/representation';
|
||||
import { ParseCif, ParsePly, ParseKin, ReadFile } from '../../../../mol-plugin-state/transforms/data';
|
||||
import { ModelFromTrajectory, ShapeFromPly, ShapeLinesFromKin, TrajectoryFromGRO, TrajectoryFromMOL, TrajectoryFromMOL2, TrajectoryFromMmCif, TrajectoryFromPDB, TrajectoryFromSDF, TrajectoryFromXYZ } from '../../../../mol-plugin-state/transforms/model';
|
||||
import { ParseCif, ParsePly, ReadFile } from '../../../../mol-plugin-state/transforms/data';
|
||||
import { ModelFromTrajectory, ShapeFromPly, TrajectoryFromGRO, TrajectoryFromMOL, TrajectoryFromMOL2, TrajectoryFromMmCif, TrajectoryFromPDB, TrajectoryFromSDF, TrajectoryFromXYZ } from '../../../../mol-plugin-state/transforms/model';
|
||||
import { Euler } from '../../../../mol-math/linear-algebra/3d/euler';
|
||||
import { Asset } from '../../../../mol-util/assets';
|
||||
import { Clip } from '../../../../mol-util/clip';
|
||||
@@ -104,34 +104,6 @@ function getPlyShapeParams(color: Color, clipVariant: Clip.Variant) {
|
||||
};
|
||||
}
|
||||
|
||||
function getKinShapeParams(color: Color, clipVariant: Clip.Variant) {
|
||||
return {
|
||||
...PD.getDefaultValues(BaseGeometry.Params),
|
||||
instanceGranularity: true,
|
||||
ignoreLight: true,
|
||||
clip: {
|
||||
variant: clipVariant,
|
||||
objects: [],
|
||||
},
|
||||
quality: 'custom',
|
||||
doubleSided: true,
|
||||
coloring: {
|
||||
name: 'uniform',
|
||||
params: { color }
|
||||
},
|
||||
grouping: {
|
||||
name: 'none',
|
||||
params: {}
|
||||
},
|
||||
material: {
|
||||
metalness: 0.0,
|
||||
roughness: 1.0,
|
||||
bumpiness: 1.0,
|
||||
},
|
||||
bumpAmplitude: 0.1,
|
||||
bumpFrequency: 0.1 / 10,
|
||||
};
|
||||
}
|
||||
export async function createGenericHierarchy(plugin: PluginContext, file: Asset.File) {
|
||||
const asset = await plugin.runTask(plugin.managers.asset.resolve(file, 'zip'));
|
||||
let manifest: GenericManifest;
|
||||
@@ -280,15 +252,6 @@ export async function createGenericHierarchy(plugin: PluginContext, file: Asset.
|
||||
.apply(ShapeFromPly, { label, transforms })
|
||||
.apply(ShapeRepresentation3D, getPlyShapeParams(color, clipVariant), { tags });
|
||||
}
|
||||
} else if (['kin'].includes(info.ext)) {
|
||||
if (['kin'].includes(info.ext)) {
|
||||
const transforms = await getTransforms(plugin, instances);
|
||||
const clipVariant = transforms.length === 1 ? 'pixel' : 'instance';
|
||||
build = build
|
||||
.apply(ParseKin)
|
||||
.apply(ShapeLinesFromKin, { label, transforms })
|
||||
.apply(ShapeRepresentation3D, getKinShapeParams(color, clipVariant), { tags });
|
||||
}
|
||||
} else {
|
||||
console.warn(`unknown file format '${info.ext}'`);
|
||||
}
|
||||
|
||||
@@ -37,34 +37,8 @@ export const PlyProvider = DataFormatProvider({
|
||||
}
|
||||
});
|
||||
|
||||
export const KinProvider = DataFormatProvider({
|
||||
label: 'KIN',
|
||||
description: 'KIN',
|
||||
category: ShapeFormatCategory,
|
||||
stringExtensions: ['kin'],
|
||||
parse: async (plugin, data) => {
|
||||
// This returns the last kinemage in the file if there are multiple
|
||||
const format = plugin.state.data.build()
|
||||
.to(data)
|
||||
.apply(StateTransforms.Data.ParseKin, {}, { state: { isGhost: true } });
|
||||
|
||||
const shape = format.apply(StateTransforms.Model.ShapeLinesFromKin);
|
||||
|
||||
await format.commit();
|
||||
|
||||
return { format: format.selector, shape: shape.selector };
|
||||
},
|
||||
visuals(plugin: PluginContext, data: { shape: StateObjectRef<PluginStateObject.Shape.Provider> }) {
|
||||
const repr = plugin.state.data.build()
|
||||
.to(data.shape)
|
||||
.apply(StateTransforms.Representation.ShapeRepresentation3D);
|
||||
return repr.commit();
|
||||
}
|
||||
});
|
||||
|
||||
export const BuiltInShapeFormats = [
|
||||
['ply', PlyProvider] as const,
|
||||
/// @todo Replaced the plugin loader with an extension ['kin', KinProvider] as const,
|
||||
] as const;
|
||||
|
||||
export type BuiltInShapeFormat = (typeof BuiltInShapeFormats)[number][0]
|
||||
export type BuiltInShapeFormat = (typeof BuiltInShapeFormats)[number][0]
|
||||
|
||||
@@ -10,7 +10,6 @@ import { CifFile } from '../mol-io/reader/cif';
|
||||
import { DcdFile } from '../mol-io/reader/dcd/parser';
|
||||
import { Dsn6File } from '../mol-io/reader/dsn6/schema';
|
||||
import { PlyFile } from '../mol-io/reader/ply/schema';
|
||||
import { Kinemage } from '../mol-io/reader/kin/schema';
|
||||
import { PsfFile } from '../mol-io/reader/psf/parser';
|
||||
import { ShapeProvider } from '../mol-model/shape/provider';
|
||||
import { Coordinates as _Coordinates, Model as _Model, Structure as _Structure, Trajectory as _Trajectory, StructureElement, Topology as _Topology } from '../mol-model/structure';
|
||||
@@ -80,7 +79,6 @@ export namespace PluginStateObject {
|
||||
export class Prmtop extends Create<PrmtopFile>({ name: 'PRMTOP File', typeClass: 'Data' }) { }
|
||||
export class Top extends Create<TopFile>({ name: 'TOP File', typeClass: 'Data' }) { }
|
||||
export class Ply extends Create<PlyFile>({ name: 'PLY File', typeClass: 'Data' }) { }
|
||||
export class Kin extends Create<Kinemage>({ name: 'KIN File', typeClass: 'Data' }) { }
|
||||
export class Ccp4 extends Create<Ccp4File>({ name: 'CCP4/MRC/MAP File', typeClass: 'Data' }) { }
|
||||
export class Dsn6 extends Create<Dsn6File>({ name: 'DSN6/BRIX File', typeClass: 'Data' }) { }
|
||||
export class Dx extends Create<DxFile>({ name: 'DX File', typeClass: 'Data' }) { }
|
||||
@@ -97,7 +95,6 @@ export namespace PluginStateObject {
|
||||
{ kind: 'dsn6', data: Dsn6File } |
|
||||
{ kind: 'dx', data: DxFile } |
|
||||
{ kind: 'ply', data: PlyFile } |
|
||||
{ kind: 'kin', data: Kinemage } |
|
||||
// For non-built-in extensions
|
||||
{ kind: 'custom', data: unknown, tag: string }
|
||||
)
|
||||
@@ -158,4 +155,4 @@ export namespace PluginStateObject {
|
||||
export namespace PluginStateTransform {
|
||||
export const CreateBuiltIn = StateTransformer.factory('ms-plugin');
|
||||
export const BuiltIn = StateTransformer.builderFactory('ms-plugin');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import * as CCP4 from '../../mol-io/reader/ccp4/parser';
|
||||
import { CIF } from '../../mol-io/reader/cif';
|
||||
import * as DSN6 from '../../mol-io/reader/dsn6/parser';
|
||||
import * as PLY from '../../mol-io/reader/ply/parser';
|
||||
import * as KIN from '../../mol-io/reader/kin/parser';
|
||||
import { Kinemage } from '../../mol-io/reader/kin/schema';
|
||||
import { parsePsf } from '../../mol-io/reader/psf/parser';
|
||||
import { PluginContext } from '../../mol-plugin/context';
|
||||
import { StateObject, StateTransformer } from '../../mol-state';
|
||||
@@ -43,7 +41,6 @@ export { ParsePsf };
|
||||
export { ParsePrmtop };
|
||||
export { ParseTop };
|
||||
export { ParsePly };
|
||||
export { ParseKin }
|
||||
export { ParseCcp4 };
|
||||
export { ParseDsn6 };
|
||||
export { ParseDx };
|
||||
@@ -406,26 +403,6 @@ const ParsePly = PluginStateTransform.BuiltIn({
|
||||
}
|
||||
});
|
||||
|
||||
type ParseKin = typeof ParseKin
|
||||
const ParseKin = PluginStateTransform.BuiltIn({
|
||||
name: 'parse-kin',
|
||||
display: { name: 'Parse KIN', description: 'Parse KIN from String data' },
|
||||
from: [SO.Data.String],
|
||||
to: SO.Format.Kin
|
||||
})({
|
||||
apply({ a }) {
|
||||
return Task.create('Parse KIN', async ctx => {
|
||||
const parsedList = await KIN.parseKin(a.data).runInContext(ctx);
|
||||
if (parsedList.isError) throw new Error(parsedList.message);
|
||||
// Read the last entry, handling the case where it is an error
|
||||
const kinemages: Kinemage[] = parsedList.result;
|
||||
const parsed = kinemages.length ? parsedList.result[kinemages.length - 1] : undefined;
|
||||
if (!parsed) return StateObject.Null;
|
||||
return new SO.Format.Kin(parsed, { label: parsed.comments[0] || 'KIN Data' });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
type ParseCcp4 = typeof ParseCcp4
|
||||
const ParseCcp4 = PluginStateTransform.BuiltIn({
|
||||
name: 'parse-ccp4',
|
||||
|
||||
@@ -12,7 +12,6 @@ import { parseGRO } from '../../mol-io/reader/gro/parser';
|
||||
import { parsePDB } from '../../mol-io/reader/pdb/parser';
|
||||
import { Mat4, Vec3 } from '../../mol-math/linear-algebra';
|
||||
import { shapeFromPly } from '../../mol-model-formats/shape/ply';
|
||||
import { shapeLinesFromKin } from '../../mol-model-formats/shape/kin';
|
||||
import { coordinatesFromDcd } from '../../mol-model-formats/structure/dcd';
|
||||
import { trajectoryFromGRO } from '../../mol-model-formats/structure/gro';
|
||||
import { trajectoryFromCCD, trajectoryFromMmCIF } from '../../mol-model-formats/structure/mmcif';
|
||||
@@ -95,7 +94,6 @@ export { StructureComponent };
|
||||
export { CustomModelProperties };
|
||||
export { CustomStructureProperties };
|
||||
export { ShapeFromPly };
|
||||
export { ShapeLinesFromKin };
|
||||
|
||||
type CoordinatesFromDcd = typeof CoordinatesFromDcd
|
||||
const CoordinatesFromDcd = PluginStateTransform.BuiltIn({
|
||||
@@ -1320,24 +1318,3 @@ const ShapeFromPly = PluginStateTransform.BuiltIn({
|
||||
}
|
||||
});
|
||||
|
||||
type ShapeLinesFromKin = typeof ShapeLinesFromKin
|
||||
const ShapeLinesFromKin = PluginStateTransform.BuiltIn({
|
||||
name: 'shape-lines-from-kin',
|
||||
display: { name: 'Shape Lines from KIN', description: 'Create Shape from KIN data' },
|
||||
from: SO.Format.Kin,
|
||||
to: SO.Shape.Provider,
|
||||
params(a) {
|
||||
return {
|
||||
transforms: PD.Optional(PD.Value<Mat4[]>([], { isHidden: true })),
|
||||
label: PD.Optional(PD.Text('', { isHidden: true }))
|
||||
};
|
||||
}
|
||||
})({
|
||||
apply({ a, params }) {
|
||||
return Task.create('Create shape from KIN', async ctx => {
|
||||
const shape = await shapeLinesFromKin(a.data, params).runInContext(ctx);
|
||||
const props = { label: params.label || 'Shape' };
|
||||
return new SO.Shape.Provider(shape, props);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user