Browse Source

Issue #643: excluding non-poly entities based on pdbx_nonpoly_scheme

cycle20 1 year ago
parent
commit
9558ef41fd
2 changed files with 31 additions and 7 deletions
  1. 3 3
      src/extensions/tmdet/behavior.ts
  2. 28 4
      src/extensions/tmdet/symmetry.ts

+ 3 - 3
src/extensions/tmdet/behavior.ts

@@ -241,10 +241,10 @@ async function downloadData(ctx: PluginUIContext, params: any, pdbtmDescriptor:
 
     const builders = ctx.builders;
     let downloadResult = await ctx.runTask(ctx.fetch({ url: params.structureUrl, type: "string" }));
-    console.log(downloadResult.slice(0, 100));
+    DebugUtil.log('First 50 chars of input data', downloadResult.slice(0, 50));
     // TODO: temporary solution
-    downloadResult = downloadResult.replace(/HETATM.+\n/mg, ''); // remove all hetatom stuffs
-    // TODO: const uncompressed: string = await ungzip(downloadResult);
+    // TODO: downloadResult = downloadResult.replace(/HETATM.+\n/mg, ''); // remove all hetatom stuffs
+    // TODO: const uncompressed: string = await ungzip(downloadResult); // it does not work right now
     // console.log(uncompressed.slice(0, 100));
 
     return await builders.data.rawData({

+ 28 - 4
src/extensions/tmdet/symmetry.ts

@@ -45,7 +45,7 @@ function constructChainListFromOperations(pdbtmDescriptor: PDBTMDescriptor): str
     return excludedChains;
 }
 
-function tmDetSymmetryFromMmCif(model: Model, chainsForOperExpression: string[]) {
+function tmDetSymmetryFromMmCif(model: Model, excludedChains: string[]) {
     if (!MmcifFormat.is(model.sourceData)) return;
 
     let data = model.sourceData.data.db;
@@ -53,8 +53,12 @@ function tmDetSymmetryFromMmCif(model: Model, chainsForOperExpression: string[])
     // update chains (asym) for each author_defined_assemly
     // NOTE: We assume that the first assembly is an author defined assembly.
     const currentAssemblyId: string = data.pdbx_struct_assembly_gen.assembly_id.value(0);
+    excludedChains = union(
+        excludedChains,
+        Array.from(data.pdbx_nonpoly_scheme.asym_id.toArray())
+    );
     const result: string[][] = createAsymIdColumnData(
-        data.pdbx_struct_assembly_gen, currentAssemblyId, chainsForOperExpression
+        data.pdbx_struct_assembly_gen, currentAssemblyId, excludedChains
     );
     asymIdColumnData = asymIdColumnData.concat(result);
 
@@ -65,13 +69,26 @@ function tmDetSymmetryFromMmCif(model: Model, chainsForOperExpression: string[])
         {
             assembly_id: data.pdbx_struct_assembly_gen.assembly_id,
             asym_id_list: asym_id_list_column,
-            oper_expression: data.pdbx_struct_assembly_gen.oper_expression
+            //oper_expression: data.pdbx_struct_assembly_gen.oper_expression
+            // NOTE: we expect here pdbx_struct_assembly_gen has only one row
+            oper_expression: Column.ofStringArray([ '1' ])
         }
     );
+    DebugUtil.log('Orig. assembly_gen', Table.formatToString(data.pdbx_struct_assembly_gen));
+    DebugUtil.log('Updated assembly_gen', Table.formatToString(updated_pdbx_struct_assembly_gen));
+
+    DebugUtil.log('Oper expression:', data.pdbx_struct_assembly_gen.oper_expression.toArray());
+    DebugUtil.log('Non-poly entities:', Table.formatToString(data.pdbx_entity_nonpoly));
+    DebugUtil.log('Non-poly chains:', data.pdbx_nonpoly_scheme.asym_id.toArray());
 
-    DebugUtil.log('Excluded chains:', chainsForOperExpression);
+    DebugUtil.log('Excluded chains:', excludedChains);
     DebugUtil.log('Included chains:', result);
 
+    DebugUtil.log('oper_list table: original:', Table.formatToString(data.pdbx_struct_oper_list));
+    DebugUtil.log('oper_list table: first row', Table.formatToString(
+        Table.ofRows(data.pdbx_struct_oper_list._schema, [ Table.getRow(data.pdbx_struct_oper_list, 0) ]))
+    );
+
     return ModelSymmetry.fromData({
         symmetry: data.symmetry,
         cell: data.cell,
@@ -102,3 +119,10 @@ function minus(a: string[], b: string[]): string[] {
     const b_set = new Set(b);
     return a.filter(x => !b_set.has(x));
 }
+
+// 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());
+}