Bladeren bron

Issue #2: PDBTMDescriptor as strict type

cycle20 2 jaren geleden
bovenliggende
commit
0155f7b08f
1 gewijzigde bestanden met toevoegingen van 37 en 10 verwijderingen
  1. 37 10
      src/extensions/tmdet/behavior.ts

+ 37 - 10
src/extensions/tmdet/behavior.ts

@@ -135,7 +135,37 @@ export async function loadWithUNITMPMembraneRepresentation(plugin: PluginUIConte
     requestAnimationFrame(() => plugin.canvas3d?.requestCameraReset());
 }
 
-type PDBTMDescriptor = any;
+type PDBTMChain = {
+    chain_label: string,
+    additional_chain_annotations: {
+        type: string,
+        num_tm: number
+    },
+    residues: {
+        pdb_res_label?: string,
+        aa_type?: string,
+        site_data?: { site_id_ref: number, confidence_classification: string }[]
+    }[]
+};
+type PDBTMResidue = PDBTMChain['residues'][0]
+    & { site: string, auth_ids: number[], color: number[] };
+type PDBTMTransformationMatrixRow = { x: number, y: number, z: number, t: number };
+type PDBTMTransformationMatrix = {
+    rowx: PDBTMTransformationMatrixRow,
+    rowy: PDBTMTransformationMatrixRow,
+    rowz: PDBTMTransformationMatrixRow
+};
+type PDBTMDescriptor = {
+    chains: PDBTMChain[],
+    site: { site_id: number, label: string }[],
+    additional_entry_annotations: {
+        membrane: {
+            normal: { x: number, y: number, z: number },
+            transformation_matrix: PDBTMTransformationMatrix,
+            radius: number
+        }
+    }
+};
 
 function createMembraneOrientation(pdbtmDescriptor: PDBTMDescriptor): MembraneOrientation {
     const membraneNormal: Vec3 = Vec3.fromObj(
@@ -153,7 +183,7 @@ function createMembraneOrientation(pdbtmDescriptor: PDBTMDescriptor): MembraneOr
         normalVector: membraneNormal,
 
         // (NOTE: the TMDET extension calculates and sets it during applying preset)
-        radius: pdbtmDescriptor['radius']
+        radius: pdbtmDescriptor.additional_entry_annotations.membrane.radius
     };
     membraneOrientation.planePoint2[0] *= -1;
     return membraneOrientation;
@@ -167,7 +197,7 @@ async function createStructureRepresentation(plugin: PluginUIContext, pdbtmDescr
     await buildStructureRepresentation(plugin, components);
 
     const siteColors = [
-        [255, 0, 0], // Side1
+        [0, 0, 255], // Side1
         [255, 0, 0], // Side2
         [255,255,0], // TM alpha
         [255,255,0], // TM beta
@@ -181,13 +211,10 @@ async function createStructureRepresentation(plugin: PluginUIContext, pdbtmDescr
     );
     pdbtmDescriptor.chains.forEach((chain: any) => {
 
-        // console.log('PDBTM descriptor', chain);
-
-
         const regionUpdates = plugin.build();
         for (let residueItem of chain.residues) {
             const siteIndex = residueItem.site_data[0].site_id_ref - 1;
-            const residue = {
+            const residue: PDBTMResidue = {
                 "auth_ids": [ Number(residueItem.pdb_res_label) ],
                 "color": siteColors[siteIndex],
                 "site": siteDefinitions[siteIndex]
@@ -206,11 +233,11 @@ async function createStructureComponents(plugin: PluginUIContext, structure: Sta
     };
 }
 
-function createRegionRepresentation(plugin: PluginUIContext, chain: string, residue: any, update: StateBuilder.To<any, any>) {
+function createRegionRepresentation(plugin: PluginUIContext, chain: string, residue: PDBTMResidue, update: StateBuilder.To<any, any>) {
     console.log('RESI', residue);
-    const regionLabel: string = `${chain} | ${residue.site}`;
+    const regionLabel: string = `${chain}: ${residue.auth_ids[0]} | ${residue.site}`;
     const color: Color = Color.fromArray(residue.color, 0);
-    const query: Expression = getAtomGroupExpression(chain, residue.auth_ids as number[]);
+    const query: Expression = getAtomGroupExpression(chain, residue.auth_ids);
 
 
     // based on https://github.com/molstar/molstar/issues/209