Преглед на файлове

Issue #1011: fixed rotation issue, when there is no assembly gen stuff in the CIF

cycle20 преди 3 месеца
родител
ревизия
3663f83b3d
променени са 2 файла, в които са добавени 27 реда и са изтрити 70 реда
  1. 2 7
      src/Tm3DStandaloneApp/tmdet-viewer/TmViewerStandalone.ts
  2. 25 63
      src/TmFv3DApp/tmdet-extension/symmetry.ts

+ 2 - 7
src/Tm3DStandaloneApp/tmdet-viewer/TmViewerStandalone.ts

@@ -25,7 +25,6 @@ import { Mat4 } from 'molstar/lib/commonjs/mol-math/linear-algebra';
 import { TrajectoryHierarchyPresetProvider } from 'molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset';
 import { registerRegionDescriptorData } from '../../TmFv3DApp/UniTmpHelper';
 import { TmDetRcsbPreset } from '../TmTrajectoryHierarchyPreset';
-import { MolScriptBuilder } from 'molstar/lib/mol-script/language/builder';
 import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms';
 import { Color } from 'molstar/lib/mol-util/color';
 
@@ -34,6 +33,8 @@ import { ColorNames } from 'molstar/lib/mol-util/color/names';
 
 export class TmViewerStandalone extends Viewer {
 
+    public pdbCode: string|undefined;
+
     constructor(elementOrId: string | HTMLElement, props: Partial<ViewerProps> = {}, withTmDetBehaviour: boolean = true) {
 
         super(elementOrId, props);
@@ -65,12 +66,6 @@ export class TmViewerStandalone extends Viewer {
         return super.loadStructureFromUrl(url, format, isBinary, config);
     }
 
-    chainSelection(auth_asym_id: string) {
-        return MolScriptBuilder.struct.generator.atomGroups({
-            'chain-test': MolScriptBuilder.core.rel.eq([MolScriptBuilder.struct.atomProperty.macromolecular.auth_asym_id(), auth_asym_id])
-        });
-    }
-
     setChainColor(labelAsymIds: string[], hexRgb: string|false = false) {
         this.overPaint(labelAsymIds, hexRgb, false);
     }

+ 25 - 63
src/TmFv3DApp/tmdet-extension/symmetry.ts

@@ -23,56 +23,49 @@ export function registerTmDetSymmetry(pdbtmDescriptor: PDBTMDescriptor) {
     });
 }
 
-function constructChainListFromOperations(pdbtmDescriptor: PDBTMDescriptor): string[] {
-    const excludedChains: string[] = [];
-    // add chain deletes
-    const biomatrix = pdbtmDescriptor.additional_entry_annotations.biomatrix;
-    if (biomatrix?.chain_deletes) {
-        biomatrix.chain_deletes.forEach(
-            chainId => excludedChains.push(chainId)
-        );
-    }
-    // exclude result of transformations
-    if (biomatrix?.matrix_list) {
-        biomatrix.matrix_list.forEach(
-            matrix => matrix.apply_to_chain_list.forEach(
-                applyItem => excludedChains.push(applyItem.new_chain_id)
-            )
-        );
-    }
-
-    return excludedChains;
+function getAnnotatedChains(pdbtmDescriptor: PDBTMDescriptor): string[] {
+    const chainList: string[] = [];
+    pdbtmDescriptor.chains.forEach(chain => chainList.push(chain.chain_label));
+    return chainList;
 }
 
 function tmDetSymmetryFromMmCif(model: Model, pdbtmDescriptor: PDBTMDescriptor) {
     if (!MmcifFormat.is(model.sourceData)) return;
 
-    let data = model.sourceData.data.db;
-    let excludedChains: string[] = constructChainListFromOperations(pdbtmDescriptor);
-    excludedChains = union(
-        excludedChains,
-        Array.from(data.pdbx_nonpoly_scheme.asym_id.toArray())
-    );
+    const data = model.sourceData.data.db;
+    const annotatedChains: string[] = getAnnotatedChains(pdbtmDescriptor);
     const structureOperations: StructureOperation[] = collectOperations(pdbtmDescriptor);
     console.log("Structure Operators:", structureOperations);
 
     const updated_pdbx_struct_assembly_gen = createPdbxStructAssemblyGen(
         structureOperations,
         data.pdbx_struct_assembly_gen,
-        excludedChains
+        annotatedChains
     );
-    console.log('Non-poly entities:', Table.formatToString(data.pdbx_entity_nonpoly));
-    console.log('Non-poly chains:', data.pdbx_nonpoly_scheme.asym_id.toArray());
+    // console.log('Non-poly entities:', Table.formatToString(data.pdbx_entity_nonpoly));
+    // console.log('Non-poly chains:', data.pdbx_nonpoly_scheme.asym_id.toArray());
 
     const updated_struct_oper_list = createPdbxStructOperList(structureOperations, data.pdbx_struct_oper_list);
-    console.log('Orig. struct oper list:', data.pdbx_struct_oper_list);
+
+    const updated_pdbx_struct_assembly = Table.ofColumns(
+        data.pdbx_struct_assembly._schema,
+        {
+            id: Column.ofStringArray([ "1" ]),
+            details: Column.ofStringArray([ "TMDET Assembly" ]),
+            method_details: Column.ofStringArray(["."]),
+            oligomeric_count: Column.ofIntArray([ annotatedChains.length ]),
+            oligomeric_details: Column.ofStringArray(["."])
+        }
+    );
+    console.log('Orig. pdbx_struct_assembly', Table.formatToString(data.pdbx_struct_assembly));
+    console.log('Updated pdbx_struct_assembly', Table.formatToString(updated_pdbx_struct_assembly));
 
     return ModelSymmetry.fromData({
         symmetry: data.symmetry,
         cell: data.cell,
         struct_ncs_oper: data.struct_ncs_oper,
         atom_sites: data.atom_sites,
-        pdbx_struct_assembly: data.pdbx_struct_assembly,
+        pdbx_struct_assembly: updated_pdbx_struct_assembly,
         pdbx_struct_assembly_gen: updated_pdbx_struct_assembly_gen,
         pdbx_struct_oper_list: updated_struct_oper_list
     });
@@ -81,18 +74,15 @@ function tmDetSymmetryFromMmCif(model: Model, pdbtmDescriptor: PDBTMDescriptor)
 function createPdbxStructAssemblyGen(
     structureOperations: StructureOperation[],
     pdbx_struct_assembly_gen: Table<mmCIF_Schema['pdbx_struct_assembly_gen']>,
-    excludedChains: string[]): Table<mmCIF_Schema['pdbx_struct_assembly_gen']> {
+    annotatedChains: string[]): Table<mmCIF_Schema['pdbx_struct_assembly_gen']> {
 
-    const asym_id_list_column = createAsymIdColumn(
-        pdbx_struct_assembly_gen, excludedChains
-    );
     const assembly_id: string[] = [];
     const asym_id_list: string[][] = [];
     const oper_expression: string[] = [];
 
     // we create only one assembly - maybe in multiple rows
     assembly_id.push("1");
-    asym_id_list.push(asym_id_list_column);
+    asym_id_list.push([ ...annotatedChains, "TM_" ]);
     oper_expression.push("0"); // this is the basic membrane plane transformation
 
     const chainMap = new Map<string, string[]>();
@@ -182,34 +172,6 @@ function createPdbxStructOperList(
     return updated_pdbx_struct_oper_list;
 }
 
-function createAsymIdColumn(pdbx_struct_assembly_gen: Table<mmCIF_Schema['pdbx_struct_assembly_gen']>,
-    excludedChains: string[]) {
-
-    let asym_id_list: string[] = [];
-    for (let i = 0; i < pdbx_struct_assembly_gen._rowCount; i++) {
-        const currentAsymIdList = pdbx_struct_assembly_gen.asym_id_list.value(i);
-        asym_id_list = asym_id_list.concat(currentAsymIdList);
-    }
-    asym_id_list = minus(asym_id_list, excludedChains);
-    console.log('Excluded chains:', excludedChains);
-    console.log('Included chains:', asym_id_list);
-
-    return asym_id_list;
-}
-
-// difference of two string arrays (interpreted as sets)
-function minus(a: string[], b: string[]): string[] {
-    const b_set = new Set(b);
-    const difference = a.filter(x => !b_set.has(x));
-    return Array.from(new Set(difference).values());
-}
-
-// union of two string arrays (interpreted as sets)
-function union(a: string[], b: string[]): string[] {
-    const a_set = new Set(a);
-    b.forEach(item => a_set.add(item));
-    return Array.from(a_set.values());
-}
 
 
 //////////////////////////////////////////////////////////////////////