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

Higher tolerance for "symmetry operators"

parent 75956de8
No related branches found
No related tags found
No related merge requests found
......@@ -21,10 +21,12 @@ namespace SymmetryOperator {
export const DefaultName = '1_555'
export const Default: SymmetryOperator = create(DefaultName, Mat4.identity());
const RotationEpsilon = 0.0001;
export function create(name: string, matrix: Mat4, hkl?: number[]): SymmetryOperator {
const _hkl = hkl ? Vec3.create(hkl[0], hkl[1], hkl[2]) : Vec3.zero();
if (Mat4.isIdentity(matrix)) return { name, matrix, inverse: Mat4.identity(), isIdentity: true, hkl: _hkl };
if (!Mat4.isRotationAndTranslation(matrix)) throw new Error(`Symmetry operator (${name}) must be a composition of rotation and translation.`);
if (!Mat4.isRotationAndTranslation(matrix, RotationEpsilon)) throw new Error(`Symmetry operator (${name}) must be a composition of rotation and translation.`);
return { name, matrix, inverse: Mat4.invert(Mat4.zero(), matrix), isIdentity: false, hkl: _hkl };
}
......
......@@ -241,9 +241,11 @@ export namespace PropertyAccess {
console.log(to_mmCIF('test', s));
}
export function testAssembly(s: Structure) {
export function testAssembly(id: string, s: Structure) {
console.time('assembly')
const a = Symmetry.buildAssembly(s, '1');
fs.writeFileSync('e:/test/molstar/1hrv_assembly.cif', to_mmCIF('test', a, false));
console.timeEnd('assembly')
fs.writeFileSync(`e:/test/molstar/${id}_assembly.bcif`, to_mmCIF(id, a, true));
console.log('exported');
//write(a);
}
......@@ -252,12 +254,12 @@ export namespace PropertyAccess {
//const { structures, models, mmcif } = await readCIF('./examples/1cbs_full.bcif');
//const { structures, models, mmcif } = await readCIF('e:/test/quick/3j3q_full.bcif');
//const { structures, models, mmcif } = await readCIF('e:/test/quick/1cbs_updated.cif');
const { structures, models/*, mmcif*/ } = await readCIF('e:/test/quick/1hrv_updated.cif');
const { structures, models/*, mmcif*/ } = await readCIF('e:/test/quick/5j7v_updated.cif');
//console.log(mmcif.pdbx_struct_oper_list.matrix.toArray());
// console.log(mmcif.pdbx_struct_oper_list.vector.toArray());
testAssembly(structures[0]);
testAssembly('5j7v', structures[0]);
throw '';
console.log(models[0].symmetry.assemblies);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment