|
@@ -1,11 +1,11 @@
|
|
|
/**
|
|
|
- * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
+ * Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
*
|
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
*/
|
|
|
|
|
|
import { Column, Table } from '../../mol-data/db';
|
|
|
-import { Model } from '../../mol-model/structure/model';
|
|
|
+import { Model, Symmetry } from '../../mol-model/structure/model';
|
|
|
import { BondType, MoleculeType } from '../../mol-model/structure/model/types';
|
|
|
import { RuntimeContext, Task } from '../../mol-task';
|
|
|
import { createModels } from './basic/parser';
|
|
@@ -14,16 +14,19 @@ import { ComponentBuilder } from './common/component';
|
|
|
import { EntityBuilder } from './common/entity';
|
|
|
import { ModelFormat } from '../format';
|
|
|
import { IndexPairBonds } from './property/bonds/index-pair';
|
|
|
-import { Mol2File } from '../../mol-io/reader/mol2/schema';
|
|
|
+import { Mol2Crysin, Mol2File } from '../../mol-io/reader/mol2/schema';
|
|
|
import { AtomPartialCharge } from './property/partial-charge';
|
|
|
import { Trajectory, ArrayTrajectory } from '../../mol-model/structure';
|
|
|
import { guessElementSymbolString } from './util';
|
|
|
+import { ModelSymmetry } from './property/symmetry';
|
|
|
+import { Spacegroup, SpacegroupCell } from '../../mol-math/geometry';
|
|
|
+import { Vec3 } from '../../mol-math/linear-algebra';
|
|
|
|
|
|
async function getModels(mol2: Mol2File, ctx: RuntimeContext) {
|
|
|
const models: Model[] = [];
|
|
|
|
|
|
for (let i = 0, il = mol2.structures.length; i < il; ++i) {
|
|
|
- const { atoms, bonds, molecule } = mol2.structures[i];
|
|
|
+ const { molecule, atoms, bonds, crysin } = mol2.structures[i];
|
|
|
|
|
|
const A = Column.ofConst('A', atoms.count, Column.Schema.str);
|
|
|
|
|
@@ -110,6 +113,9 @@ async function getModels(mol2: Mol2File, ctx: RuntimeContext) {
|
|
|
type: molecule.charge_type
|
|
|
});
|
|
|
|
|
|
+ const symmetry = getSymmetry(crysin);
|
|
|
+ if (symmetry) ModelSymmetry.Provider.set(first, symmetry);
|
|
|
+
|
|
|
models.push(first);
|
|
|
}
|
|
|
}
|
|
@@ -117,6 +123,24 @@ async function getModels(mol2: Mol2File, ctx: RuntimeContext) {
|
|
|
return new ArrayTrajectory(models);
|
|
|
}
|
|
|
|
|
|
+function getSymmetry(crysin: Mol2Crysin): Symmetry | undefined {
|
|
|
+ // TODO handle `crysin.setting`
|
|
|
+ if (crysin.setting !== 1) return;
|
|
|
+
|
|
|
+ const spaceCell = SpacegroupCell.create(
|
|
|
+ crysin.spaceGroup,
|
|
|
+ Vec3.create(crysin.a, crysin.b, crysin.c),
|
|
|
+ Vec3.scale(Vec3(), Vec3.create(crysin.alpha, crysin.beta, crysin.gamma), Math.PI / 180)
|
|
|
+ );
|
|
|
+
|
|
|
+ return {
|
|
|
+ spacegroup: Spacegroup.create(spaceCell),
|
|
|
+ assemblies: [],
|
|
|
+ isNonStandardCrystalFrame: false,
|
|
|
+ ncsOperators: []
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
//
|
|
|
|
|
|
export { Mol2Format };
|