|
@@ -9,7 +9,7 @@ import { parsePDB } from '../../../mol-io/reader/pdb/parser';
|
|
|
import { Vec3, Mat4, Quat } from '../../../mol-math/linear-algebra';
|
|
|
import { trajectoryFromMmCIF } from '../../../mol-model-formats/structure/mmcif';
|
|
|
import { trajectoryFromPDB } from '../../../mol-model-formats/structure/pdb';
|
|
|
-import { Model, Queries, QueryContext, Structure, StructureQuery, StructureSelection as Sel, StructureElement } from '../../../mol-model/structure';
|
|
|
+import { Model, Queries, QueryContext, Structure, StructureQuery, StructureSelection as Sel, StructureElement, trajectoryFromModelAndCoordinates, Coordinates } from '../../../mol-model/structure';
|
|
|
import { PluginContext } from '../../../mol-plugin/context';
|
|
|
import { MolScriptBuilder } from '../../../mol-script/language/builder';
|
|
|
import Expression from '../../../mol-script/language/expression';
|
|
@@ -28,7 +28,11 @@ import { trajectoryFrom3DG } from '../../../mol-model-formats/structure/3dg';
|
|
|
import { StructureSelectionQueries } from '../../util/structure-selection-helper';
|
|
|
import { StructureQueryHelper } from '../../util/structure-query';
|
|
|
import { ModelStructureRepresentation } from '../representation/model';
|
|
|
+import { parseDcd } from '../../../mol-io/reader/dcd/parser';
|
|
|
+import { coordinatesFromDcd } from '../../../mol-model-formats/structure/dcd';
|
|
|
|
|
|
+export { CoordinatesFromDcd };
|
|
|
+export { TrajectoryFromModelAndCoordinates };
|
|
|
export { TrajectoryFromBlob };
|
|
|
export { TrajectoryFromMmCif };
|
|
|
export { TrajectoryFromPDB };
|
|
@@ -48,6 +52,45 @@ export { StructureComplexElement };
|
|
|
export { CustomModelProperties };
|
|
|
export { CustomStructureProperties };
|
|
|
|
|
|
+type CoordinatesFromDcd = typeof CoordinatesFromDcd
|
|
|
+const CoordinatesFromDcd = PluginStateTransform.BuiltIn({
|
|
|
+ name: 'coordinates-from-dcd',
|
|
|
+ display: { name: 'Parse DCD', description: 'Parse DCD binary data.' },
|
|
|
+ from: [SO.Data.Binary],
|
|
|
+ to: SO.Molecule.Coordinates
|
|
|
+})({
|
|
|
+ apply({ a }) {
|
|
|
+ return Task.create('Parse DCD', async ctx => {
|
|
|
+ const parsed = await parseDcd(a.data).runInContext(ctx);
|
|
|
+ if (parsed.isError) throw new Error(parsed.message);
|
|
|
+ const coordinates = await coordinatesFromDcd(parsed.result).runInContext(ctx);
|
|
|
+ return new SO.Molecule.Coordinates(coordinates, { label: a.label, description: a.description });
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+type TrajectoryFromModelAndCoordinates = typeof TrajectoryFromModelAndCoordinates
|
|
|
+const TrajectoryFromModelAndCoordinates = PluginStateTransform.BuiltIn({
|
|
|
+ name: 'trajectory-from-model-and-coordinates',
|
|
|
+ display: { name: 'Trajectory from Model & Coordinates', description: 'Create a trajectory from existing model and coordinates.' },
|
|
|
+ from: SO.Root,
|
|
|
+ to: SO.Molecule.Trajectory,
|
|
|
+ params: {
|
|
|
+ modelRef: PD.Text('', { isHidden: true }),
|
|
|
+ coordinatesRef: PD.Text('', { isHidden: true }),
|
|
|
+ }
|
|
|
+})({
|
|
|
+ apply({ params, dependencies }) {
|
|
|
+ return Task.create('Create trajectory from model and coordinates', async ctx => {
|
|
|
+ const model = dependencies![params.modelRef].data as Model
|
|
|
+ const coordinates = dependencies![params.coordinatesRef].data as Coordinates
|
|
|
+ const trajectory = trajectoryFromModelAndCoordinates(model, coordinates);
|
|
|
+ const props = { label: 'Trajectory', description: `${trajectory.length} model${trajectory.length === 1 ? '' : 's'}` };
|
|
|
+ return new SO.Molecule.Trajectory(trajectory, props);
|
|
|
+ });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
type TrajectoryFromBlob = typeof TrajectoryFromBlob
|
|
|
const TrajectoryFromBlob = PluginStateTransform.BuiltIn({
|
|
|
name: 'trajectory-from-blob',
|
|
@@ -66,7 +109,7 @@ const TrajectoryFromBlob = PluginStateTransform.BuiltIn({
|
|
|
for (const x of xs) models.push(x);
|
|
|
}
|
|
|
|
|
|
- const props = { label: `Trajectory`, description: `${models.length} model${models.length === 1 ? '' : 's'}` };
|
|
|
+ const props = { label: 'Trajectory', description: `${models.length} model${models.length === 1 ? '' : 's'}` };
|
|
|
return new SO.Molecule.Trajectory(models, props);
|
|
|
});
|
|
|
}
|
|
@@ -239,7 +282,7 @@ const StructureAssemblyFromModel = PluginStateTransform.BuiltIn({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-const _translation = Vec3.zero(), _m = Mat4.zero(), _n = Mat4.zero();
|
|
|
+const _translation = Vec3(), _m = Mat4(), _n = Mat4();
|
|
|
type TransformStructureConformation = typeof TransformStructureConformation
|
|
|
const TransformStructureConformation = PluginStateTransform.BuiltIn({
|
|
|
name: 'transform-structure-conformation',
|
|
@@ -267,14 +310,14 @@ const TransformStructureConformation = PluginStateTransform.BuiltIn({
|
|
|
Mat4.mul3(m, _n, rot, _m);
|
|
|
|
|
|
const s = Structure.transform(a.data, m);
|
|
|
- const props = { label: `${a.label}`, description: `Transformed` };
|
|
|
+ const props = { label: `${a.label}`, description: 'Transformed' };
|
|
|
return new SO.Molecule.Structure(s, props);
|
|
|
},
|
|
|
interpolate(src, tar, t) {
|
|
|
// TODO: optimize
|
|
|
- const u = Mat4.fromRotation(Mat4.zero(), Math.PI / 180 * src.angle, Vec3.normalize(Vec3.zero(), src.axis));
|
|
|
+ const u = Mat4.fromRotation(Mat4.zero(), Math.PI / 180 * src.angle, Vec3.normalize(Vec3(), src.axis));
|
|
|
Mat4.setTranslation(u, src.translation);
|
|
|
- const v = Mat4.fromRotation(Mat4.zero(), Math.PI / 180 * tar.angle, Vec3.normalize(Vec3.zero(), tar.axis));
|
|
|
+ const v = Mat4.fromRotation(Mat4.zero(), Math.PI / 180 * tar.angle, Vec3.normalize(Vec3(), tar.axis));
|
|
|
Mat4.setTranslation(v, tar.translation);
|
|
|
const m = SymmetryOperator.slerp(Mat4.zero(), u, v, t);
|
|
|
const rot = Mat4.getRotation(Quat.zero(), m);
|
|
@@ -300,7 +343,7 @@ const TransformStructureConformationByMatrix = PluginStateTransform.BuiltIn({
|
|
|
},
|
|
|
apply({ a, params }) {
|
|
|
const s = Structure.transform(a.data, params.matrix);
|
|
|
- const props = { label: `${a.label}`, description: `Transformed` };
|
|
|
+ const props = { label: `${a.label}`, description: 'Transformed' };
|
|
|
return new SO.Molecule.Structure(s, props);
|
|
|
}
|
|
|
});
|